From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Mylène Josserand" <mylene.josserand@collabora.com>,
"Rob Herring" <robh+dt@kernel.org>
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel@collabora.com,
Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: [PATCHv2 2/4] Input: rotary-encoder - Fix steps property reading
Date: Mon, 7 Sep 2020 22:40:43 +0200 [thread overview]
Message-ID: <20200907204045.95530-3-sebastian.reichel@collabora.com> (raw)
In-Reply-To: <20200907204045.95530-1-sebastian.reichel@collabora.com>
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
next prev parent reply other threads:[~2020-09-07 20:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-07 20:40 [PATCHv2 0/4] Rotary Encoder Push Button Support Sebastian Reichel
2020-09-07 20:40 ` [PATCHv2 1/4] dt-bindings: input: Convert rotary-encoder bindings to schema Sebastian Reichel
2020-09-15 16:22 ` Rob Herring
2020-09-07 20:40 ` Sebastian Reichel [this message]
2020-09-07 20:40 ` [PATCHv2 3/4] Input: rotary-encoder - Use dev_err_probe Sebastian Reichel
2020-09-09 19:48 ` Rob Herring
2020-09-10 20:58 ` Sebastian Reichel
2020-09-07 20:40 ` [PATCHv2 4/4] Input: rotary-encoder - Add gpio as push button Sebastian Reichel
2020-09-15 16:33 ` Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200907204045.95530-3-sebastian.reichel@collabora.com \
--to=sebastian.reichel@collabora.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=kernel@collabora.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mylene.josserand@collabora.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).