Skip to content

Commit

Permalink
Merge tag 'leds-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/pavel/linux-leds

Pull LED updates from Pavel Machek:
 "This contains usual small updates to drivers, and removal of PAGE_SIZE
  limits on /sys/class/leds/<led>/trigger.

  We should not be really having that many triggers; but with cpu
  activity triggers we do, and we'll eventually need to fix it, but...
  remove the limit for now"

* tag 'leds-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds: (26 commits)
  leds: trigger: netdev: fix handling on interface rename
  leds: an30259a: add a check for devm_regmap_init_i2c
  leds: mlxreg: Fix possible buffer overflow
  leds: pca953x: Use of_device_get_match_data()
  leds: core: Fix leds.h structure documentation
  leds: core: Fix devm_classdev_match to reference correct structure
  leds: core: Remove extern from header
  leds: lm3601x: Convert class registration to device managed
  leds: flash: Add devm_* functions to the flash class
  leds: flash: Remove extern from the header file
  leds: flash: Convert non extended registration to inline
  leds: Kconfig: Be consistent with the usage of "LED"
  leds: remove PAGE_SIZE limit of /sys/class/leds/<led>/trigger
  leds: tlc591xx: update the maximum brightness
  leds: lm3692x: Use flags from LM3692X_BRT_CTRL
  leds: lm3692x: Use flags from LM3692X_BOOST_CTRL
  leds: lm3692x: Handle failure to probe the regulator
  leds: lm3692x: Don't overwrite return value in error path
  leds: lm3692x: Print error value on dev_err
  leds: tlc591xx: use devm_led_classdev_register_ext()
  ...
  • Loading branch information
Linus Torvalds committed Dec 2, 2019
2 parents ddebe83 + 5f820ed commit 304220b
Show file tree
Hide file tree
Showing 20 changed files with 858 additions and 207 deletions.
139 changes: 139 additions & 0 deletions Documentation/ABI/testing/sysfs-class-led-driver-el15203000
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
What: /sys/class/leds/<led>/hw_pattern
Date: September 2019
KernelVersion: 5.5
Description:
Specify a hardware pattern for the EL15203000 LED.
The LEDs board supports only predefined patterns by firmware
for specific LEDs.

Breathing mode for Screen frame light tube:
"0 4000 1 4000"

^
|
Max-| ---
| / \
| / \
| / \ /
| / \ /
Min-|- ---
|
0------4------8--> time (sec)

Cascade mode for Pipe LED:
"1 800 2 800 4 800 8 800 16 800"

^
|
0 On -|----+ +----+ +---
| | | | |
Off-| +-------------------+ +-------------------+
|
1 On -| +----+ +----+
| | | | |
Off |----+ +-------------------+ +------------------
|
2 On -| +----+ +----+
| | | | |
Off-|---------+ +-------------------+ +-------------
|
3 On -| +----+ +----+
| | | | |
Off-|--------------+ +-------------------+ +--------
|
4 On -| +----+ +----+
| | | | |
Off-|-------------------+ +-------------------+ +---
|
0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)

Inverted cascade mode for Pipe LED:
"30 800 29 800 27 800 23 800 15 800"

^
|
0 On -| +-------------------+ +-------------------+
| | | | |
Off-|----+ +----+ +---
|
1 On -|----+ +-------------------+ +------------------
| | | | |
Off | +----+ +----+
|
2 On -|---------+ +-------------------+ +-------------
| | | | |
Off-| +----+ +----+
|
3 On -|--------------+ +-------------------+ +--------
| | | | |
Off-| +----+ +----+
|
4 On -|-------------------+ +-------------------+ +---
| | | | |
Off-| +----+ +----+
|
0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)

Bounce mode for Pipe LED:
"1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800"

^
|
0 On -|----+ +--------
| | |
Off-| +---------------------------------------+
|
1 On -| +----+ +----+
| | | | |
Off |----+ +-----------------------------+ +--------
|
2 On -| +----+ +----+
| | | | |
Off-|---------+ +-------------------+ +-------------
|
3 On -| +----+ +----+
| | | | |
Off-|--------------+ +---------+ +------------------
|
4 On -| +---------+
| | |
Off-|-------------------+ +-----------------------
|
0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)

Inverted bounce mode for Pipe LED:
"30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"

^
|
0 On -| +---------------------------------------+
| | |
Off-|----+ +--------
|
1 On -|----+ +-----------------------------+ +--------
| | | | |
Off | +----+ +----+
|
2 On -|---------+ +-------------------+ +-------------
| | | | |
Off-| +----+ +----+
|
3 On -|--------------+ +---------+ +------------------
| | | | |
Off-| +----+ +----+
|
4 On -|-------------------+ +-----------------------
| | |
Off-| +---------+
|
0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)

What: /sys/class/leds/<led>/repeat
Date: September 2019
KernelVersion: 5.5
Description:
EL15203000 supports only indefinitely patterns,
so this file should always store -1.

For more info, please see:
Documentation/ABI/testing/sysfs-class-led-trigger-pattern
69 changes: 69 additions & 0 deletions Documentation/devicetree/bindings/leds/leds-el15203000.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Crane Merchandising System - EL15203000 LED driver
--------------------------------------------------

This LED Board (aka RED LEDs board) is widely used in
coffee vending machines produced by Crane Merchandising Systems.
The board manages 3 LEDs and supports predefined blinking patterns
for specific leds.

Vending area LED encoded with symbol 'V' (hex code 0x56).
Doesn't have any hardware blinking pattern.

Screen light tube LED which surrounds vending machine screen and
encoded with symbol 'S' (hex code 0x53). Supports blinking breathing pattern.

