Commit Graph

2122 Commits

Author SHA1 Message Date
Linus Torvalds
93251bdf7a - Removed unused local header files from various drivers.
- Reverted platform driver removal to the original method for consistency.
 - Introduced ordered workqueues for LED events, replacing the less efficient system_wq.
 - Switched to a safer iteration macro in several drivers to prevent potential memory leaks.
 - Fixed a refcounting bug in the mt6360 flash LED driver.
 - Fixed an uninitialized variable in the mt6370_mc_pattern_clear() function.
 - Resolved Smatch warnings in the leds-bcm6328 driver.
 - Addressed a potential NULL pointer dereference in the brightness_show() function.
 - Fixed an incorrect format specifier in the ss4200 driver.
 - Prevented a resource leak in the max5970 driver's probe function.
 - Added support for specifying the number of serial shift bits in the device tree for the BCM63138 family.
 - Implemented multicolor brightness control in the lp5562 driver.
 - Added a device tree property to override the default LED pin polarity.
 - Added a property to specify the default brightness value when the LED is initially on.
 - Set missing timing properties for the ktd2692 driver.
 - Documented the "rc-feedback" trigger for controlling LEDs based on remote control activity.
 - Converted text bindings to YAML for the pca955x driver to enable device tree validation.
 - Removed redundant checks for invalid channel numbers in the lp55xx driver.
 - Updated the MAINTAINERS file with current contact information.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmc/KSgACgkQUa+KL4f8
 d2HvLRAAsTuxvq89Ooe5eVWTY39fADykEx8sLgKTJWBs+A4EkD6a6DZAU0QQKZeX
 o7ERtasl5E0WFXF2BaVYPWNDjcSFlqG3AB5PbQLpzUUEkllJWEaWz5ZthpTMct5n
 Q/ylbTA8dYS+bw3bztTKWRWX8RMXKSHdjymJoSuoFLY7T1MLqNHZbu+whNKfC++h
 UMMXyx2M9B+3/0cDghy1EvCWkBTVOL9GzhQhAc+guQTCA8VeK+7LilnCtDOwymdO
 lScTM87S5gD6n22tcDFHhHH+qXVG8LfNpRRKiZdv6BmFJwHpXD+nAMReJOmyReDp
 jepy1aX/W/1cw/GMzd/nOMx/8u8rbO5Up9euCS/jFvgSpn9bKYIlMy2CVsAznOGN
 elt/kCD3nIxY8pzMTnvxCEVYj+hfbCKQWq51cm6G5hhQbfVw72fwiVIGTy8fadO3
 kLOiWM3EKvtpjbdMl0BzWVOIPLO0gQOeYH7ZYb7TM0g3mtFo47DhoGHYQCiaGgko
 Bpb+4fcXpeFLTutM5HGvqqfOCnl/uk4Gf3KhdECSmjFb3L0JbWE/JN3CMq+AR7oK
 FcOhYhNVEGu7VILQYScmChz/DzJT267lyLKF7y1jkmz5ZKMD2r+8XZ2xEb5ks6PG
 +gU7lMY2OXWs/lB9rGTRfCkS50DFJfNG2F5oN7fZ5UJLMWL1EY8=
 =qZhx
 -----END PGP SIGNATURE-----

Merge tag 'leds-next-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds

PULL LED updates from Lee Jones:

 - Remove unused local header files from various drivers

 - Revert platform driver removal to the original method for consistency

 - Introduce ordered workqueues for LED events, replacing the less
   efficient system_wq

 - Switch to a safer iteration macro in several drivers to prevent
   potential memory leaks

 - Fix a refcounting bug in the mt6360 flash LED driver

 - Fix an uninitialized variable in the mt6370_mc_pattern_clear()
   function

 - Resolve Smatch warnings in the leds-bcm6328 driver

 - Address a potential NULL pointer dereference in the brightness_show()
   function

 - Fix an incorrect format specifier in the ss4200 driver

 - Prevent a resource leak in the max5970 driver's probe function

 - Add support for specifying the number of serial shift bits in the
   device tree for the BCM63138 family

 - Implement multicolor brightness control in the lp5562 driver

 - Add a device tree property to override the default LED pin polarity

 - Add a property to specify the default brightness value when the LED
   is initially on

 - Set missing timing properties for the ktd2692 driver

 - Document the "rc-feedback" trigger for controlling LEDs based on
   remote control activity

 - Convert text bindings to YAML for the pca955x driver to enable device
   tree validation

 - Remove redundant checks for invalid channel numbers in the lp55xx
   driver

 - Update the MAINTAINERS file with current contact information

