b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 7a349e8c535d7327bf80710323c725df47149b8d Mon Sep 17 00:00:00 2001 |
| 2 | From: Jean-Jacques Hiblot <jjhiblot@ti.com> |
| 3 | Date: Sun, 5 Jan 2020 23:31:14 +0100 |
| 4 | Subject: [PATCH] leds: populate the device's of_node |
| 5 | |
| 6 | If initialization data is available and its fwnode is actually a |
| 7 | of_node, store this information in the led device's structure. This |
| 8 | will allow the device to use or provide OF-based API such (devm_xxx). |
| 9 | |
| 10 | Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> |
| 11 | Signed-off-by: Pavel Machek <pavel@ucw.cz> |
| 12 | [backport to 5.4] |
| 13 | --- |
| 14 | |
| 15 | --- a/drivers/leds/led-class.c |
| 16 | +++ b/drivers/leds/led-class.c |
| 17 | @@ -19,6 +19,7 @@ |
| 18 | #include <linux/spinlock.h> |
| 19 | #include <linux/timer.h> |
| 20 | #include <uapi/linux/uleds.h> |
| 21 | +#include <linux/of.h> |
| 22 | #include "leds.h" |
| 23 | |
| 24 | static struct class *leds_class; |
| 25 | @@ -277,8 +278,10 @@ int led_classdev_register_ext(struct dev |
| 26 | mutex_unlock(&led_cdev->led_access); |
| 27 | return PTR_ERR(led_cdev->dev); |
| 28 | } |
| 29 | - if (init_data && init_data->fwnode) |
| 30 | + if (init_data && init_data->fwnode) { |
| 31 | led_cdev->dev->fwnode = init_data->fwnode; |
| 32 | + led_cdev->dev->of_node = to_of_node(init_data->fwnode); |
| 33 | + } |
| 34 | |
| 35 | if (ret) |
| 36 | dev_warn(parent, "Led %s renamed to %s due to name collision", |