Skip to content

Commit 304220b

Browse files
committed
Merge tag 'leds-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/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() ...
2 parents ddebe83 + 5f820ed commit 304220b

20 files changed

+858
-207
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
What: /sys/class/leds/<led>/hw_pattern
2+
Date: September 2019
3+
KernelVersion: 5.5
4+
Description:
5+
Specify a hardware pattern for the EL15203000 LED.
6+
The LEDs board supports only predefined patterns by firmware
7+
for specific LEDs.
8+
9+
Breathing mode for Screen frame light tube:
10+
"0 4000 1 4000"
11+
12+
^
13+
|
14+
Max-| ---
15+
| / \
16+
| / \
17+
| / \ /
18+
| / \ /
19+
Min-|- ---
20+
|
21+
0------4------8--> time (sec)
22+
23+
Cascade mode for Pipe LED:
24+
"1 800 2 800 4 800 8 800 16 800"
25+
26+
^
27+
|
28+
0 On -|----+ +----+ +---
29+
| | | | |
30+
Off-| +-------------------+ +-------------------+
31+
|
32+
1 On -| +----+ +----+
33+
| | | | |
34+
Off |----+ +-------------------+ +------------------
35+
|
36+
2 On -| +----+ +----+
37+
| | | | |
38+
Off-|---------+ +-------------------+ +-------------
39+
|
40+
3 On -| +----+ +----+
41+
| | | | |
42+
Off-|--------------+ +-------------------+ +--------
43+
|
44+
4 On -| +----+ +----+
45+
| | | | |
46+
Off-|-------------------+ +-------------------+ +---
47+
|
48+
0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
49+
50+
Inverted cascade mode for Pipe LED:
51+
"30 800 29 800 27 800 23 800 15 800"
52+
53+
^
54+
|
55+
0 On -| +-------------------+ +-------------------+
56+
| | | | |
57+
Off-|----+ +----+ +---
58+
|
59+
1 On -|----+ +-------------------+ +------------------
60+
| | | | |
61+
Off | +----+ +----+
62+
|
63+
2 On -|---------+ +-------------------+ +-------------
64+
| | | | |
65+
Off-| +----+ +----+
66+
|
67+
3 On -|--------------+ +-------------------+ +--------
68+
| | | | |
69+
Off-| +----+ +----+
70+
|
71+
4 On -|-------------------+ +-------------------+ +---
72+
| | | | |
73+
Off-| +----+ +----+
74+
|
75+
0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
76+
77+
Bounce mode for Pipe LED:
78+
"1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800"
79+
80+
^
81+
|
82+
0 On -|----+ +--------
83+
| | |
84+
Off-| +---------------------------------------+
85+
|
86+
1 On -| +----+ +----+
87+
| | | | |
88+
Off |----+ +-----------------------------+ +--------
89+
|
90+
2 On -| +----+ +----+
91+
| | | | |
92+
Off-|---------+ +-------------------+ +-------------
93+
|
94+
3 On -| +----+ +----+
95+
| | | | |
96+
Off-|--------------+ +---------+ +------------------
97+
|
98+
4 On -| +---------+
99+
| | |
100+
Off-|-------------------+ +-----------------------
101+
|
102+
0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
103+
104+
Inverted bounce mode for Pipe LED:
105+
"30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"
106+
107+
^
108+
|
109+
0 On -| +---------------------------------------+
110+
| | |
111+
Off-|----+ +--------
112+
|
113+
1 On -|----+ +-----------------------------+ +--------
114+
| | | | |
115+
Off | +----+ +----+
116+
|
117+
2 On -|---------+ +-------------------+ +-------------
118+
| | | | |
119+
Off-| +----+ +----+
120+
|
121+
3 On -|--------------+ +---------+ +------------------
122+
| | | | |
123+
Off-| +----+ +----+
124+
|
125+
4 On -|-------------------+ +-----------------------
126+
| | |
127+
Off-| +---------+
128+
|
129+
0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
130+
131+
What: /sys/class/leds/<led>/repeat
132+
Date: September 2019
133+
KernelVersion: 5.5
134+
Description:
135+
EL15203000 supports only indefinitely patterns,
136+
so this file should always store -1.
137+
138+
For more info, please see:
139+
Documentation/ABI/testing/sysfs-class-led-trigger-pattern
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
Crane Merchandising System - EL15203000 LED driver
2+
--------------------------------------------------
3+
4+
This LED Board (aka RED LEDs board) is widely used in
5+
coffee vending machines produced by Crane Merchandising Systems.
6+
The board manages 3 LEDs and supports predefined blinking patterns
7+
for specific leds.
8+
9+
Vending area LED encoded with symbol 'V' (hex code 0x56).
10+
Doesn't have any hardware blinking pattern.
11+
12+
Screen light tube LED which surrounds vending machine screen and
13+
encoded with symbol 'S' (hex code 0x53). Supports blinking breathing pattern.
14+
15+
Water Pipe LED encoded with symbol 'P' (hex code 0x50) and
16+
actually consists of 5 LEDs that exposed by protocol like one LED.
17+
Supports next patterns:
18+
- cascade pattern
19+
- inversed cascade pattern
20+
- bounce pattern
21+
- inversed bounce pattern
22+
23+
Required properties:
24+
- compatible : "crane,el15203000"
25+
- #address-cells : must be 1
26+
- #size-cells : must be 0
27+
28+
Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt
29+
apply. In particular, "reg" and "spi-max-frequency" properties must be given.
30+
31+
Optional LED sub-node properties:
32+
- function:
33+
see Documentation/devicetree/bindings/leds/common.txt
34+
- color:
35+
see Documentation/devicetree/bindings/leds/common.txt
36+
37+
Example
38+
-------
39+
40+
#include <dt-bindings/leds/common.h>
41+
42+
led-controller@0 {
43+
compatible = "crane,el15203000";
44+
reg = <0>;
45+
spi-max-frequency = <50000>;
46+
#address-cells = <1>;
47+
#size-cells = <0>;
48+
49+
/* water pipe */
50+
led@50 {
51+
reg = <0x50>;
52+
function = "pipe";
53+
color = <LED_COLOR_ID_RED>;
54+
};
55+
56+
/* screen frame */
57+
led@53 {
58+
reg = <0x53>;
59+
function = "screen";
60+
color = <LED_COLOR_ID_RED>;
61+
};
62+
63+
/* vending area */
64+
led@56 {
65+
reg = <0x56>;
66+
function = "vend";
67+
color = <LED_COLOR_ID_RED>;
68+
};
69+
};

