13 #include <linux/kernel.h>
20 #include <linux/slab.h>
22 #include <linux/module.h>
34 unsigned long *delay_on,
unsigned long *delay_off);
84 unsigned long *delay_on,
unsigned long *delay_off)
96 int (*blink_set)(
unsigned,
int,
unsigned long *,
unsigned long *))
103 if (!gpio_is_valid(
template->gpio)) {
113 led_dat->
cdev.name =
template->name;
114 led_dat->
cdev.default_trigger =
template->default_trigger;
115 led_dat->
gpio =
template->gpio;
121 led_dat->
cdev.blink_set = gpio_blink_set;
123 led_dat->
cdev.brightness_set = gpio_led_set;
129 if (!
template->retain_state_suspended)
150 if (!gpio_is_valid(led->
gpio))
162 static inline int sizeof_gpio_leds_priv(
int num_leds)
169 #ifdef CONFIG_OF_GPIO
177 count = of_get_child_count(np);
191 led.
gpio = of_get_gpio_flags(
child, 0, &flags);
198 if (!
strcmp(state,
"keep"))
200 else if (!
strcmp(state,
"on"))
206 ret = create_gpio_led(&led, &priv->
leds[priv->
num_leds++],
217 for (count = priv->
num_leds - 2; count >= 0; count--)
218 delete_gpio_led(&priv->
leds[count]);
222 static const struct of_device_id of_gpio_leds_match[] = {
241 pinctrl = devm_pinctrl_get_select_default(&pdev->
dev);
244 "pins are not configured from the driver\n");
248 sizeof_gpio_leds_priv(pdata->
num_leds),
254 for (i = 0; i < priv->
num_leds; i++) {
255 ret = create_gpio_led(&pdata->
leds[i],
260 for (i = i - 1; i >= 0; i--)
261 delete_gpio_led(&priv->
leds[i]);
266 priv = gpio_leds_create_of(pdev);
271 platform_set_drvdata(pdev, priv);
281 for (i = 0; i < priv->
num_leds; i++)
282 delete_gpio_led(&priv->
leds[i]);
284 platform_set_drvdata(pdev,
NULL);
290 .probe = gpio_led_probe,