]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
led: Move OF "label" property parsing to core
authorMarek Vasut <marex@denx.de>
Sun, 3 Apr 2022 23:18:02 +0000 (01:18 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 14 Apr 2022 19:39:14 +0000 (15:39 -0400)
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>
drivers/led/led-uclass.c

index 7e298dbb06f7fdcd4e808520a933b58375c2907e..2f4aa18fb10ade2679b8a12ad71a7d7105d2c9c5 100644 (file)
@@ -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,
 };