diff mbox series

[RFC,2/2] leds: as3645a: Update LED label generation

Message ID 20171212215024.30116-2-dmurphy@ti.com
State New
Headers show
Series [RFC,1/2] dt: bindings: as3645a: Update dt node example with standard | expand

Commit Message

Dan Murphy Dec. 12, 2017, 9:50 p.m. UTC
Generate the LED label based off either the
DT label node or off the I2C ID in the
i2c device id struct.

If the label is used then this should denote
the LED function.  As an example it would
be as3645a:<function>

 Otherwise if the label is not
used the LED label will be as3645a:flash and
as3645a:indicator.

Signed-off-by: Dan Murphy <dmurphy@ti.com>

---
 drivers/leds/leds-as3645a.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

-- 
2.15.0.124.g7668cbc60

Comments

Sakari Ailus Dec. 14, 2017, 6:03 p.m. UTC | #1
Hi Dan,

Thanks for the patchset.

On Tue, Dec 12, 2017 at 03:50:24PM -0600, Dan Murphy wrote:
> Generate the LED label based off either the

> DT label node or off the I2C ID in the

> i2c device id struct.

> 

> If the label is used then this should denote

> the LED function.  As an example it would

> be as3645a:<function>

> 

>  Otherwise if the label is not

> used the LED label will be as3645a:flash and

> as3645a:indicator.


Which tree the patch is for? I see "id" is a u32 in what I have, and
also not defined in this scope.

> 

> Signed-off-by: Dan Murphy <dmurphy@ti.com>

> ---

>  drivers/leds/leds-as3645a.c | 10 ++++++----

>  1 file changed, 6 insertions(+), 4 deletions(-)

> 

> diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c

> index f883616d9e60..197acd69ddcc 100644

> --- a/drivers/leds/leds-as3645a.c

> +++ b/drivers/leds/leds-as3645a.c

> @@ -526,10 +526,11 @@ static int as3645a_parse_node(struct as3645a *flash,

>  

>  	rval = of_property_read_string(flash->flash_node, "label", &name);

>  	if (!rval)

> -		strlcpy(names->flash, name, sizeof(names->flash));

> +		snprintf(names->flash, sizeof(names->flash), "%s:%s",

> +			 id->name, name);

>  	else

>  		snprintf(names->flash, sizeof(names->flash),

> -			 "%s:flash", node->name);

> +			 "%s:flash", id->name);

>  

>  	rval = of_property_read_u32(flash->flash_node, "flash-timeout-us",

>  				    &cfg->flash_timeout_us);

> @@ -570,10 +571,11 @@ static int as3645a_parse_node(struct as3645a *flash,

>  

>  	rval = of_property_read_string(flash->indicator_node, "label", &name);

>  	if (!rval)

> -		strlcpy(names->indicator, name, sizeof(names->indicator));

> +		snprintf(names->indicator, sizeof(names->indicator), "%s:%s",

> +			 id->name, name);

>  	else

>  		snprintf(names->indicator, sizeof(names->indicator),

> -			 "%s:indicator", node->name);

> +			 "%s:indicator", id->name);

>  

>  	rval = of_property_read_u32(flash->indicator_node, "led-max-microamp",

>  				    &cfg->indicator_max_ua);




-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi
Dan Murphy Dec. 14, 2017, 7:13 p.m. UTC | #2
Sakari

On 12/14/2017 12:03 PM, Sakari Ailus wrote:
> Hi Dan,

> 

> Thanks for the patchset.

> 

> On Tue, Dec 12, 2017 at 03:50:24PM -0600, Dan Murphy wrote:

>> Generate the LED label based off either the

>> DT label node or off the I2C ID in the

>> i2c device id struct.

>>

>> If the label is used then this should denote

>> the LED function.  As an example it would

>> be as3645a:<function>

>>

>>  Otherwise if the label is not

>> used the LED label will be as3645a:flash and

>> as3645a:indicator.

> 

> Which tree the patch is for? I see "id" is a u32 in what I have, and

> also not defined in this scope.


Ah.  I did not notice that the driver used the probe_new call back.

I will be re-sending anyway since this is a RFC

Dan

> 

>>

>> Signed-off-by: Dan Murphy <dmurphy@ti.com>

>> ---

>>  drivers/leds/leds-as3645a.c | 10 ++++++----

>>  1 file changed, 6 insertions(+), 4 deletions(-)

>>

>> diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c

>> index f883616d9e60..197acd69ddcc 100644

>> --- a/drivers/leds/leds-as3645a.c

>> +++ b/drivers/leds/leds-as3645a.c

>> @@ -526,10 +526,11 @@ static int as3645a_parse_node(struct as3645a *flash,

>>  

>>  	rval = of_property_read_string(flash->flash_node, "label", &name);

>>  	if (!rval)

>> -		strlcpy(names->flash, name, sizeof(names->flash));

>> +		snprintf(names->flash, sizeof(names->flash), "%s:%s",

>> +			 id->name, name);

>>  	else

>>  		snprintf(names->flash, sizeof(names->flash),

>> -			 "%s:flash", node->name);

>> +			 "%s:flash", id->name);

>>  

>>  	rval = of_property_read_u32(flash->flash_node, "flash-timeout-us",

>>  				    &cfg->flash_timeout_us);

>> @@ -570,10 +571,11 @@ static int as3645a_parse_node(struct as3645a *flash,

>>  

>>  	rval = of_property_read_string(flash->indicator_node, "label", &name);

>>  	if (!rval)

>> -		strlcpy(names->indicator, name, sizeof(names->indicator));

>> +		snprintf(names->indicator, sizeof(names->indicator), "%s:%s",

>> +			 id->name, name);

>>  	else

>>  		snprintf(names->indicator, sizeof(names->indicator),

>> -			 "%s:indicator", node->name);

>> +			 "%s:indicator", id->name);

>>  

>>  	rval = of_property_read_u32(flash->indicator_node, "led-max-microamp",

>>  				    &cfg->indicator_max_ua);

> 

> 

> 



-- 
------------------
Dan Murphy
diff mbox series

Patch

diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
index f883616d9e60..197acd69ddcc 100644
--- a/drivers/leds/leds-as3645a.c
+++ b/drivers/leds/leds-as3645a.c
@@ -526,10 +526,11 @@  static int as3645a_parse_node(struct as3645a *flash,
 
 	rval = of_property_read_string(flash->flash_node, "label", &name);
 	if (!rval)
-		strlcpy(names->flash, name, sizeof(names->flash));
+		snprintf(names->flash, sizeof(names->flash), "%s:%s",
+			 id->name, name);
 	else
 		snprintf(names->flash, sizeof(names->flash),
-			 "%s:flash", node->name);
+			 "%s:flash", id->name);
 
 	rval = of_property_read_u32(flash->flash_node, "flash-timeout-us",
 				    &cfg->flash_timeout_us);
@@ -570,10 +571,11 @@  static int as3645a_parse_node(struct as3645a *flash,
 
 	rval = of_property_read_string(flash->indicator_node, "label", &name);
 	if (!rval)
-		strlcpy(names->indicator, name, sizeof(names->indicator));
+		snprintf(names->indicator, sizeof(names->indicator), "%s:%s",
+			 id->name, name);
 	else
 		snprintf(names->indicator, sizeof(names->indicator),
-			 "%s:indicator", node->name);
+			 "%s:indicator", id->name);
 
 	rval = of_property_read_u32(flash->indicator_node, "led-max-microamp",
 				    &cfg->indicator_max_ua);