Skip to content

Commit

Permalink
Merge tag 'leds-for-4.19-rc1' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/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
  ...
  • Loading branch information
torvalds committed Aug 14, 2018
2 parents 4d88e3d + 2224f2f commit c07b368
Show file tree
Hide file tree
Showing 28 changed files with 641 additions and 619 deletions.
2 changes: 1 addition & 1 deletion Documentation/devicetree/bindings/leds/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Optional properties for child nodes:
"backlight" - LED will act as a back-light, controlled by the framebuffer
system
"default-on" - LED will turn on (but for leds-gpio see "default-state"
property in Documentation/devicetree/bindings/gpio/led.txt)
property in Documentation/devicetree/bindings/leds/leds-gpio.txt)
"heartbeat" - LED "double" flashes at a load average based rate
"disk-activity" - LED indicates disk activity
"ide-disk" - LED indicates IDE disk activity (deprecated),
Expand Down
5 changes: 4 additions & 1 deletion Documentation/devicetree/bindings/leds/leds-lm3692x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ Optional properties:
- vled-supply : LED supply

Required child properties:
- reg : 0
- reg : 0 - Will enable all LED sync paths
1 - Will enable the LED1 sync
2 - Will enable the LED2 sync
3 - Will enable the LED3 sync (LM36923 only)

Optional child properties:
- label : see Documentation/devicetree/bindings/leds/common.txt
Expand Down
32 changes: 32 additions & 0 deletions Documentation/devicetree/bindings/leds/leds-lt3593.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Bindings for Linear Technologies LT3593 LED controller

Required properties:
- compatible: Should be "lltc,lt3593".
- lltc,ctrl-gpios: A handle to the GPIO that is connected to the 'CTRL'
pin of the chip.

The hardware supports only one LED. The properties of this LED are
configured in a sub-node in the device node.

Optional sub-node properties:
- label: A label for the LED. If none is given, the LED will be
named "lt3595::".
- linux,default-trigger: The default trigger for the LED.
See Documentation/devicetree/bindings/leds/common.txt
- default-state: The initial state of the LED.
See Documentation/devicetree/bindings/leds/common.txt

If multiple chips of this type are found in a design, each one needs to
be handled by its own device node.

Example:

led-controller {
compatible = "lltc,lt3593";
lltc,ctrl-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;

led {
label = "white:backlight";
default-state = "on";
};
};
5 changes: 3 additions & 2 deletions drivers/leds/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ config LEDS_AAT1290
depends on PINCTRL
help
This option enables support for the LEDs on the AAT1290.

config LEDS_APU
tristate "Front panel LED support for PC Engines APU/APU2 boards"
tristate "Front panel LED support for PC Engines APU/APU2/APU3 boards"
depends on LEDS_CLASS
depends on X86 && DMI
help
This driver makes the PC Engines APU/APU2 front panel LEDs
This driver makes the PC Engines APU/APU2/APU3 front panel LEDs
accessible from userspace programs through the LED subsystem.

To compile this driver as a module, choose M here: the
Expand Down
39 changes: 36 additions & 3 deletions drivers/leds/led-triggers.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,16 @@ ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
EXPORT_SYMBOL_GPL(led_trigger_show);

/* Caller must ensure led_cdev->trigger_lock held */
void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
{
unsigned long flags;
char *event = NULL;
char *envp[2];
const char *name;
int ret;

if (!led_cdev->trigger && !trig)
return;
return 0;

name = trig ? trig->name : "none";
event = kasprintf(GFP_KERNEL, "TRIGGER=%s", name);
Expand All @@ -126,16 +127,31 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
led_stop_software_blink(led_cdev);
if (led_cdev->trigger->deactivate)
led_cdev->trigger->deactivate(led_cdev);
device_remove_groups(led_cdev->dev, led_cdev->trigger->groups);
led_cdev->trigger = NULL;
led_cdev->trigger_data = NULL;
led_cdev->activated = false;
led_set_brightness(led_cdev, LED_OFF);
}
if (trig) {
write_lock_irqsave(&trig->leddev_list_lock, flags);
list_add_tail(&led_cdev->trig_list, &trig->led_cdevs);
write_unlock_irqrestore(&trig->leddev_list_lock, flags);
led_cdev->trigger = trig;

if (trig->activate)
trig->activate(led_cdev);
ret = trig->activate(led_cdev);
else
ret = 0;

if (ret)
goto err_activate;

ret = device_add_groups(led_cdev->dev, trig->groups);
if (ret) {
dev_err(led_cdev->dev, "Failed to add trigger attributes\n");
goto err_add_groups;
}
}

