Skip to content

Commit d6116d8

Browse files
mnenciaij-intel
authored andcommitted
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>
1 parent a29b5cd commit d6116d8

1 file changed

Lines changed: 22 additions & 21 deletions

File tree

  • drivers/platform/x86/intel/int3472

drivers/platform/x86/intel/int3472/led.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,56 @@
66
#include <linux/leds.h>
77
#include <linux/platform_data/x86/int3472.h>
88

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)
1110
{
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);
1412

15-
gpiod_set_value_cansleep(int3472->pled.gpio, brightness);
13+
gpiod_set_value_cansleep(led->gpio, brightness);
1614
return 0;
1715
}
1816

1917
int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio)
2018
{
19+
struct int3472_pled *led = &int3472->pled;
2120
char *p;
2221
int ret;
2322

24-
if (int3472->pled.classdev.dev)
23+
if (led->classdev.dev)
2524
return -EBUSY;
2625

27-
int3472->pled.gpio = gpio;
26+
led->gpio = gpio;
2827

2928
/* 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),
3130
"%s::privacy_led", acpi_dev_name(int3472->sensor));
32-
p = strchr(int3472->pled.name, ':');
31+
p = strchr(led->name, ':');
3332
if (p)
3433
*p = '_';
3534

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;
3938

40-
ret = led_classdev_register(int3472->dev, &int3472->pled.classdev);
39+
ret = led_classdev_register(int3472->dev, &led->classdev);
4140
if (ret)
4241
return ret;
4342

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);
4847

4948
return 0;
5049
}
5150

5251
void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472)
5352
{
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))
5556
return;
5657

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);
6061
}

0 commit comments

Comments
 (0)