[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200917223338.14164-21-marek.behun@nic.cz>
Date: Fri, 18 Sep 2020 00:33:08 +0200
From: Marek Behún <marek.behun@....cz>
To: linux-leds@...r.kernel.org
Cc: Pavel Machek <pavel@....cz>, Dan Murphy <dmurphy@...com>,
Ondřej Jirman <megous@...ous.com>,
linux-kernel@...r.kernel.org, Rob Herring <robh+dt@...nel.org>,
devicetree@...r.kernel.org,
Marek Behún <marek.behun@....cz>,
Linus Walleij <linus.walleij@...aro.org>,
Bjorn Andersson <bjorn.andersson@...aro.org>
Subject: [PATCH leds v2 20/50] leds: pm8058: use struct led_init_data when registering
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@....cz>
Cc: Linus Walleij <linus.walleij@...aro.org>
Cc: Bjorn Andersson <bjorn.andersson@...aro.org>
---
drivers/leds/leds-pm8058.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
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;
}
--
2.26.2
Powered by blists - more mailing lists