Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: int3472: Use local variable for LED struct access

Introduce a local struct int3472_pled pointer in the LED registration,
unregistration, and brightness callback 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.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Marco Nenciarini <mnencia@kcore.it>
Link: https://patch.msgid.link/20260401203638.1601661-2-mnencia@kcore.it
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Marco Nenciarini and committed by
Ilpo Järvinen
d6116d86 a29b5cd4

+22 -21
+22 -21
drivers/platform/x86/intel/int3472/led.c
··· 6 6 #include <linux/leds.h> 7 7 #include <linux/platform_data/x86/int3472.h> 8 8 9 - static int int3472_pled_set(struct led_classdev *led_cdev, 10 - enum led_brightness brightness) 9 + static int int3472_pled_set(struct led_classdev *led_cdev, enum led_brightness brightness) 11 10 { 12 - struct int3472_discrete_device *int3472 = 13 - container_of(led_cdev, struct int3472_discrete_device, pled.classdev); 11 + struct int3472_pled *led = container_of(led_cdev, struct int3472_pled, classdev); 14 12 15 - gpiod_set_value_cansleep(int3472->pled.gpio, brightness); 13 + gpiod_set_value_cansleep(led->gpio, brightness); 16 14 return 0; 17 15 } 18 16 19 17 int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio) 20 18 { 19 + struct int3472_pled *led = &int3472->pled; 21 20 char *p; 22 21 int ret; 23 22 24 - if (int3472->pled.classdev.dev) 23 + if (led->classdev.dev) 25 24 return -EBUSY; 26 25 27 - int3472->pled.gpio = gpio; 26 + led->gpio = gpio; 28 27 29 28 /* Generate the name, replacing the ':' in the ACPI devname with '_' */ 30 - snprintf(int3472->pled.name, sizeof(int3472->pled.name), 29 + snprintf(led->name, sizeof(led->name), 31 30 "%s::privacy_led", acpi_dev_name(int3472->sensor)); 32 - p = strchr(int3472->pled.name, ':'); 31 + p = strchr(led->name, ':'); 33 32 if (p) 34 33 *p = '_'; 35 34 36 - int3472->pled.classdev.name = int3472->pled.name; 37 - int3472->pled.classdev.max_brightness = 1; 38 - int3472->pled.classdev.brightness_set_blocking = int3472_pled_set; 35 + led->classdev.name = led->name; 36 + led->classdev.max_brightness = 1; 37 + led->classdev.brightness_set_blocking = int3472_pled_set; 39 38 40 - ret = led_classdev_register(int3472->dev, &int3472->pled.classdev); 39 + ret = led_classdev_register(int3472->dev, &led->classdev); 41 40 if (ret) 42 41 return ret; 43 42 44 - int3472->pled.lookup.provider = int3472->pled.name; 45 - int3472->pled.lookup.dev_id = int3472->sensor_name; 46 - int3472->pled.lookup.con_id = "privacy"; 47 - led_add_lookup(&int3472->pled.lookup); 43 + led->lookup.provider = led->name; 44 + led->lookup.dev_id = int3472->sensor_name; 45 + led->lookup.con_id = "privacy"; 46 + led_add_lookup(&led->lookup); 48 47 49 48 return 0; 50 49 } 51 50 52 51 void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472) 53 52 { 54 - if (IS_ERR_OR_NULL(int3472->pled.classdev.dev)) 53 + struct int3472_pled *led = &int3472->pled; 54 + 55 + if (IS_ERR_OR_NULL(led->classdev.dev)) 55 56 return; 56 57 57 - led_remove_lookup(&int3472->pled.lookup); 58 - led_classdev_unregister(&int3472->pled.classdev); 59 - gpiod_put(int3472->pled.gpio); 58 + led_remove_lookup(&led->lookup); 59 + led_classdev_unregister(&led->classdev); 60 + gpiod_put(led->gpio); 60 61 }