【问题标题】:How to change LED trigger?如何更改 LED 触发器?
【发布时间】:2012-05-22 18:42:58
【问题描述】:

我已在 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 可以,但可能以另一种方式存在?

【问题讨论】:

    标签: linux kernel linux-device-driver led


    【解决方案1】:
    echo "thetriggeryouwant" > /sys/class/leds/someled/trigger
    

    其中thetriggeryouwant 是例如phy0rxsomeled 是您要更改触发器的 LED 的名称。


    要获取该 LED 的所有可用触发器,您可以cat 文件:

    cat /sys/class/leds/someled/trigger
    

    例如:

    [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

    括号中的项目 ([none]) 表示当前触发器。

    【讨论】:

      猜你喜欢
      • 2011-05-21
      • 2020-12-30
      • 2017-01-28
      • 2013-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-06
      • 1970-01-01
      相关资源
      最近更新 更多