Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH v2] leds: triggers: send uevent when changing triggers

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


ccross at android

Aug 7, 2012, 12:58 PM

Post #1 of 9 (403 views)
Permalink
[PATCH v2] 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.

Signed-off-by: Colin Cross <ccross [at] android>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


gregkh at linuxfoundation

Aug 7, 2012, 1:42 PM

Post #2 of 9 (383 views)
Permalink
Re: [PATCH v2] leds: triggers: send uevent when changing triggers [In reply to]

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


ccross at android

Aug 7, 2012, 1:47 PM

Post #3 of 9 (387 views)
Permalink
Re: [PATCH v2] leds: triggers: send uevent when changing triggers [In reply to]

On Tue, Aug 7, 2012 at 1:42 PM, Greg KH <gregkh [at] linuxfoundation> 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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


gregkh at linuxfoundation

Aug 7, 2012, 1:56 PM

Post #4 of 9 (387 views)
Permalink
Re: [PATCH v2] leds: triggers: send uevent when changing triggers [In reply to]

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 [at] linuxfoundation> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


gregkh at linuxfoundation

Aug 7, 2012, 1:57 PM

Post #5 of 9 (380 views)
Permalink
Re: [PATCH v2] leds: triggers: send uevent when changing triggers [In reply to]

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 [at] android>

Acked-by: Greg Kroah-Hartman <gregkh [at] linuxfoundation>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


hmh at hmh

Aug 7, 2012, 6:12 PM

Post #6 of 9 (379 views)
Permalink
Re: [PATCH v2] leds: triggers: send uevent when changing triggers [In reply to]

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 [at] android>

Acked-by: Henrique de Moraes Holschuh <hmh [at] hmh>

--
"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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


bryan.wu at canonical

Aug 7, 2012, 7:16 PM

Post #7 of 9 (372 views)
Permalink
Re: [PATCH v2] leds: triggers: send uevent when changing triggers [In reply to]

On Wed, Aug 8, 2012 at 9:12 AM, Henrique de Moraes Holschuh
<hmh [at] hmh> 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 [at] android>
>
> Acked-by: Henrique de Moraes Holschuh <hmh [at] hmh>
>

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


bryan.wu at canonical

Aug 14, 2012, 4:34 AM

Post #8 of 9 (358 views)
Permalink
Re: [PATCH v2] leds: triggers: send uevent when changing triggers [In reply to]

On Wed, Aug 8, 2012 at 10:16 AM, Bryan Wu <bryan.wu [at] canonical> wrote:
> On Wed, Aug 8, 2012 at 9:12 AM, Henrique de Moraes Holschuh
> <hmh [at] hmh> 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 [at] android>
>>
>> Acked-by: Henrique de Moraes Holschuh <hmh [at] hmh>
>>
>
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


bryan.wu at canonical

Aug 26, 2012, 6:43 PM

Post #9 of 9 (328 views)
Permalink
Re: [PATCH v2] leds: triggers: send uevent when changing triggers [In reply to]

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 [at] canonical> wrote:
> On Wed, Aug 8, 2012 at 10:16 AM, Bryan Wu <bryan.wu [at] canonical> wrote:
>> On Wed, Aug 8, 2012 at 9:12 AM, Henrique de Moraes Holschuh
>> <hmh [at] hmh> 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 [at] android>
>>>
>>> Acked-by: Henrique de Moraes Holschuh <hmh [at] hmh>
>>>
>>
>> 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 [at] canonical>
Kernel Developer +86.186-168-78255 Mobile
Canonical Ltd. www.canonical.com
Ubuntu - Linux for human beings | www.ubuntu.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.