Water Pipe LED encoded with symbol 'P' (hex code 0x50) and
actually consists of 5 LEDs that exposed by protocol like one LED.
Supports next patterns:
- cascade pattern
- inversed cascade pattern
- bounce pattern
- inversed bounce pattern

Required properties:
- compatible : "crane,el15203000"
- #address-cells : must be 1
- #size-cells : must be 0

Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt
apply. In particular, "reg" and "spi-max-frequency" properties must be given.

Optional LED sub-node properties:
- function:
see Documentation/devicetree/bindings/leds/common.txt
- color:
see Documentation/devicetree/bindings/leds/common.txt

Example
-------

#include <dt-bindings/leds/common.h>

led-controller@0 {
compatible = "crane,el15203000";
reg = <0>;
spi-max-frequency = <50000>;
#address-cells = <1>;
#size-cells = <0>;

/* water pipe */
led@50 {
reg = <0x50>;
function = "pipe";
color = <LED_COLOR_ID_RED>;
};

/* screen frame */
led@53 {
reg = <0x53>;
function = "screen";
color = <LED_COLOR_ID_RED>;
};

/* vending area */
led@56 {
reg = <0x56>;
function = "vend";
color = <LED_COLOR_ID_RED>;
};
};
17 changes: 15 additions & 2 deletions drivers/leds/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if NEW_LEDS
config LEDS_CLASS
tristate "LED Class Support"
help
This option enables the led sysfs class in /sys/class/leds. You'll
This option enables the LED sysfs class in /sys/class/leds. You'll
need this to do anything useful with LEDs. If unsure, say N.

config LEDS_CLASS_FLASH
Expand All @@ -35,7 +35,7 @@ config LEDS_BRIGHTNESS_HW_CHANGED
depends on LEDS_CLASS
help
This option enables support for the brightness_hw_changed attribute
for led sysfs class devices under /sys/class/leds.
for LED sysfs class devices under /sys/class/leds.

See Documentation/ABI/testing/sysfs-class-led for details.

Expand Down Expand Up @@ -132,6 +132,19 @@ config LEDS_CR0014114
To compile this driver as a module, choose M here: the module
will be called leds-cr0014114.

config LEDS_EL15203000
tristate "LED Support for Crane EL15203000"
depends on LEDS_CLASS
depends on SPI
depends on OF
help
This option enables support for EL15203000 LED Board
(aka RED LED board) which is widely used in coffee vending
machines produced by Crane Merchandising Systems.

To compile this driver as a module, choose M here: the module
will be called leds-el15203000.

config LEDS_LM3530
tristate "LCD Backlight driver for LM3530"
depends on LEDS_CLASS
Expand Down
1 change: 1 addition & 0 deletions drivers/leds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ obj-$(CONFIG_LEDS_LM36274) += leds-lm36274.o
# LED SPI Drivers
obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o
obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
obj-$(CONFIG_LEDS_EL15203000) += leds-el15203000.o

# LED Userspace Drivers
obj-$(CONFIG_LEDS_USER) += uleds.o
Expand Down
50 changes: 50 additions & 0 deletions drivers/leds/led-class-flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,56 @@ void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev)
}
EXPORT_SYMBOL_GPL(led_classdev_flash_unregister);

static void devm_led_classdev_flash_release(struct device *dev, void *res)
{
led_classdev_flash_unregister(*(struct led_classdev_flash **)res);
}

int devm_led_classdev_flash_register_ext(struct device *parent,
struct led_classdev_flash *fled_cdev,
struct led_init_data *init_data)
{
struct led_classdev_flash **dr;
int ret;

dr = devres_alloc(devm_led_classdev_flash_release, sizeof(*dr),
GFP_KERNEL);
if (!dr)
return -ENOMEM;

ret = led_classdev_flash_register_ext(parent, fled_cdev, init_data);
if (ret) {
devres_free(dr);
return ret;
}

*dr = fled_cdev;
devres_add(parent, dr);

return 0;
}
EXPORT_SYMBOL_GPL(devm_led_classdev_flash_register_ext);

static int devm_led_classdev_flash_match(struct device *dev,
void *res, void *data)
{
struct led_classdev_flash **p = res;

if (WARN_ON(!p || !*p))
return 0;

return *p == data;
}

void devm_led_classdev_flash_unregister(struct device *dev,
struct led_classdev_flash *fled_cdev)
{
WARN_ON(devres_release(dev,
devm_led_classdev_flash_release,
devm_led_classdev_flash_match, fled_cdev));
}
EXPORT_SYMBOL_GPL(devm_led_classdev_flash_unregister);

static void led_clamp_align(struct led_flash_setting *s)
{
u32 v, offset;
Expand Down
10 changes: 5 additions & 5 deletions drivers/leds/led-class.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ static ssize_t max_brightness_show(struct device *dev,
static DEVICE_ATTR_RO(max_brightness);

#ifdef CONFIG_LEDS_TRIGGERS
static DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store);
static struct attribute *led_trigger_attrs[] = {
&dev_attr_trigger.attr,
static BIN_ATTR(trigger, 0644, led_trigger_read, led_trigger_write, 0);
static struct bin_attribute *led_trigger_bin_attrs[] = {
&bin_attr_trigger,
NULL,
};
static const struct attribute_group led_trigger_group = {
.attrs = led_trigger_attrs,
.bin_attrs = led_trigger_bin_attrs,
};
#endif

Expand Down Expand Up @@ -403,7 +403,7 @@ EXPORT_SYMBOL_GPL(devm_led_classdev_register_ext);

static int devm_led_classdev_match(struct device *dev, void *res, void *data)
{
struct led_cdev **p = res;
struct led_classdev **p = res;

if (WARN_ON(!p || !*p))
return 0;
Expand Down
Loading

0 comments on commit 304220b

Please sign in to comment.