Re: [PATCH v7 10/11] input: misc: Add support for MAX7360 rotary
From: Mathieu Dubois-Briand
Date: Mon May 05 2025 - 07:52:50 EST
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:
>> On Fri May 2, 2025 at 12:52 PM CEST, Andy Shevchenko wrote:
>> > On Mon, Apr 28, 2025 at 01:57:28PM +0200, Mathieu Dubois-Briand wrote:
>
> ...
>
>> >> + 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