diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-12-25 14:52:50 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-12-25 14:52:50 -0800 |
commit | 4e4390ad067a61ce4e7607bd0df31f19a4caa36a (patch) | |
tree | 4e47145ff9d2e04c933711471c9310daf1b98c77 /drivers | |
parent | b1669432b3555954124ffd987a6ff2308344c88f (diff) | |
parent | 8146aace60c7409cc60a1598bc9647a5bbb12eb4 (diff) | |
download | linux-4e4390ad067a61ce4e7607bd0df31f19a4caa36a.tar.bz2 |
Merge tag 'leds-for-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds
Pull LED updates from Jacek Anaszewski:
"There are several few-liners, where most of them are fixes and
improvments. One thing standing out is ground preparation for
inititializing trigger parameters via Device Tree.
We introduce LED_INIT_DEFAULT_TRIGGER flag for that purpose and set it
when default trigger is matched. It indicates that trigger should
parse DT properties to retrieve the initialization data when set as
default one"
* tag 'leds-for-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds:
led: triggers: Initialize LED_INIT_DEFAULT_TRIGGER if trigger is brought after class
led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag
led: triggers: Break the for loop after default trigger is found
leds: pwm: Use OF variant of LED registering function
leds: pwm: Simplify with resource-managed devm_led_classdev_register()
leds: gpio: Drop unneeded manual of_node assignment
leds: 88pm860x: Use of_node_name_eq for node name comparisons
leds: powernv: add of_node_put()
Diffstat (limited to 'drivers')
-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 |
5 files changed, 19 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, |