14 #include <linux/module.h>
16 #include <linux/slab.h>
23 #define to_regulator_led(led_cdev) \
24 container_of(led_cdev, struct regulator_led, cdev)
36 static inline int led_regulator_get_max_brightness(
struct regulator *supply)
55 static int led_regulator_get_voltage(
struct regulator *supply,
74 dev_err(led->
cdev.dev,
"Failed to enable vcc: %d\n", ret);
90 dev_err(led->
cdev.dev,
"Failed to disable vcc: %d\n", ret);
97 static void regulator_led_set_value(
struct regulator_led *led)
105 regulator_led_disable(led);
109 if (led->
cdev.max_brightness > 1) {
110 voltage = led_regulator_get_voltage(led->
vcc, led->
value);
111 dev_dbg(led->
cdev.dev,
"brightness: %d voltage: %d\n",
112 led->
value, voltage);
116 dev_err(led->
cdev.dev,
"Failed to set voltage %d: %d\n",
120 regulator_led_enable(led);
131 regulator_led_set_value(led);
134 static void regulator_led_brightness_set(
struct led_classdev *led_cdev,
167 led->
cdev.max_brightness = led_regulator_get_max_brightness(vcc);
169 dev_err(&pdev->
dev,
"Invalid default brightness %d\n",
176 led->
cdev.brightness_set = regulator_led_brightness_set;
188 platform_set_drvdata(pdev, led);
200 regulator_led_set_value(led);
215 regulator_led_disable(led);
222 .name =
"leds-regulator",
225 .probe = regulator_led_probe,