Skip to content

Commit 6eabfc0

Browse files
diandersbroonie
authored andcommitted
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>
1 parent f2906aa commit 6eabfc0

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

drivers/regulator/core.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4783,22 +4783,26 @@ int regulator_bulk_get(struct device *dev, int num_consumers,
47834783
consumers[i].consumer = regulator_get(dev,
47844784
consumers[i].supply);
47854785
if (IS_ERR(consumers[i].consumer)) {
4786-
ret = PTR_ERR(consumers[i].consumer);
47874786
consumers[i].consumer = NULL;
4787+
ret = dev_err_probe(dev, PTR_ERR(consumers[i].consumer),
4788+
"Failed to get supply '%s'",
4789+
consumers[i].supply);
47884790
goto err;
47894791
}
4792+
4793+
if (consumers[i].init_load_uA > 0) {
4794+
ret = regulator_set_load(consumers[i].consumer,
4795+
consumers[i].init_load_uA);
4796+
if (ret) {
4797+
i++;
4798+
goto err;
4799+
}
4800+
}
47904801
}
47914802

47924803
return 0;
47934804

47944805
err:
4795-
if (ret != -EPROBE_DEFER)
4796-
dev_err(dev, "Failed to get supply '%s': %pe\n",
4797-
consumers[i].supply, ERR_PTR(ret));
4798-
else
4799-
dev_dbg(dev, "Failed to get supply '%s', deferring\n",
4800-
consumers[i].supply);
4801-
48024806
while (--i >= 0)
48034807
regulator_put(consumers[i].consumer);
48044808

include/linux/regulator/consumer.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,21 @@ struct regulator;
171171
/**
172172
* struct regulator_bulk_data - Data used for bulk regulator operations.
173173
*
174-
* @supply: The name of the supply. Initialised by the user before
175-
* using the bulk regulator APIs.
176-
* @consumer: The regulator consumer for the supply. This will be managed
177-
* by the bulk API.
174+
* @supply: The name of the supply. Initialised by the user before
175+
* using the bulk regulator APIs.
176+
* @init_load_uA: After getting the regulator, regulator_set_load() will be
177+
* called with this load. Initialised by the user before
178+
* using the bulk regulator APIs.
179+
* @consumer: The regulator consumer for the supply. This will be managed
180+
* by the bulk API.
178181
*
179182
* The regulator APIs provide a series of regulator_bulk_() API calls as
180183
* a convenience to consumers which require multiple supplies. This
181184
* structure is used to manage data for these calls.
182185
*/
183186
struct regulator_bulk_data {
184187
const char *supply;
188+
int init_load_uA;
185189
struct regulator *consumer;
186190

187191
/* private: Internal use */

0 commit comments

Comments
 (0)