Skip to content

Commit c7a6ced

Browse files
committed
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds
Pull LED subsystem update from Bryan Wu. * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: (24 commits) leds: add output driver configuration for pca9633 led driver leds: lm3642: Use regmap_update_bits() in lm3642_chip_init() leds: Add new LED driver for lm3642 chips leds-lp5523: Fix riskiness of the page fault leds-lp5523: turn off the LED engines on unloading the driver leds-lm3530: Fix smatch warnings leds-lm3530: Use devm_regulator_get function leds: leds-gpio: adopt pinctrl support leds: Add new LED driver for lm355x chips leds-lp5523: use the i2c device id rather than fixed name leds-lp5523: add new device id for LP55231 leds-lp5523: support new LP55231 device leds: triggers: send uevent when changing triggers leds-lp5523: minor code style fixes leds-lp5523: change the return type of lp5523_set_mode() leds-lp5523: set the brightness to 0 forcely on removing the driver leds-lp5523: add channel name in the platform data leds: leds-gpio: Use of_get_child_count() helper leds: leds-gpio: Use platform_{get,set}_drvdata leds: leds-gpio: use of_match_ptr() ...
2 parents a188e7e + 2f73c39 commit c7a6ced

22 files changed

+1350
-658
lines changed

Documentation/leds/leds-lp5523.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,22 @@ Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
1010
Description
1111
-----------
1212
LP5523 can drive up to 9 channels. Leds can be controlled directly via
13-
the led class control interface. Channels have generic names:
14-
lp5523:channelx where x is 0...8
13+
the led class control interface.
14+
The name of each channel is configurable in the platform data - name and label.
15+
There are three options to make the channel name.
16+
17+
a) Define the 'name' in the platform data
18+
To make specific channel name, then use 'name' platform data.
19+
/sys/class/leds/R1 (name: 'R1')
20+
/sys/class/leds/B1 (name: 'B1')
21+
22+
b) Use the 'label' with no 'name' field
23+
For one device name with channel number, then use 'label'.
24+
/sys/class/leds/RGB:channelN (label: 'RGB', N: 0 ~ 8)
25+
26+
c) Default
27+
If both fields are NULL, 'lp5523' is used by default.
28+
/sys/class/leds/lp5523:channelN (N: 0 ~ 8)
1529

1630
The chip provides 3 engines. Each engine can control channels without
1731
interaction from the main CPU. Details of the micro engine code can be found
@@ -46,12 +60,13 @@ Note - chan_nr can have values between 0 and 8.
4660

4761
static struct lp5523_led_config lp5523_led_config[] = {
4862
{
63+
.name = "D1",
4964
.chan_nr = 0,
5065
.led_current = 50,
5166
.max_current = 130,
5267
},
5368
...
54-
}, {
69+
{
5570
.chan_nr = 8,
5671
.led_current = 50,
5772
.max_current = 130,

drivers/leds/Kconfig

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ config LEDS_LM3533
6363
hardware-accelerated blinking with maximum on and off periods of 9.8
6464
and 77 seconds respectively.
6565

66+
config LEDS_LM3642
67+
tristate "LED support for LM3642 Chip"
68+
depends on LEDS_CLASS && I2C
69+
select REGMAP_I2C
70+
help
71+
This option enables support for LEDs connected to LM3642.
72+
The LM3642 is a 4MHz fixed-frequency synchronous boost
73+
converter plus 1.5A constant current driver for a high-current
74+
white LED.
75+
76+
6677
config LEDS_LOCOMO
6778
tristate "LED Support for Locomo device"
6879
depends on LEDS_CLASS
@@ -192,11 +203,12 @@ config LEDS_LP5521
192203
programming the engines.
193204

194205
config LEDS_LP5523
195-
tristate "LED Support for N.S. LP5523 LED driver chip"
206+
tristate "LED Support for TI/National LP5523/55231 LED driver chip"
196207
depends on LEDS_CLASS && I2C
197208
help
198-
If you say yes here you get support for the National Semiconductor
199-
LP5523 LED driver. It is 9 channel chip with programmable engines.
209+
If you say yes here you get support for TI/National Semiconductor
210+
LP5523/55231 LED driver.
211+
It is 9 channel chip with programmable engines.
200212
Driver provides direct control via LED class and interface for
201213
programming the engines.
202214

@@ -422,13 +434,13 @@ config LEDS_MAX8997
422434
This option enables support for on-chip LED drivers on
423435
MAXIM MAX8997 PMIC.
424436

425-
config LEDS_LM3556
426-
tristate "LED support for LM3556 Chip"
437+
config LEDS_LM355x
438+
tristate "LED support for LM355x Chips, LM3554 and LM3556"
427439
depends on LEDS_CLASS && I2C
428440
select REGMAP_I2C
429441
help
430-
This option enables support for LEDs connected to LM3556.
431-
LM3556 includes Torch, Flash and Indicator functions.
442+
This option enables support for LEDs connected to LM355x.
443+
LM355x includes Torch, Flash and Indicator functions.
432444

433445
config LEDS_OT200
434446
tristate "LED support for the Bachmann OT200"

drivers/leds/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o
1111
obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o
1212
obj-$(CONFIG_LEDS_LM3530) += leds-lm3530.o
1313
obj-$(CONFIG_LEDS_LM3533) += leds-lm3533.o
14+
obj-$(CONFIG_LEDS_LM3642) += leds-lm3642.o
1415
obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o
1516
obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
1617
obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
@@ -48,7 +49,7 @@ obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o
4849
obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o
4950
obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o
5051
obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
51-
obj-$(CONFIG_LEDS_LM3556) += leds-lm3556.o
52+
obj-$(CONFIG_LEDS_LM355x) += leds-lm355x.o
5253
obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o
5354

5455
# LED SPI Drivers

drivers/leds/led-class.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ static void led_timer_function(unsigned long data)
124124
mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay));
125125
}
126126

