summaryrefslogtreecommitdiff
path: root/drivers/leds
AgeCommit message (Collapse)AuthorFilesLines
2023-08-18leds: trigger: netdev: Use module_led_trigger macro to simplify the codeLi Zetao1-12/+1
Use the module_led_trigger macro to simplify the code, which is the same as declaring with module_init() and module_exit(). Signed-off-by: Li Zetao <lizetao1@huawei.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20230815075944.1089298-2-lizetao1@huawei.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-18leds: turris-omnia: Drop unnecessary mutex lockingMarek Behún1-10/+1
Do not lock driver mutex in the global LED panel brightness sysfs accessors brightness_show() and brightness_store(). The mutex locking is unnecessary here. The I2C transfers are guarded by I2C core locking mechanism, and the LED commands itself do not interfere with other commands. Fixes: 089381b27abe ("leds: initial support for Turris Omnia LEDs") Signed-off-by: Marek Behún <kabel@kernel.org> Reviewed-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230802160748.11208-2-kabel@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-18leds: turris-omnia: Use sysfs_emit() instead of sprintf()Marek Behún1-1/+1
Use the dedicated sysfs_emit() function instead of sprintf() in sysfs attribute accessor brightness_show(). Signed-off-by: Marek Behún <kabel@kernel.org> Link: https://lore.kernel.org/r/20230802160748.11208-4-kabel@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-18leds: Make leds_class a static const structureIvan Orlov1-13/+13
Now that the driver core allows for struct class to be in read-only memory, move the leds_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time. Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com> Link: https://lore.kernel.org/r/20230810174905.7997-1-ivan.orlov0322@gmail.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-17leds: Remove redundant of_match_ptr()Zhu Wang6-14/+7
The driver depends on CONFIG_OF, so it is not necessary to use of_match_ptr() here. We remove both CONFIG_OF and of_match_ptr() here. Signed-off-by: Zhu Wang <wangzhu9@huawei.com> Link: https://lore.kernel.org/r/20230808111108.24262-1-wangzhu9@huawei.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-17leds: trigger: tty: Do not use LED_ON/OFF constants, use ↵Marek Behún1-4/+8
led_blink_set_oneshot instead The tty LED trigger uses the obsolete LED_ON & LED_OFF constants when setting LED brightness. This is bad because the LED_ON constant is equal to 1, and so when activating the tty LED trigger on a LED class device with max_brightness greater than 1, the LED is dimmer than it can be (when max_brightness is 255, the LED is very dimm indeed; some devices translate 1/255 to 0, so the LED is OFF all the time). Instead of directly setting brightness to a specific value, use the led_blink_set_oneshot() function from LED core to configure the blink. This function takes the current configured brightness as blink brightness if not zero, and max brightness otherwise. This also changes the behavior of the TTY LED trigger. Previously if rx/tx stats kept changing, the LED was ON all the time they kept changing. With this patch the LED will blink on TTY activity. Fixes: fd4a641ac88f ("leds: trigger: implement a tty trigger") Signed-off-by: Marek Behún <kabel@kernel.org> Link: https://lore.kernel.org/r/20230802090753.13611-1-kabel@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-17leds: Fix BUG_ON check for LED_COLOR_ID_MULTI that is always falseMarek Behún1-4/+4
At the time we call BUG_ON(props.color == LED_COLOR_ID_MULTI); the props variable is still initialized to zero. Call the BUG_ON only after we parse fwnode into props. Fixes: 77dce3a22e89 ("leds: disallow /sys/class/leds/*:multi:* for now") Signed-off-by: Marek Behún <kabel@kernel.org> Link: https://lore.kernel.org/r/20230801151623.30387-1-kabel@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-17leds: multicolor: Use rounded division when calculating color componentsMarek Behún1-3/+5
Given channel intensity, LED brightness and max LED brightness, the multicolor LED framework helper led_mc_calc_color_components() computes the color channel brightness as chan_brightness = brightness * chan_intensity / max_brightness Consider the situation when (brightness, intensity, max_brightness) is for example (16, 15, 255), then chan_brightness is computed to 0 although the fractional divison would give 0.94, which should be rounded to 1. Use DIV_ROUND_CLOSEST here for the division to give more realistic component computation: chan_brightness = DIV_ROUND_CLOSEST(brightness * chan_intensity, max_brightness) Fixes: 55d5d3b46b08 ("leds: multicolor: Introduce a multicolor class definition") Signed-off-by: Marek Behún <kabel@kernel.org> Link: https://lore.kernel.org/r/20230801124931.8661-1-kabel@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-17leds: rgb: Add a multicolor LED driver to group monochromatic LEDsJean-Jacques Hiblot3-0/+182
Grouping multiple monochrome LEDs into a multicolor LED device has a few benefits over handling the group in user-space: - The state of the LEDs relative to each other is consistent. In other words, if 2 threads competes to set the LED to green and red, the end-result cannot be black or yellow. - The multicolor LED as a whole can be driven through the sysfs LED interface. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com> Reviewed-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230728153731.3742339-5-jjhiblot@traphandler.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-17leds: class: Store the color index in struct led_classdevJean-Jacques Hiblot1-0/+21
Store the color of the LED so that it is not lost after the LED's name has been composed. This color information can then be exposed to the user space or used by the LED consumer. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com> Link: https://lore.kernel.org/r/20230728153731.3742339-3-jjhiblot@traphandler.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-17leds: Provide devm_of_led_get_optional()Jean-Jacques Hiblot1-0/+25
Add an optional variant of devm_of_led_get(). It behaves the same as devm_of_led_get() except where the LED doesn't exist. In this case, instead of returning -ENOENT, the function returns NULL. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20230728153731.3742339-2-jjhiblot@traphandler.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-15leds: pca995x: Fix MODULE_DEVICE_TABLE for OFMarek Vasut1-1/+1
Fix copy-paste error in MODULE_DEVICE_TABLE() for the OF table, use the 'of' first parameter instead of duplicate 'i2c'. Fixes: ee4e80b2962e ("leds: pca995x: Add support for PCA995X chips") Signed-off-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20230809125314.531806-1-marex@denx.de Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-11leds: trig-netdev: Disable offload on deactivation of triggerAndrew Lunn1-0/+2
Ensure that the offloading of blinking is stopped when the trigger is deactivated. Calling led_set_brightness() is documented as stopping offload and setting the LED to a constant brightness. Suggested-by: Daniel Golle <daniel@makrotopia.org> Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Simon Horman <simon.horman@corigine.com> Tested-by: Daniel Golle <daniel@makrotopia.org> Link: https://lore.kernel.org/r/20230808210436.838995-5-andrew@lunn.ch Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-08-11led: trig: netdev: Fix requesting offload deviceAndrew Lunn1-3/+5
When the netdev trigger is activates, it tries to determine what device the LED blinks for, and what the current blink mode is. The documentation for hw_control_get() says: * Return 0 on success, a negative error number on failing parsing the * initial mode. Error from this function is NOT FATAL as the device * may be in a not supported initial state by the attached LED trigger. */ For the Marvell PHY and the Armada 370-rd board, the initial LED blink mode is not supported by the trigger, so it returns an error. This resulted in not getting the device the LED is blinking for. As a result, the device is unknown and offloaded is never performed. Change to condition to always get the device if offloading is supported, and reduce the scope of testing for an error from hw_control_get() to skip setting trigger internal state if there is an error. Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Andrew Lunn <andrew@lunn.ch> Tested-by: Daniel Golle <daniel@makrotopia.org> Link: https://lore.kernel.org/r/20230808210436.838995-2-andrew@lunn.ch Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-07-31leds: simatic-ipc-leds: default config switch to platform switchHenning Schild1-0/+1
If a user did choose to enable Siemens Simatic platform support they likely want the LED drivers to be enabled without having to flip more config switches. So we make the LED drivers config switch default to the platform driver switches value. Signed-off-by: Henning Schild <henning.schild@siemens.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230719153518.13073-3-henning.schild@siemens.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2023-07-28leds: qcom-lpg: Drop assignment to struct pwmchip::baseUwe Kleine-König1-1/+0
Since commit f9a8ee8c8bcd ("pwm: Always allocate PWM chip base ID dynamically") there is no effect any more for assigning this variable. See pwmchip_add() which unconditionally overwrites this member. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230728065739.580281-1-u.kleine-koenig@pengutronix.de Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: flash: leds-qcom-flash: Put child node if registration failedFenglin Wu1-0/+1
Put the child node if register flash LED device failed. Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com> Link: https://lore.kernel.org/r/20230725-leds-qcom-flash-driver-tiny-fixes-v2-3-0f5cbce5fed0@quicinc.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: flash: leds-qcom-flash: Turn off LED before setting flash currentFenglin Wu1-0/+4
Strobe off the LED before setting flash current to avoid it's being enabled with an incorrect current if it has been working in torch mode. Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com> Link: https://lore.kernel.org/r/20230725-leds-qcom-flash-driver-tiny-fixes-v2-2-0f5cbce5fed0@quicinc.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: flash: leds-qcom-flash: Declare the driver as a moduleFenglin Wu1-0/+2
Explain in Kconfig that the driver can be compiled as a module. Signed-off-by: Fenglin Wu <quic_fenglinw@quicinc.com> Link: https://lore.kernel.org/r/20230725-leds-qcom-flash-driver-tiny-fixes-v2-1-0f5cbce5fed0@quicinc.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: ns2: Slightly simplify a memory allocationChristophe JAILLET1-1/+1
Use devm_kcalloc() instead of devm_kzalloc()+array_size(). Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/560b8f140c19a7da40f5e9540c3ef312969b0dc4.1690057595.git.christophe.jaillet@wanadoo.fr Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: Explicitly include correct DT includesRob Herring13-14/+7
The DT of_device.h and of_platform.h date back to the separate of_platform_bus_type before it as merged into the regular platform bus. As part of that merge prepping Arm DT support 13 years ago, they "temporarily" include each other. They also include platform_device.h and of.h. As a result, there's a pretty much random mix of those include files used throughout the tree. In order to detangle these headers and replace the implicit includes with struct declarations, users need to explicitly include the correct includes. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230714174651.4058753-1-robh@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: bcm63138: Rename dependency symbol ARCH_BCM4908 to ARCH_BCMBCARafał Miłecki1-2/+2
Symbol ARCH_BCM4908 has been merged/removed without updating leds Kconfig. Fixes: dd5c672d7ca9 ("arm64: bcmbca: Merge ARCH_BCM4908 to ARCH_BCMBCA") Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Reviewed-by: William Zhang <william.zhang@broadcom.com> Link: https://lore.kernel.org/r/20230714063214.3791-1-zajec5@gmail.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: simatic-ipc-leds-gpio: Add Elkhart Lake versionHenning Schild4-0/+75
This is used for the Siemens Simatic IPC BX-21A, which has its LEDs connected to GPIOs provided by the Intel Elkhart Lake pinctrl driver. Signed-off-by: Henning Schild <henning.schild@siemens.com> Link: https://lore.kernel.org/r/20230713115639.16419-3-henning.schild@siemens.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: pca995x: Add support for PCA995X chipsIsai Gaspar3-0/+214
The PCA995x chips are I2C controlled LED drivers. Each chip has up to 16 outputs, each one with an individual 8-bit resolution PWM for brightness control. Signed-off-by: Isai Gaspar <isaiezequiel.gaspar@nxp.com> Signed-off-by: Marek Vasut <marex@denx.de> # Basically rewrite the driver Link: https://lore.kernel.org/r/20230713163516.21644-2-marex@denx.de Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: simatic-ipc-leds-gpio: Fix comment style in SPDX headerHenning Schild1-1/+1
This was found with giving the file to checkpatch. Signed-off-by: Henning Schild <henning.schild@siemens.com> Link: https://lore.kernel.org/r/20230706161040.21152-3-henning.schild@siemens.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: pwm: Fix error code in led_pwm_create_fwnode()Dan Carpenter1-1/+1
Negative -EINVAL was intended, not positive EINVAL. Fix it. Fixes: 95138e01275e ("leds: pwm: Make error handling more robust") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/a33b981a-b2c4-4dc2-b00a-626a090d2f11@moroto.mountain Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28led: led-class: Read max-brightness from devicetreeAstrid Rost1-0/+4
Normally, the maximum brightness is determined by the hardware, and this property is not required. This property is used to set a software limit. It could happen that an LED is made so bright that it gets damaged or causes damage due to restrictions in a specific system, such as mounting conditions. Note that this flag is mainly used for PWM-LEDs, where it is not possible to map brightness to current. Drivers for other controllers should use led-max-microamp. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Astrid Rost <astrid.rost@axis.com> Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> Link: https://lore.kernel.org/r/20230703130313.548519-3-astrid.rost@axis.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: ip30: Convert to devm_platform_ioremap_resource()Yangtao Li1-7/+1
Use devm_platform_ioremap_resource() to simplify code. Signed-off-by: Yangtao Li <frank.li@vivo.com> Link: https://lore.kernel.org/r/20230704094745.25665-1-frank.li@vivo.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: aw200xx: Switch back to use struct i2c_driver::probeUwe Kleine-König1-1/+1
struct i2c_driver::probe_new is about to go away. Switch the driver to use the probe callback with the same prototype. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230626090254.556206-1-u.kleine-koenig@pengutronix.de Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: simatic-ipc-leds-gpio: Restore LEDS_CLASS dependencyArnd Bergmann1-0/+1
A recent rework accidentally lost the dependency on LEDS_CLASS, which leads to a link error when LED support is disbled: x86_64-linux-ld: drivers/leds/simple/simatic-ipc-leds.o: in function `simatic_ipc_leds_probe': simatic-ipc-leds.c:(.text+0x10c): undefined reference to `devm_led_classdev_register_ext' Add back the dependency that was there originally. Fixes: a6c80bec3c935 ("leds: simatic-ipc-leds-gpio: Add GPIO version of Siemens driver") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/20230623152233.2246285-1-arnd@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-28leds: aw200xx: Fix error code in probe()Dan Carpenter1-1/+1
The "ret" variable is zero/success here. Don't return that, return -EINVAL instead. Fixes: 36a87f371b7a ("leds: Add AW20xx driver") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/r/4d791b69-01c7-4532-818c-63712d3f63e1@moroto.mountain Signed-off-by: Lee Jones <lee@kernel.org>
2023-07-03Merge tag 'leds-next-6.5' of ↵Linus Torvalds56-345/+1938
git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds Pull LED updates from Lee Jones: "New Drivers: - Add support for Intel Cherry Trail Whiskey Cove PMIC LEDs - Add support for Awinic AW20036/AW20054/AW20072 LEDs New Device Support: - Add support for PMI632 LPG to QCom LPG - Add support for PMI8998 to QCom Flash - Add support for MT6331, WLEDs and MT6332 to Mediatek MT6323 PMIC New Functionality: - Implement the LP55xx Charge Pump - Add support for suspend / resume to Intel Cherry Trail Whiskey Cove PMIC - Add support for breathing mode to Intel Cherry Trail Whiskey Cove PMIC - Enable per-pin resolution Pinctrl in LEDs GPIO Fix-ups: - Allow thread to sleep by switching from spinlock to mutex - Add lots of Device Tree bindings / support - Adapt relationships / dependencies driven by Kconfig - Switch I2C drivers from .probe_new() to .probe() - Remove superfluous / duplicate code - Replace strlcpy() with strscpy() for efficiency and overflow prevention - Staticify various functions - Trivial: Fixing coding style - Simplify / reduce code Bug Fixes: - Prevent NETDEV_LED_MODE_LINKUP from being cleared on rename - Repair race between led_set_brightness(LED_{OFF,FULL}) - Fix Oops relating to sleeping in critical sections - Clear LED_INIT_DEFAULT_TRIGGER flag when clearing the current trigger - Do not leak resources in error handling paths - Fix unsigned comparison which can never be negative - Provide missing NULL terminating entries in tables - Fix misnaming issues" * tag 'leds-next-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds: (53 commits) leds: leds-mt6323: Adjust return/parameter types in wled get/set callbacks leds: sgm3140: Add richtek,rt5033-led compatible dt-bindings: leds: sgm3140: Document richtek,rt5033 compatible dt-bindings: backlight: kinetic,ktz8866: Add missing type for "current-num-sinks" dt-bindings: leds: Drop unneeded quotes leds: Fix config reference for AW200xx driver leds: leds-mt6323: Add support for WLEDs and MT6332 leds: leds-mt6323: Add support for MT6331 leds leds: leds-mt6323: Open code and drop MT6323_CAL_HW_DUTY macro leds: leds-mt6323: Drop MT6323_ prefix from macros and defines leds: leds-mt6323: Specify registers and specs in platform data dt-bindings: leds: leds-mt6323: Document mt6332 compatible dt-bindings: leds: leds-mt6323: Document mt6331 compatible leds: simatic-ipc-leds-gpio: Introduce more Kconfig switches leds: simatic-ipc-leds-gpio: Split up into multiple drivers leds: simatic-ipc-leds-gpio: Move two extra gpio pins into another table leds: simatic-ipc-leds-gpio: Add terminating entries to gpio tables leds: flash: leds-qcom-flash: Fix an unsigned comparison which can never be negative leds: cht-wcove: Remove unneeded semicolon leds: cht-wcove: Fix an unsigned comparison which can never be negative ...
2023-06-23leds: leds-mt6323: Adjust return/parameter types in wled get/set callbacksNathan Chancellor1-3/+3
Clang's kernel Control Flow Integrity (kCFI) is a compiler-based security mitigation that ensures the target of an indirect function call matches the expected type of the call and trapping if they do not match exactly. The warning -Wincompatible-function-pointer-types-strict aims to catch these issues at compile time, which reveals: drivers/leds/leds-mt6323.c:598:49: error: incompatible function pointer types assigning to 'int (*)(struct led_classdev *, enum led_brightness)' from 'int (struct led_classdev *, unsigned int)' [-Werror,-Wincompatible-function-pointer-types-strict] 598 | leds->led[reg]->cdev.brightness_set_blocking = | ^ 599 | mt6323_wled_set_brightness; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/leds/leds-mt6323.c:600:40: error: incompatible function pointer types assigning to 'enum led_brightness (*)(struct led_classdev *)' from 'unsigned int (struct led_classdev *)' [-Werror,-Wincompatible-function-pointer-types-strict] 600 | leds->led[reg]->cdev.brightness_get = | ^ 601 | mt6323_get_wled_brightness; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 errors generated. While 'unsigned int' is ABI compatible with 'enum led_brightness' (hence no warning from -Wincompatible-function-pointer-types) and the callers of these callbacks use/pass the values as 'unsigned int', the mismatch between the prototype and the called function will trip kCFI at runtime. Change the types in the implementations to match the prototypes, clearing up the warning and avoiding kCFI failures. Fixes: 9bb0a9e0626c ("leds: leds-mt6323: Add support for WLEDs and MT6332") Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230622-mt6323-wled-wincompatible-function-pointer-types-strict-v1-1-6ad256f220e8@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-06-22leds: trigger: netdev: expose hw_control status via sysfsChristian Marangi1-0/+11
Expose hw_control status via sysfs for the netdev trigger to give userspace better understanding of the current state of the trigger and the LED. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> Acked-by: Lee Jones <lee@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-06-22leds: trigger: netdev: add additional specific link duplex modeChristian Marangi1-2/+25
Add additional modes for specific link duplex. Use ethtool APIs to get the current link duplex and enable the LED accordingly. Under netdev event handler the rtnl lock is already held and is not needed to be set to access ethtool APIs. This is especially useful for PHY and Switch that supports LEDs hw control for specific link duplex. Add additional modes: - half_duplex: Turn on LED when link is half duplex - full_duplex: Turn on LED when link is full duplex Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Acked-by: Lee Jones <lee@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-06-22leds: trigger: netdev: add additional specific link speed modeChristian Marangi1-10/+70
Add additional modes for specific link speed. Use ethtool APIs to get the current link speed and enable the LED accordingly. Under netdev event handler the rtnl lock is already held and is not needed to be set to access ethtool APIs. This is especially useful for PHY and Switch that supports LEDs hw control for specific link speed. (example scenario a PHY that have 2 LED connected one green and one orange where the green is turned on with 1000mbps speed and orange is turned on with 10mpbs speed) On mode set from sysfs we check if we have enabled split link speed mode and reject enabling generic link mode to prevent wrong and redundant configuration. Rework logic on the set baseline state to support these new modes to select if we need to turn on or off the LED. Add additional modes: - link_10: Turn on LED when link speed is 10mbps - link_100: Turn on LED when link speed is 100mbps - link_1000: Turn on LED when link speed is 1000mbps Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Acked-by: Lee Jones <lee@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-06-21leds: sgm3140: Add richtek,rt5033-led compatibleRaymond Hackley1-0/+1
Richtek's rt5033-led has pin configurations similar to sgm3140. Add it to the compatible list. Signed-off-by: Raymond Hackley <raymondhackley@protonmail.com> Link: https://lore.kernel.org/r/20230602131024.260297-1-raymondhackley@protonmail.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-06-15leds: Fix config reference for AW200xx driverLukas Bulwahn1-1/+1
Commit 36a87f371b7a ("leds: Add AW20xx driver") adds config LEDS_AW200XX in drivers/leds/Kconfig, but then in drivers/leds/Makefile accidently refers to CONFIG_LEDS_W200XX; note the missing A! This typo makes it impossible to add the driver to a kernel build. Fix this wrong config reference. Fixes: 36a87f371b7a ("leds: Add AW20xx driver") Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com> Link: https://lore.kernel.org/r/20230609100233.4111-1-lukas.bulwahn@gmail.com Signed-off-by: Lee Jones <lee@kernel.org>
2023-06-15leds: trigger: netdev: uninitialized variable in netdev_trig_activate()Dan Carpenter1-1/+1
The qca8k_cled_hw_control_get() function which implements ->hw_control_get sets the appropriate bits but does not clear them. This leads to an uninitialized variable bug. Fix this by setting mode to zero at the start. Fixes: e0256648c831 ("net: dsa: qca8k: implement hw_control ops") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Acked-by: Lee Jones <lee@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2023-06-09leds: leds-mt6323: Add support for WLEDs and MT6332AngeloGioacchino Del Regno1-7/+164
Add basic code to turn on and off WLEDs and wire up MT6332 support to take advantage of it. This is a simple approach due to the aforementioned PMIC supporting only on/off status so, at the time of writing, it is impossible for me to validate more advanced functionality due to lack of hardware. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230601110813.2373764-9-angelogioacchino.delregno@collabora.com
2023-06-09leds: leds-mt6323: Add support for MT6331 ledsAngeloGioacchino Del Regno1-0/+17
Add the register offsets for MT6331. The hwspec is the same as MT6323. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Acked-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230601110813.2373764-8-angelogioacchino.delregno@collabora.com
2023-06-09leds: leds-mt6323: Open code and drop MT6323_CAL_HW_DUTY macroAngeloGioacchino Del Regno1-3/+1
There is only one instance of using this macro and it's anyway not simplifying the flow, or increasing the readability of this driver. Drop this macro by open coding it in mt6323_led_set_blink(). No functional changes. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230601110813.2373764-7-angelogioacchino.delregno@collabora.com
2023-06-09leds: leds-mt6323: Drop MT6323_ prefix from macros and definesAngeloGioacchino Del Regno1-63/+60
This renames all definitions and macros to drop the MT6323_ prefix, since it is now possible to easily add support to more PMICs in this driver. While at it, also fix related formatting where possible. This commit brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230601110813.2373764-6-angelogioacchino.delregno@collabora.com
2023-06-09leds: leds-mt6323: Specify registers and specs in platform dataAngeloGioacchino Del Regno1-38/+115
In order to enhance the flexibility of this driver and let it support more than just one MediaTek LEDs IP for more than just one PMIC, add platform data structure specifying the register offsets and data that commonly varies between different IPs. This commit brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230601110813.2373764-5-angelogioacchino.delregno@collabora.com
2023-06-08Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski1-4/+4
Cross-merge networking fixes after downstream PR. Conflicts: net/sched/sch_taprio.c d636fc5dd692 ("net: sched: add rcu annotations around qdisc->qdisc_sleeping") dced11ef84fb ("net/sched: taprio: don't overwrite "sch" variable in taprio_dump_class_stats()") net/ipv4/sysctl_net_ipv4.c e209fee4118f ("net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294") ccce324dabfe ("tcp: make the first N SYN RTO backoffs linear") https://lore.kernel.org/all/20230605100816.08d41a7b@canb.auug.org.au/ No adjacent changes. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-06-08leds: simatic-ipc-leds-gpio: Introduce more Kconfig switchesHenning Schild2-7/+31
To describe the dependency chain better and allow for potential fine-grained config tuning, introduce Kconfig switch for the individual GPIO based drivers. Signed-off-by: Henning Schild <henning.schild@siemens.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230524124628.32295-5-henning.schild@siemens.com
2023-06-08leds: simatic-ipc-leds-gpio: Split up into multiple driversHenning Schild7-165/+261
In order to clearly describe the dependencies between the GPIO controller drivers and the users the driver is split up into a core, two drivers and a common header. Signed-off-by: Henning Schild <henning.schild@siemens.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230524124628.32295-4-henning.schild@siemens.com
2023-06-08leds: simatic-ipc-leds-gpio: Move two extra gpio pins into another tableHenning Schild1-3/+25
There are two special pins needed to init the LEDs. We used to have them at the end of the gpiod_lookup table to give to "leds-gpio". A cleaner way is to have a dedicated table for the special pins. Signed-off-by: Henning Schild <henning.schild@siemens.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230524124628.32295-3-henning.schild@siemens.com
2023-06-08leds: simatic-ipc-leds-gpio: Add terminating entries to gpio tablesHenning Schild1-0/+2
The entries do not seem to be stricly needed when the number of entries is given via the number of LEDs. But adding them is a safeguard should anyone ever iterate over the tables to their end, it also gets us in line with other drivers that register "leds-gpio" tables. Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Henning Schild <henning.schild@siemens.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230524124628.32295-2-henning.schild@siemens.com
2023-06-08leds: flash: leds-qcom-flash: Fix an unsigned comparison which can never be ↵Jiapeng Chong1-2/+2
negative The variable 'count' is defined as unsigned type, so the following if statement is invalid, we can modify the type of count to int. if (count <= 0) { dev_err(dev, "No led-sources specified\n"); return -ENODEV; } ./drivers/leds/flash/leds-qcom-flash.c:546:5-10: WARNING: Unsigned expression compared with zero: count <= 0. Reported-by: Abaci Robot <abaci@linux.alibaba.com> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5344 Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230531053559.5702-1-jiapeng.chong@linux.alibaba.com