lkml.org 
[lkml]   [2020]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCHv2 2/4] Input: rotary-encoder - Fix steps property reading
Date
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@collabora.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
\
 
 \ /
  Last update: 2020-09-07 22:42    [W:0.154 / U:5.920 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site