Re: [PATCH v5 1/4] platform/x86: int3472: Use local variable for LED struct access
From: Andy Shevchenko
Date: Mon Mar 30 2026 - 05:31:05 EST
On Fri, Mar 27, 2026 at 07:10:28PM +0100, Marco Nenciarini wrote:
> Introduce a local struct int3472_pled pointer in the LED registration
> and unregistration functions to avoid repeatedly dereferencing
> int3472->pled. In the brightness callback, use container_of() to get
> the int3472_pled struct directly instead of going through
> int3472_discrete_device.
>
> No functional change.
...
> static int int3472_pled_set(struct led_classdev *led_cdev,
> - enum led_brightness brightness)
> + enum led_brightness brightness)
> {
> - struct int3472_discrete_device *int3472 =
> - container_of(led_cdev, struct int3472_discrete_device, pled.classdev);
> + struct int3472_pled *pled = container_of(led_cdev, struct int3472_pled, classdev);
The idea was to call it led from the beginning, currently I don't see how this
reduces a churn I mentioned.
struct int3472_pled *led = container_of(led_cdev, struct int3472_pled, classdev);
> - gpiod_set_value_cansleep(int3472->pled.gpio, brightness);
> + gpiod_set_value_cansleep(pled->gpio, brightness);
gpiod_set_value_cansleep(led->gpio, brightness);
> return 0;
In the next patch it will be only a single line changed (data type on both sides).
> }
...
> int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio)
Same here.
--
With Best Regards,
Andy Shevchenko