History log of /linux-master/drivers/regulator/max8907-regulator.c
Revision Date Author Comments
# 259b93b2 16-Mar-2023 Douglas Anderson <dianders@chromium.org>

regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14

Probing of regulators can be a slow operation and can contribute to
slower boot times. This is especially true if a regulator is turned on
at probe time (with regulator-boot-on or regulator-always-on) and the
regulator requires delays (off-on-time, ramp time, etc).

While the overall kernel is not ready to switch to async probe by
default, as per the discussion on the mailing lists [1] it is believed
that the regulator subsystem is in good shape and we can move
regulator drivers over wholesale. There is no way to just magically
opt in all regulators (regulators are just normal drivers like
platform_driver), so we set PROBE_PREFER_ASYNCHRONOUS for all
regulators found in 'drivers/regulator' individually.

Given the number of drivers touched and the impossibility to test this
ahead of time, it wouldn't be shocking at all if this caused a
regression for someone. If there is a regression caused by this patch,
it's likely to be one of the cases talked about in [1]. As a "quick
fix", drivers involved in the regression could be fixed by changing
them to PROBE_FORCE_SYNCHRONOUS. That being said, the correct fix
would be to directly fix the problem that caused the issue with async
probe.

The approach here follows a similar approach that was used for the mmc
subsystem several years ago [2]. In fact, I ran nearly the same python
script to auto-generate the changes. The only thing I changed was to
search for "i2c_driver", "spmi_driver", and "spi_driver" in addition
to "platform_driver".

[1] https://lore.kernel.org/r/06db017f-e985-4434-8d1d-02ca2100cca0@sirena.org.uk
[2] https://lore.kernel.org/r/20200903232441.2694866-1-dianders@chromium.org/

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20230316125351.1.I2a4677392a38db5758dee0788b2cea5872562a82@changeid
Signed-off-by: Mark Brown <broonie@kernel.org>


# b08af72d 17-Jun-2020 Rikard Falkeborn <rikard.falkeborn@gmail.com>

regulator: max8907: Constify static structs

These are not modified so make them const to allow the compiler to put
them in read-only memory.

Before:
text data bss dec hex filename
2753 7328 0 10081 2761 drivers/regulator/max8907-regulator.o

After:
text data bss dec hex filename
9405 684 0 10089 2769 drivers/regulator/max8907-regulator.o

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Link: https://lore.kernel.org/r/20200617223247.25566-5-rikard.falkeborn@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 472b39c3 03-Oct-2019 Yizhuo <yzhai003@ucr.edu>

regulator: max8907: Fix the usage of uninitialized variable in max8907_regulator_probe()

Inside function max8907_regulator_probe(), variable val could
be uninitialized if regmap_read() fails. However, val is used
later in the if statement to decide the content written to
"pmic", which is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
Link: https://lore.kernel.org/r/20191003175813.16415-1-yzhai003@ucr.edu
Signed-off-by: Mark Brown <broonie@kernel.org>


# d2912cb1 04-Jun-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500

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 <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 88c9d47a 28-Jan-2017 Bhumika Goyal <bhumirks@gmail.com>

regulator: max8907-regulator: constify regulator_ops structure

Declare regulator_ops structure as const as it is only stored in the ops
field of a regulator_desc structure. This field is of type const, so
regulator_ops structures having this property can be made const too.

File size before: drivers/regulator/max8907-regulator.o
text data bss dec hex filename
1384 9424 256 11064 2b38 regulator/max8907-regulator.o

File size after: drivers/regulator/max8907-regulator.o
text data bss dec hex filename
2664 8400 0 11064 2b38 regulator/max8907-regulator.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6c794b26 20-Oct-2014 Wolfram Sang <wsa@kernel.org>

regulator: drop owner assignment from platform_drivers

A platform_driver does not need to set an owner, it will be populated by the
driver core.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# b8b27a44 09-Sep-2014 Guodong Xu <guodong.xu@linaro.org>

regulator: remove unnecessary of_node_get() to parent

These of_node_get() were added to balance refcount decrements inside of
of_find_node_by_name().
See: commit c92f5dd2c42f ("regulator: Add missing of_node_put()")

However of_find_node_by_name() was then replaced by of_get_child_by_name(),
which doesn't call of_node_put() against its input parameter.

So, need to remove these unnecessary of_node_get() calls.

Signed-off-by: Guodong Xu <guodong.xu@linaro.org>
Reviewed-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# f991525a 10-Mar-2014 Krzysztof Kozlowski <krzk@kernel.org>

regulator: max8907: Remove regulator_dev array from state container

Don't store array of regulator_dev returned by devm_regulator_register()
in state container. It isn't used anywhere outside of
max8907_regulator_probe() function.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# d016bdc7 20-Feb-2014 Sachin Kamat <sachin.kamat@linaro.org>

regulator: max8907: Remove redundant error message

kzalloc prints its own OOM message upon failure.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# c61f1401 14-Feb-2014 Sachin Kamat <sachin.kamat@linaro.org>

