07 Oct, 2020
1 commit
-
Since commit 141f15c66d94 ("leds: pwm: remove header") that platform
interface is not usable from outside and there seems to be no in tree
user anymore. All in-tree users of the leds-pwm driver seem to use DT
currently. Getting rid of the old platform interface allows the
leds-pwm driver to switch over from 'devm_led_classdev_register()' to
'devm_led_classdev_register_ext()'.Signed-off-by: Alexander Dahl
Cc: Denis Osterland-Heim
Reviewed-by: Marek Behún
Signed-off-by: Pavel Machek
27 Sep, 2020
2 commits
-
Do the parsing of `linux,default-trigger` DT property to LED core.
Currently it is done in many different drivers and the code is repeated.This patch removes the parsing from 23 drivers:
an30259a, aw2013, bcm6328, bcm6358, cr0014114, el15203000, gpio,
is31fl32xx, lm3532, lm36274, lm3692x, lm3697, lp50xx, lp8860, lt3593,
max77650, mt6323, ns2, pm8058, pwm, syscon, tlc591xx and turris-omnia.There is one driver in drivers/input which parses this property on it's
own. I shall send a separate patch there after this is applied.There are still 8 drivers that parse this property on their own because
they do not pass the led_init_data structure to the registering
function. I will try to refactor those in the future.Signed-off-by: Marek Behún
Signed-off-by: Pavel Machek -
If LEDs are configured through device tree and the property 'label' is
omitted, the label is supposed to be generated from the properties
'function' and 'color' if present. While this works fine for e.g. the
'leds-gpio' driver, it did not for 'leds-pwm'.The reason is, you get this label naming magic only if you add a LED
device through 'devm_led_classdev_register_ext()' and pass a pointer to
the current device tree node.For the following node from dts the LED appeared as 'led-5' in sysfs
before and as 'red:debug' after this change.pwm_leds {
compatible = "pwm-leds";led-5 {
function = LED_FUNCTION_DEBUG;
color = ;
pwms = ;
max-brightness = ;linux,default-trigger = "heartbeat";
panic-indicator;
};
};Signed-off-by: Alexander Dahl
Cc: Marek Behún
Signed-off-by: Pavel Machek
09 Sep, 2020
1 commit
-
Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and also it prints the error value.Signed-off-by: Krzysztof Kozlowski
Signed-off-by: Pavel Machek
27 Apr, 2020
1 commit
-
led_pwm_set() now returns an error when setting the PWM fails.
Signed-off-by: Denis Osterland-Heim
Signed-off-by: Pavel Machek
21 Mar, 2020
3 commits
-
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:struct foo {
int stuff;
struct boo array[];
};By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.Also, notice that, dynamic memory allocations won't be affected by
this change:"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]This issue was found with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")Signed-off-by: Gustavo A. R. Silva
Signed-off-by: Pavel Machek -
This member seems to was a way to pass PWM period to the LED.
Since there is no header anymore, this is useless.Signed-off-by: Denis Osterland-Heim
Signed-off-by: Pavel Machek -
The header is only used by leds_pwm.c, so move contents to leds_pwm.c
and remove it.
Apply minor changes suggested by checkpatch.
Remove deprecated and unused pwm_id member.Suggested-by: Pavel Machek
Signed-off-by: Denis Osterland-Heim
Signed-off-by: Pavel Machek
27 Feb, 2020
2 commits
-
pwm_config(), pwm_enable() and pwm_disable() should get removed in the
long run. So update the driver to use the atomic API that is here to
stay.A few side effects:
- led_pwm_set() now returns an error when setting the PWM fails.
- During .probe() the PWM isn't disabled implicitly by pwm_apply_args()
any more.Signed-off-by: Uwe Kleine-König
Tested-by: Jeff LaBundy
Signed-off-by: Pavel Machek -
.pwm_period_ns is an unsigned integer. So when led->pwm_period_ns > 0
is false, we now assign 0 to a value that is already 0, so it doesn't
hurt and we can skip checking the actual value.Signed-off-by: Uwe Kleine-König
Tested-by: Jeff LaBundy
Signed-off-by: Pavel Machek
01 Sep, 2019
1 commit
-
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
Reviewed-by: Kees Cook
Signed-off-by: Jacek Anaszewski
26 Jul, 2019
1 commit
-
Replace of_led_classdev_register() with led_classdev_register_ext(), which
accepts easily extendable struct led_init_data, instead of the fixed
struct device_node argument. The latter can be now passed in an fwnode
property of the struct led_init_data.The modification is driven by the need for passing additional arguments
required for the forthcoming generic mechanism for composing LED names.
Currently the LED name is conveyed in the "name" char pointer property of
the struct led_classdev. This is redundant since LED class device name
is accessible throughout the whole LED class device life time via
associated struct device's kobj->name property.The change will not break any existing clients since the patch alters
also existing led_classdev{_flash}_register() macro wrappers, that pass
NULL in place of init_data, which leads to using legacy name
initialization path basing on the struct led_classdev's "name" property.Three existing users of devm_of_led_classdev_registers() are modified
to use devm_led_classdev_register(), which will not impact their
operation since they in fact didn't need to pass struct device_node on
registration from the beginning.Signed-off-by: Jacek Anaszewski
Cc: Baolin Wang
Cc: Dan Murphy
Cc: Daniel Mack
Cc: Linus Walleij
Cc: Oleh Kravchenko
Cc: Sakari Ailus
Cc: Simon Shields
Acked-by: Pavel Machek
09 Jul, 2019
1 commit
-
…erry.reding/linux-pwm
Pull pwm updates from Thierry Reding:
"This set of changes contains a new driver for SiFive SoCs as well as
enhancements to the core (device links are used to track dependencies
between PWM providers and consumers, support for PWM controllers via
ACPI, sysfs will now suspend/resume PWMs that it has claimed) and
various existing drivers"* tag 'pwm/for-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (37 commits)
pwm: fsl-ftm: Make sure to unlock mutex on failure
pwm: fsl-ftm: Use write protection for prescaler & polarity
pwm: fsl-ftm: More relaxed permissions for updating period
pwm: atmel-hlcdc: Add compatible for SAM9X60 HLCDC's PWM
pwm: bcm2835: Improve precision of PWM
leds: pwm: Support ACPI via firmware-node framework
pwm: Add support referencing PWMs from ACPI
pwm: rcar: Remove suspend/resume support
pwm: sysfs: Add suspend/resume support
pwm: Add power management descriptions
pwm: meson: Add documentation to the driver
pwm: meson: Add support PWM_POLARITY_INVERSED when disabling
pwm: meson: Don't cache struct pwm_state internally
pwm: meson: Read the full hardware state in meson_pwm_get_state()
pwm: meson: Simplify the calculation of the pre-divider and count
pwm: meson: Move pwm_set_chip_data() to meson_pwm_request()
pwm: meson: Add the per-channel register offsets and bits in a struct
pwm: meson: Add the meson_pwm_channel data to struct meson_pwm
pwm: meson: Pass struct pwm_device to meson_pwm_calc()
pwm: meson: Don't duplicate the polarity internally
...
26 Jun, 2019
1 commit
-
DT specific handling is replaced by firmware-node abstration to support
ACPI specification of PWM LEDS.Example ASL:
Device (PWML)
{
Name (_HID, "PRP0001")
Name (_DSD, Package () {
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () { Package () {"compatible",
Package () {"pwm-leds"}}}})Device (PWL0)
{
Name (_HID, "PRP0001")
Name (_DSD, Package () {
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () {
Package () {"label", "alarm-led"},
Package () {"pwms", Package ()
{\_SB_.PCI0.PWM, 0, 600000, 0}},
Package () {"linux,default-state", "off"}}})
}
}Signed-off-by: Nikolaus Voss
Acked-by: Pavel Machek
Signed-off-by: Thierry Reding
19 Jun, 2019
1 commit
-
Based on 2 normalized pattern(s):
this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundationthis program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation #extracted by the scancode license scanner the SPDX license identifier
GPL-2.0-only
has been chosen to replace the boilerplate/reference in 4122 file(s).
Signed-off-by: Thomas Gleixner
Reviewed-by: Enrico Weigelt
Reviewed-by: Kate Stewart
Reviewed-by: Allison Randal
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman
09 Dec, 2018
2 commits
-
The PWM leds can be instantiated from Device Tree so pass the
respective device node to LED core. This provides the LED system with
proper device node and exposes it through uevent.Signed-off-by: Krzysztof Kozlowski
Signed-off-by: Jacek Anaszewski -
Simplify the exit path with resource-managed version of registering LED
class device. The code should be functionally the same, except that on
device removal the led_pwm_priv->num_leds is not decremented to zero
(which should not have any effect as device is going away).Signed-off-by: Krzysztof Kozlowski
Signed-off-by: Jacek Anaszewski
09 Sep, 2018
1 commit
-
When probing, if we fail to get the pwm due to probe deferal, we shouldn't
print an error message. Just be silent in this case.Signed-off-by: Jerome Brunet
Signed-off-by: Jacek Anaszewski
09 Jan, 2018
1 commit
-
There is nothing provided by that is used here,
so remove this unneeded header file.Signed-off-by: Fabio Estevam
Signed-off-by: Jacek Anaszewski
04 Jan, 2017
1 commit
-
PWM devices have all been marked as "might sleep" since v4.5. It no
longer makes sense to keep the alternative code paths around because
it is effectively dead code.Signed-off-by: Thierry Reding
17 May, 2016
1 commit
-
The PWM framework has clarified the concept of reference PWM config (the
platform dependent config retrieved from the DT or the PWM lookup table)
and real PWM state.Use pwm_get_args() when the PWM user wants to retrieve this reference
config and not the current state.This is part of the rework allowing the PWM framework to support
hardware readout and expose real PWM state even when the PWM has just
been requested (before the user calls pwm_config/enable/disable()).Signed-off-by: Boris Brezillon
Acked-by: Jacek Anaszewski
Signed-off-by: Thierry Reding
04 Jan, 2016
3 commits
-
Signed-off-by: Uwe Kleine-König
Signed-off-by: Jacek Anaszewski -
Some PWMs are disabled by default or the default pin setting
does not match the LED_OFF state (e.g., active-low leds).
Hence, the driver may end up reporting 0 brightness, but
the leds are actually on using full brightness, because
it never enforces its default configuration.
So enforce it by calling led_pwm_set() after successfully
registering the device.Tested on a Phytec phyFLEX i.MX6Q board based on kernel
v3.19.5.Signed-off-by: Markus Hofstaetter
Tested-by: Markus Hofstaetter
Signed-off-by: Jacek Anaszewski -
Now the core implements the work queue, remove it from the drivers,
and switch to using brightness_set_blocking op.Signed-off-by: Jacek Anaszewski
Cc: Raphael Assenat
25 Feb, 2015
1 commit
-
pwm_get_period() is called twice in case the child parameter is set. I
assume retrieving this parameter once is enough therefore this patch
removes the conditial invocation of pwm_get_period().Signed-off-by: Sebastian Andrzej Siewior
Signed-off-by: Bryan Wu
20 Oct, 2014
1 commit
-
A platform_driver does not need to set an owner, it will be populated by the
driver core.Signed-off-by: Wolfram Sang
13 Jun, 2014
1 commit
-
Pull LED updates from Bryan Wu:
"I just found merge window is open and I'm quite busy and almost forget
to send out this pull request. Thanks Russell and Alexandre ping me
about this.So basically we got some clean up and leds-pwm fixing patches from
Russell"* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds:
leds: Remove duplicated OOM message for individual driver
drivers/leds: Replace __get_cpu_var use through this_cpu_ptr
leds: lp55xx: add DT bindings for LP55231
leds: 88pm860x: Fix missing refcount decrement for parent of_node
leds: 88pm860x: Use of_get_child_by_name
leds: leds-pwm: add DT support for LEDs wired to supply
leds: leds-pwm: implement PWM inversion
leds: leds-pwm: convert OF parsing code to use led_pwm_add()
leds: leds-pwm: provide a common function to setup a single led-pwm device
leds: pca9685: Remove leds-pca9685 driver
dell-led: add mic mute led interface
21 May, 2014
1 commit
-
The PWM core is now able to initialize the PWM period from a lookup
table defined by board files. Use it if available and fallback to the
value supplied in pwm_period_ns.Signed-off-by: Alexandre Belloni
Signed-off-by: Thierry Reding
08 May, 2014
4 commits
-
The non-DT driver allowed an active low property to be specified, but DT
is missing this in its description. Add the property to the DT binding
document, making it optional. It defaults to active high, which retains
compatibility with existing descriptions.This should only be used for causes where the LED is wired to supply,
and the PWM does not sensibly support its own inversion.Signed-off-by: Russell King
Signed-off-by: Bryan Wu -
Some PWM outputs are wired such that the LED they're controlling is
connected to supply rather than ground. These PWMs may not support
output inversion, or when they do, disabling the PWM may set the
PWM output low, causing a "brightness" value of zero to turn the LED
fully on.The platform data for this driver already indicates that this was
thought about, and we have the "active_low" property there already.
However, the implementation for this is missing.Add the trivial implementation for this feature.
Signed-off-by: Russell King
Acked-by: Thierry Reding
Signed-off-by: Bryan Wu -
Convert the OF parsing code to use the common PWM LED registration code,
which means we have a consistent method, and single point where the
registration happens for both paths.Signed-off-by: Russell King
Signed-off-by: Bryan Wu -
Provide a common function to setup a single led-pwm device, replacing
the platform data initialisation path with this function. This allows
us to have a common method of creating these devices in a consistent
manner, which then allows us to place the probe failure cleanup in one
place.Signed-off-by: Russell King
Signed-off-by: Bryan Wu
08 Apr, 2014
1 commit
-
When probing with DT, we add each LED one at a time. If we find a LED
without a PWM device (because it is not available yet) we fail the
initialisation, unregister previous LEDs, and then by way of managed
resources, we free the structure.The problem with this is we may have a scheduled and active work_struct
in this structure, and this results in a nasty kernel oops.We need to cancel this work_struct properly upon cleanup - and the
cleanup we require is the same cleanup as we do when the LED platform
device is removed. Rather than writing this same code three times,
move it into a separate function and use it in all three places.Fixes: c971ff185f64 ("leds: leds-pwm: Defer led_pwm_set() if PWM can sleep")
Signed-off-by: Russell King
Signed-off-by: Bryan Wu
28 Feb, 2014
1 commit
-
None of these files are actually using any __init type directives
and hence don't need to include . Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.Cc: Bryan Wu
Cc: Richard Purdie
Cc: linux-leds@vger.kernel.org
Signed-off-by: Paul Gortmaker
Signed-off-by: Bryan Wu
28 Jan, 2014
2 commits
-
This removes a warning on non-DT-enabled platforms:
drivers/leds/leds-pwm.c: In function 'led_pwm_create_of':
drivers/leds/leds-pwm.c:88:22: warning: unused variable 'node'Really caused by the local variable that is assigned to and then never
used. Just do away with the local var, it's not needed.Technically this code path can never be entered without DT enabled,
since there's an earlier check about number of children in the calling
function, but the compiler can't see that.Signed-off-by: Olof Johansson
Signed-off-by: Bryan Wu -
Overflow maybe occurs when calculates the duty time. For instance,
the period time is 990000000ns, and the max_brightness is 127, when
setting the brightness to 12, the duty value will be 25906026ns, but
it should be 93543307ns.Signed-off-by: Bryan Wu
03 Dec, 2013
1 commit
-
We need to make sure that the error code from devm_of_pwm_get() is the one
the module returns in case of failure.
Restructure the code to make this possible for DT booted case.
With this patch the driver can ask for deferred probing when the board is
booted with DT.
Fixes for example omap4-sdp board's keyboard backlight led.Signed-off-by: Peter Ujfalusi
Signed-off-by: Bryan Wu
23 Oct, 2013
1 commit
-
The data structure of_match_ptr() protects is always compiled in.
Hence of_match_ptr() is not needed.Signed-off-by: Sachin Kamat
Signed-off-by: Bryan Wu
27 Aug, 2013
1 commit
-
Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly.Signed-off-by: Jingoo Han
Signed-off-by: Bryan Wu
02 Apr, 2013
1 commit
-
Call to led_pwm_set() can happen inside atomic context, like triggers.
If the PWM call can sleep, defer using a worker.Signed-off-by: Florian Vaussard
Reviewed-by: Peter Ujfalusi
Acked-by: Thierry Reding
Signed-off-by: Bryan Wu