summaryrefslogtreecommitdiff
path: root/drivers/leds
AgeCommit message (Collapse)AuthorFilesLines
2020-01-07leds: lm3692x: Disable chip on brightness 0Guido Günther1-1/+17
Otherwise there's a noticeable glow even with brightness 0. Also turning off the regulator can save additional power. Signed-off-by: Guido Günther <agx@sigxcpu.org> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-07leds: lm3692x: Split out lm3692x_leds_disableGuido Günther1-16/+26
Move the relevant parts out of lm3692x_remove() and call it from there. No functional change. Signed-off-by: Guido Günther <agx@sigxcpu.org> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-07leds: lm3692x: Move lm3692x_init and rename to lm3692x_leds_enableGuido Günther1-35/+35
This moves lm3692x_init so it can be used from lm3692x_brightness_set. Rename to lm3692_leds_enable to pair up with lm3692x_leds_disable. No functional change. Signed-off-by: Guido Günther <agx@sigxcpu.org> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-07leds: lm3692x: Make sure we don't exceed the maximum LED currentGuido Günther1-1/+19
The current is given by the formular from page 12 of https://www.ti.com/lit/ds/symlink/lm36922.pdf. We use this to limit the led's max_brightness using the led-max-microamp DT property. The formula for the lm36923 is identical according to the data sheet. Signed-off-by: Guido Günther <agx@sigxcpu.org> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-06leds: lm3692x: Allow to configure over voltage protectionGuido Günther1-4/+30
Overvoltage protection is currently using the default of 29V. Make it configurable via DT. Signed-off-by: Guido Günther <agx@sigxcpu.org> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-06leds: populate the device's of_nodeJean-Jacques Hiblot1-1/+3
If initialization data is available and its fwnode is actually a of_node, store this information in the led device's structure. This will allow the device to use or provide OF-based API such (devm_xxx). Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-06leds: Add managed API to get a LED from a device driverJean-Jacques Hiblot1-0/+49
If the LED is acquired by a consumer device with devm_led_get(), it is automatically released when the device is detached. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-06leds: Add of_led_get() and led_put()Tomi Valkeinen1-0/+44
This patch adds basic support for a kernel driver to get a LED device. This will be used by the led-backlight driver. Only OF version is implemented for now, and the behavior is similar to PWM's of_pwm_get() and pwm_put(). Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-06leds: lm3532: add pointer to documentation and fix typoPavel1-1/+2
Add pointer to datasheet and fix typo in printk message. Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-04leds: lm3532: use extended registration so that LED can be used for backlightPavel1-1/+7
Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-03leds: lm3642: remove warnings for bad strtol, cleanup gotosPavel Machek1-23/+14
Bad string from userspace is not worth printing warning on; gotos that just directly return are not good, plus a comment fix. Cc: jacek.anaszewski@gmail.com, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, dmurphy@ti.com Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-03leds: rb532: cleanup whitespacePavel Machek1-1/+0
Trivial cleanup removing empty line at wrong place. Signed-off-by: Pavel Machek <pavel@ucw.cz>
2020-01-03ledtrig-pattern: fix email address quoting in MODULE_AUTHOR()Pavel Machek1-2/+2
Apparently it is quite easy to forget ">" in quoting of email address. This fixes it. Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-12-21leds: tps6105x: add driver for MFD chip LED modeSven Van Asbroeck3-0/+100
This driver adds support for the LED operational mode of the tps6105x MFD device. Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-12-21led: max77650: add of_match tableBartosz Golaszewski1-0/+7
We need the of_match table if we want to use the compatible string in the pmic's child node and get the led driver loaded automatically. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-12-21leds: bd2802: Convert to use GPIO descriptorsLinus Walleij1-9/+18
The Rohm BD2802 have no in-kernel users so we can drop the GPIO number from the platform data and require users to provide the GPIO line using machine descriptors. As the descriptors come with inherent polarity inversion semantics, we invert the calls to set the GPIO line such that 0 means "unasserted" and 1 means "asserted". Put a note in the driver that machine descriptor tables will need to specify that the line is active low. Cc: Kim Kyuwon <chammoru@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-12-21leds: pca963x: Fix open-drain initializationZahari Petkov1-3/+5
Before commit bb29b9cccd95 ("leds: pca963x: Add bindings to invert polarity") Mode register 2 was initialized directly with either 0x01 or 0x05 for open-drain or totem pole (push-pull) configuration. Afterwards, MODE2 initialization started using bitwise operations on top of the default MODE2 register value (0x05). Using bitwise OR for setting OUTDRV with 0x01 and 0x05 does not produce correct results. When open-drain is used, instead of setting OUTDRV to 0, the driver keeps it as 1: Open-drain: 0x05 | 0x01 -> 0x05 (0b101 - incorrect) Totem pole: 0x05 | 0x05 -> 0x05 (0b101 - correct but still wrong) Now OUTDRV setting uses correct bitwise operations for initialization: Open-drain: 0x05 & ~0x04 -> 0x01 (0b001 - correct) Totem pole: 0x05 | 0x04 -> 0x05 (0b101 - correct) Additional MODE2 register definitions are introduced now as well. Fixes: bb29b9cccd95 ("leds: pca963x: Add bindings to invert polarity") Signed-off-by: Zahari Petkov <zahari@balena.io> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-12-21leds-as3645a: Drop fwnode reference on ignored nodeSakari Ailus1-1/+2
If a node is ignored, do not get a reference to it. Fix the bug by moving fwnode_handle_get() where a reference to an fwnode is saved for clarity. Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-12-21leds: gpio: Fix uninitialized gpio label for fwnode based probeJacek Anaszewski1-1/+9
When switching to using generic LED name composition mechanism via devm_led_classdev_register_ext() API the part of code initializing struct gpio_led's template name property was removed alongside. It was however overlooked that the property was also passed to devm_fwnode_get_gpiod_from_child() in place of "label" parameter, which when set to NULL, results in gpio label being initialized to '?'. It could be observed in debugfs and failed to properly identify gpio association with LED consumer. Fix this shortcoming by updating the GPIO label after the LED is registered and its final name is known. Fixes: d7235f5feaa0 ("leds: gpio: Use generic support for composing LED names") Cc: Russell King <linux@armlinux.org.uk> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> [fixed comment] Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-12-02Merge tag 'leds-5.5-rc1' of ↵Linus Torvalds16-138/+578
git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds Pull LED updates from Pavel Machek: "This contains usual small updates to drivers, and removal of PAGE_SIZE limits on /sys/class/leds/<led>/trigger. We should not be really having that many triggers; but with cpu activity triggers we do, and we'll eventually need to fix it, but... remove the limit for now" * tag 'leds-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds: (26 commits) leds: trigger: netdev: fix handling on interface rename leds: an30259a: add a check for devm_regmap_init_i2c leds: mlxreg: Fix possible buffer overflow leds: pca953x: Use of_device_get_match_data() leds: core: Fix leds.h structure documentation leds: core: Fix devm_classdev_match to reference correct structure leds: core: Remove extern from header leds: lm3601x: Convert class registration to device managed leds: flash: Add devm_* functions to the flash class leds: flash: Remove extern from the header file leds: flash: Convert non extended registration to inline leds: Kconfig: Be consistent with the usage of "LED" leds: remove PAGE_SIZE limit of /sys/class/leds/<led>/trigger leds: tlc591xx: update the maximum brightness leds: lm3692x: Use flags from LM3692X_BRT_CTRL leds: lm3692x: Use flags from LM3692X_BOOST_CTRL leds: lm3692x: Handle failure to probe the regulator leds: lm3692x: Don't overwrite return value in error path leds: lm3692x: Print error value on dev_err leds: tlc591xx: use devm_led_classdev_register_ext() ...
2019-11-21leds: Use all-in-one vtime aware kcpustat accessorFrederic Weisbecker1-5/+9
We can now safely read user kcpustat fields on nohz_full CPUs. Use the appropriate accessor. [ mingo: Fixed build failure. ] Reported-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com> (maintainer:LED SUBSYSTEM) Cc: Pavel Machek <pavel@ucw.cz> (maintainer:LED SUBSYSTEM) Cc: Dan Murphy <dmurphy@ti.com> (reviewer:LED SUBSYSTEM) Cc: Peter Zijlstra <peterz@infradead.org> Cc: Wanpeng Li <wanpengli@tencent.com> Link: https://lkml.kernel.org/r/20191121024430.19938-6-frederic@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
2019-11-03leds: trigger: netdev: fix handling on interface renameMartin Schiller1-1/+4
The NETDEV_CHANGENAME code is not "unneeded" like it is stated in commit 4cb6560514fa ("leds: trigger: netdev: fix refcnt leak on interface rename"). The event was accidentally misinterpreted equivalent to NETDEV_UNREGISTER, but should be equivalent to NETDEV_REGISTER. This was the case in the original code from the openwrt project. Otherwise, you are unable to set netdev led triggers for (non-existent) netdevices, which has to be renamed. This is the case, for example, for ppp interfaces in openwrt. Fixes: 06f502f57d0d ("leds: trigger: Introduce a NETDEV trigger") Fixes: 4cb6560514fa ("leds: trigger: netdev: fix refcnt leak on interface rename") Signed-off-by: Martin Schiller <ms@dev.tdt.de> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: an30259a: add a check for devm_regmap_init_i2cChuhong Yuan1-0/+7
an30259a_probe misses a check for devm_regmap_init_i2c and may cause problems. Add a check and print errors like other leds drivers. Signed-off-by: Chuhong Yuan <hslester96@gmail.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: mlxreg: Fix possible buffer overflowOleh Kravchenko1-2/+2
Error was detected by PVS-Studio: V512 A call of the 'sprintf' function will lead to overflow of the buffer 'led_data->led_cdev_name'. Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: pca953x: Use of_device_get_match_data()Stephen Boyd1-12/+2
This driver can use the of_device_get_match_data() API to simplify the code. Replace calls to of_match_device() with this newer API under the assumption that where it is called will be when we know the device is backed by a DT node. This nicely avoids referencing the match table when it is undefined with configurations where CONFIG_OF=n. Cc: Arnd Bergmann <arnd@arndb.de> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Riku Voipio <riku.voipio@iki.fi> Cc: Rob Herring <robh+dt@kernel.org> Cc: Frank Rowand <frowand.list@gmail.com> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com> Cc: Pavel Machek <pavel@ucw.cz> Cc: Dan Murphy <dmurphy@ti.com> Cc: <linux-leds@vger.kernel.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: core: Fix devm_classdev_match to reference correct structureDan Murphy1-1/+1
Fix the devm_classdev_match pointer initialization to the correct structure type. Signed-off-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: lm3601x: Convert class registration to device managedDan Murphy1-3/+1
Convert LED flash class registration to device managed class registration API. Signed-off-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: flash: Add devm_* functions to the flash classDan Murphy1-0/+50
Add the missing device managed API for registration and unregistration for the LED flash class. Signed-off-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: Kconfig: Be consistent with the usage of "LED"Dan Murphy1-2/+2
Update the Kconfig to be consistent in the case of using "LED" in the Kconfig. LED is an acronym and should be capitalized. Signed-off-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: remove PAGE_SIZE limit of /sys/class/leds/<led>/triggerAkinobu Mita3-26/+78
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-11-03leds: tlc591xx: update the maximum brightnessJean-Jacques Hiblot1-3/+4
The TLC chips actually offer 257 levels: - 0: led OFF - 1-255: Led dimmed is using a PWM. The duty cycle range from 0.4% to 99.6% - 256: led fully ON Fixes: e370d010a5fe ("leds: tlc591xx: Driver for the TI 8/16 Channel i2c LED driver") Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: lm3692x: Use flags from LM3692X_BRT_CTRLGuido Günther1-1/+1
Use LM3692X_RAMP_EN instead of LM3692X_PWM_HYSTER_4LSB since the later is a flag for the PWM register. The actual register value remains unchanged. Signed-off-by: Guido Günther <agx@sigxcpu.org> Reviewed-by: Dan Murphy <dmurphy@ti.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: lm3692x: Use flags from LM3692X_BOOST_CTRLGuido Günther1-3/+3
The current setup of LM3692X_BOOST_CTRL uses flags from LM3692X_BRT_CTRL. Use flags from LM3692X_BOOST_CTRL but leave the resulting register value unchanged. Signed-off-by: Guido Günther <agx@sigxcpu.org> Reviewed-by: Dan Murphy <dmurphy@ti.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: lm3692x: Handle failure to probe the regulatorGuido Günther1-2/+11
Instead use devm_regulator_get_optional since the regulator is optional and check for errors. Signed-off-by: Guido Günther <agx@sigxcpu.org> Acked-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: lm3692x: Don't overwrite return value in error pathGuido Günther1-4/+5
The driver currently reports successful initialization on every failure as long as it's able to power off the regulator. Don't check the return value of regulator_disable to avoid that. Signed-off-by: Guido Günther <agx@sigxcpu.org> Acked-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: lm3692x: Print error value on dev_errGuido Günther1-7/+10
This gives a way better idea what is going on. Signed-off-by: Guido Günther <agx@sigxcpu.org> Reviewed-by: Dan Murphy <dmurphy@ti.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: tlc591xx: use devm_led_classdev_register_ext()Jean-Jacques Hiblot1-3/+5
Use devm_led_classdev_register_ext() to pass the fwnode to the LED core. The fwnode can then be used by the firmware core to create meaningful names. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: tlc591xx: simplify driver by using the managed led APIJean-Jacques Hiblot1-62/+22
Use the managed API of the LED class (devm_led_classdev_register() instead of led_classdev_register()). This allows us to remove the code used to track-and-destroy the LED devices. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: bcm6358: Use devm_platform_ioremap_resource() in bcm6358_leds_probe()Markus Elfring1-6/+1
Simplify this function implementation by using a known wrapper function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: bcm6328: Use devm_platform_ioremap_resource() in bcm6328_leds_probe()Markus Elfring1-6/+1
Simplify this function implementation by using a known wrapper function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03drivers: leds: tlc591xx: check error during device initDaniel Mack1-1/+4
The driver currently ignores errors from register writes at probe time. It will hence register an LED class device no matter whether the pyhsical device is present or not. To fix this, make the device probe fail in case regmap operations return an error. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-11-03leds: add LED driver for EL15203000 boardOleh Kravchenko3-0/+371
This patch adds a LED class driver for the LEDs found on the Crane Merchandising System EL15203000 LEDs board (aka RED LEDs board). Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua> Reviewed-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
2019-10-29leds: Use vtime aware kcpustat accessor to fetch CPUTIME_SYSTEMFrederic Weisbecker1-1/+1
Now that we have a vtime safe kcpustat accessor for CPUTIME_SYSTEM, use it to start fixing frozen kcpustat values on nohz_full CPUs. Reported-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Pavel Machek <pavel@ucw.cz> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rafael J . Wysocki <rjw@rjwysocki.net> Cc: Rik van Riel <riel@surriel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Viresh Kumar <viresh.kumar@linaro.org> Cc: Wanpeng Li <wanpengli@tencent.com> Link: https://lkml.kernel.org/r/20191016025700.31277-15-frederic@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
2019-09-12leds: lm3532: Fix optional led-max-microamp prop error handlingDan Murphy1-5/+8
Fix the error handling for the led-max-microamp property. Need to check if the property is present and then if it is retrieve the setting and its max boundary Reported-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
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-09-03leds: ti-lmu-common: Move static keyword to the front of declarationKrzysztof Wilczynski1-1/+1
Move the static keyword to the front of declaration of ramp_table, and resolve the following compiler warning that can be seen when building with warnings enabled (W=1): drivers/leds/leds-ti-lmu-common.c:14:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration] Signed-off-by: Krzysztof Wilczynski <kw@linux.com> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2019-09-03leds: lm3532: Move static keyword to the front of declarationsKrzysztof Wilczynski1-3/+3
Move the static keyword to the front of declarations ramp_table, als_avrg_table and als_imp_table, and resolve the following compiler warnings that can be seen when building with warnings enabled (W=1): drivers/leds/leds-lm3532.c:209:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration] drivers/leds/leds-lm3532.c:266:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration] drivers/leds/leds-lm3532.c:281:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration] Signed-off-by: Krzysztof Wilczynski <kw@linux.com> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
2019-09-01leds: trigger: gpio: GPIO 0 is validAndy Shevchenko1-5/+7
Allow all valid GPIOs to be used in the driver. Fixes: 17354bfe8527 ("leds: Add gpio-led trigger") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
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-09-01leds: is31fl32xx: 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 is31fl32xx_priv { ... struct is31fl32xx_led_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_is31fl32xx_priv(int num_leds) { return sizeof(struct is31fl32xx_priv) + (sizeof(struct is31fl32xx_led_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> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>