if (event) {
Expand All @@ -146,6 +162,23 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
"%s: Error sending uevent\n", __func__);
kfree(event);
}

return 0;

err_add_groups:

if (trig->deactivate)
trig->deactivate(led_cdev);
err_activate:

led_cdev->trigger = NULL;
led_cdev->trigger_data = NULL;
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);
led_set_brightness(led_cdev, LED_OFF);

return ret;
}
EXPORT_SYMBOL_GPL(led_trigger_set);

Expand Down
44 changes: 43 additions & 1 deletion drivers/leds/leds-apu.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ static const struct apu_led_profile apu2_led_profile[] = {
{ "apu2:green:3", LED_OFF, APU2_FCH_GPIO_BASE + 70 * APU2_IOSIZE },
};

/* Same as apu2_led_profile, but with "3" in the LED names. */
static const struct apu_led_profile apu3_led_profile[] = {
{ "apu3:green:1", LED_ON, APU2_FCH_GPIO_BASE + 68 * APU2_IOSIZE },
{ "apu3:green:2", LED_OFF, APU2_FCH_GPIO_BASE + 69 * APU2_IOSIZE },
{ "apu3:green:3", LED_OFF, APU2_FCH_GPIO_BASE + 70 * APU2_IOSIZE },
};

static const struct dmi_system_id apu_led_dmi_table[] __initconst = {
{
.ident = "apu",
Expand Down Expand Up @@ -134,6 +141,30 @@ static const struct dmi_system_id apu_led_dmi_table[] __initconst = {
DMI_MATCH(DMI_BOARD_NAME, "PC Engines apu2")
}
},
/* PC Engines APU3 with "Legacy" bios < 4.0.8 */
{
.ident = "apu3",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
DMI_MATCH(DMI_BOARD_NAME, "APU3")
}
},
/* PC Engines APU3 with "Legacy" bios >= 4.0.8 */
{
.ident = "apu3",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
DMI_MATCH(DMI_BOARD_NAME, "apu3")
}
},
/* PC Engines APU2 with "Mainline" bios */
{
.ident = "apu3",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
DMI_MATCH(DMI_BOARD_NAME, "PC Engines apu3")
}
},
{}
};
MODULE_DEVICE_TABLE(dmi, apu_led_dmi_table);
Expand Down Expand Up @@ -235,6 +266,14 @@ static int __init apu_led_probe(struct platform_device *pdev)
apu_led->platform = APU2_LED_PLATFORM;
apu_led->num_led_instances = ARRAY_SIZE(apu2_led_profile);
apu_led->iosize = APU2_IOSIZE;
} else if (dmi_match(DMI_BOARD_NAME, "APU3") ||
dmi_match(DMI_BOARD_NAME, "apu3") ||
dmi_match(DMI_BOARD_NAME, "PC Engines apu3")) {
apu_led->profile = apu3_led_profile;
/* Otherwise identical to APU2. */
apu_led->platform = APU2_LED_PLATFORM;
apu_led->num_led_instances = ARRAY_SIZE(apu3_led_profile);
apu_led->iosize = APU2_IOSIZE;
}

spin_lock_init(&apu_led->lock);
Expand All @@ -259,7 +298,10 @@ static int __init apu_led_init(void)
if (!(dmi_match(DMI_PRODUCT_NAME, "APU") ||
dmi_match(DMI_PRODUCT_NAME, "APU2") ||
dmi_match(DMI_PRODUCT_NAME, "apu2") ||
dmi_match(DMI_PRODUCT_NAME, "PC Engines apu2"))) {
dmi_match(DMI_PRODUCT_NAME, "PC Engines apu2") ||
dmi_match(DMI_PRODUCT_NAME, "APU3") ||
dmi_match(DMI_PRODUCT_NAME, "apu3") ||
dmi_match(DMI_PRODUCT_NAME, "PC Engines apu3"))) {
pr_err("Unknown PC Engines board: %s\n",
dmi_get_system_info(DMI_PRODUCT_NAME));
return -ENODEV;
Expand Down
Loading

0 comments on commit c07b368

Please sign in to comment.