linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: adc-joystick - fix optional value handling
@ 2024-07-31  9:33 John Keeping
  2024-07-31 17:21 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: John Keeping @ 2024-07-31  9:33 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: John Keeping, Artur Rojek, Chris Morgan, Javier Carrasco,
	linux-input, linux-kernel

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>
---
 drivers/input/joystick/adc-joystick.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c
index 130245be884bc..02713e624df1c 100644
--- a/drivers/input/joystick/adc-joystick.c
+++ b/drivers/input/joystick/adc-joystick.c
@@ -180,8 +180,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);
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Input: adc-joystick - fix optional value handling
  2024-07-31  9:33 [PATCH] Input: adc-joystick - fix optional value handling John Keeping
@ 2024-07-31 17:21 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2024-07-31 17:21 UTC (permalink / raw)
  To: John Keeping
  Cc: Artur Rojek, Chris Morgan, Javier Carrasco, linux-input,
	linux-kernel

On Wed, Jul 31, 2024 at 10:33:09AM +0100, John Keeping wrote:
> 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>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-31 17:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31  9:33 [PATCH] Input: adc-joystick - fix optional value handling John Keeping
2024-07-31 17:21 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).