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


02 Feb, 2013

4 commits

  • The DT binding for the pwm-leds devices are similar to the gpio-leds type.
    LEDs are represented as sub-nodes of the pwm-leds device.
    The code for handling the DT boot is based on the code found in the
    leds-gpio driver and adapted to use PWMs instead of GPIOs.
    To avoid having custom cleanup code in case of DT boot the newly created
    devm_of_pwm_get() API is used to get the correct PWM instance.

    For usage see:
    Documentation/devicetree/bindings/leds/leds-pwm.txt

    Signed-off-by: Peter Ujfalusi
    Acked-by: Grant Likely
    Signed-off-by: Bryan Wu

    Peter Ujfalusi
     
  • The code looks more nicer if we use:

    while (i--)

    instead:
    if (i > 0)
    for (i = i - 1; i >= 0; i--)

    Signed-off-by: Peter Ujfalusi
    Signed-off-by: Bryan Wu

    Peter Ujfalusi
     
  • In order to be able to add device tree support for leds-pwm driver we need
    to rearrange the data structures used by the drivers.

    Signed-off-by: Peter Ujfalusi
    Signed-off-by: Bryan Wu

    Peter Ujfalusi
     
  • Update the driver to use the new API for requesting pwm so we can take
    advantage of the pwm_lookup table to find the correct pwm to be used for the
    LED functionality.

    Signed-off-by: Peter Ujfalusi
    Signed-off-by: Bryan Wu

    Peter Ujfalusi
     

16 Dec, 2012

1 commit

  • Pull LED subsystem update from Bryan Wu.

    * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: (47 commits)
    leds: leds-lp5521: return an error code on error in probe()
    leds: leds-clevo-mail: Use pr_* instead of printks
    leds: leds-rb532: Fix checkpatch errors
    leds: led-triggers: Fix checkpatch warnings
    leds: ledtrig-backlight: Fix checkpatch error
    leds: leds-wrap: Use instead of
    leds: leds-wm8350: Use dev_err instead of printk
    leds: leds-pwm: Fix checkpatch warning
    leds: leds-pca955x: Use dev_info instead of printk
    leds: leds-net48xx: Use linux/io.h instead of asm/io.h
    leds: leds-lt3593: Fix checkpatch warnings
    leds: leds-gpio: Use dev_info instead of printk
    leds: leds-da903x: Fix checkpatch error and warnings
    leds: leds-bd2802: Fix checkpatch warnings
    leds: leds-adp5520: Fix checkpatch warnings
    leds: led-class: Fix checkpatch warning
    leds: leds-ns2: use devm_gpio_request_one
    leds: leds-lt3593: use devm_gpio_request_one
    leds: leds-gpio: use devm_gpio_request_one
    leds: lp3944: Fix return value
    ...

    Linus Torvalds
     

29 Nov, 2012

2 commits


28 Nov, 2012

1 commit


24 Jul, 2012

1 commit


11 Jan, 2012

1 commit

  • Factor out some boilerplate code for platform driver registration into
    module_platform_driver.

    Signed-off-by: Axel Lin
    Acked-by: Haojian Zhuang [led-88pm860x.c]
    Acked-by: Mark Brown
    Cc: Richard Purdie
    Cc: Michael Hennerich
    Cc: Mike Rapoport
    Cc: Guennadi Liakhovetski
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Axel Lin