* tag 'leds-next-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds: (46 commits)
  leds: ss4200: Fix the wrong format specifier for 'blinking'
  leds: pwm: Add optional DT property default-brightness
  dt-bindings: leds: pwm: Add default-brightness property
  leds: class: Protect brightness_show() with led_cdev->led_access mutex
  leds: ktd2692: Set missing timing properties
  leds: max5970: Fix unreleased fwnode_handle in probe function
  leds: Introduce ordered workqueue for LEDs events instead of system_wq
  MAINTAINERS: Replace Siemens IPC related bouncing maintainers
  leds: bcm6328: Replace divide condition with comparison for shift value
  leds: lp55xx: Remove redundant test for invalid channel number
  dt-bindings: leds: pca955x: Convert text bindings to YAML
  leds: rgb: leds-mt6370-rgb: Fix uninitialized variable 'ret' in mt6370_mc_pattern_clear
  leds: lp5562: Add multicolor brightness control
  dt-bindings: leds: Add 'active-high' property
  leds: Switch back to struct platform_driver::remove()
  leds: bcm63138: Add some register defines
  leds: bcm63138: Handle shift register config
  leds: bcm63138: Use scopes and guards
  dt-bindings: leds: bcm63138: Add shift register bits
  leds: leds-gpio-register: Reorganize kerneldoc parameter names
  ...
2024-11-22 16:25:20 -08:00
Zhu Jun
e850185803 leds: ss4200: Fix the wrong format specifier for 'blinking'
The format specifier of "signed int" in sprintf() should be "%d", not
"%u".

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Link: https://lore.kernel.org/r/20241111065809.3814-1-zhujun2@cmss.chinamobile.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-11-12 14:39:26 +00:00
George Stark
8cb0810183 leds: pwm: Add optional DT property default-brightness
When probing if default LED state is on then default brightness will be
applied instead of max brightness.

Signed-off-by: George Stark <gnstark@salutedevices.com>
Link: https://lore.kernel.org/r/20241105185006.1380166-3-gnstark@salutedevices.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-11-12 12:14:00 +00:00
Andy Shevchenko
e6a2f0ea51 leds: gpio: Avoid using GPIOF_ACTIVE_LOW
Avoid using GPIOF_ACTIVE_LOW as it's deprecated and subject to remove.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Lee Jones <lee@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241104093609.156059-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-11-09 14:55:33 +01:00
Mukesh Ojha
4ca7cd9387 leds: class: Protect brightness_show() with led_cdev->led_access mutex
There is NULL pointer issue observed if from Process A where hid device
being added which results in adding a led_cdev addition and later a
another call to access of led_cdev attribute from Process B can result
in NULL pointer issue.

Use mutex led_cdev->led_access to protect access to led->cdev and its
attribute inside brightness_show() and max_brightness_show() and also
update the comment for mutex that it should be used to protect the led
class device fields.

	Process A 				Process B

 kthread+0x114
 worker_thread+0x244
 process_scheduled_works+0x248
 uhid_device_add_worker+0x24
 hid_add_device+0x120
 device_add+0x268
 bus_probe_device+0x94
 device_initial_probe+0x14
 __device_attach+0xfc
 bus_for_each_drv+0x10c
 __device_attach_driver+0x14c
 driver_probe_device+0x3c
 __driver_probe_device+0xa0
 really_probe+0x190
 hid_device_probe+0x130
 ps_probe+0x990
 ps_led_register+0x94
 devm_led_classdev_register_ext+0x58
 led_classdev_register_ext+0x1f8
 device_create_with_groups+0x48
 device_create_groups_vargs+0xc8
 device_add+0x244
 kobject_uevent+0x14
 kobject_uevent_env[jt]+0x224
 mutex_unlock[jt]+0xc4
 __mutex_unlock_slowpath+0xd4
 wake_up_q+0x70
 try_to_wake_up[jt]+0x48c
 preempt_schedule_common+0x28
 __schedule+0x628
 __switch_to+0x174
						el0t_64_sync+0x1a8/0x1ac
						el0t_64_sync_handler+0x68/0xbc
						el0_svc+0x38/0x68
						do_el0_svc+0x1c/0x28
						el0_svc_common+0x80/0xe0
						invoke_syscall+0x58/0x114
						__arm64_sys_read+0x1c/0x2c
						ksys_read+0x78/0xe8
						vfs_read+0x1e0/0x2c8
						kernfs_fop_read_iter+0x68/0x1b4
						seq_read_iter+0x158/0x4ec
						kernfs_seq_show+0x44/0x54
						sysfs_kf_seq_show+0xb4/0x130
						dev_attr_show+0x38/0x74
						brightness_show+0x20/0x4c
						dualshock4_led_get_brightness+0xc/0x74

