[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D8PGXIKGXXK9.244NSFST6C0YD@bootlin.com>
Date: Tue, 25 Mar 2025 16:56:20 +0100
From: "Mathieu Dubois-Briand" <mathieu.dubois-briand@...tlin.com>
To: "Andy Shevchenko" <andriy.shevchenko@...el.com>
Cc: "Lee Jones" <lee@...nel.org>, "Rob Herring" <robh@...nel.org>,
"Krzysztof Kozlowski" <krzk+dt@...nel.org>, "Conor Dooley"
<conor+dt@...nel.org>, "Kamel Bouhara" <kamel.bouhara@...tlin.com>, "Linus
Walleij" <linus.walleij@...aro.org>, "Bartosz Golaszewski" <brgl@...ev.pl>,
"Dmitry Torokhov" <dmitry.torokhov@...il.com>,
Uwe Kleine-König <ukleinek@...nel.org>, "Michael Walle"
<mwalle@...nel.org>, "Mark Brown" <broonie@...nel.org>, "Greg
Kroah-Hartman" <gregkh@...uxfoundation.org>, "Rafael J. Wysocki"
<rafael@...nel.org>, "Danilo Krummrich" <dakr@...nel.org>,
<devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-gpio@...r.kernel.org>, <linux-input@...r.kernel.org>,
<linux-pwm@...r.kernel.org>, Grégory Clement
<gregory.clement@...tlin.com>, "Thomas Petazzoni"
<thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH v5 10/11] input: misc: Add support for MAX7360 rotary
On Wed Mar 19, 2025 at 1:11 PM CET, Andy Shevchenko wrote:
> On Tue, Mar 18, 2025 at 05:26:26PM +0100, Mathieu Dubois-Briand wrote:
> > Add driver for Maxim Integrated MAX7360 rotary encoder controller,
> > supporting a single rotary switch.
>
> ...
>
> > +static irqreturn_t max7360_rotary_irq(int irq, void *data)
> > +{
> > + struct max7360_rotary *max7360_rotary = data;
> > + int val;
> > + int ret;
> > +
> > + ret = regmap_read(max7360_rotary->regmap, MAX7360_REG_RTR_CNT, &val);
> > + if (ret < 0) {
> > + dev_err(&max7360_rotary->input->dev,
> > + "Failed to read rotary counter\n");
> > + return IRQ_NONE;
> > + }
> > +
> > + if (val == 0) {
> > + dev_dbg(&max7360_rotary->input->dev,
> > + "Got a spurious interrupt\n");
> > +
> > + return IRQ_NONE;
> > + }
> > +
> > + input_report_rel(max7360_rotary->input, max7360_rotary->axis,
> > + (int8_t)val);
>
> This is strange:
> 1) why casting to begin with?
> 2) why to C type and not kernel (s8) type?
>
I believe the cast is needed, as, while the value read with
regmap_read() is stored in an int, the underlying value is indeed a
signed 8 bits integer.
Without cast negative values will not be correct: -1 (0xFF) -> will be
interpreted as 255 (0x000000FF).
Ok for s8.
Thanks for your review
Mathieu
--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Powered by blists - more mailing lists