Thread (36 messages) 36 messages, 5 authors, 2025-05-07

Re: [PATCH v7 10/11] input: misc: Add support for MAX7360 rotary

From: "Mathieu Dubois-Briand" <mathieu.dubois-briand@bootlin.com>
Date: 2025-05-05 11:52:39
Also in: linux-gpio, linux-input, linux-pwm, lkml

On Fri May 2, 2025 at 4:09 PM CEST, Andy Shevchenko wrote:
On Fri, May 02, 2025 at 03:58:04PM +0200, Mathieu Dubois-Briand wrote:
quoted
On Fri May 2, 2025 at 12:52 PM CEST, Andy Shevchenko wrote:
quoted
On Mon, Apr 28, 2025 at 01:57:28PM +0200, Mathieu Dubois-Briand wrote:
...
quoted
quoted
quoted
+				pos = max(0, (int)pos + steps);
Please, no castings for min()/max()/clamp(). It diminishes the use of those
macros.
Sorry, I'm not sure to get the point. Should I use MIN_T() instead?
Are the second argument is compile-time constant? I don't think so. Hence no
use for MIN*()/MAX*(). First of all, try to answer to the Q: Why is the explicit
casting being used? The second Q: How can it be easily fixed without using _t()
variants of the macros?
Err right, no MIN/MAX of course.

Explicit cast is here because the unsigned int + int sum would result in
an unsigned int.

I will use an intermediate signed value. Also the whole logic here can
be simplified a bit, so I will rework the whole block.

Best regards,
Mathieu

-- 
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help