Skip to content

Commit

Permalink
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…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()
  ...
  • Loading branch information
Linus Torvalds committed Oct 10, 2012
2 parents a188e7e + 2f73c39 commit c7a6ced
Show file tree
Hide file tree
Showing 22 changed files with 1,350 additions and 658 deletions.
21 changes: 18 additions & 3 deletions Documentation/leds/leds-lp5523.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,22 @@ Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
Description
-----------
LP5523 can drive up to 9 channels. Leds can be controlled directly via
the led class control interface. Channels have generic names:
lp5523:channelx where x is 0...8
the led class control interface.
The name of each channel is configurable in the platform data - name and label.
There are three options to make the channel name.

a) Define the 'name' in the platform data
To make specific channel name, then use 'name' platform data.
/sys/class/leds/R1 (name: 'R1')
/sys/class/leds/B1 (name: 'B1')

b) Use the 'label' with no 'name' field
For one device name with channel number, then use 'label'.
/sys/class/leds/RGB:channelN (label: 'RGB', N: 0 ~ 8)

c) Default
If both fields are NULL, 'lp5523' is used by default.
/sys/class/leds/lp5523:channelN (N: 0 ~ 8)

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

static struct lp5523_led_config lp5523_led_config[] = {
{
.name = "D1",
.chan_nr = 0,
.led_current = 50,
.max_current = 130,
},
...
}, {
{
.chan_nr = 8,
.led_current = 50,
.max_current = 130,
Expand Down
26 changes: 19 additions & 7 deletions drivers/leds/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ config LEDS_LM3533
hardware-accelerated blinking with maximum on and off periods of 9.8
and 77 seconds respectively.

config LEDS_LM3642
tristate "LED support for LM3642 Chip"
depends on LEDS_CLASS && I2C
select REGMAP_I2C
help
This option enables support for LEDs connected to LM3642.
The LM3642 is a 4MHz fixed-frequency synchronous boost
converter plus 1.5A constant current driver for a high-current
white LED.


config LEDS_LOCOMO
tristate "LED Support for Locomo device"
depends on LEDS_CLASS
Expand Down Expand Up @@ -192,11 +203,12 @@ config LEDS_LP5521
programming the engines.

config LEDS_LP5523
tristate "LED Support for N.S. LP5523 LED driver chip"
tristate "LED Support for TI/National LP5523/55231 LED driver chip"
depends on LEDS_CLASS && I2C
help
If you say yes here you get support for the National Semiconductor
LP5523 LED driver. It is 9 channel chip with programmable engines.
If you say yes here you get support for TI/National Semiconductor
LP5523/55231 LED driver.
It is 9 channel chip with programmable engines.
Driver provides direct control via LED class and interface for
programming the engines.

Expand Down Expand Up @@ -422,13 +434,13 @@ config LEDS_MAX8997
This option enables support for on-chip LED drivers on
MAXIM MAX8997 PMIC.

config LEDS_LM3556
tristate "LED support for LM3556 Chip"
config LEDS_LM355x
tristate "LED support for LM355x Chips, LM3554 and LM3556"
depends on LEDS_CLASS && I2C
select REGMAP_I2C
help
This option enables support for LEDs connected to LM3556.
LM3556 includes Torch, Flash and Indicator functions.
This option enables support for LEDs connected to LM355x.
LM355x includes Torch, Flash and Indicator functions.

config LEDS_OT200
tristate "LED support for the Bachmann OT200"
Expand Down
3 changes: 2 additions & 1 deletion drivers/leds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o
obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o
obj-$(CONFIG_LEDS_LM3530) += leds-lm3530.o
obj-$(CONFIG_LEDS_LM3533) += leds-lm3533.o
obj-$(CONFIG_LEDS_LM3642) += leds-lm3642.o
obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o
obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
Expand Down Expand Up @@ -48,7 +49,7 @@ obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o
obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o
obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o
obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
obj-$(CONFIG_LEDS_LM3556) += leds-lm3556.o
obj-$(CONFIG_LEDS_LM355x) += leds-lm355x.o
obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o

# LED SPI Drivers
Expand Down
15 changes: 15 additions & 0 deletions drivers/leds/led-class.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ static void led_timer_function(unsigned long data)
mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay));
}

static void set_brightness_delayed(struct work_struct *ws)
{
struct led_classdev *led_cdev =
container_of(ws, struct led_classdev, set_brightness_work);

led_stop_software_blink(led_cdev);

__led_set_brightness(led_cdev, led_cdev->delayed_set_value);
}

