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

From: Mathieu Dubois-Briand
Date: Fri May 02 2025 - 09:58:28 EST


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:
>> Add driver for Maxim Integrated MAX7360 rotary encoder controller,
>> supporting a single rotary switch.
>
> ...
>
>> +struct max7360_rotary {
>> + struct input_dev *input;
>> + unsigned int debounce_ms;
>> + struct regmap *regmap;
>> +
>> + u32 steps;
>> + u32 axis;
>> + bool relative_axis;
>> + bool rollover;
>> +
>> + unsigned int pos;
>> +};
>
> I believe `pahole` can recommend better layout (look for the better position
> of debounce_ms).
>
> ...
>

Oh yes it does on arm64. Moving it after the regmap pointer, it should
be better.

>> +static void max7360_rotaty_report_event(struct max7360_rotary *max7360_rotary, int steps)
>> +{
>> + if (max7360_rotary->relative_axis) {
>> + input_report_rel(max7360_rotary->input, max7360_rotary->axis, steps);
>> + } else {
>> + unsigned int pos = max7360_rotary->pos;
>> +
>> + if (steps < 0) {
>> + /* turning counter-clockwise */
>> + if (max7360_rotary->rollover)
>> + pos += max7360_rotary->steps + steps;
>> + else
>
>> + 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?

>
> ...
>
>> +static int max7360_rotary_probe(struct platform_device *pdev)
>> +{
>> + struct max7360_rotary *max7360_rotary;
>> + struct device *dev = &pdev->dev;
>> + struct input_dev *input;
>> + struct regmap *regmap;
>> + int irq;
>> + int error;
>> +
>> + regmap = dev_get_regmap(dev->parent, NULL);
>> + if (!regmap)
>> + dev_err_probe(dev, -ENODEV, "Could not get parent regmap\n");
>
> Missing return. Copy'n'paste error over all drivers?
>

Probably more an error while replacing all dev_err()+return by
dev_err_probe(), but yes. I will look for similar issues.

> ...

OK with all other comments.

Thanks for your review.
Mathieu

--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com