Message ID | 20200907204045.95530-3-sebastian.reichel@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Rotary Encoder Push Button Support | expand |
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);
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(+)