LED: Add LED Class
Subsystems (2)
PATCH 2/12 LED: Add LED Class
Add the foundations of a new LEDs subsystem. This patch adds a class which presents LED devices within sysfs and allows their brightness to be controlled.
Signed-off-by Richard Purdie <[email protected]>
drivers/leds/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ + +menu "LED devices" + +config NEW_LEDS + bool "LED Support" + help + Say Y to enable Linux LED support. This is not related to standard + keyboard LEDs which are controlled via the input system. + +config LEDS_CLASS + tristate "LED Class Support" + depends NEW_LEDS + help + This option enables the led sysfs class in /sys/class/leds. You'll + need this to do anything useful with LEDs. If unsure, say N. + +endmenu +
drivers/leds/Makefile new file +4 -0
@@ -0,0 +1,4 @@ + +# LED Core +obj-$(CONFIG_NEW_LEDS) += led-core.o +obj-$(CONFIG_LEDS_CLASS) += led-class.o
include/linux/leds.h new file +48 -0
48 lines not on this page · raw message
arch/arm/Kconfig +2 -0
@@ -774,6 +774,8 @@ source "drivers/mfd/Kconfig" +source "drivers/leds/Kconfig" + source "drivers/media/Kconfig" source "drivers/video/Kconfig"
drivers/Makefile +1 -0
@@ -68,6 +68,7 @@ obj-$(CONFIG_EISA) += eisa/ obj-$(CONFIG_CPU_FREQ) += cpufreq/ obj-$(CONFIG_MMC) += mmc/ +obj-$(CONFIG_NEW_LEDS) += leds/ obj-$(CONFIG_INFINIBAND) += infiniband/ obj-$(CONFIG_SGI_IOC4) += sn/ obj-y += firmware/
drivers/Kconfig +2 -0
@@ -64,6 +64,8 @@ source "drivers/mmc/Kconfig" +source "drivers/leds/Kconfig" + source "drivers/infiniband/Kconfig" source "drivers/sn/Kconfig"
drivers/leds/leds.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* LED Core +* +* Copyright 2005 Openedhand Ltd. +* +* Author: Richard Purdie <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ + +/* led_cdev->lock must be held as write */ +static inline void led_set_brightness (struct led_classdev *led_cdev,enum led_brightness value) +{ +if (value >LED_FULL ) + value =LED_FULL ; + led_cdev->brightness = value; +if (!(led_cdev->flags &LED_SUSPENDED )) + led_cdev->brightness_set (led_cdev, value); +} + +extern rwlock_t leds_list_lock; +extern struct list_head leds_list; +
drivers/leds/led-class.c new file +150 -0
150 lines not on this page · raw message
drivers/leds/led-core.c new file +24 -0
@@ -0,0 +1,24 @@ +/* +* LED Class Core +* +* Copyright 2005-2006 Openedhand Ltd. +* +* Author: Richard Purdie <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ + +#include <linux/kernel.h> +#include <linux/list.h> +#include <linux/module.h> +#include <linux/spinlock.h> +#include <linux/leds.h> +#include "leds.h" + +rwlock_t leds_list_lock =RW_LOCK_UNLOCKED ; +LIST_HEAD (leds_list); + +EXPORT_SYMBOL_GPL (leds_list);