leds-lp5521: modify the way of setting led device name
authorArun Murthy <arun.murthy@stericsson.com>
Thu, 13 Jan 2011 00:59:20 +0000 (16:59 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 13 Jan 2011 16:03:06 +0000 (08:03 -0800)
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>
Acked-by: Samu Onkalo <samu.p.onkalo@nokia.com>
Cc: Ilkka Koskinen <ilkka.koskinen@nokia.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/leds/leds-lp5521.c
include/linux/leds-lp5521.h

index 4d91c08..80a3ae3 100644 (file)
@@ -617,7 +617,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);
index 38368d7..fd548d2 100644 (file)
@@ -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 */