/**
* led_classdev_suspend - suspend an led_classdev.
* @led_cdev: the led_classdev to suspend.
Expand Down Expand Up @@ -191,6 +201,8 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)

led_update_brightness(led_cdev);

INIT_WORK(&led_cdev->set_brightness_work, set_brightness_delayed);

init_timer(&led_cdev->blink_timer);
led_cdev->blink_timer.function = led_timer_function;
led_cdev->blink_timer.data = (unsigned long)led_cdev;
Expand Down Expand Up @@ -221,7 +233,10 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
up_write(&led_cdev->trigger_lock);
#endif

cancel_work_sync(&led_cdev->set_brightness_work);

/* Stop blinking */
led_stop_software_blink(led_cdev);
led_set_brightness(led_cdev, LED_OFF);

device_unregister(led_cdev->dev);
Expand Down
16 changes: 13 additions & 3 deletions drivers/leds/led-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,23 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev,
}
EXPORT_SYMBOL(led_blink_set_oneshot);

void led_set_brightness(struct led_classdev *led_cdev,
enum led_brightness brightness)
void led_stop_software_blink(struct led_classdev *led_cdev)
{
/* stop and clear soft-blink timer */
del_timer_sync(&led_cdev->blink_timer);
led_cdev->blink_delay_on = 0;
led_cdev->blink_delay_off = 0;
}
EXPORT_SYMBOL_GPL(led_stop_software_blink);

void led_set_brightness(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
/* delay brightness setting if need to stop soft-blink timer */
if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) {
led_cdev->delayed_set_value = brightness;
schedule_work(&led_cdev->set_brightness_work);
return;
}

__led_set_brightness(led_cdev, brightness);
}
Expand Down
17 changes: 16 additions & 1 deletion drivers/leds/led-triggers.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,21 @@ EXPORT_SYMBOL_GPL(led_trigger_show);
void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
{
unsigned long flags;
char *event = NULL;
char *envp[2];
const char *name;

name = trig ? trig->name : "none";
event = kasprintf(GFP_KERNEL, "TRIGGER=%s", name);

/* Remove any existing trigger */
if (led_cdev->trigger) {
write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
list_del(&led_cdev->trig_list);
write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock,
flags);
cancel_work_sync(&led_cdev->set_brightness_work);
led_stop_software_blink(led_cdev);
if (led_cdev->trigger->deactivate)
led_cdev->trigger->deactivate(led_cdev);
led_cdev->trigger = NULL;
Expand All @@ -122,6 +130,13 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
if (trig->activate)
trig->activate(led_cdev);
}

if (event) {
envp[0] = event;
envp[1] = NULL;
kobject_uevent_env(&led_cdev->dev->kobj, KOBJ_CHANGE, envp);
kfree(event);
}
}
EXPORT_SYMBOL_GPL(led_trigger_set);

Expand Down Expand Up @@ -224,7 +239,7 @@ void led_trigger_event(struct led_trigger *trig,
struct led_classdev *led_cdev;

led_cdev = list_entry(entry, struct led_classdev, trig_list);
__led_set_brightness(led_cdev, brightness);
led_set_brightness(led_cdev, brightness);
}
read_unlock(&trig->leddev_list_lock);
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/leds/leds-clevo-mail.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
}

/*
* struct mail_led_whitelist - List of known good models
* struct clevo_mail_led_dmi_table - List of known good models
*
* Contains the known good models this driver is compatible with.
* When adding a new model try to be as strict as possible. This
* makes it possible to keep the false positives (the model is
* detected as working, but in reality it is not) as low as
* possible.
*/
static struct dmi_system_id __initdata mail_led_whitelist[] = {
static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
{
.callback = clevo_mail_led_dmi_callback,
.ident = "Clevo D410J",
Expand All @@ -59,11 +59,10 @@ static struct dmi_system_id __initdata mail_led_whitelist[] = {
},
{
.callback = clevo_mail_led_dmi_callback,
.ident = "Positivo Mobile",
.ident = "Clevo M5x0V",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "CLEVO Co. "),
DMI_MATCH(DMI_BOARD_NAME, "M5X0V "),
DMI_MATCH(DMI_PRODUCT_NAME, "Positivo Mobile"),
DMI_MATCH(DMI_PRODUCT_VERSION, "VT6198")
}
},
Expand All @@ -89,6 +88,7 @@ static struct dmi_system_id __initdata mail_led_whitelist[] = {
},
{ }
};
MODULE_DEVICE_TABLE(dmi, clevo_mail_led_dmi_table);

