diff options
author | John Keeping <jkeeping@inmusicbrands.com> | 2024-07-31 10:33:09 +0100 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2024-07-31 10:20:43 -0700 |
commit | 684890a0185dabf5920c43b639133adc4c2632cf (patch) | |
tree | c3156da0fd385f8323f8359b83c181672c85d720 | |
parent | da897484557b34a54fabb81f6c223c19a69e546d (diff) |
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 <jkeeping@inmusicbrands.com>
Link: https://lore.kernel.org/r/20240731093310.3696919-1-jkeeping@inmusicbrands.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/joystick/adc-joystick.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c index 5f46a7104b52..de1fa4cf291b 100644 --- a/drivers/input/joystick/adc-joystick.c +++ b/drivers/input/joystick/adc-joystick.c @@ -182,8 +182,11 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy) swap(range[0], range[1]); } - fwnode_property_read_u32(child, "abs-fuzz", &fuzz); - fwnode_property_read_u32(child, "abs-flat", &flat); + if (fwnode_property_read_u32(child, "abs-fuzz", &fuzz)) + fuzz = 0; + + if (fwnode_property_read_u32(child, "abs-flat", &flat)) + flat = 0; input_set_abs_params(joy->input, axes[i].code, range[0], range[1], fuzz, flat); |