127+
static void set_brightness_delayed(struct work_struct *ws)
128+
{
129+
struct led_classdev *led_cdev =
130+
container_of(ws, struct led_classdev, set_brightness_work);
131+
132+
led_stop_software_blink(led_cdev);
133+
134+
__led_set_brightness(led_cdev, led_cdev->delayed_set_value);
135+
}
136+
127137
/**
128138
* led_classdev_suspend - suspend an led_classdev.
129139
* @led_cdev: the led_classdev to suspend.
@@ -191,6 +201,8 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
191201

192202
led_update_brightness(led_cdev);
193203

204+
INIT_WORK(&led_cdev->set_brightness_work, set_brightness_delayed);
205+
194206
init_timer(&led_cdev->blink_timer);
195207
led_cdev->blink_timer.function = led_timer_function;
196208
led_cdev->blink_timer.data = (unsigned long)led_cdev;
@@ -221,7 +233,10 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
221233
up_write(&led_cdev->trigger_lock);
222234
#endif
223235

236+
cancel_work_sync(&led_cdev->set_brightness_work);
237+
224238
/* Stop blinking */
239+
led_stop_software_blink(led_cdev);
225240
led_set_brightness(led_cdev, LED_OFF);
226241

227242
device_unregister(led_cdev->dev);

drivers/leds/led-core.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,23 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev,
103103
}
104104
EXPORT_SYMBOL(led_blink_set_oneshot);
105105

106-
void led_set_brightness(struct led_classdev *led_cdev,
107-
enum led_brightness brightness)
106+
void led_stop_software_blink(struct led_classdev *led_cdev)
108107
{
109-
/* stop and clear soft-blink timer */
110108
del_timer_sync(&led_cdev->blink_timer);
111109
led_cdev->blink_delay_on = 0;
112110
led_cdev->blink_delay_off = 0;
111+
}
112+
EXPORT_SYMBOL_GPL(led_stop_software_blink);
113+
114+
void led_set_brightness(struct led_classdev *led_cdev,
115+
enum led_brightness brightness)
116+
{
117+
/* delay brightness setting if need to stop soft-blink timer */
118+
if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) {
119+
led_cdev->delayed_set_value = brightness;
120+
schedule_work(&led_cdev->set_brightness_work);
121+
return;
122+
}
113123

114124
__led_set_brightness(led_cdev, brightness);
115125
}

