Skip to content

Commit c07b368

Browse files
committed
Merge tag 'leds-for-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds
Pull LED updates from Jacek Anaszewski: "LED triggers improvements make the biggest part of this pull request. The most striking ones, that allowed for nice cleanups in the triggers are: - centralized handling of creation and removal of trigger sysfs attributes via attribute group - addition of module_led_trigger() helper The other things that need to be mentioned: New features and improvements to existing LED class drivers: - lt3593: add DT support, switch to gpiod interface - lm3692x: support LED sync configuration, change OF calls to fwnode calls - apu: modify PC Engines apu/apu2 driver to support apu3 Change in the drivers/net/can/led.c: - mark led trigger as broken since it's in the way for the further cleanups. It implements a subset of the netdev trigger and an Ack is needed from someone who can actually test and confirm that the netdev trigger works for can devices" * tag 'leds-for-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds: (32 commits) leds: ns2: Change unsigned to unsigned int usb: simplify usbport trigger leds: gpio trigger: simplifications from core changes leds: backlight trigger: simplifications from core changes leds: activity trigger: simplifications from core changes leds: default-on trigger: make use of module_led_trigger() leds: heartbeat trigger: simplifications from core changes leds: oneshot trigger: simplifications from core changes leds: transient trigger: simplifications from core changes leds: timer trigger: simplifications from core changes leds: netdev trigger: simplifications from core changes leds: triggers: new function led_set_trigger_data() leds: triggers: define module_led_trigger helper leds: triggers: handle .trigger_data and .activated() in the core leds: triggers: add device attribute support leds: triggers: let struct led_trigger::activate() return an error code leds: triggers: make the MODULE_LICENSE string match the actual license leds: lm3692x: Support LED sync configuration dt: bindings: lm3692x: Update binding for LED sync control leds: lm3692x: Change DT calls to fwnode calls ...
2 parents 4d88e3d + 2224f2f commit c07b368

28 files changed

Lines changed: 641 additions & 619 deletions

‎Documentation/devicetree/bindings/leds/common.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Optional properties for child nodes:
3131
"backlight" - LED will act as a back-light, controlled by the framebuffer
3232
system
3333
"default-on" - LED will turn on (but for leds-gpio see "default-state"
34-
property in Documentation/devicetree/bindings/gpio/led.txt)
34+
property in Documentation/devicetree/bindings/leds/leds-gpio.txt)
3535
"heartbeat" - LED "double" flashes at a load average based rate
3636
"disk-activity" - LED indicates disk activity
3737
"ide-disk" - LED indicates IDE disk activity (deprecated),

‎Documentation/devicetree/bindings/leds/leds-lm3692x.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ Optional properties:
2020
- vled-supply : LED supply
2121

2222
Required child properties:
23-
- reg : 0
23+
- reg : 0 - Will enable all LED sync paths
24+
1 - Will enable the LED1 sync
25+
2 - Will enable the LED2 sync
26+
3 - Will enable the LED3 sync (LM36923 only)
2427

2528
Optional child properties:
2629
- label : see Documentation/devicetree/bindings/leds/common.txt
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Bindings for Linear Technologies LT3593 LED controller
2+
3+
Required properties:
4+
- compatible: Should be "lltc,lt3593".
5+
- lltc,ctrl-gpios: A handle to the GPIO that is connected to the 'CTRL'
6+
pin of the chip.
7+
8+
The hardware supports only one LED. The properties of this LED are
9+
configured in a sub-node in the device node.
10+
11+
Optional sub-node properties:
12+
- label: A label for the LED. If none is given, the LED will be
13+
named "lt3595::".
14+
- linux,default-trigger: The default trigger for the LED.
15+
See Documentation/devicetree/bindings/leds/common.txt
16+
- default-state: The initial state of the LED.
17+
See Documentation/devicetree/bindings/leds/common.txt
18+
19+
If multiple chips of this type are found in a design, each one needs to
20+
be handled by its own device node.
21+
22+
Example:
23+
24+
led-controller {
25+
compatible = "lltc,lt3593";
26+
lltc,ctrl-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
27+
28+
led {
29+
label = "white:backlight";
30+
default-state = "on";
31+
};
32+
};

‎drivers/leds/Kconfig‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ config LEDS_AAT1290
5757
depends on PINCTRL
5858
help
5959
This option enables support for the LEDs on the AAT1290.
60+
6061
config LEDS_APU
61-
tristate "Front panel LED support for PC Engines APU/APU2 boards"
62+
tristate "Front panel LED support for PC Engines APU/APU2/APU3 boards"
6263
depends on LEDS_CLASS
6364
depends on X86 && DMI
6465
help
65-
This driver makes the PC Engines APU/APU2 front panel LEDs
66+
This driver makes the PC Engines APU/APU2/APU3 front panel LEDs
6667
accessible from userspace programs through the LED subsystem.
6768

6869
To compile this driver as a module, choose M here: the

‎drivers/leds/led-triggers.c‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,16 @@ ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
103103
EXPORT_SYMBOL_GPL(led_trigger_show);
104104

