leds-lp5521: modify the way of setting led device name
PATCH 1/1 leds-lp5521: modify the way of setting led device name
Currently the led device name is fetched from the device_type in I2C_BOARD_INFO which comes from the platform data. This name is in turn used to create an entry in sysfs.
If there exists two or more lp5521 on a particular platform, the device_type in I2C_BOARD_INFO has to be the same, else lp5521 driver probe wont be called and if used so, results in run time warning "cannot create sysfs with same name" and hence a failure.
The name that is used to create sysfs entry is to be passed by the struct led_platform_data. Hence adding an element of type const char * and change in lp5521 driver to use this name in creating the led device if present else use the name obtained by I2C_BOARD_INFO.
--- drivers/leds/leds-lp5521.c | 3 ++- include/linux/leds-lp5521.h | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)
drivers/leds/leds-lp5521.c +2 -1
@@ -651,7 +651,8 @@ static int __init lp5521_init_led(struct lp5521_led *led,return -EINVAL ; } -snprintf (name,sizeof (name),"%s:channel%d" , client->name, chan); +snprintf (name,sizeof (name),"%s:channel%d" , + pdata->label ?: client->name, chan); led->cdev.brightness_set = lp5521_set_brightness; led->cdev.name = name; res =led_classdev_register (dev, &led->cdev);
include/linux/leds-lp5521.h +1 -0
@@ -42,6 +42,7 @@ struct lp5521_platform_data {int (*setup_resources)(void );void (*release_resources)(void );void (*enable)(bool state); + const char *label; };#endif /* __LINUX_LP5521_H */
Signature · 1 line
1.7.2.dirty
Quoted 9 lines · ext Arun Murthy
Currently the led device name is fetched from the
device_typeinI2C_BOARD_INFOwhich comes from the platform data. This name is in turn used to create an entry in sysfs.If there exists two or more lp5521 on a particular platform, the
device_typeinI2C_BOARD_INFOhas to be the same, else lp5521 driver probe wont be called and if used so, results in run time warning "cannot create sysfs with same name" and hence a failure.
Quoted 6 lines
The name that is used to create sysfs entry is to be passed by the struct
led_platform_data. Hence adding an element of type const char * and change in lp5521 driver to use this name in creating the led device if present else use the name obtained byI2C_BOARD_INFO.Signed-off-by Arun Murthy <[email protected]>
Looks ok.
I'll make similar patch for lp5523 at some point.
Quoted 31 lines
--- drivers/leds/leds-lp5521.c | 3 ++- include/linux/leds-lp5521.h | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)drivers/leds/leds-lp5521.c +2
-1@@ -651,7 +651,8 @@ static int __init lp5521_init_led(struct lp5521_led *led,return -EINVAL ; } -snprintf (name,sizeof (name),"%s:channel%d" , client->name, chan); +snprintf (name,sizeof (name),"%s:channel%d" , + pdata->label ?: client->name, chan); led->cdev.brightness_set = lp5521_set_brightness; led->cdev.name = name; res =led_classdev_register (dev, &led->cdev);include/linux/leds-lp5521.h +1
-0@@ -42,6 +42,7 @@ struct lp5521_platform_data {int (*setup_resources)(void );void (*release_resources)(void );void (*enable)(bool state); + const char *label; };#endif /* __LINUX_LP5521_H */
Hi Andrew,
Since Richard is not active in the community, can you please push this
patch through your mm tree.
Thanks and Regards,
Arun R Murthy
--------------
Quoted 28 lines
-----Original Message-----
From: Onkalo Samu [mailto:[email protected]]
Sent: Thursday, December 16, 2010 6:37 PM
To: Arun MURTHY
Cc: [email protected]; [email protected]; Linus WALLEIJ; linux- [email protected]
Subject: Re: [PATCH] leds-lp5521: modify the way of setting led device nameQuoted 2 lines · ext Arun Murthy
Currently the led device name is fetched from the
device_typeinI2C_BOARD_INFOwhich comes from the platform data. This name is inturn
Quoted 5 lines
used to create an entry in sysfs.
If there exists two or more lp5521 on a particular platform, the
device_typeinI2C_BOARD_INFOhas to be the same, else lp5521 driver probe wont be called and if used so, results in run time warning"cannot
Quoted 4 lines
create sysfs with same name" and hence a failure.
The name that is used to create sysfs entry is to be passed by the struct
led_platform_data. Hence adding an element of type const char*
Quoted 1 line
and change in lp5521 driver to use this name in creating the led
device
Quoted 2 lines
if present else use the name obtained by
I2C_BOARD_INFO.
Quoted 7 lines
Quoted 1 line
Signed-off-by Arun Murthy <[email protected]>Looks ok.
I'll make similar patch for lp5523 at some point.
Acked-by Samu Onkalo <[email protected]>
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