drivers/leds/Kconfig

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if NEW_LEDS
1717
config LEDS_CLASS
1818
tristate "LED Class Support"
1919
help
20-
This option enables the led sysfs class in /sys/class/leds. You'll
20+
This option enables the LED sysfs class in /sys/class/leds. You'll
2121
need this to do anything useful with LEDs. If unsure, say N.
2222

2323
config LEDS_CLASS_FLASH
@@ -35,7 +35,7 @@ config LEDS_BRIGHTNESS_HW_CHANGED
3535
depends on LEDS_CLASS
3636
help
3737
This option enables support for the brightness_hw_changed attribute
38-
for led sysfs class devices under /sys/class/leds.
38+
for LED sysfs class devices under /sys/class/leds.
3939

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

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

135+
config LEDS_EL15203000
136+
tristate "LED Support for Crane EL15203000"
137+
depends on LEDS_CLASS
138+
depends on SPI
139+
depends on OF
140+
help
141+
This option enables support for EL15203000 LED Board
142+
(aka RED LED board) which is widely used in coffee vending
143+
machines produced by Crane Merchandising Systems.
144+
145+
To compile this driver as a module, choose M here: the module
146+
will be called leds-el15203000.
147+
135148
config LEDS_LM3530
136149
tristate "LCD Backlight driver for LM3530"
137150
depends on LEDS_CLASS

drivers/leds/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ obj-$(CONFIG_LEDS_LM36274) += leds-lm36274.o
8989
# LED SPI Drivers
9090
obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o
9191
obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
92+
obj-$(CONFIG_LEDS_EL15203000) += leds-el15203000.o
9293

9394
# LED Userspace Drivers
9495
obj-$(CONFIG_LEDS_USER) += uleds.o

drivers/leds/led-class-flash.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,56 @@ void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev)
327327
}
328328
EXPORT_SYMBOL_GPL(led_classdev_flash_unregister);
329329

330+
static void devm_led_classdev_flash_release(struct device *dev, void *res)
331+
{
332+
led_classdev_flash_unregister(*(struct led_classdev_flash **)res);
333+
}
334+
335+
int devm_led_classdev_flash_register_ext(struct device *parent,
336+
struct led_classdev_flash *fled_cdev,
337+
struct led_init_data *init_data)
338+
{
339+
struct led_classdev_flash **dr;
340+
int ret;
341+
342+
dr = devres_alloc(devm_led_classdev_flash_release, sizeof(*dr),
343+
GFP_KERNEL);
344+
if (!dr)
345+
return -ENOMEM;
346+
347+
ret = led_classdev_flash_register_ext(parent, fled_cdev, init_data);
348+
if (ret) {
349+
devres_free(dr);
350+
return ret;
351+
}
352+
353+
*dr = fled_cdev;
354+
devres_add(parent, dr);
355+
356+
return 0;
357+
}
358+
EXPORT_SYMBOL_GPL(devm_led_classdev_flash_register_ext);
359+
360+
static int devm_led_classdev_flash_match(struct device *dev,
361+
void *res, void *data)
362+
{
363+
struct led_classdev_flash **p = res;
364+
365+
if (WARN_ON(!p || !*p))
366+
return 0;
367+
368+
return *p == data;
369+
}
370+
371+
void devm_led_classdev_flash_unregister(struct device *dev,
372+
struct led_classdev_flash *fled_cdev)
373+
{
374+
WARN_ON(devres_release(dev,
375+
devm_led_classdev_flash_release,
376+
devm_led_classdev_flash_match, fled_cdev));
377+
}
378+
EXPORT_SYMBOL_GPL(devm_led_classdev_flash_unregister);
379+
330380
static void led_clamp_align(struct led_flash_setting *s)
331381
{
332382
u32 v, offset;

drivers/leds/led-class.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ static ssize_t max_brightness_show(struct device *dev,
7474
static DEVICE_ATTR_RO(max_brightness);
7575

7676
#ifdef CONFIG_LEDS_TRIGGERS
77-
static DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store);
78-
static struct attribute *led_trigger_attrs[] = {
79-
&dev_attr_trigger.attr,
77+
static BIN_ATTR(trigger, 0644, led_trigger_read, led_trigger_write, 0);
78+
static struct bin_attribute *led_trigger_bin_attrs[] = {
79+
&bin_attr_trigger,
8080
NULL,
8181
};
8282
static const struct attribute_group led_trigger_group = {
83-
.attrs = led_trigger_attrs,
83+
.bin_attrs = led_trigger_bin_attrs,
8484
};
8585
#endif
8686

@@ -403,7 +403,7 @@ EXPORT_SYMBOL_GPL(devm_led_classdev_register_ext);
403403

404404
static int devm_led_classdev_match(struct device *dev, void *res, void *data)
405405
{
406-
struct led_cdev **p = res;
406+
struct led_classdev **p = res;
407407

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

0 commit comments

Comments
 (0)