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

* Re: [PATCH v2] leds: triggers: send uevent when changing triggers
  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:57 ` Greg KH
  2012-08-08  1:12 ` Henrique de Moraes Holschuh
  2 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2012-08-07 20:42 UTC (permalink / raw)
  To: Colin Cross
  Cc: linux-kernel, Henrique de Moraes Holschuh, Bryan Wu,
	Richard Purdie, linux-leds

On Tue, Aug 07, 2012 at 12:58:15PM -0700, Colin Cross wrote:
> 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.

Why would a change event be needed at this point in time?  Nothing would
have changed from the original "add" notification, right?

greg k-h

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

* Re: [PATCH v2] leds: triggers: send uevent when changing triggers
  2012-08-07 20:42 ` Greg KH
@ 2012-08-07 20:47   ` Colin Cross
  2012-08-07 20:56     ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Colin Cross @ 2012-08-07 20:47 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel, Henrique de Moraes Holschuh, Bryan Wu,
	Richard Purdie, linux-leds

On Tue, Aug 7, 2012 at 1:42 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Tue, Aug 07, 2012 at 12:58:15PM -0700, Colin Cross wrote:
>> 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.
>
> Why would a change event be needed at this point in time?  Nothing would
> have changed from the original "add" notification, right?

If the led class device has a default trigger configured,
device_create will called before the trigger has been set and the
trigger sysfs files have been created.  The "change" notification will
happen after the extra files have been created.

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

* Re: [PATCH v2] leds: triggers: send uevent when changing triggers
  2012-08-07 20:47   ` Colin Cross
@ 2012-08-07 20:56     ` Greg KH
  0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2012-08-07 20:56 UTC (permalink / raw)
  To: Colin Cross
  Cc: linux-kernel, Henrique de Moraes Holschuh, Bryan Wu,
	Richard Purdie, linux-leds

On Tue, Aug 07, 2012 at 01:47:23PM -0700, Colin Cross wrote:
> On Tue, Aug 7, 2012 at 1:42 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> > On Tue, Aug 07, 2012 at 12:58:15PM -0700, Colin Cross wrote:
> >> 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.
> >
> > Why would a change event be needed at this point in time?  Nothing would
> > have changed from the original "add" notification, right?
> 
> If the led class device has a default trigger configured,
> device_create will called before the trigger has been set and the
> trigger sysfs files have been created.  The "change" notification will
> happen after the extra files have been created.

Ok, that make sense, and is a good reason to send the change event,
thanks for explaining it.

greg k-h

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

* Re: [PATCH v2] leds: triggers: send uevent when changing triggers
  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:57 ` Greg KH
  2012-08-08  1:12 ` Henrique de Moraes Holschuh
  2 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2012-08-07 20:57 UTC (permalink / raw)
  To: Colin Cross
  Cc: linux-kernel, Henrique de Moraes Holschuh, Bryan Wu,
	Richard Purdie, linux-leds

On Tue, Aug 07, 2012 at 12:58:15PM -0700, Colin Cross wrote:
> 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>

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH v2] leds: triggers: send uevent when changing triggers
  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:57 ` Greg KH
@ 2012-08-08  1:12 ` Henrique de Moraes Holschuh
  2012-08-08  2:16   ` Bryan Wu
  2 siblings, 1 reply; 9+ messages in thread
From: Henrique de Moraes Holschuh @ 2012-08-08  1:12 UTC (permalink / raw)
  To: Colin Cross; +Cc: linux-kernel, Greg KH, Bryan Wu, Richard Purdie, linux-leds

On Tue, 07 Aug 2012, Colin Cross wrote:
> 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>

Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

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

* Re: [PATCH v2] leds: triggers: send uevent when changing triggers
  2012-08-08  1:12 ` Henrique de Moraes Holschuh
@ 2012-08-08  2:16   ` Bryan Wu
  2012-08-14 11:34     ` Bryan Wu
  0 siblings, 1 reply; 9+ messages in thread
From: Bryan Wu @ 2012-08-08  2:16 UTC (permalink / raw)
  To: Henrique de Moraes Holschuh
  Cc: Colin Cross, linux-kernel, Greg KH, Richard Purdie, linux-leds

On Wed, Aug 8, 2012 at 9:12 AM, Henrique de Moraes Holschuh
<hmh@hmh.eng.br> wrote:
> On Tue, 07 Aug 2012, Colin Cross wrote:
>> 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>
>
> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
>

Colin, could you please resend an update patch with some
documentations as Henrique pointed out? Then I will add Ack from
Henrique and Greg and apply this patch.

Thanks,
-Bryan

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

* Re: [PATCH v2] leds: triggers: send uevent when changing triggers
  2012-08-08  2:16   ` Bryan Wu
@ 2012-08-14 11:34     ` Bryan Wu
  2012-08-27  1:43       ` Bryan Wu
  0 siblings, 1 reply; 9+ messages in thread
From: Bryan Wu @ 2012-08-14 11:34 UTC (permalink / raw)
  To: Colin Cross, Henrique de Moraes Holschuh
  Cc: linux-kernel, Greg KH, Richard Purdie, linux-leds

On Wed, Aug 8, 2012 at 10:16 AM, Bryan Wu <bryan.wu@canonical.com> wrote:
> On Wed, Aug 8, 2012 at 9:12 AM, Henrique de Moraes Holschuh
> <hmh@hmh.eng.br> wrote:
>> On Tue, 07 Aug 2012, Colin Cross wrote:
>>> 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>
>>
>> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
>>
>
> Colin, could you please resend an update patch with some
> documentations as Henrique pointed out? Then I will add Ack from
> Henrique and Greg and apply this patch.
>

Colin, will you update the patch or just keep this one.

-Bryan

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

* Re: [PATCH v2] leds: triggers: send uevent when changing triggers
  2012-08-14 11:34     ` Bryan Wu
@ 2012-08-27  1:43       ` Bryan Wu
  0 siblings, 0 replies; 9+ messages in thread
From: Bryan Wu @ 2012-08-27  1:43 UTC (permalink / raw)
  To: Colin Cross, Henrique de Moraes Holschuh
  Cc: linux-kernel, Greg KH, Richard Purdie, linux-leds

My bad. I apologize to the delay. I missed the v2 original patch email
in this thread, but googled and found it.
Applied to my for-next branch now.

Thanks,
-Bryan

On Tue, Aug 14, 2012 at 7:34 PM, Bryan Wu <bryan.wu@canonical.com> wrote:
> On Wed, Aug 8, 2012 at 10:16 AM, Bryan Wu <bryan.wu@canonical.com> wrote:
>> On Wed, Aug 8, 2012 at 9:12 AM, Henrique de Moraes Holschuh
>> <hmh@hmh.eng.br> wrote:
>>> On Tue, 07 Aug 2012, Colin Cross wrote:
>>>> 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>
>>>
>>> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
>>>
>>
>> Colin, could you please resend an update patch with some
>> documentations as Henrique pointed out? Then I will add Ack from
>> Henrique and Greg and apply this patch.
>>
>
> Colin, will you update the patch or just keep this one.
>
> -Bryan



-- 
Bryan Wu <bryan.wu@canonical.com>
Kernel Developer    +86.186-168-78255 Mobile
Canonical Ltd.      www.canonical.com
Ubuntu - Linux for human beings | www.ubuntu.com

^ permalink raw reply	[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).