27 Sep, 2020

5 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
     
  • By using struct led_init_data when registering we do not need to parse
    `label` DT property. Moreover `label` is deprecated and if it is not
    present but `color` and `function` are, LED core will compose a name
    from these properties instead.

    Signed-off-by: Marek Behún
    Cc: H. Nikolaus Schaller
    Cc: David Rivshin
    Signed-off-by: Pavel Machek

    Marek Behún
     
  • Various drivers count and iterate over OF children nodes via
    of_get_child_count and for_each_child_of_node. Instead they should use
    of_get_available_child_count and for_each_available_child_of_node, so
    that if a given node has the `status` property set to `disabled`, the
    child will be ignored.

    Signed-off-by: Marek Behún
    Cc: Andrew Lunn
    Cc: Andrey Utkin
    Cc: Baolin Wang
    Cc: Baolin Wang
    Cc: Benjamin Herrenschmidt
    Cc: Christian Mauderer
    Cc: Chunyan Zhang
    Cc: Dan Murphy
    Cc: David Rivshin
    Cc: Haojian Zhuang
    Cc: H. Nikolaus Schaller
    Cc: Michael Ellerman
    Cc: Milo Kim
    Cc: NeilBrown
    Cc: Nikita Travkin
    Cc: Orson Zhai
    Cc: Paul Mackerras
    Cc: Philippe Retornaz
    Cc: Riku Voipio
    Cc: Simon Guinot
    Cc: Simon Shields
    Cc: Vasant Hegde
    Cc: Xiaotong Lu
    Signed-off-by: Pavel Machek

    Marek Behún
     
  • The dev_of_node function should be preferred.

    Signed-off-by: Marek Behún
    Cc: Orson Zhai
    Cc: Baolin Wang
    Cc: Chunyan Zhang
    Cc: Sean Wang
    Cc: Matthias Brugger
    Cc: Riku Voipio
    Signed-off-by: Pavel Machek

    Marek Behún
     
  • Simply use device_get_match_data instead of matching against the match
    table again.

    Signed-off-by: Marek Behún
    Cc: H. Nikolaus Schaller
    Cc: David Rivshin
    Cc: Sebastian Reichel
    Cc: Christian Mauderer
    Cc: Andrew Lunn
    Signed-off-by: Pavel Machek

    Marek Behún
     

21 Mar, 2020

1 commit

  • 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
     

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 is31fl32xx_priv {
    ...
    struct is31fl32xx_led_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_is31fl32xx_priv(int num_leds)
    {
    return sizeof(struct is31fl32xx_priv) +
    (sizeof(struct is31fl32xx_led_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
    Acked-by: Pavel Machek
    Signed-off-by: Jacek Anaszewski

    Gustavo A. R. Silva
     

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
     

13 Aug, 2017

1 commit

  • Now that we have a custom printf format specifier, convert users of
    full_name to use %pOF instead. This is preparation to remove storing
    of the full path string for each node.

    Signed-off-by: Rob Herring
    Cc: Richard Purdie
    Cc: linux-leds@vger.kernel.org
    Acked-by: Pavel Machek
    Signed-off-by: Jacek Anaszewski

    Rob Herring
     

19 Jul, 2016

2 commits


14 Mar, 2016

2 commits

  • Si-En Technology was acquired by ISSI in 2011, and it appears that
    the IS31FL3218/IS31FL3216 are just rebranded SN3218/SN3216 devices.

    Add the "si-en,sn3218" and "si-en,sn3216" compatible strings into the
    IS31FL32XX driver as aliases for the issi equivalents, and update
    binding documentation.

    Datasheets:
    IS31FL3218: http://www.issi.com/WW/pdf/31FL3218.pdf
    SN3218: http://www.si-en.com/uploadpdf/s2011517171720.pdf

    IS31FL3216: http://www.issi.com/WW/pdf/31FL3216.pdf
    SN3216: http://www.si-en.com/uploadpdf/SN3216201152410148.pdf

    Signed-off-by: David Rivshin
    Acked-by: Rob Herring
    Tested-by: Stefan Wahren
    Signed-off-by: Jacek Anaszewski

    David Rivshin
     
  • The IS31FL32xx family of LED controllers are I2C devices with multiple
    constant-current channels, each with independent 256-level PWM control.

    Datasheets: http://www.issi.com/US/product-analog-fxled-driver.shtml

    This has been tested on the IS31FL3236 and IS31FL3216, on an ARM
    (TI am335x) platform.

    The programming paradigm of these devices is similar in the following
    ways:
    - All registers are 8 bit
    - All LED control registers are write-only
    - Each LED channel has a PWM register (0-255)
    - PWM register writes are shadowed until an Update register is poked
    - All have a concept of Software Shutdown, which disables output

    However, there are some differences in devices:
    - 3236/3235 have a separate Control register for each LED,
    (3218/3216 pack the enable bits into fewer registers)
    - 3236/3235 have a per-channel current divisor setting
    - 3236/3235 have a Global Control register that can turn off all LEDs
    - 3216 is unique in a number of ways
    - OUT9-OUT16 can be configured as GPIOs instead of LED controls
    - LEDs can be programmed with an 8-frame animation, with
    programmable delay between frames
    - LEDs can be modulated by an input audio signal
    - Max output current can be adjusted from 1/4 to 2x globally
    - Has a Configuration register instead of a Shutdown register

    This driver currently only supports the base PWM control function
    of these devices. The following features of these devices are not
    implemented, although it should be possible to add them in the future:
    - All devices are capable of going into a lower-power "software
    shutdown" mode.
    - The is31fl3236 and is31fl3235 can reduce the max output current
    per-channel with a divisor of 1, 2, 3, or 4.
    - The is31fl3216 can use some LED channels as GPIOs instead.
    - The is31fl3216 can animate LEDs in hardware.
    - The is31fl3216 can modulate LEDs according to an audio input.
    - The is31fl3216 can reduce/increase max output current globally.

    Signed-off-by: David Rivshin
    Signed-off-by: Jacek Anaszewski

    David Rivshin