regulator: max8907: Use of_get_child_by_name

of_find_node_by_name walks the allnodes list, and can thus walk
outside of the parent node. Use of_get_child_by_name instead.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 5ecdf140 03-Sep-2013 Sachin Kamat <sachin.kamat@linaro.org>

regulator: max8907-regulator: Use devm_regulator_register

devm_* simplifies the code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>


# c92f5dd2 27-Jan-2013 Axel Lin <axel.lin@ingics.com>

regulator: Add missing of_node_put()

of_find_node_by_name() returns a node pointer with refcount incremented, use
of_node_put() on it when done.

of_find_node_by_name() will call of_node_put() against from parameter,
thus we also need to call of_node_get(from) before calling
of_find_node_by_name().

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# f40cbcb9 24-Jan-2013 Axel Lin <axel.lin@ingics.com>

regulator: max8907: Fix using wrong dev argument for calling of_regulator_match

The dev parameter is the device requesting the data.
In this case it should be &pdev->dev rather than pdev->dev.parent.

The dev parameter is used to call devm_kzalloc in of_get_regulator_init_data(),
which means this fixes a memory leak because the memory is allocated every time
probe() is called, thus it should be freed when this driver is unloaded.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 8dc995f5 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

regulator: remove use of __devexit

CONFIG_HOTPLUG is going away as an option so __devexit is no
longer needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# a5023574 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

regulator: remove use of __devinit

CONFIG_HOTPLUG is going away as an option so __devinit is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 5eb9f2b9 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

regulator: remove use of __devexit_p

CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# d154f0a6 25-Aug-2012 Axel Lin <axel.lin@gmail.com>

regulator: max8907: Add MODULE_ALIAS

This driver can be built as a module, add MODULE_ALIAS for it.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 5fc72f57 23-Aug-2012 Stephen Warren <swarren@nvidia.com>

regulator: max8907: fix use of possibly NULL idata

If a regulator is not used by a board, it's quite legitimate not to
provide platform data or a device tree node to configure it (i.e.
regulator_init_data). In that case, during MAX8907 regulator's
probe(), the idata variable will be NULL for that regulator. Prevent
dereferincing it.

If the MBATT regulator's init_data is not specified, or no name was
specified in the constraints, the regulator will be named based on
the regulator descriptor, so initialize mbatt_rail_name from there.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# db551682 20-Aug-2012 Stephen Warren <swarren@nvidia.com>

regulator: max8907: fix compile error when !CONFIG_OF

Fix the following:

CC [M] drivers/regulator/max8907-regulator.o
drivers/regulator/max8907-regulator.c: In function 'max8907_regulator_probe':
drivers/regulator/max8907-regulator.c:297:12: error: 'max8907_matches' undeclared (first use in this function)

by removing direct references to max8907_matches[], which only exists when
CONFIG_OF is defined.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 0764ef59 18-Aug-2012 Axel Lin <axel.lin@gmail.com>

regulator: max8907: Properly set pmic pointer in max8907_regulator_remove()

Add missing platform_get_drvdata() call in max8907_regulator_remove(), this
fixes below build warning:

CC [M] drivers/regulator/max8907-regulator.o
drivers/regulator/max8907-regulator.c: In function 'max8907_regulator_remove':
drivers/regulator/max8907-regulator.c:353:23: warning: 'pmic' is used uninitialized in this function [-Wuninitialized]

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# 7305608b 15-Aug-2012 Axel Lin <axel.lin@gmail.com>

regulator: max8907: Fix n_voltages for MAX8907B SD1

For linear voltage mapping, the n_voltages is (max - min) / step + 1

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>


# ffee1909 09-Aug-2012 Gyungoh Yoo <jack.yoo@maxim-ic.com>

regulator: add MAX8907 driver

The MAX8907 is an I2C-based power-management IC containing voltage
regulators, a reset controller, a real-time clock, and a touch-screen
controller.

The original driver was written by:
* Gyungoh Yoo <jack.yoo@maxim-ic.com>

Various fixes and enhancements by:
* Jin Park <jinyoungp@nvidia.com>
* Tom Cherry <tcherry@nvidia.com>
* Prashant Gaikwad <pgaikwad@nvidia.com>
* Dan Willemsen <dwillemsen@nvidia.com>
* Laxman Dewangan <ldewangan@nvidia.com>

During upstreaming, I (swarren):
* Converted to regmap.
* Allowed probing from device tree.
* Reworked the regulator driver to be represented as a single device that
provides multiple regulators, rather than as a device per regulator.
* Replaced many regulator ops with standard functions.
* Added ability to specify supplies for each regulator.
* Removed the WLED regulator. If/when we expose this in the driver, it
should be a backlight object not a regulator object.
* Renamed from max8907c->max8907, since the driver covers at least the
C and B revisions.
* General cleanup.

Signed-off-by: Gyungoh Yoo <jack.yoo@maxim-ic.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>