]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/leds/leds-gpio.c
Merge tag 'core-debugobjects-2020-01-28' of git://git.kernel.org/pub/scm/linux/kernel...
[linux.git] / drivers / leds / leds-gpio.c
index a5c73f3d5f797dc63b2ee03c738a213a9f8529fb..2bf74595610f5c607173ef2597fe95c41e99ce5d 100644 (file)
@@ -151,9 +151,14 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
                struct gpio_led led = {};
                const char *state = NULL;
 
+               /*
+                * Acquire gpiod from DT with uninitialized label, which
+                * will be updated after LED class device is registered,
+                * Only then the final LED name is known.
+                */
                led.gpiod = devm_fwnode_get_gpiod_from_child(dev, NULL, child,
                                                             GPIOD_ASIS,
-                                                            led.name);
+                                                            NULL);
                if (IS_ERR(led.gpiod)) {
                        fwnode_handle_put(child);
                        return ERR_CAST(led.gpiod);
@@ -186,6 +191,9 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
                        fwnode_handle_put(child);
                        return ERR_PTR(ret);
                }
+               /* Set gpiod label to match the corresponding LED name. */
+               gpiod_set_consumer_name(led_dat->gpiod,
+                                       led_dat->cdev.dev->kobj.name);
                priv->num_leds++;
        }