drivers/leds/led-triggers.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,21 @@ EXPORT_SYMBOL_GPL(led_trigger_show);
102102
void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
103103
{
104104
unsigned long flags;
105+
char *event = NULL;
106+
char *envp[2];
107+
const char *name;
108+
109+
name = trig ? trig->name : "none";
110+
event = kasprintf(GFP_KERNEL, "TRIGGER=%s", name);
105111

106112
/* Remove any existing trigger */
107113
if (led_cdev->trigger) {
108114
write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
109115
list_del(&led_cdev->trig_list);
110116
write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock,
111117
flags);
118+
cancel_work_sync(&led_cdev->set_brightness_work);
119+
led_stop_software_blink(led_cdev);
112120
if (led_cdev->trigger->deactivate)
113121
led_cdev->trigger->deactivate(led_cdev);
114122
led_cdev->trigger = NULL;
@@ -122,6 +130,13 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
122130
if (trig->activate)
123131
trig->activate(led_cdev);
124132
}
133+
134+
if (event) {
135+
envp[0] = event;
136+
envp[1] = NULL;
137+
kobject_uevent_env(&led_cdev->dev->kobj, KOBJ_CHANGE, envp);
138+
kfree(event);
139+
}
125140
}
126141
EXPORT_SYMBOL_GPL(led_trigger_set);
127142

@@ -224,7 +239,7 @@ void led_trigger_event(struct led_trigger *trig,
224239
struct led_classdev *led_cdev;
225240

226241
led_cdev = list_entry(entry, struct led_classdev, trig_list);
227-
__led_set_brightness(led_cdev, brightness);
242+
led_set_brightness(led_cdev, brightness);
228243
}
229244
read_unlock(&trig->leddev_list_lock);
230245
}

drivers/leds/leds-clevo-mail.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
3131
}
3232

