Re: [PATCH v4 2/4] platform/x86: int3472: Use local variable for LED struct access

From: Andy Shevchenko

Date: Fri Mar 27 2026 - 06:21:56 EST


On Fri, Mar 27, 2026 at 10:07:51AM +0100, Marco Nenciarini wrote:
> Introduce a local struct int3472_led pointer in the LED registration
> and unregistration functions to avoid repeatedly dereferencing
> int3472->led. In the brightness callback, use container_of to get the

container_of()

> int3472_led struct directly instead of going through
> int3472_discrete_device.
>
> No functional change.

...

> static int int3472_led_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, led.classdev);
> + struct int3472_led *led =
> + container_of(led_cdev, struct int3472_led, classdev);

Now it can be a single line

struct int3472_led *led = container_of(led_cdev, struct int3472_led, classdev);

(the original code span to 85 characters, this line is 87, which is fine
I believe).


> - gpiod_set_value_cansleep(int3472->led.gpio, brightness);
> + gpiod_set_value_cansleep(led->gpio, brightness);
> return 0;
> }

...

> int skl_int3472_register_led(struct int3472_discrete_device *int3472, struct gpio_desc *gpio)
> {
> + struct int3472_led *led = &int3472->led;

Okay, make this patch going first, before renaming, so you will have the local
variable already be converted:

struct int3472_led *led = &int3472->pled;

This will reduce a lot of churn in both patches.

--
With Best Regards,
Andy Shevchenko