[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200907204045.95530-3-sebastian.reichel@collabora.com>
Date: Mon, 7 Sep 2020 22:40:43 +0200
From: Sebastian Reichel <sebastian.reichel@...labora.com>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>,
Mylène Josserand
<mylene.josserand@...labora.com>, Rob Herring <robh+dt@...nel.org>
Cc: linux-input@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel@...labora.com,
Sebastian Reichel <sebastian.reichel@...labora.com>
Subject: [PATCHv2 2/4] Input: rotary-encoder - Fix steps property reading
The DT binding specifies 24 being used by default, but driver
initializes to 0. The steps variable will be used for a modulo
operation at a later step, so do not allow 0 (does not make
sense in any case).
Signed-off-by: Sebastian Reichel <sebastian.reichel@...labora.com>
---
drivers/input/misc/rotary_encoder.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 6d613f2a017c..e9a5dbb10513 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -198,7 +198,12 @@ static int rotary_encoder_probe(struct platform_device *pdev)
mutex_init(&encoder->access_mutex);
+ encoder->steps = 24;
device_property_read_u32(dev, "rotary-encoder,steps", &encoder->steps);
+ if (!encoder->steps) {
+ dev_err(dev, "invalid steps setting\n");
+ return -EINVAL;
+ }
err = device_property_read_u32(dev, "rotary-encoder,steps-per-period",
&steps_per_period);
--
2.28.0
Powered by blists - more mailing lists