3333
/*
34-
* struct mail_led_whitelist - List of known good models
34+
* struct clevo_mail_led_dmi_table - List of known good models
3535
*
3636
* Contains the known good models this driver is compatible with.
3737
* When adding a new model try to be as strict as possible. This
3838
* makes it possible to keep the false positives (the model is
3939
* detected as working, but in reality it is not) as low as
4040
* possible.
4141
*/
42-
static struct dmi_system_id __initdata mail_led_whitelist[] = {
42+
static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
4343
{
4444
.callback = clevo_mail_led_dmi_callback,
4545
.ident = "Clevo D410J",
@@ -59,11 +59,10 @@ static struct dmi_system_id __initdata mail_led_whitelist[] = {
5959
},
6060
{
6161
.callback = clevo_mail_led_dmi_callback,
62-
.ident = "Positivo Mobile",
62+
.ident = "Clevo M5x0V",
6363
.matches = {
6464
DMI_MATCH(DMI_BOARD_VENDOR, "CLEVO Co. "),
6565
DMI_MATCH(DMI_BOARD_NAME, "M5X0V "),
66-
DMI_MATCH(DMI_PRODUCT_NAME, "Positivo Mobile"),
6766
DMI_MATCH(DMI_PRODUCT_VERSION, "VT6198")
6867
}
6968
},
@@ -89,6 +88,7 @@ static struct dmi_system_id __initdata mail_led_whitelist[] = {
8988
},
9089
{ }
9190
};
91+
MODULE_DEVICE_TABLE(dmi, clevo_mail_led_dmi_table);
9292

9393
static void clevo_mail_led_set(struct led_classdev *led_cdev,
9494
enum led_brightness value)
@@ -180,7 +180,7 @@ static int __init clevo_mail_led_init(void)
180180

181181
/* Check with the help of DMI if we are running on supported hardware */
182182
if (!nodetect) {
183-
count = dmi_check_system(mail_led_whitelist);
183+
count = dmi_check_system(clevo_mail_led_dmi_table);
184184
} else {
185185
count = 1;
186186
printk(KERN_ERR KBUILD_MODNAME ": Skipping DMI detection. "

drivers/leds/leds-gpio.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/slab.h>
2121
#include <linux/workqueue.h>
2222
#include <linux/module.h>
23+
#include <linux/pinctrl/consumer.h>
2324

2425
struct gpio_led_data {
2526
struct led_classdev cdev;
@@ -170,11 +171,10 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev
170171
{
171172
struct device_node *np = pdev->dev.of_node, *child;
172173
struct gpio_leds_priv *priv;
173-
int count = 0, ret;
174+
int count, ret;
174175

175176
/* count LEDs in this device, so we know how much to allocate */
176-
for_each_child_of_node(np, child)
177-
count++;
177+
count = of_get_child_count(np);
178178
if (!count)
179179
return NULL;
180180

@@ -228,16 +228,21 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev
228228
{
229229
return NULL;
230230
}
231-
#define of_gpio_leds_match NULL
232231
#endif /* CONFIG_OF_GPIO */
233232

234233

235234
static int __devinit gpio_led_probe(struct platform_device *pdev)
236235
{
237236
struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
238237
struct gpio_leds_priv *priv;
238+
struct pinctrl *pinctrl;
239239
int i, ret = 0;
240240

241+
pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
242+
if (IS_ERR(pinctrl))
243+
dev_warn(&pdev->dev,
244+
"pins are not configured from the driver\n");
245+
241246
if (pdata && pdata->num_leds) {
242247
priv = devm_kzalloc(&pdev->dev,
243248
sizeof_gpio_leds_priv(pdata->num_leds),
@@ -270,13 +275,13 @@ static int __devinit gpio_led_probe(struct platform_device *pdev)
270275

271276
static int __devexit gpio_led_remove(struct platform_device *pdev)
272277
{
273-
struct gpio_leds_priv *priv = dev_get_drvdata(&pdev->dev);
278+
struct gpio_leds_priv *priv = platform_get_drvdata(pdev);
274279
int i;
275280

276281
for (i = 0; i < priv->num_leds; i++)
277282
delete_gpio_led(&priv->leds[i]);
278283

279-
dev_set_drvdata(&pdev->dev, NULL);
284+
platform_set_drvdata(pdev, NULL);
280285

281286
return 0;
282287
}
@@ -287,7 +292,7 @@ static struct platform_driver gpio_led_driver = {
287292
.driver = {
288293
.name = "leds-gpio",
289294
.owner = THIS_MODULE,
290-
.of_match_table = of_gpio_leds_match,
295+
.of_match_table = of_match_ptr(of_gpio_leds_match),
291296
},
292297
};
293298

drivers/leds/leds-lm3530.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static int lm3530_get_mode_from_str(const char *str)
150150
if (sysfs_streq(str, mode_map[i].mode))
151151
return mode_map[i].mode_val;
152152

153-
return -1;
153+
return -EINVAL;
154154
}
155155

156156
static void lm3530_als_configure(struct lm3530_platform_data *pdata,
@@ -358,7 +358,7 @@ static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute
358358
mode = lm3530_get_mode_from_str(buf);
359359
if (mode < 0) {
360360
dev_err(dev, "Invalid mode\n");
361-
return -EINVAL;
361+
return mode;
362362
}
363363

364364
drvdata->mode = mode;
@@ -416,7 +416,7 @@ static int __devinit lm3530_probe(struct i2c_client *client,
416416

417417
i2c_set_clientdata(client, drvdata);
418418

419-
drvdata->regulator = regulator_get(&client->dev, "vin");
419+
drvdata->regulator = devm_regulator_get(&client->dev, "vin");
420420
if (IS_ERR(drvdata->regulator)) {
421421
dev_err(&client->dev, "regulator get failed\n");
422422
err = PTR_ERR(drvdata->regulator);
@@ -429,15 +429,13 @@ static int __devinit lm3530_probe(struct i2c_client *client,
429429
if (err < 0) {
430430
dev_err(&client->dev,
431431
"Register Init failed: %d\n", err);
432-
err = -ENODEV;
433-
goto err_reg_init;
432+
return err;
434433
}
435434
}
436435
err = led_classdev_register(&client->dev, &drvdata->led_dev);
437436
if (err < 0) {
438437
dev_err(&client->dev, "Register led class failed: %d\n", err);
439-
err = -ENODEV;
440-
goto err_class_register;
438+
return err;
441439
}
442440

443441
err = device_create_file(drvdata->led_dev.dev, &dev_attr_mode);
@@ -451,9 +449,6 @@ static int __devinit lm3530_probe(struct i2c_client *client,
451449

452450
err_create_file:
453451
led_classdev_unregister(&drvdata->led_dev);
454-
err_class_register:
455-
err_reg_init:
456-
regulator_put(drvdata->regulator);
457452
return err;
458453
}
459454

@@ -465,7 +460,6 @@ static int __devexit lm3530_remove(struct i2c_client *client)
465460

466461
if (drvdata->enable)
467462
regulator_disable(drvdata->regulator);
468-
regulator_put(drvdata->regulator);
469463
led_classdev_unregister(&drvdata->led_dev);
470464
return 0;
471465
}

0 commit comments

Comments
 (0)