Skip to content

Commit

Permalink
leds: triggers: send uevent when changing triggers
Browse files Browse the repository at this point in the history
Some triggers create sysfs files when they are enabled. Send a uevent
"change" notification whenever the trigger is changed to allow userspace
processes such as udev to modify permissions on the new files.

A change notification will also be sent during registration of led class
devices or led triggers if the default trigger of an led class device
is found.

(bryan.wu@canonical.com: rename trigger to trig to fix the build error)

Signed-off-by: Colin Cross <ccross@android.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
  • Loading branch information
Colin Cross authored and Bryan Wu committed Sep 11, 2012
1 parent 469eba0 commit 52c4774
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/leds/led-triggers.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ 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) {
Expand All @@ -124,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

0 comments on commit 52c4774

Please sign in to comment.