Re: [PATCH 08/24] leds: lt3593: Use led_compose_name()

From: Daniel Mack
Date: Thu Nov 08 2018 - 03:33:26 EST


On 7/11/2018 8:49 PM, Jacek Anaszewski wrote:
On 11/07/2018 08:37 PM, Daniel Mack wrote:
On 6/11/2018 11:07 PM, Jacek Anaszewski wrote:
Switch to using generic LED support for composing LED class
device name.

Thanks for the rework!

Signed-off-by: Jacek Anaszewski <jacek.anaszewski@xxxxxxxxx>
---
 drivers/leds/leds-lt3593.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c
index de3623e..d005abc 100644
--- a/drivers/leds/leds-lt3593.c
+++ b/drivers/leds/leds-lt3593.c
@@ -10,10 +10,10 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <uapi/linux/uleds.h>
+
+#define LED_LT3593_NAME "lt3593"
  struct lt3593_led_data {
-ÂÂÂ char name[LED_MAX_NAME_SIZE];
ÂÂÂÂÂ struct led_classdev cdev;
ÂÂÂÂÂ struct gpio_desc *gpiod;
 };
@@ -111,6 +111,7 @@ static int lt3593_led_probe(struct platform_device
*pdev)
ÂÂÂÂÂ struct fwnode_handle *child;
ÂÂÂÂÂ int ret, state = LEDS_GPIO_DEFSTATE_OFF;
ÂÂÂÂÂ enum gpiod_flags flags = GPIOD_OUT_LOW;
+ÂÂÂ struct led_init_data init_data;
ÂÂÂÂÂ const char *tmp;
 Â if (dev_get_platdata(dev)) {
@@ -138,14 +139,11 @@ static int lt3593_led_probe(struct
platform_device *pdev)
ÂÂÂÂÂÂÂÂÂ return PTR_ERR(led_data->gpiod);
 Â child = device_get_next_child_node(dev, NULL);
+ÂÂÂ init_data.fwnode = child;

Not quite following. `fwnode' is the only member of that struct that is
initialized?

 - ret = fwnode_property_read_string(child, "label", &tmp);
-ÂÂÂ if (ret < 0)
-ÂÂÂÂÂÂÂ snprintf(led_data->name, sizeof(led_data->name),
-ÂÂÂÂÂÂÂÂÂÂÂÂ "lt3593::");
-ÂÂÂ else
-ÂÂÂÂÂÂÂ snprintf(led_data->name, sizeof(led_data->name),
-ÂÂÂÂÂÂÂÂÂÂÂÂ "lt3593:%s", tmp);
+ÂÂÂ ret = led_compose_name(child, LED_LT3593_NAME, ":", init_data.name);

... and here, a member that wasn't written before is used? What am I
missing?

init_data.name pointer is passed to led_compose_name(), which fills
this array with the composed name.

Ah, that's the target. Stupid me!

With this:

Acked-by: Daniel Mack <daniel@xxxxxxxxxx>


Thanks,
Daniel