diff options
author | Marek Vasut <marex@denx.de> | 2022-04-04 01:18:02 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-04-14 15:39:14 -0400 |
commit | 83c63f0d11856ab5664506f0dd12d7d76c46a3a4 (patch) | |
tree | 253e2659a33b62219d14638c09f759c5bc7f3257 | |
parent | aecb338163e2fe55e32d3e2039af737a8bfaaa19 (diff) | |
download | u-boot-83c63f0d11856ab5664506f0dd12d7d76c46a3a4.tar.gz u-boot-83c63f0d11856ab5664506f0dd12d7d76c46a3a4.tar.bz2 u-boot-83c63f0d11856ab5664506f0dd12d7d76c46a3a4.zip |
led: Move OF "label" property parsing to core
Every driver in drivers/led/ currently does some form of "label" OF
property parsing in its bind() callback. Move this label parsing to
LED core, since this "label" OF property is a generic property. This
permits code deduplication in subseuqent patches.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Alex Nemirovsky <alex.nemirovsky@cortina-access.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philippe Reynes <philippe.reynes@softathome.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Steven Lawrance <steven.lawrance@softathome.com>
-rw-r--r-- | drivers/led/led-uclass.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index 7e298dbb06..2f4aa18fb1 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -95,8 +95,20 @@ int led_default_state(void) return ret; } +static int led_post_bind(struct udevice *dev) +{ + struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); + + uc_plat->label = dev_read_string(dev, "label"); + if (!uc_plat->label) + uc_plat->label = ofnode_get_name(dev_ofnode(dev)); + + return 0; +} + UCLASS_DRIVER(led) = { .id = UCLASS_LED, .name = "led", .per_device_plat_auto = sizeof(struct led_uc_plat), + .post_bind = led_post_bind, }; |