[ 3313.874295][ T4013] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000060
[ 3313.874301][ T4013] Mem abort info:
[ 3313.874303][ T4013]   ESR = 0x0000000096000006
[ 3313.874305][ T4013]   EC = 0x25: DABT (current EL), IL = 32 bits
[ 3313.874307][ T4013]   SET = 0, FnV = 0
[ 3313.874309][ T4013]   EA = 0, S1PTW = 0
[ 3313.874311][ T4013]   FSC = 0x06: level 2 translation fault
[ 3313.874313][ T4013] Data abort info:
[ 3313.874314][ T4013]   ISV = 0, ISS = 0x00000006, ISS2 = 0x00000000
[ 3313.874316][ T4013]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[ 3313.874318][ T4013]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[ 3313.874320][ T4013] user pgtable: 4k pages, 39-bit VAs, pgdp=00000008f2b0a000
..

[ 3313.874332][ T4013] Dumping ftrace buffer:
[ 3313.874334][ T4013]    (ftrace buffer empty)
..
..
[ dd3313.874639][ T4013] CPU: 6 PID: 4013 Comm: InputReader
[ 3313.874648][ T4013] pc : dualshock4_led_get_brightness+0xc/0x74
[ 3313.874653][ T4013] lr : led_update_brightness+0x38/0x60
[ 3313.874656][ T4013] sp : ffffffc0b910bbd0
..
..
[ 3313.874685][ T4013] Call trace:
[ 3313.874687][ T4013]  dualshock4_led_get_brightness+0xc/0x74
[ 3313.874690][ T4013]  brightness_show+0x20/0x4c
[ 3313.874692][ T4013]  dev_attr_show+0x38/0x74
[ 3313.874696][ T4013]  sysfs_kf_seq_show+0xb4/0x130
[ 3313.874700][ T4013]  kernfs_seq_show+0x44/0x54
[ 3313.874703][ T4013]  seq_read_iter+0x158/0x4ec
[ 3313.874705][ T4013]  kernfs_fop_read_iter+0x68/0x1b4
[ 3313.874708][ T4013]  vfs_read+0x1e0/0x2c8
[ 3313.874711][ T4013]  ksys_read+0x78/0xe8
[ 3313.874714][ T4013]  __arm64_sys_read+0x1c/0x2c
[ 3313.874718][ T4013]  invoke_syscall+0x58/0x114
[ 3313.874721][ T4013]  el0_svc_common+0x80/0xe0
[ 3313.874724][ T4013]  do_el0_svc+0x1c/0x28
[ 3313.874727][ T4013]  el0_svc+0x38/0x68
[ 3313.874730][ T4013]  el0t_64_sync_handler+0x68/0xbc
[ 3313.874732][ T4013]  el0t_64_sync+0x1a8/0x1ac

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
Reviewed-by: Anish Kumar <yesanishhere@gmail.com>
Link: https://lore.kernel.org/r/20241103160527.82487-1-quic_mojha@quicinc.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-11-06 08:42:59 +00:00
Raymond Hackley
95c65546f0 leds: ktd2692: Set missing timing properties
props.timing is not set after commit b5a8c50e5c ("leds: ktd2692: Convert
to use ExpressWire library"). Set it with ktd2692_timing.

Fixes: b5a8c50e5c ("leds: ktd2692: Convert to use ExpressWire library")
Signed-off-by: Raymond Hackley <raymondhackley@protonmail.com>
Acked-by: Duje Mihanović <duje.mihanovic@skole.hr>
Link: https://lore.kernel.org/r/20241103083505.49648-1-raymondhackley@protonmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-11-06 08:35:21 +00:00
Javier Carrasco
02f58f9741 leds: max5970: Fix unreleased fwnode_handle in probe function
An object initialized via device_get_named_child_node() requires calls
to fwnode_handle_put() when it is no longer required to avoid leaking
memory.

Add the automatic cleanup facility for 'led_node' to ensure that
fwnode_handle_put() is called in all execution paths.

Fixes: 736214b4b0 ("leds: max5970: Add support for max5970")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20241031-max5970-of_node_put-v2-1-0ffe1f1d3bc9@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-11-06 08:13:14 +00:00
Dmitry Rokosov
32360bf6a5 leds: Introduce ordered workqueue for LEDs events instead of system_wq
This allows to setup ordered workqueue for LEDs events. This may be
useful, because default 'system_wq' does not guarantee execution order
of each work_struct, thus for several brightness update requests (for
multiple LEDs), real brightness switch could be in random order.

Yes, for sysfs-based LEDs we have flush_work() call inside
brightness_store() operation, but it's blocking call, so userspace
caller can be blocked at a long time, which means LEDs animation stream
can be broken.

Ordered workqueue has the same behaviour as system_wq + flush_work(),
but all scheduled works are async and userspace caller is not blocked,
which it better for userspace animation scheduling.

Signed-off-by: Alexey Romanov <avromanov@salutedevices.com>
Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>
Link: https://lore.kernel.org/r/20240903223936.21292-1-ddrokosov@salutedevices.com
[Lee: Couple of style fix-ups]
Signed-off-by: Lee Jones <lee@kernel.org>
2024-11-06 08:11:19 +00:00
Dipendra Khadka
99d36eed05 leds: bcm6328: Replace divide condition with comparison for shift value
Fixes the following Smatch warnings:
drivers/leds/leds-bcm6328.c:116 bcm6328_led_mode() warn: replace divide condition 'shift / 16' with 'shift >= 16'
drivers/leds/leds-bcm6328.c:360 bcm6328_led() warn: replace divide condition 'shift / 16' with 'shift >= 16'

Signed-off-by: Dipendra Khadka <kdipendra88@gmail.com>
Reviewed-by: Pavel Machek <pavel@ucw.cz>
Link: https://lore.kernel.org/r/20241019073302.35499-1-kdipendra88@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-31 16:22:23 +00:00
Michal Vokáč
09b1ef9813 leds: lp55xx: Remove redundant test for invalid channel number
Since commit 92a81562e6 ("leds: lp55xx: Add multicolor framework
support to lp55xx") there are two subsequent tests if the chan_nr
(reg property) is in valid range. One in the lp55xx_init_led()
function and one in the lp55xx_parse_common_child() function that
was added with the mentioned commit.

There are two issues with that.

First is in the lp55xx_parse_common_child() function where the reg
property is tested right after it is read from the device tree.
Test for the upper range is not correct though. Valid reg values are
0 to (max_channel - 1) so it should be >=.

Second issue is that in case the parsed value is out of the range
the probe just fails and no error message is shown as the code never
reaches the second test that prints and error message.

Remove the test form lp55xx_parse_common_child() function completely
and keep the one in lp55xx_init_led() function to deal with it.

Fixes: 92a81562e6 ("leds: lp55xx: Add multicolor framework support to lp55xx")
Cc: stable@vger.kernel.org
Signed-off-by: Michal Vokáč <michal.vokac@ysoft.com>
Link: https://lore.kernel.org/r/20241017150812.3563629-1-michal.vokac@ysoft.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-31 15:01:01 +00:00
Suraj Sonawane
6cbf5c9954 leds: rgb: leds-mt6370-rgb: Fix uninitialized variable 'ret' in mt6370_mc_pattern_clear
Fix the uninitialized symbol 'ret' in the function mt6370_mc_pattern_clear
to resolve the following warning:
drivers/leds/rgb/leds-mt6370-rgb.c:604 mt6370_mc_pattern_clear()
error: uninitialized symbol 'ret'.
Initialize 'ret' to 0 to prevent undefined behavior from uninitialized
access.

Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
Link: https://lore.kernel.org/r/20241016042142.8088-1-surajsonawane0215@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-16 08:52:40 +01:00
Michal Vokáč
681d5fa644 leds: lp5562: Add multicolor brightness control
The framework for multicolor brightness control is already in place
in the lp55xx-common code but the function to control the multicolor
brightness for this particular chip is still missing.

Implement the multicolor_brightness_fn function to allow multicolor
brightness control of LEDs connected to the LP5562 LED driver.

Signed-off-by: Michal Vokáč <michal.vokac@ysoft.com>
Link: https://lore.kernel.org/r/20241009095635.2790613-1-michal.vokac@ysoft.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-15 12:58:41 +01:00
Uwe Kleine-König
6bdc6d4a37 leds: Switch back to struct platform_driver::remove()
After commit 0edb555a65 ("platform: Make platform_driver::remove()
return void") .remove() is (again) the right callback to implement for
platform drivers.

Convert all platform drivers below drivers/leds/ to use .remove(), with
the eventual goal to drop struct platform_driver::remove_new(). As
.remove() and .remove_new() have the same prototypes, conversion is done
by just changing the structure member name in the driver initializer.

While touching these files, make indention of the struct initializer
consistent in several files.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20241010203622.839625-5-u.kleine-koenig@baylibre.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-15 09:58:10 +01:00
Linus Walleij
def9c8b7bc leds: bcm63138: Add some register defines
The Power LUT (Look-up Table) register base was missing, also
add the bit define for sending serial LED data in reverse order,
and use the BIT() macro to define the bits in the control
register.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/r/20241010-bcm63138-leds-v4-4-cdb80780a555@linaro.org
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-11 08:37:16 +01:00
Linus Walleij
5f312fdace leds: bcm63138: Handle shift register config
This adds code to optionally read the width of the shift register
chain from the device tree and use it to set up the register
controlling the shifter hardware.

If the property is not present, the boot-time default is used so
existing device trees keep working as this is what they assume.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/r/20241010-bcm63138-leds-v4-3-cdb80780a555@linaro.org
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-11 08:37:12 +01:00
Linus Walleij
61574073e1 leds: bcm63138: Use scopes and guards
Use scoped helpers and guards to handle DT node iterations
and spinlocks. This cuts some lines of code and eliminates
common mistakes (such as the missing of_node_put()).

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/r/20241010-bcm63138-leds-v4-2-cdb80780a555@linaro.org
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-11 08:37:05 +01:00
Julia Lawall
42507413bb leds: leds-gpio-register: Reorganize kerneldoc parameter names
Reorganize kerneldoc parameter names to match the parameter
order in the function header.

Problems identified using Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Link: https://lore.kernel.org/r/20240930112121.95324-8-Julia.Lawall@inria.fr
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-10 14:42:33 +01:00
Javier Carrasco
3cfd6ad3e1 leds: turris-omnia: Remove unused local leds.h
This driver does not require any element from the local leds.h. Drop
unused header.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_unused_leds_h-v1-6-46fbf41ed4ae@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:37:34 +01:00
Javier Carrasco
9fd316962a leds: pwm: Remove unused local leds.h
Commit 156a5bb89c ("leds: Move led_init_default_state_get() to the
global header") moved the only element leds-gpio required from the local
leds.h to its global counterpart. Drop the inclusion of the local leds.h
as it is no longer used.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_unused_leds_h-v1-5-46fbf41ed4ae@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:37:34 +01:00
Javier Carrasco
d1aa93196c leds: lp50xx: Remove unused local leds.h
This driver does not require any element from the local leds.h. Drop
unused header.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_unused_leds_h-v1-4-46fbf41ed4ae@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:37:34 +01:00
Javier Carrasco
e7160d5ee3 leds: gpio: Remove unused local leds.h
Commit 156a5bb89c ("leds: Move led_init_default_state_get() to the
global header") moved the only element leds-gpio required from the local
leds.h to its global counterpart. Drop the inclusion of the local leds.h
as it is no longer used.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_unused_leds_h-v1-3-46fbf41ed4ae@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:37:34 +01:00
Javier Carrasco
026432e7c2 leds: multicolor: Remove unused local leds.h
This driver does not require any element from the local leds.h. Drop
unused header.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_unused_leds_h-v1-2-46fbf41ed4ae@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:37:34 +01:00
Javier Carrasco
827a0a3724 leds: flash: Remove unused local leds.h
This driver does not require any element from the local leds.h. Drop
unused header.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_unused_leds_h-v1-1-46fbf41ed4ae@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:37:33 +01:00
Javier Carrasco
bf3fba7276 leds: rgb: mt6370: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

After switching to the scoped variant, there is no longer need for a
jump to 'fwnode_release', as an immediate return is possible. Given that
the loop is called in the probe function, and it already uses
dev_err_probe(), the common "dev_err() + return" has been updated as
well.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-18-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:19:22 +01:00
Javier Carrasco
48259638fe leds: rgb: ktd202x: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error path.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-17-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:19:16 +01:00
Javier Carrasco
01728d0419 leds: tca6507: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error path.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-16-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:19:09 +01:00
Javier Carrasco
8cf103de9a leds: sun50i-a100: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

The error handling after 'err_put_child' has been moved to the only goto
that jumps to it (second device_for_each_child_node()), and the call to
fwnode_handle_put() has been removed accordingly.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-15-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:19:02 +01:00
Javier Carrasco
e345607185 leds: pwm: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

After switching to the scoped variant, there is no longer need for a
jump to 'err_child_out', as an immediate return is possible.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-14-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:18:51 +01:00
Javier Carrasco
dea90acb09 leds: pca963x: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

After switching to the scoped variant, there is no longer need for a
jump to 'err', as an immediate return is possible.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-13-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:18:44 +01:00
Javier Carrasco
5b5d936db0 leds: ns2: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error path.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-12-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:18:37 +01:00
Javier Carrasco
4ab3ae432d leds: max77650: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

After switching to the scoped variant, there is no longer need for a
jump to 'err_node_out', as an immediate return is possible.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-11-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:18:29 +01:00
Javier Carrasco
ba35b9a4c1 leds: lp50xx: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

After switching to the scoped variant, there is no longer need for a
jump to 'child_out', as an immediate return is possible.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-10-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:18:23 +01:00
Javier Carrasco
6e2d1d83b7 leds: lm3697: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

After switching to the scoped variant, there is no longer need for a
jump to 'child_out', as an immediate return is possible.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-9-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:17:27 +01:00
Javier Carrasco
7bd4b9277b leds: lm3532: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

After switching to the scoped variant, there is no longer need for a
jump to 'child_out', as an immediate return is possible.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-8-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:17:20 +01:00
Javier Carrasco
42b4967160 leds: gpio: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-7-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:17:14 +01:00
Javier Carrasco
9e445e28ae leds: el15203000: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

After switching to the scoped variant, there is no longer need for a
jump to 'err_child_out', as an immediate return is possible.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-6-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:17:06 +01:00
Javier Carrasco
65135e2ccf leds: cr0014114: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-5-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:16:59 +01:00
Javier Carrasco
a361af3c16 leds: aw200xx: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-4-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:16:42 +01:00
Javier Carrasco
f64dd42a4f leds: flash: leds-qcom-flash: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-3-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:16:30 +01:00
Javier Carrasco
19d1cc765e leds: flash: mt6370: Switch to device_for_each_child_node_scoped()
Switch to device_for_each_child_node_scoped() to simplify the code by
removing the need for calls to fwnode_handle_put() in the error paths.

This also prevents possible memory leaks if new error paths are added
without the required call to fwnode_handle_put().

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-2-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:16:23 +01:00
Javier Carrasco
73b03b2773 leds: flash: mt6360: Fix device_for_each_child_node() refcounting in error paths
The device_for_each_child_node() macro requires explicit calls to
fwnode_handle_put() upon early exits to avoid memory leaks, and in
this case the error paths are handled after jumping to
'out_flash_realease', which misses that required call to
to decrement the refcount of the child node.

A more elegant and robust solution is using the scoped variant of the
loop, which automatically handles such early exits.

Fix the child node refcounting in the error paths by using
device_for_each_child_node_scoped().

Cc: stable@vger.kernel.org
Fixes: 679f865206 ("leds: Add mt6360 driver")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240927-leds_device_for_each_child_node_scoped-v1-1-95c0614b38c8@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 15:16:13 +01:00
WangYuli
da0806e4e8 leds: rgb: leds-group-multicolor: Correct the typo 'acccess'
There is a spelling mistake of 'acccess' which should be instead of
'access'.

Signed-off-by: WangYuli <wangyuli@uniontech.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/B586A1E6EA476B68+20240920024514.1182292-1-wangyuli@uniontech.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-10-09 10:37:20 +01:00
Al Viro
5f60d5f6bb move asm/unaligned.h to linux/unaligned.h
asm/unaligned.h is always an include of asm-generic/unaligned.h;
might as well move that thing to linux/unaligned.h and include
that - there's nothing arch-specific in that header.

auto-generated by the following:

for i in `git grep -l -w asm/unaligned.h`; do
	sed -i -e "s/asm\/unaligned.h/linux\/unaligned.h/" $i
done
for i in `git grep -l -w asm-generic/unaligned.h`; do
	sed -i -e "s/asm-generic\/unaligned.h/linux\/unaligned.h/" $i
done
git mv include/asm-generic/unaligned.h include/linux/unaligned.h
git mv tools/include/asm-generic/unaligned.h tools/include/linux/unaligned.h
sed -i -e "/unaligned.h/d" include/asm-generic/Kbuild
sed -i -e "s/__ASM_GENERIC/__LINUX/" include/linux/unaligned.h tools/include/linux/unaligned.h
2024-10-02 17:23:23 -04:00
Al Viro
cb787f4ac0 [tree-wide] finally take no_llseek out
no_llseek had been defined to NULL two years ago, in commit 868941b144
("fs: remove no_llseek")

To quote that commit,

  At -rc1 we'll need do a mechanical removal of no_llseek -

  git grep -l -w no_llseek | grep -v porting.rst | while read i; do
	sed -i '/\<no_llseek\>/d' $i
  done

  would do it.

Unfortunately, that hadn't been done.  Linus, could you do that now, so
that we could finally put that thing to rest? All instances are of the
form
	.llseek = no_llseek,
so it's obviously safe.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-09-27 08:18:43 -07:00
Liao Chen
64c3886650 leds: turris-omnia: Fix module autoloading with MODULE_DEVICE_TABLE()
Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded
based on the alias from of_device_id table.

Signed-off-by: Liao Chen <liaochen4@huawei.com>
Link: https://lore.kernel.org/r/20240827122431.430818-1-liaochen4@huawei.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-08-30 09:05:08 +01:00
Bastien Curutchet
2aad93b6de leds: pca9532: Remove irrelevant blink configuration error message
The update_hw_blink() function prints an error message when hardware is
not able to handle a blink configuration on its own. IMHO, this isn't a
'real' error since the software fallback is used afterwards.

Remove the error messages to avoid flooding the logs with unnecessary
messages.

Cc: stable@vger.kernel.org
Fixes: 48ca7f302c ("leds: pca9532: Use PWM1 for hardware blinking")
Signed-off-by: Bastien Curutchet <bastien.curutchet@bootlin.com>
Link: https://lore.kernel.org/r/20240826133237.134604-1-bastien.curutchet@bootlin.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-08-30 09:01:08 +01:00
Kees Cook
045391a02b leds: gpio: Set num_leds after allocation
With the new __counted_by annotation, the "num_leds" variable needs to
valid for accesses to the "leds" array. This requirement is not met in
gpio_leds_create(), since "num_leds" starts at "0", so "leds" index "0"
will not be considered valid (num_leds would need to be "1" to access
index "0").

Fix this by setting the allocation size after allocation, and then update
the final count based on how many were actually added to the array.

Fixes: 52cd75108a ("leds: gpio: Annotate struct gpio_leds_priv with __counted_by")
Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20240716212455.work.809-kees@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
2024-08-23 08:40:43 +01:00
Huan Yang
4968f67213 leds: lp55xx: Use devm_clk_get_enabled() helpers
Simplify the code a bunch by using managed resource helpers.

Also, there is no need to save clk pointer anymore.

Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Huan Yang <link@vivo.com>
Link: https://lore.kernel.org/r/20240821013725.785956-1-link@vivo.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-08-22 14:48:24 +01:00
Javier Carrasco
77b2b47598 leds: as3645a: Use device_* to iterate over device child nodes
Drop the manual access to the fwnode of the device to iterate over its
child nodes. `device_for_each_child_node` macro provides direct access
to the child nodes, and given that the `child` variable is only required
within the loop, the scoped variant of the macro can be used.

Use the `device_for_each_child_node_scoped` macro to iterate over the
direct child nodes of the device.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Link: https://lore.kernel.org/r/20240820-device_child_node_access-v3-2-1ee09bdedb9e@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2024-08-22 14:48:02 +01:00
Krzysztof Kozlowski
9557b4376d leds: qcom-lpg: Simplify with scoped for each OF child loop
Use scoped for_each_available_child_of_node_scoped() when iterating over
device nodes to make code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240816-cleanup-h-of-node-put-var-v1-17-1d0292802470@linaro.org
Signed-off-by: Lee Jones <lee@kernel.org>
2024-08-22 14:23:11 +01:00