static void clevo_mail_led_set(struct led_classdev *led_cdev,
enum led_brightness value)
Expand Down Expand Up @@ -180,7 +180,7 @@ static int __init clevo_mail_led_init(void)

/* Check with the help of DMI if we are running on supported hardware */
if (!nodetect) {
count = dmi_check_system(mail_led_whitelist);
count = dmi_check_system(clevo_mail_led_dmi_table);
} else {
count = 1;
printk(KERN_ERR KBUILD_MODNAME ": Skipping DMI detection. "
Expand Down
19 changes: 12 additions & 7 deletions drivers/leds/leds-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/module.h>
#include <linux/pinctrl/consumer.h>

struct gpio_led_data {
struct led_classdev cdev;
Expand Down Expand Up @@ -170,11 +171,10 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev
{
struct device_node *np = pdev->dev.of_node, *child;
struct gpio_leds_priv *priv;
int count = 0, ret;
int count, ret;

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

Expand Down Expand Up @@ -228,16 +228,21 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev
{
return NULL;
}
#define of_gpio_leds_match NULL
#endif /* CONFIG_OF_GPIO */


static int __devinit gpio_led_probe(struct platform_device *pdev)
{
struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
struct gpio_leds_priv *priv;
struct pinctrl *pinctrl;
int i, ret = 0;

pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
if (IS_ERR(pinctrl))
dev_warn(&pdev->dev,
"pins are not configured from the driver\n");

if (pdata && pdata->num_leds) {
priv = devm_kzalloc(&pdev->dev,
sizeof_gpio_leds_priv(pdata->num_leds),
Expand Down Expand Up @@ -270,13 +275,13 @@ static int __devinit gpio_led_probe(struct platform_device *pdev)

static int __devexit gpio_led_remove(struct platform_device *pdev)
{
struct gpio_leds_priv *priv = dev_get_drvdata(&pdev->dev);
struct gpio_leds_priv *priv = platform_get_drvdata(pdev);
int i;

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

dev_set_drvdata(&pdev->dev, NULL);
platform_set_drvdata(pdev, NULL);

return 0;
}
Expand All @@ -287,7 +292,7 @@ static struct platform_driver gpio_led_driver = {
.driver = {
.name = "leds-gpio",
.owner = THIS_MODULE,
.of_match_table = of_gpio_leds_match,
.of_match_table = of_match_ptr(of_gpio_leds_match),
},
};

Expand Down
16 changes: 5 additions & 11 deletions drivers/leds/leds-lm3530.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static int lm3530_get_mode_from_str(const char *str)
if (sysfs_streq(str, mode_map[i].mode))
return mode_map[i].mode_val;

return -1;
return -EINVAL;
}

static void lm3530_als_configure(struct lm3530_platform_data *pdata,
Expand Down Expand Up @@ -358,7 +358,7 @@ static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute
mode = lm3530_get_mode_from_str(buf);
if (mode < 0) {
dev_err(dev, "Invalid mode\n");
return -EINVAL;
return mode;
}

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

i2c_set_clientdata(client, drvdata);

drvdata->regulator = regulator_get(&client->dev, "vin");
drvdata->regulator = devm_regulator_get(&client->dev, "vin");
if (IS_ERR(drvdata->regulator)) {
dev_err(&client->dev, "regulator get failed\n");
err = PTR_ERR(drvdata->regulator);
Expand All @@ -429,15 +429,13 @@ static int __devinit lm3530_probe(struct i2c_client *client,
if (err < 0) {
dev_err(&client->dev,
"Register Init failed: %d\n", err);
err = -ENODEV;
goto err_reg_init;
return err;
}
}
err = led_classdev_register(&client->dev, &drvdata->led_dev);
if (err < 0) {
dev_err(&client->dev, "Register led class failed: %d\n", err);
err = -ENODEV;
goto err_class_register;
return err;
}

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

err_create_file:
led_classdev_unregister(&drvdata->led_dev);
err_class_register:
err_reg_init:
regulator_put(drvdata->regulator);
return err;
}

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

if (drvdata->enable)
regulator_disable(drvdata->regulator);
regulator_put(drvdata->regulator);
led_classdev_unregister(&drvdata->led_dev);
return 0;
}
Expand Down
Loading

0 comments on commit c7a6ced

Please sign in to comment.