leds: triggers: send uevent when changing triggers
PATCH v2 1/1 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.
--- drivers/leds/led-triggers.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/leds/led-triggers.c +13 -0
@@ -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);
Signature · 1 line
1.7.7.3
Quoted 7 lines · 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.
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
Quoted 11 lines · Greg KH
Quoted 7 lines · 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.
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.
Quoted 10 lines · Colin Cross
Quoted 9 lines · Greg KH
Quoted 7 lines · 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.
Quoted 7 lines
Quoted 2 lines
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_createwill 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
Quoted 9 lines · 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 <[email protected]>
Quoted 9 lines · 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 <[email protected]>
Signature · 4 lines
"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
Quoted 5 lines · Henrique de Moraes Holschuh
Quoted 4 lines · 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.
Quoted 8 lines
Quoted 5 lines
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 <[email protected]>
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
Quoted 11 lines · Bryan Wu
Quoted 9 lines · Henrique de Moraes Holschuh
Quoted 8 lines · 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.
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Colin Cross <[email protected]>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
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
Quoted 25 lines · Bryan Wu
Quoted 11 lines · Bryan Wu
Quoted 9 lines · Henrique de Moraes Holschuh
Quoted 8 lines · 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.
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Colin Cross <[email protected]>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
Signature · 4 lines
Bryan Wu <[email protected]> Kernel Developer +86.186-168-78255 Mobile Canonical Ltd. www.canonical.com Ubuntu - Linux for human beings | www.ubuntu.com