105105
/* Caller must ensure led_cdev->trigger_lock held */
106-
void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
106+
int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
107107
{
108108
unsigned long flags;
109109
char *event = NULL;
110110
char *envp[2];
111111
const char *name;
112+
int ret;
112113

113114
if (!led_cdev->trigger && !trig)
114-
return;
115+
return 0;
115116

116117
name = trig ? trig->name : "none";
117118
event = kasprintf(GFP_KERNEL, "TRIGGER=%s", name);
@@ -126,16 +127,31 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
126127
led_stop_software_blink(led_cdev);
127128
if (led_cdev->trigger->deactivate)
128129
led_cdev->trigger->deactivate(led_cdev);
130+
device_remove_groups(led_cdev->dev, led_cdev->trigger->groups);
129131
led_cdev->trigger = NULL;
132+
led_cdev->trigger_data = NULL;
133+
led_cdev->activated = false;
130134
led_set_brightness(led_cdev, LED_OFF);
131135
}
132136
if (trig) {
133137
write_lock_irqsave(&trig->leddev_list_lock, flags);
134138
list_add_tail(&led_cdev->trig_list, &trig->led_cdevs);
135139
write_unlock_irqrestore(&trig->leddev_list_lock, flags);
136140
led_cdev->trigger = trig;
141+
137142
if (trig->activate)
138-
trig->activate(led_cdev);
143+
ret = trig->activate(led_cdev);
144+
else
145+
ret = 0;
146+
147+
if (ret)
148+
goto err_activate;
149+
150+
ret = device_add_groups(led_cdev->dev, trig->groups);
151+
if (ret) {
152+
dev_err(led_cdev->dev, "Failed to add trigger attributes\n");
153+
goto err_add_groups;
154+
}
139155
}
140156

141157
if (event) {
@@ -146,6 +162,23 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
146162
"%s: Error sending uevent\n", __func__);
147163
kfree(event);
148164
}
165+
166+
return 0;
167+
168+
err_add_groups:
169+
170+
if (trig->deactivate)
171+
trig->deactivate(led_cdev);
172+
err_activate:
173+
174+
led_cdev->trigger = NULL;
175+
led_cdev->trigger_data = NULL;
176+
write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
177+
list_del(&led_cdev->trig_list);
178+
write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock, flags);
179+
led_set_brightness(led_cdev, LED_OFF);
180+
181+
return ret;
149182
}
150183
EXPORT_SYMBOL_GPL(led_trigger_set);
151184

‎drivers/leds/leds-apu.c‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ static const struct apu_led_profile apu2_led_profile[] = {
102102
{ "apu2:green:3", LED_OFF, APU2_FCH_GPIO_BASE + 70 * APU2_IOSIZE },
103103
};
104104

105+
/* Same as apu2_led_profile, but with "3" in the LED names. */
106+
static const struct apu_led_profile apu3_led_profile[] = {
107+
{ "apu3:green:1", LED_ON, APU2_FCH_GPIO_BASE + 68 * APU2_IOSIZE },
108+
{ "apu3:green:2", LED_OFF, APU2_FCH_GPIO_BASE + 69 * APU2_IOSIZE },
109+
{ "apu3:green:3", LED_OFF, APU2_FCH_GPIO_BASE + 70 * APU2_IOSIZE },
110+
};
111+
105112
static const struct dmi_system_id apu_led_dmi_table[] __initconst = {
106113
{
107114
.ident = "apu",
@@ -134,6 +141,30 @@ static const struct dmi_system_id apu_led_dmi_table[] __initconst = {
134141
DMI_MATCH(DMI_BOARD_NAME, "PC Engines apu2")
135142
}
136143
},
144+
/* PC Engines APU3 with "Legacy" bios < 4.0.8 */
145+
{
146+
.ident = "apu3",
147+
.matches = {
148+
DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
149+
DMI_MATCH(DMI_BOARD_NAME, "APU3")
150+
}
151+
},
152+
/* PC Engines APU3 with "Legacy" bios >= 4.0.8 */
153+
{
154+
.ident = "apu3",
155+
.matches = {
156+
DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
157+
DMI_MATCH(DMI_BOARD_NAME, "apu3")
158+
}
159+
},
160+
/* PC Engines APU2 with "Mainline" bios */
161+
{
162+
.ident = "apu3",
163+
.matches = {
164+
DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
165+
DMI_MATCH(DMI_BOARD_NAME, "PC Engines apu3")
166+
}
167+
},
137168
{}
138169
};
139170
MODULE_DEVICE_TABLE(dmi, apu_led_dmi_table);
@@ -235,6 +266,14 @@ static int __init apu_led_probe(struct platform_device *pdev)
235266
apu_led->platform = APU2_LED_PLATFORM;
236267
apu_led->num_led_instances = ARRAY_SIZE(apu2_led_profile);
237268
apu_led->iosize = APU2_IOSIZE;
269+
} else if (dmi_match(DMI_BOARD_NAME, "APU3") ||
270+
dmi_match(DMI_BOARD_NAME, "apu3") ||
271+
dmi_match(DMI_BOARD_NAME, "PC Engines apu3")) {
272+
apu_led->profile = apu3_led_profile;
273+
/* Otherwise identical to APU2. */
274+
apu_led->platform = APU2_LED_PLATFORM;
275+
apu_led->num_led_instances = ARRAY_SIZE(apu3_led_profile);
276+
apu_led->iosize = APU2_IOSIZE;
238277
}
239278

240279
spin_lock_init(&apu_led->lock);
@@ -259,7 +298,10 @@ static int __init apu_led_init(void)
259298
if (!(dmi_match(DMI_PRODUCT_NAME, "APU") ||
260299
dmi_match(DMI_PRODUCT_NAME, "APU2") ||
261300
dmi_match(DMI_PRODUCT_NAME, "apu2") ||
262-
dmi_match(DMI_PRODUCT_NAME, "PC Engines apu2"))) {
301+
dmi_match(DMI_PRODUCT_NAME, "PC Engines apu2") ||
302+
dmi_match(DMI_PRODUCT_NAME, "APU3") ||
303+
dmi_match(DMI_PRODUCT_NAME, "apu3") ||
304+
dmi_match(DMI_PRODUCT_NAME, "PC Engines apu3"))) {
263305
pr_err("Unknown PC Engines board: %s\n",
264306
dmi_get_system_info(DMI_PRODUCT_NAME));
265307
return -ENODEV;

0 commit comments

Comments
 (0)