aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-pwm.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-09-01leds: pwm: Use struct_size() helperGustavo A. R. Silva1-7/+1
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct led_pwm_priv { ... struct led_pwm_data leds[0]; }; Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. So, replace the following function: static inline size_t sizeof_pwm_leds_priv(int num_leds) { return sizeof(struct led_pwm_priv) + (sizeof(struct led_pwm_data) * num_leds); } with: struct_size(priv, leds, count) This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2019-07-25leds: class: Improve LED and LED flash class registration APIJacek Anaszewski1-2/+1
Replace of_led_classdev_register() with led_classdev_register_ext(), which accepts easily extendable struct led_init_data, instead of the fixed struct device_node argument. The latter can be now passed in an fwnode property of the struct led_init_data. The modification is driven by the need for passing additional arguments required for the forthcoming generic mechanism for composing LED names. Currently the LED name is conveyed in the "name" char pointer property of the struct led_classdev. This is redundant since LED class device name is accessible throughout the whole LED class device life time via associated struct device's kobj->name property. The change will not break any existing clients since the patch alters also existing led_classdev{_flash}_register() macro wrappers, that pass NULL in place of init_data, which leads to using legacy name initialization path basing on the struct led_classdev's "name" property. Three existing users of devm_of_led_classdev_registers() are modified to use devm_led_classdev_register(), which will not impact their operation since they in fact didn't need to pass struct device_node on registration from the beginning. Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> Cc: Baolin Wang <baolin.wang@linaro.org> Cc: Dan Murphy <dmurphy@ti.com> Cc: Daniel Mack <daniel@zonque.org> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Oleh Kravchenko <oleg@kaa.org.ua> Cc: Sakari Ailus <sakari.ailus@linux.intel.com> Cc: Simon Shields <simon@lineageos.org> Acked-by: Pavel Machek <pavel@ucw.cz>
2019-07-09Merge tag 'pwm/for-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwmLinus Torvalds1-18/+27
Pull pwm updates from Thierry Reding: "This set of changes contains a new driver for SiFive SoCs as well as enhancements to the core (device links are used to track dependencies between PWM providers and consumers, support for PWM controllers via ACPI, sysfs will now suspend/resume PWMs that it has claimed) and various existing drivers" * tag 'pwm/for-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (37 commits) pwm: fsl-ftm: Make sure to unlock mutex on failure pwm: fsl-ftm: Use write protection for prescaler & polarity pwm: fsl-ftm: More relaxed permissions for updating period pwm: atmel-hlcdc: Add compatible for SAM9X60 HLCDC's PWM pwm: bcm2835: Improve precision of PWM leds: pwm: Support ACPI via firmware-node framework pwm: Add support referencing PWMs from ACPI pwm: rcar: Remove suspend/resume support pwm: sysfs: Add suspend/resume support pwm: Add power management descriptions pwm: meson: Add documentation to the driver pwm: meson: Add support PWM_POLARITY_INVERSED when disabling pwm: meson: Don't cache struct pwm_state internally pwm: meson: Read the full hardware state in meson_pwm_get_state() pwm: meson: Simplify the calculation of the pre-divider and count pwm: meson: Move pwm_set_chip_data() to meson_pwm_request() pwm: meson: Add the per-channel register offsets and bits in a struct pwm: meson: Add the meson_pwm_channel data to struct meson_pwm pwm: meson: Pass struct pwm_device to meson_pwm_calc() pwm: meson: Don't duplicate the polarity internally ...
2019-06-26leds: pwm: Support ACPI via firmware-node frameworkNikolaus Voss1-18/+27
DT specific handling is replaced by firmware-node abstration to support ACPI specification of PWM LEDS. Example ASL: Device (PWML) { Name (_HID, "PRP0001") Name (_DSD, Package () { ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package () { Package () {"compatible", Package () {"pwm-leds"}}}}) Device (PWL0) { Name (_HID, "PRP0001") Name (_DSD, Package () { ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package () { Package () {"label", "alarm-led"}, Package () {"pwms", Package () {\_SB_.PCI0.PWM, 0, 600000, 0}}, Package () {"linux,default-state", "off"}}}) } } Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2019-06-19treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500Thomas Gleixner1-4/+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-08leds: pwm: Use OF variant of LED registering functionKrzysztof Kozlowski1-1/+1
The PWM leds can be instantiated from Device Tree so pass the respective device node to LED core. This provides the LED system with proper device node and exposes it through uevent. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2018-12-08leds: pwm: Simplify with resource-managed devm_led_classdev_register()Krzysztof Kozlowski1-20/+2
Simplify the exit path with resource-managed version of registering LED class device. The code should be functionally the same, except that on device removal the led_pwm_priv->num_leds is not decremented to zero (which should not have any effect as device is going away). Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2018-09-08leds: pwm: silently error out on EPROBE_DEFERJerome Brunet1-2/+3
When probing, if we fail to get the pwm due to probe deferal, we shouldn't print an error message. Just be silent in this case. Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2018-01-08leds: pwm: Remove unneeded header fileFabio Estevam1-1/+0
There is nothing provided by <linux/fb.h> that is used here, so remove this unneeded header file. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2017-01-04leds: pwm: Remove atomic code pathsThierry Reding1-13/+3
PWM devices have all been marked as "might sleep" since v4.5. It no longer makes sense to keep the alternative code paths around because it is effectively dead code. Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2016-05-17leds: pwm: Use pwm_get_args() where appropriateBoris Brezillon1-1/+10
The PWM framework has clarified the concept of reference PWM config (the platform dependent config retrieved from the DT or the PWM lookup table) and real PWM state. Use pwm_get_args() when the PWM user wants to retrieve this reference config and not the current state. This is part of the rework allowing the PWM framework to support hardware readout and expose real PWM state even when the PWM has just been requested (before the user calls pwm_config/enable/disable()). Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2016-01-04leds: pwm: fix driver description and make license match the headerUwe Kleine-König1-2/+2
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
2016-01-04leds: call led_pwm_set() in leds-pwm to enforce default LED_OFFMarkus Hofstaetter1-0/+1
Some PWMs are disabled by default or the default pin setting does not match the LED_OFF state (e.g., active-low leds). Hence, the driver may end up reporting 0 brightness, but the leds are actually on using full brightness, because it never enforces its default configuration. So enforce it by calling led_pwm_set() after successfully registering the device. Tested on a Phytec phyFLEX i.MX6Q board based on kernel v3.19.5. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at> Tested-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
2016-01-04leds: pwm: remove work queueJacek Anaszewski1-21/+13
Now the core implements the work queue, remove it from the drivers, and switch to using brightness_set_blocking op. Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> Cc: Raphael Assenat <raph@8d.com>
2015-02-24leds: leds-pwm: drop one pwm_get_period() callSebastian Andrzej Siewior1-3/+0
pwm_get_period() is called twice in case the child parameter is set. I assume retrieving this parameter once is enough therefore this patch removes the conditial invocation of pwm_get_period(). Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2014-10-20leds: drop owner assignment from platform_driversWolfram Sang1-1/+0
A platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2014-06-12Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-ledsLinus Torvalds1-77/+73
Pull LED updates from Bryan Wu: "I just found merge window is open and I'm quite busy and almost forget to send out this pull request. Thanks Russell and Alexandre ping me about this. So basically we got some clean up and leds-pwm fixing patches from Russell" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: leds: Remove duplicated OOM message for individual driver drivers/leds: Replace __get_cpu_var use through this_cpu_ptr leds: lp55xx: add DT bindings for LP55231 leds: 88pm860x: Fix missing refcount decrement for parent of_node leds: 88pm860x: Use of_get_child_by_name leds: leds-pwm: add DT support for LEDs wired to supply leds: leds-pwm: implement PWM inversion leds: leds-pwm: convert OF parsing code to use led_pwm_add() leds: leds-pwm: provide a common function to setup a single led-pwm device leds: pca9685: Remove leds-pca9685 driver dell-led: add mic mute led interface
2014-05-21leds: leds-pwm: retrieve configured PWM periodAlexandre Belloni1-1/+4
The PWM core is now able to initialize the PWM period from a lookup table defined by board files. Use it if available and fallback to the value supplied in pwm_period_ns. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2014-05-08leds: leds-pwm: add DT support for LEDs wired to supplyRussell King1-0/+1
The non-DT driver allowed an active low property to be specified, but DT is missing this in its description. Add the property to the DT binding document, making it optional. It defaults to active high, which retains compatibility with existing descriptions. This should only be used for causes where the LED is wired to supply, and the PWM does not sensibly support its own inversion. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2014-05-08leds: leds-pwm: implement PWM inversionRussell King1-0/+4
Some PWM outputs are wired such that the LED they're controlling is connected to supply rather than ground. These PWMs may not support output inversion, or when they do, disabling the PWM may set the PWM output low, causing a "brightness" value of zero to turn the LED fully on. The platform data for this driver already indicates that this was thought about, and we have the "active_low" property there already. However, the implementation for this is missing. Add the trivial implementation for this feature. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Acked-by: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2014-05-08leds: leds-pwm: convert OF parsing code to use led_pwm_add()Russell King1-39/+23
Convert the OF parsing code to use the common PWM LED registration code, which means we have a consistent method, and single point where the registration happens for both paths. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2014-05-08leds: leds-pwm: provide a common function to setup a single led-pwm deviceRussell King1-39/+46
Provide a common function to setup a single led-pwm device, replacing the platform data initialisation path with this function. This allows us to have a common method of creating these devices in a consistent manner, which then allows us to place the probe failure cleanup in one place. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2014-04-07leds: leds-pwm: properly clean up after probe failureRussell King1-10/+13
When probing with DT, we add each LED one at a time. If we find a LED without a PWM device (because it is not available yet) we fail the initialisation, unregister previous LEDs, and then by way of managed resources, we free the structure. The problem with this is we may have a scheduled and active work_struct in this structure, and this results in a nasty kernel oops. We need to cancel this work_struct properly upon cleanup - and the cleanup we require is the same cleanup as we do when the LED platform device is removed. Rather than writing this same code three times, move it into a separate function and use it in all three places. Fixes: c971ff185f64 ("leds: leds-pwm: Defer led_pwm_set() if PWM can sleep") Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> 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: pwm: Remove a warning on non-DT platformsOlof Johansson1-2/+1
This removes a warning on non-DT-enabled platforms: drivers/leds/leds-pwm.c: In function 'led_pwm_create_of': drivers/leds/leds-pwm.c:88:22: warning: unused variable 'node' Really caused by the local variable that is assigned to and then never used. Just do away with the local var, it's not needed. Technically this code path can never be entered without DT enabled, since there's an earlier check about number of children in the calling function, but the compiler can't see that. Signed-off-by: Olof Johansson <olof@lixom.net> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2014-01-27leds: leds-pwm: fix duty time overflow.Xiubo Li1-2/+4
Overflow maybe occurs when calculates the duty time. For instance, the period time is 990000000ns, and the max_brightness is 127, when setting the brightness to 12, the duty value will be 25906026ns, but it should be 93543307ns. Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-12-02leds: pwm: Fix for deferred probe in DT booted modePeter Ujfalusi1-27/+26
We need to make sure that the error code from devm_of_pwm_get() is the one the module returns in case of failure. Restructure the code to make this possible for DT booted case. With this patch the driver can ask for deferred probing when the board is booted with DT. Fixes for example omap4-sdp board's keyboard backlight led. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-10-22leds: pwm: Remove redundant of_match_ptrSachin Kamat1-1/+1
The data structure of_match_ptr() protects is always compiled in. Hence of_match_ptr() is not needed. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-08-26leds: use dev_get_platdata()Jingoo Han1-1/+1
Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-04-01leds: leds-pwm: Defer led_pwm_set() if PWM can sleepFlorian Vaussard1-8/+42
Call to led_pwm_set() can happen inside atomic context, like triggers. If the PWM call can sleep, defer using a worker. Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch> Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Acked-by: Thierry Reding <thierry.reding@avionic-design.de> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-01leds: leds-pwm: Add device tree bindingsPeter Ujfalusi1-20/+92
The DT binding for the pwm-leds devices are similar to the gpio-leds type. LEDs are represented as sub-nodes of the pwm-leds device. The code for handling the DT boot is based on the code found in the leds-gpio driver and adapted to use PWMs instead of GPIOs. To avoid having custom cleanup code in case of DT boot the newly created devm_of_pwm_get() API is used to get the correct PWM instance. For usage see: Documentation/devicetree/bindings/leds/leds-pwm.txt Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Acked-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-01leds: leds-pwm: Simplify cleanup codePeter Ujfalusi1-4/+2
The code looks more nicer if we use: while (i--) instead: if (i > 0) for (i = i - 1; i >= 0; i--) Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-01leds: leds-pwm: Preparing the driver for device tree supportPeter Ujfalusi1-16/+23
In order to be able to add device tree support for leds-pwm driver we need to rearrange the data structures used by the drivers. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2013-02-01leds: leds-pwm: Convert to use devm_get_pwmPeter Ujfalusi1-13/+6
Update the driver to use the new API for requesting pwm so we can take advantage of the pwm_lookup table to find the correct pwm to be used for the LED functionality. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2012-12-15Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-ledsLinus Torvalds1-1/+1
Pull LED subsystem update from Bryan Wu. * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: (47 commits) leds: leds-lp5521: return an error code on error in probe() leds: leds-clevo-mail: Use pr_* instead of printks leds: leds-rb532: Fix checkpatch errors leds: led-triggers: Fix checkpatch warnings leds: ledtrig-backlight: Fix checkpatch error leds: leds-wrap: Use <linux/io.h> instead of <asm/io.h> leds: leds-wm8350: Use dev_err instead of printk leds: leds-pwm: Fix checkpatch warning leds: leds-pca955x: Use dev_info instead of printk leds: leds-net48xx: Use linux/io.h instead of asm/io.h leds: leds-lt3593: Fix checkpatch warnings leds: leds-gpio: Use dev_info instead of printk leds: leds-da903x: Fix checkpatch error and warnings leds: leds-bd2802: Fix checkpatch warnings leds: leds-adp5520: Fix checkpatch warnings leds: led-class: Fix checkpatch warning leds: leds-ns2: use devm_gpio_request_one leds: leds-lt3593: use devm_gpio_request_one leds: leds-gpio: use devm_gpio_request_one leds: lp3944: Fix return value ...
2012-11-28leds: remove use of __devexitBill Pemberton1-1/+1
CONFIG_HOTPLUG is going away as an option so __devexit is no longer needed. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Jan-Simon Moeller <jansimon.moeller@gmx.de> Acked-by: Bryan Wu <cooloney@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-28leds: remove use of __devexit_pBill Pemberton1-1/+1
CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer needed. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Jan-Simon Moeller <jansimon.moeller@gmx.de> Acked-by: Bryan Wu <cooloney@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-27leds: leds-pwm: Fix checkpatch warningSachin Kamat1-1/+1
Fixes the following checkpatch warning: WARNING: please, no space before tabs FILE: leds/leds-pwm.c:29: ^Iunsigned int ^I^Iactive_low;$ Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Bryan Wu <cooloney@gmail.com>
2012-07-24leds: Use devm_kzalloc in leds-pwm.c fileSachin Kamat1-5/+2
devm_kzalloc() makes cleanup simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
2012-01-10leds: convert led platform drivers to module_platform_driverAxel Lin1-12/+1
Factor out some boilerplate code for platform driver registration into module_platform_driver. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Haojian Zhuang <hzhuang1@marvell.com> [led-88pm860x.c] Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Michael Hennerich <hennerich@blackfin.uclinux.org> Cc: Mike Rapoport <mike@compulab.co.il> Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-01-26leds: leds-pwm: return proper error if pwm_request failedAxel Lin1-0/+1
Return PTR_ERR(led_dat->pwm) instead of 0 if pwm_request failed Signed-off-by: Axel Lin <axel.lin@gmail.com> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Luotao Fu <l.fu@pengutronix.de> Cc: Reviewed-by: Dmitry Torokhov <dtor@mail.ru> 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-12-17leds: leds-pwm: Set led_classdev max_brightnessLars-Peter Clausen1-3/+2
Currently the driver leds-pwm doesn't set max_brightness for the led device although it's platform data proides a maximum brightness. Instead it stores its own private driver struct. The max_brightness defaults to 255 for led device if it has not been set. As a result any leds-pwm device with a different maximum brightness will show incorrect behavior, as it is posible to either set a longer then period duty time or not be able to switch the led to full brightness. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2009-04-06leds: simple driver for pwm driven LEDsLuotao Fu1-0/+153
Add a simple driver for pwm driver LEDs. pwm_id and period can be defined in board file. It is developed for pxa, however it is probably generic enough to be used on other platforms with pwm. Signed-off-by: Luotao Fu <l.fu@pengutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>