Skip to content

Commit 684890a

Browse files
johnkeepingdtor
authored andcommitted
Input: adc-joystick - fix optional value handling
The abs-fuzz and abs-flat properties are documented as optional. When these are absent, fwnode_property_read_u32() will leave the input unchanged, meaning that an axis either picks up the value for the previous axis or an uninitialized value. Explicitly set these values to zero when they are unspecified to match the documented behaviour in the device tree bindings. Signed-off-by: John Keeping <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent da89748 commit 684890a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/input/joystick/adc-joystick.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,11 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
182182
swap(range[0], range[1]);
183183
}
184184

185-
fwnode_property_read_u32(child, "abs-fuzz", &fuzz);
186-
fwnode_property_read_u32(child, "abs-flat", &flat);
185+
if (fwnode_property_read_u32(child, "abs-fuzz", &fuzz))
186+
fuzz = 0;
187+
188+
if (fwnode_property_read_u32(child, "abs-flat", &flat))
189+
flat = 0;
187190

188191
input_set_abs_params(joy->input, axes[i].code,
189192
range[0], range[1], fuzz, flat);

0 commit comments

Comments
 (0)