Commit 6b8274de authored by Marek Behún's avatar Marek Behún Committed by Pavel Machek

leds: mt6323: 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.

Since init_data is passed with fwnode handle, we do not need to set
the of_node member of the newly created LED classdev.
Signed-off-by: default avatarMarek Behún <marek.behun@nic.cz>
Cc: Sean Wang <sean.wang@mediatek.com>
Cc: John Crispin <john@phrozen.org>
Cc: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
parent d7d02b8a
...@@ -342,7 +342,6 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev, ...@@ -342,7 +342,6 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev,
const char *state; const char *state;
int ret = 0; int ret = 0;
led->cdev.name = of_get_property(np, "label", NULL) ? : np->name;
led->cdev.default_trigger = of_get_property(np, led->cdev.default_trigger = of_get_property(np,
"linux,default-trigger", "linux,default-trigger",
NULL); NULL);
...@@ -402,6 +401,8 @@ static int mt6323_led_probe(struct platform_device *pdev) ...@@ -402,6 +401,8 @@ static int mt6323_led_probe(struct platform_device *pdev)
} }
for_each_available_child_of_node(np, child) { for_each_available_child_of_node(np, child) {
struct led_init_data init_data = {};
ret = of_property_read_u32(child, "reg", &reg); ret = of_property_read_u32(child, "reg", &reg);
if (ret) { if (ret) {
dev_err(dev, "Failed to read led 'reg' property\n"); dev_err(dev, "Failed to read led 'reg' property\n");
...@@ -437,13 +438,15 @@ static int mt6323_led_probe(struct platform_device *pdev) ...@@ -437,13 +438,15 @@ static int mt6323_led_probe(struct platform_device *pdev)
goto put_child_node; goto put_child_node;
} }
ret = devm_led_classdev_register(dev, &leds->led[reg]->cdev); init_data.fwnode = of_fwnode_handle(child);
ret = devm_led_classdev_register_ext(dev, &leds->led[reg]->cdev,
&init_data);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to register LED: %d\n", dev_err(&pdev->dev, "Failed to register LED: %d\n",
ret); ret);
goto put_child_node; goto put_child_node;
} }
leds->led[reg]->cdev.dev->of_node = child;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment