1 // SPDX-License-Identifier: GPL-2.0
2 /* Author: Hans de Goede <hdegoede@redhat.com> */
4 #include <linux/acpi.h>
5 #include <linux/gpio/consumer.h>
6 #include <linux/leds.h>
9 static int int3472_pled_set(struct led_classdev
*led_cdev
,
10 enum led_brightness brightness
)
12 struct int3472_discrete_device
*int3472
=
13 container_of(led_cdev
, struct int3472_discrete_device
, pled
.classdev
);
15 gpiod_set_value_cansleep(int3472
->pled
.gpio
, brightness
);
19 int skl_int3472_register_pled(struct int3472_discrete_device
*int3472
, struct gpio_desc
*gpio
)
24 if (int3472
->pled
.classdev
.dev
)
27 int3472
->pled
.gpio
= gpio
;
29 /* Generate the name, replacing the ':' in the ACPI devname with '_' */
30 snprintf(int3472
->pled
.name
, sizeof(int3472
->pled
.name
),
31 "%s::privacy_led", acpi_dev_name(int3472
->sensor
));
32 p
= strchr(int3472
->pled
.name
, ':');
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
;
40 ret
= led_classdev_register(int3472
->dev
, &int3472
->pled
.classdev
);
44 int3472
->pled
.lookup
.provider
= int3472
->pled
.name
;
45 int3472
->pled
.lookup
.dev_id
= int3472
->sensor_name
;
46 int3472
->pled
.lookup
.con_id
= "privacy-led";
47 led_add_lookup(&int3472
->pled
.lookup
);
52 void skl_int3472_unregister_pled(struct int3472_discrete_device
*int3472
)
54 if (IS_ERR_OR_NULL(int3472
->pled
.classdev
.dev
))
57 led_remove_lookup(&int3472
->pled
.lookup
);
58 led_classdev_unregister(&int3472
->pled
.classdev
);