aboutsummaryrefslogtreecommitdiff
path: root/drivers/leds/led-class.c
AgeCommit message (Collapse)AuthorFilesLines
2012-07-24leds: add oneshot blink functionsFabio Baltieri1-0/+19
Add two new functions, led_blink_set_oneshot and led_trigger_blink_oneshot, to be used by triggers for one-shot blink of led devices. This is implemented extending the existing software-blink code, and uses the same timer and handler function. The behavior of the code is to do a blink-on, blink-off sequence when the function is called, ignoring other calls until the sequence is completed so that the leds keep blinking at constant rate if the functions are called repeatedly. This is meant to be used by drivers which needs to trigger on sporadic event, but doesn't have clear busy/idle trigger points. After the blink sequence the led remains off. This behavior can be inverted setting the "invert" argument, which blink the led off, than on and leave the led on after the sequence. ([email protected]: rebase to commit 'leds: don't disable blinking when writing the same value to delay_on or delay_off') Signed-off-by: Fabio Baltieri <[email protected]> Acked-by: Shuah Khan <[email protected]> Signed-off-by: Bryan Wu <[email protected]>
2012-06-12leds: fixed a coding style issue.Jeffrin Jose1-1/+1
Fixed a coding style issue relating to trailing white space error found by checkpatch.pl tool in drivers/leds/led-class.c Signed-off-by: Jeffrin Jose <[email protected]> Signed-off-by: Bryan Wu <[email protected]>
2012-05-29leds: simple_strtoul() cleanupShuah Khan1-13/+8
led-class.c and ledtrig-timer.c still use simple_strtoul(). Change them to use kstrtoul() instead of obsolete simple_strtoul(). Also fix the existing int ret declaration to be ssize_t to match the return type for _store functions in ledtrig-timer.c. Signed-off-by: Shuah Khan <[email protected]> Cc: Joe Perches <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Bryan Wu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-03-23led-class: change back LEDS_CLASS to tristate instead of boolBryan Wu1-70/+0
After moving some core functions to led-core.c, led-class.c can be built as module again. Signed-off-by: Bryan Wu <[email protected]> Acked-by: Richard Purdie <[email protected]> Acked-by: Linus Walleij <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-01-06Merge branch 'driver-core-next' into Linux 3.2Greg Kroah-Hartman1-1/+0
This resolves the conflict in the arch/arm/mach-s3c64xx/s3c6400.c file, and it fixes the build error in the arch/x86/kernel/microcode_core.c file, that the merge did not catch. The microcode_core.c patch was provided by Stephen Rothwell <[email protected]> who was invaluable in the merge issues involved with the large sysdev removal process in the driver-core tree. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2011-12-21driver-core: remove sysdev.h usage.Kay Sievers1-1/+0
The sysdev.h file should not be needed by any in-kernel code, so remove the .h file from these random files that seem to still want to include it. The sysdev code will be going away soon, so this include needs to be removed no matter what. Cc: Jiandong Zheng <[email protected]> Cc: Scott Branden <[email protected]> Cc: Russell King <[email protected]> Cc: Kukjin Kim <[email protected]> Cc: David Brown <[email protected]> Cc: Daniel Walker <[email protected]> Cc: Bryan Huntsman <[email protected]> Cc: Ben Dooks <[email protected]> Cc: Wan ZongShun <[email protected]> Cc: Haavard Skinnemoen <[email protected]> Cc: Hans-Christian Egtvedt <[email protected]> Cc: Guan Xuetao <[email protected]> Cc: "Venkatesh Pallipadi Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Grant Likely <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Matthew Garrett <[email protected]> Signed-off-by: Kay Sievers <[email protected]>
2011-11-15Revert "leds: save the delay values after a successful call to blink_set()"Johan Hovold1-4/+1
Revert commit 6123b0e274503a0d3588e84fbe07c9aa01bfaf5d. The problem this patch intends to solve has alreadqy been fixed by commit 7a5caabd090b ("drivers/leds/ledtrig-timer.c: fix broken sysfs delay handling"). Signed-off-by: Johan Hovold <[email protected]> Cc: Antonio Ospite <[email protected]> Cc: Johannes Berg <[email protected]> Cc: Richard Purdie <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-10-31leds: turn the blink_timer off before starting to blinkAntonio Ospite1-0/+2
Depending on the implementation of the hardware blinking function in blink_set(), the led can support hardware blinking for some values of delay_on and delay_off and fall-back to software blinking for some other values. Turning off the blink_timer unconditionally before starting to blink make sure that a sequence like: OFF hardware blinking software blinking hardware blinking does not leave the software blinking timer active. Signed-off-by: Antonio Ospite <[email protected]> Reviewed-by: Johannes Berg <[email protected]> Cc: Richard Purdie <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-10-31leds: save the delay values after a successful call to blink_set()Antonio Ospite1-1/+4
When calling the hardware blinking function implemented by blink_set(), the delay_on and delay_off values are not preserved across calls. Fix that and make the "timer" trigger work as expected when hardware blinking is available. BEFORE the fix: $ cd /sys/class/leds/someled $ echo timer > trigger $ cat delay_on delay_off 0 0 $ echo 100 > delay_on $ cat delay_on delay_off 0 0 $ echo 100 > delay_off $ cat delay_on delay_off 0 0 AFTER the fix: $ cd /sys/class/leds/someled $ echo timer > trigger $ cat delay_on delay_off 0 0 $ echo 100 > delay_on $ cat delay_on delay_off 100 0 $ echo 100 > delay_off $ cat delay_on delay_off 100 100 Signed-off-by: Antonio Ospite <[email protected]> Reviewed-by: Johannes Berg <[email protected]> Cc: Richard Purdie <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-05-25leds: support automatic start of blinking with ledtrig-timerEsben Haabendal1-1/+2
By setting initial values blink_delay_on and blink_delay_off in a led_classdev struct, this change starts the blinking when the led is initialized. With this patch, you can initialize blink_delay_on and blink_delay_off in led_classdev with default_trigger set to "timer", and the led will start up blinking. The current ledtrig-timer implementation ignores any initial blink_delay_on/blink_delay_off settings, and requires setting blink_delay_on/blink_delay_off (typically from userspace) before the led blinks. Signed-off-by: Esben Haabendal <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Randy Dunlap <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2010-12-22led_class: fix typo in blink APIJohannes Berg1-1/+1
When I added led_blink_set I had a typo: the return value of the hw offload is a regular error code that is zero when succesful, and in that case software emulation should not be used, rather than the other way around. Signed-off-by: Johannes Berg <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2010-11-12led-class: always implement blinkingJohannes Berg1-1/+104
Currently, blinking LEDs can be awkward because it is not guaranteed that all LEDs implement blinking. The trigger that wants it to blink then needs to implement its own timer solution. Rather than require that, add led_blink_set() API that triggers can use. This function will attempt to use hw blinking, but if that fails implements a timer for it. To stop blinking again, brightness_set() also needs to be wrapped into API that will stop the software blink. As a result of this, the timer trigger becomes a very trivial one, and hopefully we can finally see triggers using blinking as well because it's always easy to use. Signed-off-by: Johannes Berg <[email protected]> Acked-by: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2010-05-26leds: led-class: set permissions on max_brightness file to 0444Axel Lin1-1/+1
max_brightness is not writable, thus set permissions to 0444. Signed-off-by: Axel Lin <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
2010-03-16leds: Fix race between LED device uevent and actual attributes creationFlorian Fainelli1-32/+8
If we were to dynamically register/unregister leds and have udev or other daemons handle the leds class uevents, we would be notified of the adding of a new LED and if the daemon immediately tries to open one of the attributes of the led device, it would fail with a "no such file or directory" error since this the attributes are not yet created. Fix this by switching attributes to be class-wide, such that the driver core will register these attributes with device_add_attrs and then emit the kobject_uevent ADD signal. Signed-off-by: Fainelli <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
2010-03-16leds: led-class.c - Quiet boot messagesH Hartley Sweeten1-1/+1
As each led device gets registered a kernel message gets printed. In an embedded system with a number of leds this can produce a lot of output that just looks like noise. Change the message type to KERN_DEBUG since it might be useful in the dmesg output "after" booting. Signed-off-by: H Hartley Sweeten <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
2009-12-15tree-wide: convert open calls to remove spaces to skip_spaces() lib functionAndré Goddard Rosa1-1/+1
Makes use of skip_spaces() defined in lib/string.c for removing leading spaces from strings all over the tree. It decreases lib.a code size by 47 bytes and reuses the function tree-wide: text data bss dec hex filename 64688 584 592 65864 10148 (TOTALS-BEFORE) 64641 584 592 65817 10119 (TOTALS-AFTER) Also, while at it, if we see (*str && isspace(*str)), we can be sure to remove the first condition (*str) as the second one (isspace(*str)) also evaluates to 0 whenever *str == 0, making it redundant. In other words, "a char equals zero is never a space". Julia Lawall tried the semantic patch (http://coccinelle.lip6.fr) below, and found occurrences of this pattern on 3 more files: drivers/leds/led-class.c drivers/leds/ledtrig-timer.c drivers/video/output.c @@ expression str; @@ ( // ignore skip_spaces cases while (*str && isspace(*str)) { \(str++;\|++str;\) } | - *str && isspace(*str) ) Signed-off-by: André Goddard Rosa <[email protected]> Cc: Julia Lawall <[email protected]> Cc: Martin Schwidefsky <[email protected]> Cc: Jeff Dike <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Neil Brown <[email protected]> Cc: Kyle McMartin <[email protected]> Cc: Henrique de Moraes Holschuh <[email protected]> Cc: David Howells <[email protected]> Cc: <[email protected]> Cc: Samuel Ortiz <[email protected]> Cc: Patrick McHardy <[email protected]> Cc: Takashi Iwai <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2009-04-06leds: allow led-drivers to use a variable range of brightness valuesGuennadi Liakhovetski1-1/+20
This patch allows drivers to override the default maximum brightness value of 255. We take care to preserve backwards-compatibility as much as possible, so that user-space ABI doesn't change for existing drivers. LED trigger code has also been updated to use the per-LED maximum. Signed-off-by: Guennadi Liakhovetski <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
2009-01-08leds: Add suspend/resume to the core classRichard Purdie1-0/+22
Add suspend/resume to the core class and remove all the now unneeded code from various drivers. Originally the class code couldn't support suspend/resume but since class_device can there is no reason for each driver doing its own suspend/resume anymore.
2009-01-08leds: Fixup kdoc comment to match parameter namesSven Wegener1-1/+1
Signed-off-by: Sven Wegener <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
2008-10-20leds: Fix trigger registration raceRichard Purdie1-2/+3
Fix a race during trigger registration where we could try and use a lock before it was initialised. Signed-off-by: Richard Purdie <[email protected]>
2008-10-20leds: Fix leds-class.c commentQinghuang Feng1-1/+1
led_classdev_unregister() has no "__" prefix, remove it. Signed-off-by: Qinghuang Feng <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
2008-10-20leds: Remove uneeded strlen callsSven Wegener1-4/+1
There's no need for the additional call to strlen(), we can directly return the value returned by sprintf(). We now return a length value that doesn't include the final '\0', but user space shouldn't bother about it anyway. Signed-off-by: Sven Wegener <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
2008-10-16device create: misc: convert device_create_drvdata to device_createGreg Kroah-Hartman1-2/+2
Now that device_create() has been audited, rename things back to the original call to be sane. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2008-05-20LEDS: fix race in device_createGreg Kroah-Hartman1-4/+2
There is a race from when a device is created with device_create() and then the drvdata is set with a call to dev_set_drvdata() in which a sysfs file could be open, yet the drvdata will be NULL, causing all sorts of bad things to happen. This patch fixes the problem by using the new function, device_create_drvdata(). Cc: Kay Sievers <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2008-04-29Remove duplicated unlikely() in IS_ERR()Hirofumi Nakagawa1-1/+1
Some drivers have duplicated unlikely() macros. IS_ERR() already has unlikely() in itself. This patch cleans up such pointless code. Signed-off-by: Hirofumi Nakagawa <[email protected]> Acked-by: David S. Miller <[email protected]> Acked-by: Jeff Garzik <[email protected]> Cc: Paul Clements <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Alessandro Zummo <[email protected]> Cc: David Brownell <[email protected]> Cc: James Bottomley <[email protected]> Cc: Michael Halcrow <[email protected]> Cc: Anton Altaparmakov <[email protected]> Cc: Al Viro <[email protected]> Cc: Carsten Otte <[email protected]> Cc: Patrick McHardy <[email protected]> Cc: Paul Mundt <[email protected]> Cc: Jaroslav Kysela <[email protected]> Cc: Takashi Iwai <[email protected]> Acked-by: Mike Frysinger <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-04-24leds: Add support to leds with readable statusHenrique de Moraes Holschuh1-0/+9
Some led hardware allows drivers to query the led state, and this patch adds a hook to let the led class take advantage of that information when available. Without this functionality, when access to the led hardware is not exclusive (i.e. firmware or hardware might change its state behind the kernel's back), reality goes out of sync with the led class' idea of what the led is doing, which is annoying at best. Behaviour for drivers that do not or cannot read the led status is unchanged. Signed-off-by: Henrique de Moraes Holschuh <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
2008-04-24leds: disable triggers on brightness setNémeth Márton1-0/+3
Disable any active triggers when the brightness attribute is set to zero. Signed-off-by: Henrique de Moraes Holschuh <[email protected]> Signed-off-by: Márton Németh <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
2008-04-19PM: Remove destroy_suspended_device()Rafael J. Wysocki1-8/+3
After 2.6.24 there was a plan to make the PM core acquire all device semaphores during a suspend/hibernation to protect itself from concurrent operations involving device objects. That proved to be too heavy-handed and we found a better way to achieve the goal, but before it happened, we had introduced the functions device_pm_schedule_removal() and destroy_suspended_device() to allow drivers to "safely" destroy a suspended device and we had adapted some drivers to use them. Now that these functions are no longer necessary, it seems reasonable to remove them and modify their users to use the normal device unregistration instead. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Pavel Machek <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2008-02-05leds: add possibility to remove leds classdevs during suspend/resumeRafael J. Wysocki1-4/+9
Make it possible to unregister a led classdev object in a safe way during a suspend/resume cycle. Signed-off-by: Rafael J. Wysocki <[email protected]> Cc: Michael Buesch <[email protected]> Cc: Pavel Machek <[email protected]> Cc: "John W. Linville" <[email protected]> Cc: Alan Stern <[email protected]> Cc: Len Brown <[email protected]> Cc: Greg KH <[email protected]> Cc: Kay Sievers <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2007-12-31leds: Fix leds_list_lock locking issuesRichard Purdie1-4/+4
Covert leds_list_lock to a rw_sempahore to match previous LED trigger locking fixes, fixing lock ordering. Signed-off-by: Richard Purdie <[email protected]>
2007-12-07leds: Fix led trigger locking bugsRichard Purdie1-3/+3
Convert part of the led trigger core from rw spinlocks to rw semaphores. We're calling functions which can sleep from invalid contexts otherwise. Fixes bug #9264. Signed-off-by: Richard Purdie <[email protected]>
2007-07-16leds: Convert from struct class_device to struct deviceRichard Purdie1-27/+22
Convert the LEDs class from struct class_device to struct device since class_device is scheduled for removal. Signed-off-by: Richard Purdie <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]>
2006-10-17[PATCH] drivers/led: handle sysfs errorsJeff Garzik1-5/+21
Signed-off-by: Jeff Garzik <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-10-03kerneldoc-typo in led-class.cHenrik Kretzschmar1-1/+1
Fixes a typo in led-class.c kerneldoc. Signed-off-by: Henrik Kretzschmar <[email protected]> Signed-off-by: Adrian Bunk <[email protected]>
2006-06-30Remove obsolete #include <linux/config.h>Jörn Engel1-1/+0
Signed-off-by: Jörn Engel <[email protected]> Signed-off-by: Adrian Bunk <[email protected]>
2006-05-15[PATCH] LED: Fix sysfs store function error handlingRichard Purdie1-2/+7
Fix the error handling of some LED _store functions. This corrects them to return -EINVAL if the value is not numeric with an optional byte of trailing whitespace. Signed-off-by: Richard Purdie <[email protected]> Cc: Greg KH <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-03-31[PATCH] LED: add LED trigger tupportRichard Purdie1-0/+20
Add support for LED triggers to the LED subsystem. "Triggers" are events which change the state of an LED. Two kinds of trigger are available, simple ones which can be added to exising code with minimum disruption and complex ones for implementing new or more complex functionality. Signed-off-by: Richard Purdie <[email protected]> Cc: Russell King <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2006-03-31[PATCH] LED: add LED classRichard Purdie1-0/+147
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]> Cc: Russell King <[email protected]> Cc: Greg KH <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>