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

    Alexander Dahl
     

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

    Marek Behún
     
  • 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

    Alexander Dahl
     

09 Sep, 2020

1 commit


27 Apr, 2020

1 commit


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

    Gustavo A. R. Silva
     
  • 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

    Denis Osterland-Heim
     
  • 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

    Denis Osterland-Heim
     

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

    Uwe Kleine-König
     
  • .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

    Uwe Kleine-König
     

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

    Gustavo A. R. Silva
     

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

    Jacek Anaszewski
     

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
    ...

    Linus Torvalds
     

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

    Nikolaus Voss
     

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 foundation

    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 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

    Thomas Gleixner
     

09 Dec, 2018

2 commits


09 Sep, 2018

1 commit


09 Jan, 2018

1 commit


04 Jan, 2017

1 commit


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

    Boris Brezillon
     

04 Jan, 2016

3 commits


25 Feb, 2015

1 commit


20 Oct, 2014

1 commit


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

    Linus Torvalds
     

21 May, 2014

1 commit


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

    Russell King
     
  • 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

    Russell King
     
  • 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

    Russell King
     
  • 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

    Russell King
     

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

    Russell King
     

28 Feb, 2014

1 commit


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

    Olof Johansson
     
  • 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

    Xiubo Li
     

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

    Peter Ujfalusi
     

23 Oct, 2013

1 commit


27 Aug, 2013

1 commit


02 Apr, 2013

1 commit