linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] leds: triggers: send uevent when changing triggers
@ 2012-08-07 19:58 Colin Cross
  2012-08-07 20:42 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Colin Cross @ 2012-08-07 19:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg KH, Henrique de Moraes Holschuh, Bryan Wu, Richard Purdie,
	linux-leds, Colin Cross

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.

Signed-off-by: Colin Cross <ccross@android.com>
---
 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 46b4c76..a85ce09 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -102,6 +102,12 @@ ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
 void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger)
 {
 	unsigned long flags;
+	char *event = NULL;
+	char *envp[2];
+	const char *name;
+
+	name = trigger ? trigger->name : "none";
+	event = kasprintf(GFP_KERNEL, "TRIGGER=%s", name);
 
 	/* Remove any existing trigger */
 	if (led_cdev->trigger) {
@@ -122,6 +128,13 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger)
 		if (trigger->activate)
 			trigger->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);
 
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-08-27  1:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-07 19:58 [PATCH v2] leds: triggers: send uevent when changing triggers Colin Cross
2012-08-07 20:42 ` Greg KH
2012-08-07 20:47   ` Colin Cross
2012-08-07 20:56     ` Greg KH
2012-08-07 20:57 ` Greg KH
2012-08-08  1:12 ` Henrique de Moraes Holschuh
2012-08-08  2:16   ` Bryan Wu
2012-08-14 11:34     ` Bryan Wu
2012-08-27  1:43       ` Bryan Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).