All of lore.kernel.org
 help / color / mirror / Atom feed
From: Colin Cross <ccross@android.com>
To: linux-kernel@vger.kernel.org
Cc: Greg KH <gregkh@linuxfoundation.org>,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
	Colin Cross <ccross@android.com>,
	Bryan Wu <bryan.wu@canonical.com>,
	Richard Purdie <rpurdie@rpsys.net>,
	linux-leds@vger.kernel.org
Subject: [PATCH] leds: triggers: send uevent when changing triggers
Date: Tue, 24 Jul 2012 17:32:50 -0700	[thread overview]
Message-ID: <1343176370-5856-1-git-send-email-ccross@android.com> (raw)

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.

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


             reply	other threads:[~2012-07-25  0:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-25  0:32 Colin Cross [this message]
2012-07-25  6:11 ` [PATCH] leds: triggers: send uevent when changing triggers Bryan Wu
2012-07-25 14:36   ` Greg KH
2012-07-25 18:54   ` Colin Cross
2012-07-26  3:29     ` Bryan Wu
2012-07-26  3:59       ` Greg KH
2012-07-26  5:03         ` Bryan Wu
2012-07-26 16:51           ` Greg KH
2012-07-27  4:04             ` Bryan Wu
2012-07-31 18:28               ` Colin Cross
2012-08-07  2:57                 ` Bryan Wu
2012-08-07  3:34                   ` Greg KH
     [not found]                     ` <CAK5ve-KLdwEqW6MLbusMRkaHBQkxTqOGLoVWzSmiuo2qxwtwmA@mail.gmail.com>
2012-08-07  3:43                       ` Greg KH
2012-08-07 14:36                   ` Henrique de Moraes Holschuh
2012-08-07 19:44                     ` Colin Cross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343176370-5856-1-git-send-email-ccross@android.com \
    --to=ccross@android.com \
    --cc=bryan.wu@canonical.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hmh@hmh.eng.br \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.