[PATCH] leds: automatically request trigger module

From: Uwe Kleine-KÃnig
Date: Wed Apr 09 2008 - 04:47:30 EST


This allows:
lala:/sys/class/leds/porta6# cat trigger
[none] heartbeat
lala:/sys/class/leds/porta6# echo timer > trigger
lala:/sys/class/leds/porta6# cat trigger
none heartbeat [timer]

Signed-off-by: Uwe Kleine-KÃnig <Uwe.Kleine-Koenig@xxxxxxxx>
---
Hello,

this change is convenient but I'm not sure if it adds policy to the
kernel.

What do you think about requesting ("ledtrig-%s", trigger_name)? Maybe
better use something like ("ledtrigger:%s", trigger_name)? This looks
better IMHO, but you would need to add module aliases to the trigger
modules.

Best regards
Uwe

drivers/leds/led-triggers.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 13c9026..26cfeae 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -51,6 +51,8 @@ ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
return count;
}

+ request_module("ledtrig-%s", trigger_name);
+
down_read(&triggers_list_lock);
list_for_each_entry(trig, &trigger_list, next_trig) {
if (!strcmp(trigger_name, trig->name)) {
@@ -146,6 +148,8 @@ void led_trigger_set_default(struct led_classdev *led_cdev)
if (!led_cdev->default_trigger)
return;

+ request_module("ledtrig-%s", led_cdev->default_trigger);
+
down_read(&triggers_list_lock);
down_write(&led_cdev->trigger_lock);
list_for_each_entry(trig, &trigger_list, next_trig) {
--
1.5.4.5

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