The CPU trigger is invoked on ARM from CPU-idle. That trigger later
invokes led_trigger_event() which may invoke the callback of the actual driver.
That driver can acquire a spinlock_t which is okay on kernel without
PREEMPT_RT. On a PREEMPT_RT enabled kernel this lock is turned into a
sleeping lock and must not be acquired with disabled interrupts.
Disable the CPU trigger on PREEMPT_RT.
Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Pavel Machek <[email protected]>
Even with the previous commit 27af8e2c90
("leds: trigger: fix potential deadlock with libata")
to this file, we still get lockdep unhappy, and Boqun
explained the report here:
https://lore.kernel.org/r/YNA+d1X4UkoQ7g8a@boqun-archlinux
Effectively, this means that the read_lock_irqsave() isn't
enough here because another CPU might be trying to do a
write lock, and thus block the readers.
This is all pretty messy, but it doesn't seem right that
the LEDs framework imposes some locking requirements on
users, in particular we'd have to make the spinlock in the
iwlwifi driver always disable IRQs, even if we don't need
that for any other reason, just to avoid this deadlock.
Since writes to the led_cdevs list are rare (and are done
by userspace), just switch the list to RCU. This costs a
synchronize_rcu() at removal time so we can ensure things
are correct, but that seems like a small price to pay for
getting lock-free iterations and no deadlocks (nor any
locking requirements imposed on users.)
Signed-off-by: Johannes Berg <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
gcc-11 warns when building with W=1:
drivers/leds/led-class-flash.c: In function 'flash_fault_show':
drivers/leds/led-class-flash.c:210:16: error: 'sprintf' argument 3 overlaps destination object 'buf' [-Werror=restrict]
210 | return sprintf(buf, "%s\n", buf);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/led-class-flash.c:187:54: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
187 | struct device_attribute *attr, char *buf)
| ~~~~~~^~~
There is no need for the sprintf() here when a strcat() does
the same thing without invoking undefined behavior.
Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
The deprecated i2c probe functionality doesn't work with OF
compatible strings, as it only checks for the i2c device id. Switch
to the new way of probing and grab the match data to select the
chip type.
Signed-off-by: Eddie James <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Much of the fwnode processing in the PCA955x driver is now in the
LEDs core driver, so pass the fwnode in the init data when
registering the LED device. In order to preserve the existing naming
scheme, check for an empty name and set it to the LED number.
Signed-off-by: Eddie James <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
In order to retain the LED state after a system reboot, check the
documented default-state device tree property during initialization.
Modify the behavior of the probe according to the property.
Signed-off-by: Eddie James <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Format the code. Add some variables to help shorten lines.
Signed-off-by: Eddie James <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Read the retain-state-shutdown device tree property to set the
existing LED_RETAIN_AT_SHUTDOWN flag. Then check the flag when
unregistering, and if set, don't set the brightness to OFF. This
is useful for systems that want to keep the HW state of the LED
across reboots.
Signed-off-by: Eddie James <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Commit b7fb14d3ac ("ide: remove the legacy ide driver") removes the
definition of the config IDE_GD_ATA.
So, remove the obsolete reference in ./drivers/leds/trigger/Kconfig.
Signed-off-by: Lukas Bulwahn <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
This patch adds support for "default-state" devicetree property, which
allows to defer pwm init to first use of led.
This allows to configure the PWM early in bootloader to let the LED
blink until an application in Linux userspace sets something different.
Signed-off-by: Denis Osterland-Heim <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
This patch introduces a new function to read initial
default_state from fwnode.
Suggested-by: Pavel Machek <[email protected]>
Signed-off-by: Denis Osterland-Heim <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Adjust initialization not to trigger Coverity warnings.
Reported-by: Colin Ian King <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
The one of the latest change to the driver reveals the problem that
the error codes from callee aren't propagated to the caller of
__sso_led_dt_parse(). Fix this accordingly.
Fixes: 9999908ca1 ("leds: lgm-sso: Put fwnode in any case during ->probe()")
Fixes: c3987cd2bc ("leds: lgm: Add LED controller driver for LGM SoC")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Some 2-in-1s with a detachable (USB) keyboard(dock) have mute-LEDs in
the speaker- and/or mic-mute keys on the keyboard.
Examples of this are the Lenovo Thinkpad10 tablet (with its USB kbd-dock)
and the HP x2 10 series.
The detachable nature of these keyboards means that the keyboard and
thus the mute LEDs may show up after the user (or userspace restoring
old mixer settings) has muted the speaker and/or mic.
Current LED-class devices with a default_trigger of "audio-mute" or
"audio-micmute" initialize the brightness member of led_classdev with
ledtrig_audio_get() before registering the LED.
This makes the software state after attaching the keyboard match the
actual audio mute state, e.g. cat /sys/class/leds/foo/brightness will
show the right value.
But before this commit nothing was actually calling the led_classdev's
brightness_set[_blocking] callback so the value returned by
ledtrig_audio_get() was never actually being sent to the hw, leading
to the mute LEDs staying in their default power-on state, after
attaching the keyboard, even if ledtrig_audio_get() returned a different
state.
This could be fixed by having the individual LED drivers call
brightness_set[_blocking] themselves after registering the LED,
but this really is something which should be done by a led-trigger
activate callback.
Add an activate callback for this, fixing the issue of the
mute LEDs being out of sync after (re)attaching the keyboard.
Cc: Takashi Iwai <[email protected]>
Fixes: faa2541f5b ("leds: trigger: Introduce audio mute LED trigger")
Reviewed-by: Marek Behún <[email protected]>
Signed-off-by: Hans de Goede <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
fwnode_get_next_available_child_node() bumps a reference counting of
a returned variable. We have to balance it whenever we return to
the caller.
Fixes: e1c6edcbea ("leds: rt8515: Add Richtek RT8515 LED driver")
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
device_get_next_child_node() bumps a reference counting of a returned variable.
We have to balance it whenever we return to the caller.
Fixes: 8cd7d6daba ("leds: lt3593: Add device tree probing glue")
Cc: Daniel Mack <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
It's easy to miss necessary clean up, e.g. firmware node reference counting,
during error path in ->probe(). Make it more robust by moving to a single
point of return.
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Currently the headers to be included look rather like a random set.
Update them a bit to reflect the reality.
While at it, drop unneeded dependcy to OF.
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
There is no user of of*.h headers, but mod_devicetable.h.
Update header block accordingly.
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Convert to use list_for_each_entry*() API insted of open coded variants.
It saves few lines of code and makes iteasier to read and maintain.
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
The idea of managed resources is that they will be cleaned up automatically
and in the proper order. Remove explicit GPIO cleanup.
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
When requesting GPIO line the probe can be deferred.
In such case don't spam logs with an error message.
This can be achieved by switching to dev_err_probe().
Fixes: c3987cd2bc ("leds: lgm: Add LED controller driver for LGM SoC")
Cc: Amireddy Mallikarjuna reddy <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
fwnode_get_next_child_node() bumps a reference counting of a returned variable.
We have to balance it whenever we return to the caller.
All the same in fwnode_for_each_child_node() case.
Fixes: c3987cd2bc ("leds: lgm: Add LED controller driver for LGM SoC")
Cc: Amireddy Mallikarjuna reddy <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
There is no user of of*.h headers, but mod_devicetable.h.
Update header block accordingly.
Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Oleh Kravchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
The error code is missing in this code scenario, add the error code
'-EINVAL' to the return value 'ret'.
Eliminate the follow smatch warning:
drivers/leds/leds-is31fl32xx.c:388 is31fl32xx_parse_dt() warn: missing
error code 'ret'.
Reported-by: Abaci Robot <[email protected]>
Signed-off-by: Jiapeng Chong <[email protected]>
Fixes: 9d7cffaf99 ("leds: Add driver for the ISSI IS31FL32xx family of LED controllers")
Acked-by: David Rivshin <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
We created a subdirectory for LED drivers that depend on
CONFIG_LEDS_CLASS_FLASH, and this driver does so let's
move it there.
Cc: Ingi Kim <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
We created a subdirectory for LED drivers that depend on
CONFIG_LEDS_CLASS_FLASH, and this driver does so let's
move it there.
Cc: Dan Murphy <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
We created a subdirectory for LED drivers that depend on
CONFIG_LEDS_CLASS_FLASH, and this driver does so let's
move it there.
Cc: Luca Weiss <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
We created a subdirectory for LED drivers that depend on
CONFIG_LEDS_CLASS_FLASH, and this driver does so let's
move it there.
Signed-off-by: Linus Walleij <[email protected]>
Acked-by: Jacek Anaszewski <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
We created a subdirectory for LED drivers that depend on
CONFIG_LEDS_CLASS_FLASH, and this driver does so let's
move it there.
Signed-off-by: Linus Walleij <[email protected]>
Acked-by: Sakari Ailus <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
We created a subdirectory for LED drivers that depend on
CONFIG_LEDS_CLASS_FLASH, and this driver does so let's
move it there.
Signed-off-by: Linus Walleij <[email protected]>
Acked-by: Jacek Anaszewski <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Pull LED updates from Pavel Machek:
"This contains quite a lot of fixes, with more fixes in my inbox that
did not make it (sorry)"
* tag 'leds-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds: (36 commits)
leds: lgm: Fix up includes
leds: ktd2692: Fix an error handling path
leds: as3645a: Fix error return code in as3645a_parse_node()
leds: turris-omnia: add missing MODULE_DEVICE_TABLE
leds: lp55xx: Initialize enable GPIO direction to output
leds: lm36274: Add missed property.h
leds: el15203000: Make error handling more robust
leds: pwm: Make error handling more robust
leds: lt3593: Make use of device properties
leds: lp50xx: Put fwnode in error case during ->probe()
leds: lm3697: Don't spam logs when probe is deferred
leds: lm3692x: Put fwnode in any case during ->probe()
leds: lm36274: Correct headers (of*.h -> mod_devicetable.h)
leds: lm36274: Put fwnode in error case during ->probe()
leds: lm3532: Make error handling more robust
leds: lm3532: select regmap I2C API
leds: lgm-sso: Drop duplicate NULL check for GPIO operations
leds: lgm-sso: Remove unneeded of_match_ptr()
leds: lgm-sso: Fix clock handling
leds: el15203000: Introduce to_el15203000_led() helper
...
This driver is including the legacy GPIO header <linux/gpio.h>
but the only thing it is using from that header is the wrong
define for GPIOF_DIR_OUT.
Fix it up by using GPIO_LINE_DIRECTION_OUT and including the
correct consumer and driver headers.
Cc: Amireddy Mallikarjuna reddy <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
In 'ktd2692_parse_dt()', if an error occurs after a successful
'regulator_enable()' call, we should call 'regulator_enable()'.
This is the same in 'ktd2692_probe()', if an error occurs after a
successful 'ktd2692_parse_dt()' call.
Instead of adding 'regulator_enable()' in several places, implement a
resource managed solution and simplify the remove function accordingly.
Fixes: b7da8c5c72 ("leds: Add ktd2692 flash LED driver")
Signed-off-by: Christophe JAILLET <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Return error code -ENODEV rather than '0' when the indicator node can not
be found.
Fixes: a56ba8fbcb ("media: leds: as3645a: Add LED flash class driver")
Reported-by: Hulk Robot <[email protected]>
Acked-by: Sakari Ailus <[email protected]>
Signed-off-by: Zhen Lei <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
This patch adds missing MODULE_DEVICE_TABLE definition which generates
correct modalias for automatic loading of this driver when it is built
as an external module.
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Zou Wei <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
The "Convert to use GPIO descriptors" commit changed the
initialization of the enable GPIO from GPIOF_DIR_OUT to
GPIOD_ASIS. This breaks systems where the GPIO does not
default to output. Changing the enable initialization
to GPIOD_OUT_LOW.
Signed-off-by: Doug Zobel <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
It appears that property.h has been included in some configurations implicitly,
but in some it's not and hence build may fail. Add missed property.h explicitly.
Fixes: e2e8e4e818 ("leds: lm36274: Correct headers (of*.h -> mod_devicetable.h)")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
It's easy to miss necessary clean up, e.g. firmware node reference counting,
during error path in ->probe(). Make it more robust by moving to a single
point of return.
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
It's easy to miss necessary clean up, e.g. firmware node reference counting,
during error path in ->probe(). Make it more robust by moving to a single
point of return.
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
Device property API allows to gather device resources from different sources,
such as ACPI. Convert the driver to unleash the power of device property API.
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
fwnode_for_each_child_node() bumps a reference counting of a returned variable.
We have to balance it whenever we return to the caller.
OTOH, the successful iteration will drop reference count under the hood, no need
to do it twice.
Fixes: 242b81170f ("leds: lp50xx: Add the LP50XX family of the RGB LED driver")
Cc: Dan Murphy <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
When requesting GPIO line the probe can be deferred.
In such case don't spam logs with an error message.
This can be achieved by switching to dev_err_probe().
Fixes: 5c1d824cda ("leds: lm3697: Introduce the lm3697 driver")
Cc: Dan Murphy <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
device_get_next_child_node() bumps a reference counting of a returned variable.
We have to balance it whenever we return to the caller.
Fixes: 9a5c1c64ac ("leds: lm3692x: Change DT calls to fwnode calls")
Cc: Dan Murphy <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
There is no user of of*.h headers, but mod_devicetable.h.
Update header block accordingly.
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
device_get_next_child_node() bumps a reference counting of a returned variable.
We have to balance it whenever we return to the caller.
In the older code the same is implied with device_for_each_child_node().
Fixes: 11e1bbc116 ("leds: lm36274: Introduce the TI LM36274 LED driver")
Fixes: a448fcf19c ("leds: lm36274: don't iterate through children since there is only one")
Cc: Dan Murphy <[email protected]>
Cc: Marek Behún <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
It's easy to miss necessary clean up, e.g. firmware node reference counting,
during error path in ->probe(). Make it more robust by moving to a single
point of return.
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>