diff options
-rw-r--r-- | drivers/leds/led-triggers.c | 9 | ||||
-rw-r--r-- | drivers/leds/leds-88pm860x.c | 2 | ||||
-rw-r--r-- | drivers/leds/leds-gpio.c | 1 | ||||
-rw-r--r-- | drivers/leds/leds-powernv.c | 12 | ||||
-rw-r--r-- | drivers/leds/leds-pwm.c | 22 | ||||
-rw-r--r-- | include/linux/leds.h | 1 |
6 files changed, 20 insertions, 27 deletions
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index 17d73db1456e..2d451b6c24af 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -200,8 +200,11 @@ void led_trigger_set_default(struct led_classdev *led_cdev) down_read(&triggers_list_lock); down_write(&led_cdev->trigger_lock); list_for_each_entry(trig, &trigger_list, next_trig) { - if (!strcmp(led_cdev->default_trigger, trig->name)) + if (!strcmp(led_cdev->default_trigger, trig->name)) { + led_cdev->flags |= LED_INIT_DEFAULT_TRIGGER; led_trigger_set(led_cdev, trig); + break; + } } up_write(&led_cdev->trigger_lock); up_read(&triggers_list_lock); @@ -248,8 +251,10 @@ int led_trigger_register(struct led_trigger *trig) list_for_each_entry(led_cdev, &leds_list, node) { down_write(&led_cdev->trigger_lock); if (!led_cdev->trigger && led_cdev->default_trigger && - !strcmp(led_cdev->default_trigger, trig->name)) + !strcmp(led_cdev->default_trigger, trig->name)) { + led_cdev->flags |= LED_INIT_DEFAULT_TRIGGER; led_trigger_set(led_cdev, trig); + } up_write(&led_cdev->trigger_lock); } up_read(&leds_list_lock); diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c index 77a104d2b124..036d4a536697 100644 --- a/drivers/leds/leds-88pm860x.c +++ b/drivers/leds/leds-88pm860x.c @@ -130,7 +130,7 @@ static int pm860x_led_dt_init(struct platform_device *pdev, return -ENODEV; } for_each_child_of_node(nproot, np) { - if (!of_node_cmp(np->name, data->name)) { + if (of_node_name_eq(np, data->name)) { of_property_read_u32(np, "marvell,88pm860x-iset", &iset); data->iset = PM8606_LED_CURRENT(iset); diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 45e012093865..998f2ff6914d 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -190,7 +190,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) fwnode_handle_put(child); return ERR_PTR(ret); } - led_dat->cdev.dev->of_node = np; priv->num_leds++; } diff --git a/drivers/leds/leds-powernv.c b/drivers/leds/leds-powernv.c index b1adbd70ce2e..fbab86cb3cc7 100644 --- a/drivers/leds/leds-powernv.c +++ b/drivers/leds/leds-powernv.c @@ -285,6 +285,7 @@ static int powernv_led_probe(struct platform_device *pdev) struct device_node *led_node; struct powernv_led_common *powernv_led_common; struct device *dev = &pdev->dev; + int rc; led_node = of_find_node_by_path("/ibm,opal/leds"); if (!led_node) { @@ -295,15 +296,20 @@ static int powernv_led_probe(struct platform_device *pdev) powernv_led_common = devm_kzalloc(dev, sizeof(*powernv_led_common), GFP_KERNEL); - if (!powernv_led_common) - return -ENOMEM; + if (!powernv_led_common) { + rc = -ENOMEM; + goto out; + } mutex_init(&powernv_led_common->lock); powernv_led_common->max_led_type = cpu_to_be64(OPAL_SLOT_LED_TYPE_MAX); platform_set_drvdata(pdev, powernv_led_common); - return powernv_led_classdev(pdev, led_node, powernv_led_common); + rc = powernv_led_classdev(pdev, led_node, powernv_led_common); +out: + of_node_put(led_node); + return rc; } /* Platform driver remove */ diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index 5d3faae51d59..af08bcdc4fd8 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -74,12 +74,6 @@ static inline size_t sizeof_pwm_leds_priv(int num_leds) (sizeof(struct led_pwm_data) * num_leds); } -static void led_pwm_cleanup(struct led_pwm_priv *priv) -{ - while (priv->num_leds--) - led_classdev_unregister(&priv->leds[priv->num_leds].cdev); -} - static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, struct led_pwm *led, struct device_node *child) { @@ -120,7 +114,7 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, if (!led_data->period && (led->pwm_period_ns > 0)) led_data->period = led->pwm_period_ns; - ret = led_classdev_register(dev, &led_data->cdev); + ret = devm_of_led_classdev_register(dev, child, &led_data->cdev); if (ret == 0) { priv->num_leds++; led_pwm_set(&led_data->cdev, led_data->cdev.brightness); @@ -191,25 +185,14 @@ static int led_pwm_probe(struct platform_device *pdev) ret = led_pwm_create_of(&pdev->dev, priv); } - if (ret) { - led_pwm_cleanup(priv); + if (ret) return ret; - } platform_set_drvdata(pdev, priv); return 0; } -static int led_pwm_remove(struct platform_device *pdev) -{ - struct led_pwm_priv *priv = platform_get_drvdata(pdev); - - led_pwm_cleanup(priv); - - return 0; -} - static const struct of_device_id of_pwm_leds_match[] = { { .compatible = "pwm-leds", }, {}, @@ -218,7 +201,6 @@ MODULE_DEVICE_TABLE(of, of_pwm_leds_match); static struct platform_driver led_pwm_driver = { .probe = led_pwm_probe, - .remove = led_pwm_remove, .driver = { .name = "leds_pwm", .of_match_table = of_pwm_leds_match, diff --git a/include/linux/leds.h b/include/linux/leds.h index 580cbaef789a..5263f87e1d2c 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -51,6 +51,7 @@ struct led_classdev { #define LED_PANIC_INDICATOR BIT(20) #define LED_BRIGHT_HW_CHANGED BIT(21) #define LED_RETAIN_AT_SHUTDOWN BIT(22) +#define LED_INIT_DEFAULT_TRIGGER BIT(23) /* set_brightness_work / blink_timer flags, atomic, private. */ unsigned long work_flags; |