13 Feb, 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
    inadvertenly introduced[3] to the codebase from now on.

    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
    Acked-by: Adam Thomson
    Link: https://lore.kernel.org/r/20200211234612.GA28682@embeddedor
    Signed-off-by: Mark Brown

    Gustavo A. R. Silva
     

23 Nov, 2019

1 commit


15 Nov, 2019

2 commits

  • This patch adds of_map_mode support for bucks to set regulator modes
    from within regulator framework.

    Signed-off-by: Christoph Fritz
    Signed-off-by: Christian Hemp
    Signed-off-by: Stefan Riedmueller
    Link: https://lore.kernel.org/r/1573652416-9848-3-git-send-email-chf.fritz@googlemail.com
    Signed-off-by: Mark Brown

    Christoph Fritz
     
  • This patch refactors buck modes into a header file so that device trees
    can make use of these mode constants.

    The new header filename uses da9063 because DA9063 was the earlier chip
    and its driver code will want updating at some point in a similar manner.

    Signed-off-by: Christoph Fritz
    Link: https://lore.kernel.org/r/1573652416-9848-2-git-send-email-chf.fritz@googlemail.com
    Signed-off-by: Mark Brown

    Christoph Fritz
     

09 Oct, 2019

2 commits


07 Oct, 2019

1 commit


24 Sep, 2019

1 commit

  • Currently the suspend reg_field maps to the pmic voltage selection bits
    and is used during suspend_enabe/disable() and during get_mode(). This
    seems to be wrong for both use cases.

    Use case one (suspend_enabe/disable):
    Those callbacks are used to mark a regulator device as enabled/disabled
    during suspend. Marking the regulator enabled during suspend is done by
    the LDOx_CONF/BUCKx_CONF bit within the LDOx_CONT/BUCKx_CONT registers.
    Setting this bit tells the DA9062 PMIC state machine to keep the
    regulator on in POWERDOWN mode and switch to suspend voltage.

    Use case two (get_mode):
    The get_mode callback is used to retrieve the active mode state. Since
    the regulator-setting-A is used for the active state and
    regulator-setting-B for the suspend state there is no need to check
    which regulator setting is active.

    Fixes: 4068e5182ada ("regulator: da9062: DA9062 regulator driver")
    Signed-off-by: Marco Felsch
    Reviewed-by: Adam Thomson
    Link: https://lore.kernel.org/r/20190917124246.11732-2-m.felsch@pengutronix.de
    Signed-off-by: Mark Brown

    Marco Felsch
     

02 Aug, 2019

1 commit

  • We don't need dev_err() messages when platform_get_irq() fails now that
    platform_get_irq() prints an error message itself when something goes
    wrong. Let's remove these prints with a simple semantic patch.

    //
    @@
    expression ret;
    struct platform_device *E;
    @@

    ret =
    (
    platform_get_irq(E, ...)
    |
    platform_get_irq_byname(E, ...)
    );

    if ( \( ret < 0 \| ret

    While we're here, remove braces on if statements that only have one
    statement (manually).

    Cc: Liam Girdwood
    Cc: Mark Brown
    Cc: Greg Kroah-Hartman
    Signed-off-by: Stephen Boyd
    Link: https://lore.kernel.org/r/20190730181557.90391-38-swboyd@chromium.org
    Signed-off-by: Mark Brown

    Stephen Boyd
     

20 Jun, 2019

1 commit

  • According to the DA9061 and DA9062 datasheets the LDO voltage selection
    registers have a lower value of 0x02. This applies to voltage registers
    VLDO1_A, VLDO2_A, VLDO3_A and VLDO4_A. This linear offset of 0x02 was
    previously not observed by the driver, causing the LDO output voltage to
    be systematically lower by two steps (= 0.1V).

    This patch fixes the minimum linear selector offset by setting it to a
    value of 2 and increases the n_voltages by the same amount allowing
    voltages in the range 0x02 -> 0.9V to 0x38 -> 3.6V to be correctly
    selected. Also fixes an incorrect calculaton for the n_voltages value in
    the regulator LDO2.

    These fixes effect all LDO regulators for DA9061 and DA9062.

    Acked-by: Steve Twiss
    Tested-by: Steve Twiss
    Signed-off-by: Felix Riemann
    Signed-off-by: Steve Twiss
    Signed-off-by: Mark Brown

    Felix Riemann
     

03 May, 2019

1 commit


18 Mar, 2019

1 commit


13 Mar, 2019

1 commit

  • The mutex for the regulator_dev must be controlled by the caller of
    the regulator_notifier_call_chain(), as described in the comment
    for that function.

    Failure to mutex lock and unlock surrounding the notifier call results
    in a kernel WARN_ON_ONCE() which will dump a backtrace for the
    regulator_notifier_call_chain() when that function call is first made.
    The mutex can be controlled using the regulator_lock/unlock() API.

    Fixes: 4068e5182ada ("regulator: da9062: DA9062 regulator driver")
    Suggested-by: Adam Thomson
    Signed-off-by: Steve Twiss
    Signed-off-by: Mark Brown

    Steve Twiss
     

26 Feb, 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 foo {
    int stuff;
    struct boo entry[];
    };

    size = sizeof(struct foo) + count * sizeof(struct boo);
    instance = alloc(size, GFP_KERNEL)

    Instead of leaving these open-coded and prone to type mistakes, we can
    now use the new struct_size() helper:

    instance = alloc(struct_size(instance, entry, count), GFP_KERNEL)

    Notice that, in this case, variable size is not necessary, hence it is
    removed.

    This code was detected with the help of Coccinelle.

    Signed-off-by: Gustavo A. R. Silva
    Acked-by: Steve Twiss
    Signed-off-by: Mark Brown

    Gustavo A. R. Silva
     

19 Feb, 2019

1 commit


28 Jan, 2019

1 commit


08 Jun, 2017

1 commit

  • Regulator support for the DA9061 is added into the DA9062 regulator driver.

    The regulators for DA9061 differ from those of DA9062.
    A new DA9061 enumeration list for the LDOs and Bucks supported by this
    device is added. Regulator information added: the old regulator
    information for DA9062 is renamed from local_regulator_info[] to
    local_da9062_regulator_info[] and a new array is added to support
    local_da9061_regulator_info[].

    The probe() function switches on the da9062_compatible_types enumeration
    and configures the correct da9062_regulator_info array and number of
    regulator entries.

    Kconfig is updated to reflect support for DA9061 and DA9062 regulators.

    Signed-off-by: Steve Twiss
    Signed-off-by: Mark Brown

    Steve Twiss
     

23 Dec, 2015

1 commit


15 Jul, 2015

1 commit


02 Jun, 2015

1 commit

  • Remove the unused variable build warning for reg_matches that appears
    during the compilation of the DA9062 regulator driver.

    da9062-regulator.c: In function da9062_regulator_probe:
    da9062-regulator.c:727:29: warning: unused variable reg_matches

    Signed-off-by: Steve Twiss
    Signed-off-by: Mark Brown

    S Twiss
     

25 May, 2015

1 commit


21 May, 2015

1 commit