diff options
author | Colin Cross <ccross@android.com> | 2012-08-26 21:31:49 -0400 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-09-11 06:32:41 -0400 |
commit | 52c47742f79d9240f90af9a6722fe8bb3fa8c0f9 (patch) | |
tree | 057217b5690f6db9421080a7aa039a2fe4899463 /drivers/leds/led-triggers.c | |
parent | 469eba023087d8fa3974827e6bedf874a620d0e7 (diff) |
leds: triggers: send uevent when changing triggers
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>
Diffstat (limited to 'drivers/leds/led-triggers.c')
-rw-r--r-- | drivers/leds/led-triggers.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index b53bf54023f6..262eb4193710 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c | |||
@@ -102,6 +102,12 @@ EXPORT_SYMBOL_GPL(led_trigger_show); | |||
102 | void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) | 102 | void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) |
103 | { | 103 | { |
104 | unsigned long flags; | 104 | unsigned long flags; |
105 | char *event = NULL; | ||
106 | char *envp[2]; | ||
107 | const char *name; | ||
108 | |||
109 | name = trig ? trig->name : "none"; | ||
110 | event = kasprintf(GFP_KERNEL, "TRIGGER=%s", name); | ||
105 | 111 | ||
106 | /* Remove any existing trigger */ | 112 | /* Remove any existing trigger */ |
107 | if (led_cdev->trigger) { | 113 | if (led_cdev->trigger) { |
@@ -124,6 +130,13 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) | |||
124 | if (trig->activate) | 130 | if (trig->activate) |
125 | trig->activate(led_cdev); | 131 | trig->activate(led_cdev); |
126 | } | 132 | } |
133 | |||
134 | if (event) { | ||
135 | envp[0] = event; | ||
136 | envp[1] = NULL; | ||
137 | kobject_uevent_env(&led_cdev->dev->kobj, KOBJ_CHANGE, envp); | ||
138 | kfree(event); | ||
139 | } | ||
127 | } | 140 | } |
128 | EXPORT_SYMBOL_GPL(led_trigger_set); | 141 | EXPORT_SYMBOL_GPL(led_trigger_set); |
129 | 142 | ||