如何更换LED触发器?

时间:2012-05-15 09:14:32

标签: linux kernel linux-device-driver led

我在BSP注册了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);
}

如何在运行时更改触发器?我知道sysfs可以实现,但可能存在另一种方式吗?

1 个答案:

答案 0 :(得分:1)

#echo -n "thetriggeryouwant" >/sys/class/leds/someled/trigger

其中thetriggeryouwant例如phy0rx,而someled是要为其更改触发器的LED的名称。