mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 13:11:40 +00:00
regulator: core: Allow specifying an initial load w/ the bulk API
There are a number of drivers that follow a pattern that looks like this: 1. Use the regulator bulk API to get a bunch of regulators. 2. Set the load on each of the regulators to use whenever the regulators are enabled. Let's make this easier by just allowing the drivers to pass the load in. As part of this change we need to move the error printing in regulator_bulk_get() around; let's switch to the new dev_err_probe() to simplify it. Signed-off-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20220726103631.v2.4.Ie85f68215ada39f502a96dcb8a1f3ad977e3f68a@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
f2906aa863
commit
6eabfc018e
@ -4783,22 +4783,26 @@ int regulator_bulk_get(struct device *dev, int num_consumers,
|
|||||||
consumers[i].consumer = regulator_get(dev,
|
consumers[i].consumer = regulator_get(dev,
|
||||||
consumers[i].supply);
|
consumers[i].supply);
|
||||||
if (IS_ERR(consumers[i].consumer)) {
|
if (IS_ERR(consumers[i].consumer)) {
|
||||||
ret = PTR_ERR(consumers[i].consumer);
|
|
||||||
consumers[i].consumer = NULL;
|
consumers[i].consumer = NULL;
|
||||||
|
ret = dev_err_probe(dev, PTR_ERR(consumers[i].consumer),
|
||||||
|
"Failed to get supply '%s'",
|
||||||
|
consumers[i].supply);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (consumers[i].init_load_uA > 0) {
|
||||||
|
ret = regulator_set_load(consumers[i].consumer,
|
||||||
|
consumers[i].init_load_uA);
|
||||||
|
if (ret) {
|
||||||
|
i++;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (ret != -EPROBE_DEFER)
|
|
||||||
dev_err(dev, "Failed to get supply '%s': %pe\n",
|
|
||||||
consumers[i].supply, ERR_PTR(ret));
|
|
||||||
else
|
|
||||||
dev_dbg(dev, "Failed to get supply '%s', deferring\n",
|
|
||||||
consumers[i].supply);
|
|
||||||
|
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
regulator_put(consumers[i].consumer);
|
regulator_put(consumers[i].consumer);
|
||||||
|
|
||||||
|
@ -171,10 +171,13 @@ struct regulator;
|
|||||||
/**
|
/**
|
||||||
* struct regulator_bulk_data - Data used for bulk regulator operations.
|
* struct regulator_bulk_data - Data used for bulk regulator operations.
|
||||||
*
|
*
|
||||||
* @supply: The name of the supply. Initialised by the user before
|
* @supply: The name of the supply. Initialised by the user before
|
||||||
* using the bulk regulator APIs.
|
* using the bulk regulator APIs.
|
||||||
* @consumer: The regulator consumer for the supply. This will be managed
|
* @init_load_uA: After getting the regulator, regulator_set_load() will be
|
||||||
* by the bulk API.
|
* called with this load. Initialised by the user before
|
||||||
|
* using the bulk regulator APIs.
|
||||||
|
* @consumer: The regulator consumer for the supply. This will be managed
|
||||||
|
* by the bulk API.
|
||||||
*
|
*
|
||||||
* The regulator APIs provide a series of regulator_bulk_() API calls as
|
* The regulator APIs provide a series of regulator_bulk_() API calls as
|
||||||
* a convenience to consumers which require multiple supplies. This
|
* a convenience to consumers which require multiple supplies. This
|
||||||
@ -182,6 +185,7 @@ struct regulator;
|
|||||||
*/
|
*/
|
||||||
struct regulator_bulk_data {
|
struct regulator_bulk_data {
|
||||||
const char *supply;
|
const char *supply;
|
||||||
|
int init_load_uA;
|
||||||
struct regulator *consumer;
|
struct regulator *consumer;
|
||||||
|
|
||||||
/* private: Internal use */
|
/* private: Internal use */
|
||||||
|
Loading…
Reference in New Issue
Block a user