How to change LED trigger?

kernel, led, linux, linux-device-driver

Solution

echo "thetriggeryouwant" > /sys/class/leds/someled/trigger

where `thetriggeryouwant` is for example `phy0rx` and `someled` is the name of the led you want to change the trigger for.

To get all available triggers for that led, you can `cat` the file:

cat /sys/class/leds/someled/trigger

gives for example:

`[none] timer oneshot mtd nand-disk heartbeat backlight gpio cpu cpu0 cpu1 activity default-on 2188000.ethernet-2:00:link 2188000.ethernet-2:00:100Mbps 2188000.ethernet-2:00:10Mbps`

where the item in brackets (`[none]`) denotes the current trigger.

Problem

I have register in BSP's the LED: ``` static struct gpio_led ic_leds[] = { { .name = "led1:green", .gpio = USER_LED, .default_trigger = "heartbeat", .active_low = 1, }, }; static struct gpio_led_platform_data ic_led_info = { .num_leds = ARRAY_SIZE(ic_leds), .leds = ic_leds, }; static struct platform_device ic_leds_device = { .name = "leds-gpio", .id = -1, .dev = { .platform_data = &ic_led_info, }, }; static void __init ic_add_device_leds(void) { platform_device_register(&ic_leds_device); } ``` How can I change the trigger in run time? I know that it's possible with sysfs, but maybe exist another way?

Original source