public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds-lp5521: modify the way of setting led device name
@ 2010-12-15 11:55 Arun Murthy
  2010-12-16 13:07 ` Onkalo Samu
  0 siblings, 1 reply; 3+ messages in thread
From: Arun Murthy @ 2010-12-15 11:55 UTC (permalink / raw)
  To: samu.p.onkalo, akpm, rpurdie; +Cc: arun.murthy, linus.walleij, linux-kernel

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.

Signed-off-by: Arun Murthy <arun.murthy@stericsson.com>
---
 drivers/leds/leds-lp5521.c  |    3 ++-
 include/linux/leds-lp5521.h |    1 +
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 33facd0..745ad99 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -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);
diff --git a/include/linux/leds-lp5521.h b/include/linux/leds-lp5521.h
index 38368d7..fd548d2 100644
--- a/include/linux/leds-lp5521.h
+++ b/include/linux/leds-lp5521.h
@@ -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 */
-- 
1.7.2.dirty


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] leds-lp5521: modify the way of setting led device name
  2010-12-15 11:55 [PATCH] leds-lp5521: modify the way of setting led device name Arun Murthy
@ 2010-12-16 13:07 ` Onkalo Samu
  2010-12-19 10:57   ` Arun MURTHY
  0 siblings, 1 reply; 3+ messages in thread
From: Onkalo Samu @ 2010-12-16 13:07 UTC (permalink / raw)
  To: ext Arun Murthy; +Cc: akpm, rpurdie, linus.walleij, linux-kernel

On Wed, 2010-12-15 at 17:25 +0530, ext Arun Murthy wrote:
> 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.
> 
> Signed-off-by: Arun Murthy <arun.murthy@stericsson.com>

Looks ok.

I'll make similar patch for lp5523 at some point.

Acked-by: Samu Onkalo <samu.p.onkalo@nokia.com>

> ---
>  drivers/leds/leds-lp5521.c  |    3 ++-
>  include/linux/leds-lp5521.h |    1 +
>  2 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
> index 33facd0..745ad99 100644
> --- a/drivers/leds/leds-lp5521.c
> +++ b/drivers/leds/leds-lp5521.c
> @@ -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);
> diff --git a/include/linux/leds-lp5521.h b/include/linux/leds-lp5521.h
> index 38368d7..fd548d2 100644
> --- a/include/linux/leds-lp5521.h
> +++ b/include/linux/leds-lp5521.h
> @@ -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 */



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] leds-lp5521: modify the way of setting led device name
  2010-12-16 13:07 ` Onkalo Samu
@ 2010-12-19 10:57   ` Arun MURTHY
  0 siblings, 0 replies; 3+ messages in thread
From: Arun MURTHY @ 2010-12-19 10:57 UTC (permalink / raw)
  To: akpm@linux-foundation.org
  Cc: rpurdie@rpsys.net, Linus WALLEIJ, linux-kernel@vger.kernel.org,
	samu.p.onkalo@nokia.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1650 bytes --]

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
--------------

> -----Original Message-----
> From: Onkalo Samu [mailto:samu.p.onkalo@nokia.com]
> Sent: Thursday, December 16, 2010 6:37 PM
> To: Arun MURTHY
> Cc: akpm@linux-foundation.org; rpurdie@rpsys.net; Linus WALLEIJ; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH] leds-lp5521: modify the way of setting led device
> name
> 
> On Wed, 2010-12-15 at 17:25 +0530, ext Arun Murthy wrote:
> > 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.
> >
> > Signed-off-by: Arun Murthy <arun.murthy@stericsson.com>
> 
> Looks ok.
> 
> I'll make similar patch for lp5523 at some point.
> 
> Acked-by: Samu Onkalo <samu.p.onkalo@nokia.com>
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-19 10:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-15 11:55 [PATCH] leds-lp5521: modify the way of setting led device name Arun Murthy
2010-12-16 13:07 ` Onkalo Samu
2010-12-19 10:57   ` Arun MURTHY

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox