diff mbox series

[leds,v2,20/50] leds: pm8058: use struct led_init_data when registering

Message ID 20200917223338.14164-21-marek.behun@nic.cz
State New
Headers show
Series None | expand

Commit Message

Marek Behún Sept. 17, 2020, 10:33 p.m. UTC
By using struct led_init_data when registering we do not need to parse
`label` DT property. Moreover `label` is deprecated and if it is not
present but `color` and `function` are, LED core will compose a name
from these properties instead.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/leds/leds-pm8058.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Linus Walleij Sept. 29, 2020, 1:14 p.m. UTC | #1
On Fri, Sep 18, 2020 at 12:33 AM Marek Behún <marek.behun@nic.cz> wrote:

> By using struct led_init_data when registering we do not need to parse
> `label` DT property. Moreover `label` is deprecated and if it is not
> present but `color` and `function` are, LED core will compose a name
> from these properties instead.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>

For this and the other PM8058 patches:
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c
index dcd7d8c3d6b44..e085bf9ffc1de 100644
--- a/drivers/leds/leds-pm8058.c
+++ b/drivers/leds/leds-pm8058.c
@@ -87,6 +87,7 @@  static enum led_brightness pm8058_led_get(struct led_classdev *cled)
 
 static int pm8058_led_probe(struct platform_device *pdev)
 {
+	struct led_init_data init_data = {};
 	struct pm8058_led *led;
 	struct device_node *np = dev_of_node(&pdev->dev);
 	int ret;
@@ -113,8 +114,6 @@  static int pm8058_led_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	/* Use label else node name */
-	led->cdev.name = of_get_property(np, "label", NULL) ? : np->name;
 	led->cdev.default_trigger =
 		of_get_property(np, "linux,default-trigger", NULL);
 	led->cdev.brightness_set = pm8058_led_set;
@@ -142,10 +141,12 @@  static int pm8058_led_probe(struct platform_device *pdev)
 	    led->ledtype == PM8058_LED_TYPE_FLASH)
 		led->cdev.flags	= LED_CORE_SUSPENDRESUME;
 
-	ret = devm_led_classdev_register(&pdev->dev, &led->cdev);
+	init_data.fwnode = of_fwnode_handle(np);
+
+	ret = devm_led_classdev_register_ext(&pdev->dev, &led->cdev,
+					     &init_data);
 	if (ret) {
-		dev_err(&pdev->dev, "unable to register led \"%s\"\n",
-			led->cdev.name);
+		dev_err(&pdev->dev, "Failed to register LED for %pOF\n", np);
 		return ret;
 	}