aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/led-triggers.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-11-03leds: remove PAGE_SIZE limit of /sys/class/leds/<led>/triggerAkinobu Mita1-22/+68
Reading /sys/class/leds/<led>/trigger returns all available LED triggers. However, the size of this file is limited to PAGE_SIZE because of the limitation for sysfs attribute. Enabling LED CPU trigger on systems with thousands of CPUs easily hits PAGE_SIZE limit, and makes it impossible to see all available LED triggers and which trigger is currently activated. We work around it here by converting /sys/class/leds/<led>/trigger to binary attribute, which is not limited by length. This is _not_ good design, do not copy it. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: "Rafael J. Wysocki" <rafael@kernel.org> Cc: Pavel Machek <pavel@ucw.cz> Cc: Dan Murphy <dmurphy@ti.com>A Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-09-05led: triggers: Fix dereferencing of null pointerOleh Kravchenko1-2/+2
Error was detected by PVS-Studio: V522 Dereferencing of the null pointer 'led_cdev->trigger' might take place. Fixes: 2282e125a406 ("leds: triggers: let struct led_trigger::activate() return an error code") Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2019-08-20led: triggers: Fix a memory leak bugWenwen Wang1-0/+1
In led_trigger_set(), 'event' is allocated in kasprintf(). However, it is not deallocated in the following execution if the label 'err_activate' or 'err_add_groups' is entered, leading to memory leaks. To fix this issue, free 'event' before returning the error. Fixes: 52c47742f79d ("leds: triggers: send uevent when changing triggers") Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2019-06-19treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500Thomas Gleixner1-5/+1
Based on 2 normalized pattern(s): 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 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 # extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 4122 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Enrico Weigelt <info@metux.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-10led: triggers: Initialize LED_INIT_DEFAULT_TRIGGER if trigger is brought after classKrzysztof Kozlowski1-1/+3
Trigger driver can be initialized after the LED class device driver. In such case led_trigger_set_default() won't be called and flag LED_INIT_DEFAULT_TRIGGER should be set from led_trigger_register(). Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2018-12-10led: triggers: Add LED_INIT_DEFAULT_TRIGGER flagJacek Anaszewski1-0/+1
Add the flag LED_INIT_DEFAULT_TRIGGER for indicating that trigger being set is a default trigger for the LED class device, and thus it should be initialized with settings provided in the fwnode. Set the flag in the led_trigger_set_default(). It is expected to be cleared in the activate() op of a trigger after trigger fwnode initialization data is parsed and applied. This should happen only once after LED class device registration, to allow leaving triggers in the idle state on re-apply and let the users apply their own settings without interference from the default ones. Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
2018-12-10led: triggers: Break the for loop after default trigger is foundJacek Anaszewski1-1/+3
It is of no avail to continue iterating through registered triggers in the led_trigger_set_default() after the trigger to set has been found. Add "break" statement to fix this omission. Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
2018-07-05leds: triggers: handle .trigger_data and .activated() in the coreUwe Kleine-König1-0/+3
This helps keeping these two fields consistent and drivers don't need to care for this themselves any more. Note that .activated isn't set to true automatically because that might confuse some triggers when deactivating (e.g. ledtrig-gpio). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2018-07-05leds: triggers: add device attribute supportUwe Kleine-König1-0/+12
As many triggers use device attributes, add support for these in led_trigger_set which allows simplifying the drivers accordingly. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2018-07-05leds: triggers: let struct led_trigger::activate() return an error codeUwe Kleine-König1-3/+21
Given that activating a trigger can fail, let the callback return an indication. This prevents to have a trigger active according to the "trigger" sysfs attribute but not functional. All users are changed accordingly to return 0 for now. There is no intended change in behaviour. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2016-09-20leds: triggers: Check return value of kobject_uevent_env()Jacek Anaszewski1-1/+3
Log error message if kobject_uevent_env() fails in led_trigger_set(). Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-20leds: triggers: Return from led_trigger_set() if there is nothing to doJacek Anaszewski1-0/+3
If led_trigger_set() is called with "trig" argument set to NULL, and there is no trigger to remove then the function should return immediately so as to avoid doing unnecessary allocation and sending uevent. Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> Reported-by: Daniel Romell <daro@hms.se> Acked-by Daniel Romell <daro@hms.se>
2016-08-16leds: do not overflow sysfs buffer in led_trigger_showNathan Sullivan1-5/+7
Per the documentation, use scnprintf instead of sprintf to ensure there is never more than PAGE_SIZE bytes of trigger names put into the buffer. Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com> Signed-off-by: Zach Brown <zach.brown@ni.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
2016-08-16leds: make triggers explicitly non-modularPaul Gortmaker1-5/+1
The Kconfig currently controlling compilation of this code is: drivers/leds/trigger/Kconfig:menuconfig LEDS_TRIGGERS drivers/leds/trigger/Kconfig: bool "LED Trigger support" ...meaning that it currently is not being built as a module by anyone. Lets remove the couple traces of modular infrastructure use, so that when reading the driver there is no doubt it is builtin-only. We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments. We don't replace module.h with init.h since the file doesn't need that. However it does use EXPORT_SYMBOL, so we add the export.h header. Cc: Richard Purdie <rpurdie@rpsys.net> Cc: linux-leds@vger.kernel.org Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
2016-07-04leds: triggers: return error if invalid trigger name is provided via sysfsHeiner Kallweit1-0/+2
If an invalid trigger name is provided via sysfs currently no error is returned. Therefore it's not possible to determine whether the trigger was set successfully. Fix this by returning -EINVAL if no trigger is matched. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
2016-05-06leds: triggers: Allow to switch the trigger to "panic" on a kernel panicEzequiel Garcia1-1/+1
This commit adds a new led_cdev flag LED_PANIC_INDICATOR, which allows to mark a specific LED to be switched to the "panic" trigger, on a kernel panic. This is useful to allow the user to assign a regular trigger to a given LED, and still blink that LED on a kernel panic. Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Reviewed-by: Matthias Brugger <mbrugger@suse.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
2016-03-14leds: triggers: simplify led_trigger_storeHeiner Kallweit1-11/+2
led_trigger_store can be significantly simplified by using sysfs_streq(). Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
2016-01-04leds: core: add managed version of led_trigger_registerHeiner Kallweit1-0/+28
Complementing devm_led_classdev_register add a managed version of led_trigger_register. I omit a managed version of led_classdev_unregister as the equivalent devm_led_classdev_unregister isn't used in the kernel as of today. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
2014-11-14leds: implement sysfs interface locking mechanismJacek Anaszewski1-3/+13
Add a mechanism for locking LED subsystem sysfs interface. This patch prepares ground for addition of LED Flash Class extension, whose API will be integrated with V4L2 Flash API. Such a fusion enforces introducing a locking scheme, which will secure consistent access to the LED Flash Class device. The mechanism being introduced allows for disabling LED subsystem sysfs interface by calling led_sysfs_disable function and enabling it by calling led_sysfs_enable. The functions alter the LED_SYSFS_DISABLE flag state and must be called under mutex lock. The state of the lock is checked with use of led_sysfs_is_disabled function. Such a design allows for providing immediate feedback to the user space on whether the LED Flash Class device is available or is under V4L2 Flash sub-device control. Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> Cc: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2014-04-07leds: make sure we unregister a trigger only onceSasha Levin1-1/+4
Currently, we may attempt to unregister a trigger more than once, for example when we receive two consecutive reboot notifications, or when we do a regular unregistration plus reboot notification. This leads to the following error since we try to delete the list node twice: [ 2780.254922] WARNING: CPU: 0 PID: 13764 at lib/list_debug.c:53 __list_del_entry+0x3e/0xe0() [ 2780.265559] list_del corruption, ffffffffa5eb6470->next is LIST_POISON1 (dead000000100100) [ 2780.271710] Modules linked in: [ 2780.274156] CPU: 0 PID: 13764 Comm: kworker/0:2 Tainted: G W 3.14.0-next-20140403-sasha-00012-gef5fa7d-dirty #373 [ 2780.283063] Workqueue: events do_poweroff [ 2780.285644] 0000000000000009 ffff8800330dbb38 ffffffffa34bfa33 0000000000002fe0 [ 2780.291571] ffff8800330dbb88 ffff8800330dbb78 ffffffffa015a37c ffff8800330dbb68 [ 2780.296670] ffffffffa5eb6470 0000000000000000 ffffffffa5eb6400 ffffffffa5ad7430 [ 2780.299756] Call Trace: [ 2780.301530] dump_stack (lib/dump_stack.c:52) [ 2780.303802] warn_slowpath_common (kernel/panic.c:418) [ 2780.306151] warn_slowpath_fmt (kernel/panic.c:433) [ 2780.308156] __list_del_entry (lib/list_debug.c:51 (discriminator 1)) [ 2780.310800] list_del (lib/list_debug.c:78) [ 2780.313175] led_trigger_unregister (drivers/leds/led-triggers.c:225) [ 2780.315599] heartbeat_reboot_notifier (drivers/leds/trigger/ledtrig-heartbeat.c:119) [ 2780.317247] notifier_call_chain (kernel/notifier.c:95) [ 2780.320014] __blocking_notifier_call_chain (kernel/notifier.c:316) [ 2780.323263] blocking_notifier_call_chain (kernel/notifier.c:326) [ 2780.326096] kernel_power_off (include/linux/kmod.h:95 kernel/reboot.c:153 kernel/reboot.c:179) [ 2780.327883] do_poweroff (kernel/power/poweroff.c:23) [ 2780.330748] process_one_work (kernel/workqueue.c:2221 include/linux/jump_label.h:105 include/trace/events/workqueue.h:111 kernel/workqueue.c:2226) [ 2780.333027] ? process_one_work (include/linux/workqueue.h:186 kernel/workqueue.c:611 kernel/workqueue.c:638 kernel/workqueue.c:2214) [ 2780.335487] process_scheduled_works (include/linux/list.h:188 kernel/workqueue.c:2277) [ 2780.337101] worker_thread (kernel/workqueue.c:2352) [ 2780.338712] ? rescuer_thread (kernel/workqueue.c:2297) [ 2780.341326] kthread (kernel/kthread.c:219) [ 2780.343446] ? kthread_create_on_node (kernel/kthread.c:185) [ 2780.345733] ret_from_fork (arch/x86/kernel/entry_64.S:555) [ 2780.347168] ? kthread_create_on_node (kernel/kthread.c:185) Prevent it by making sure we don't attempt to unregister a trigger that is not in the triggers list. Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2014-02-27drivers/leds: delete non-required instances of include <linux/init.h>Paul Gortmaker1-1/+0
None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next. Cc: Bryan Wu <cooloney@gmail.com> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: linux-leds@vger.kernel.org Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2014-01-27leds: replace list_for_each with list_for_each_entryZHAO Gang1-11/+4
Use the more convenient macro. Signed-off-by: ZHAO Gang <gamerh2o@gmail.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2012-11-27leds: led-triggers: Fix checkpatch warningsSachin Kamat1-6/+6
Fixes the following type of warnings: WARNING: Prefer netdev_warn(netdev, ... then dev_warn(dev, ... then pr_warn(... to printk(KERN_WARNING ... WARNING: quoted string split across lines While at it also fix a coding style issue w.r.t braces. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2012-11-26leds: add led_trigger_rename functionFabio Baltieri1-0/+13
Implements a "led_trigger_rename" function to rename a trigger with proper locking. This assumes that led name was originally allocated in non-constant storage. Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com> Cc: Kurt Van Dijck <kurt.van.dijck@eia.be> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2012-09-11leds: triggers: send uevent when changing triggersColin Cross1-0/+13
Some triggers create sysfs files when they are enabled. Send a uevent "change" notification whenever the trigger is changed to allow userspace processes such as udev to modify permissions on the new files. A change notification will also be sent during registration of led class devices or led triggers if the default trigger of an led class device is found. (bryan.wu@canonical.com: rename trigger to trig to fix the build error) Signed-off-by: Colin Cross <ccross@android.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
2012-09-11leds: delay led_set_brightness if stopping soft-blinkFabio Baltieri1-1/+3
Delay execution of led_set_brightness() if need to stop soft-blink timer. This allows led_set_brightness to be called in hard-irq context even if soft-blink was activated on that LED. Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com> Cc: Pawel Moll <pawel.moll@arm.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
2012-08-13Revert "leds: use led_set_brightness in led_trigger_event"Fabio Baltieri1-1/+1
This reverts commit a0193cbee0809d65362a0767b2d50306b145b2f5. The problem with the original commit was that it caused a warning with the MMC trigger calling del_timer_sync from hard-irq context. Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com> Reported-by: Pawel Moll <pawel.moll@arm.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
2012-07-24leds: fix sparse warnings due to missing staticBryan Wu1-1/+1
drivers/leds/led-core.c:56:6: sparse: symbol 'led_blink_setup' was not declared. Should it be static? drivers/leds/led-triggers.c:233:6: sparse: symbol 'led_trigger_blink_setup' was not declared. Should it be static? Reported-by: Fengguang Wu <wfg@linux.intel.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
2012-07-24leds: use led_set_brightness in led_trigger_eventFabio Baltieri1-1/+1
Fix led_trigger_event() to use led_set_brightness() instead of __led_set_brightness(), so that any pending blink timer is stopped before setting the new brightness value. Without this fix LED status may be overridden by a pending timer. This allows a trigger to use a mix of led_trigger_event(), led_trigger_blink() and led_trigger_blink_oneshot() without races. (applied over: leds: Rename led_brightness_set() to led_set_brightness()) Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com> Cc: Shuah Khan <shuahkhan@gmail.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
2012-07-24leds: Rename led_brightness_set() to led_set_brightness()Shuah Khan1-1/+1
Rename leds external interface led_brightness_set() to led_set_brightness(). This is the second phase of the change to reduce confusion between the leds internal and external interfaces that set brightness. With this change, now the external interface is led_set_brightness(). The first phase renamed the internal interface led_set_brightness() to __led_set_brightness(). There are no changes to the interface implementations. Signed-off-by: Shuah Khan <shuahkhan@gmail.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
2012-07-24leds: Rename led_set_brightness() to __led_set_brightness()Shuah Khan1-1/+1
Rename leds internal interface led_set_brightness() to __led_set_brightness() to reduce confusion between led_set_brightness() and the external interface led_brightness_set(). led_brightness_set() cancels the timer and then calls led_set_brightness(). Signed-off-by: Shuah Khan <shuahkhan@gmail.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
2012-07-24leds: add oneshot blink functionsFabio Baltieri1-4/+26
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. (bryan.wu@canonical.com: rebase to commit 'leds: don't disable blinking when writing the same value to delay_on or delay_off') Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com> Acked-by: Shuah Khan <shuahkhan@gmail.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
2012-07-24led-triggers: rename *trigger to *trig for unified naming schemeBryan Wu1-42/+42
No functional change. Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
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 <jdzheng@broadcom.com> Cc: Scott Branden <sbranden@broadcom.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Kukjin Kim <kgene.kim@samsung.com> Cc: David Brown <davidb@codeaurora.org> Cc: Daniel Walker <dwalker@fifo99.com> Cc: Bryan Huntsman <bryanh@codeaurora.org> Cc: Ben Dooks <ben-linux@fluff.org> Cc: Wan ZongShun <mcuos.com@gmail.com> Cc: Haavard Skinnemoen <hskinnemoen@gmail.com> Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn> Cc: "Venkatesh Pallipadi Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Matthew Garrett <mjg@redhat.com> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
2011-10-31drivers/leds/led-triggers.c: fix memory leakMasakazu Mokuno1-1/+4
The memory for struct led_trigger should be kfreed in the led_trigger_register() error path. Also this function should return NULL on error. Signed-off-by: Masakazu Mokuno <mokuno@sm.sony.co.jp> Cc: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-01-31leds: Add ability to blink via simple triggerVasily Khoruzhick1-0/+20
As blink API is now available, it's possible to add ability to blink via simple trigger. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
2010-11-12led-class: always implement blinkingJohannes Berg1-1/+1
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 <johannes.berg@intel.com> Acked-by: Richard Purdie <rpurdie@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-03-30include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.hTejun Heo1-0/+1
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2009-04-06leds: Prevent multiple LED triggers with the same nameAdam Nielsen1-1/+9
Signed-off-by: Adam Nielsen <a.nielsen@shikadi.net> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2008-07-23leds: Ensure led->trigger is set earlierDmitry Baryshkov1-1/+2
Make sure led->trigger is valid before calling trigger->activate Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
2008-04-24leds: Cleanup various whitespace and code style issuesNémeth Márton1-55/+55
Break the lines which were more than 80 characters into more lines; replace SPACEs with TABs; correct ident at switch-case; change character encoding from ISO-8859-2 to UTF-8. The order of the functions in led-triggers.c changed in order the similar functions can still be together under titles "Used by LED Class", "LED Trigger Interface" and "Simple LED Tigger Interface" as was grouped before when exported with EXPORT_SYMBOL. Signed-off-by: Márton Németh <nm127@freemail.hu> Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
2008-04-24leds: disable triggers on brightness setNémeth Márton1-3/+9
Disable any active triggers when the brightness attribute is set to zero. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Signed-off-by: Márton Németh <nm127@freemail.hu> Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
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 <rpurdie@rpsys.net>
2007-12-07leds: Fix led trigger locking bugsRichard Purdie1-24/+25
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 <rpurdie@rpsys.net>
2007-07-16leds: Convert from struct class_device to struct deviceRichard Purdie1-6/+7
Convert the LEDs class from struct class_device to struct device since class_device is scheduled for removal. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
2007-07-16leds: Add warning printks in error pathsRichard Purdie1-2/+9
Add warning printks if led_trigger_register_simple() fails. Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
2007-07-16leds: Fix trigger unregister_simple if register_simple failsRichard Purdie1-1/+2
Fix led_trigger_unregister_simple to handle the case where led_trigger_register_simple fails, avoiding a NULL pointer dereference. Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
2006-10-01[PATCH] leds: turn LED off when changing triggersPaul Collins1-0/+1
I was playing with LED triggers when I noticed that changing from heartbeat (or ide-disk) to "none" at the right moment would leave the LED stuck on. This is easy to reproduce by doing "find / >/dev/null" with the ide-disk trigger enabled and then switching to "none". Here is a patch that fixes the problem by explicitly turning the LED off after removing the existing trigger. Signed-off-by: Paul Collins <paul@ondioline.org> Acked-by: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-30Remove obsolete #include <linux/config.h>Jörn Engel1-1/+0
Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de> Signed-off-by: Adrian Bunk <bunk@stusta.de>
2006-06-27[PATCH] spin/rwlock init cleanupsIngo Molnar1-1/+1
locking init cleanups: - convert " = SPIN_LOCK_UNLOCKED" to spin_lock_init() or DEFINE_SPINLOCK() - convert rwlocks in a similar manner this patch was generated automatically. Motivation: - cleanliness - lockdep needs control of lock initialization, which the open-coded variants do not give - it's also useful for -rt and for lock debugging in general Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>