Skip to content

Commit cfcdf39

Browse files
jbrun3tbroonie
authored andcommitted
regulator: core: add callback to perform runtime init
Provide an initialisation callback to handle runtime parameters. The idea is similar to the regulator_init() callback, but it provides regulator specific structures, instead of just the driver specific data. As an example, this allows the driver to amend the regulator constraints based on runtime parameters if necessary. Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Link: https://patch.msgid.link/20241008-regulator-ignored-data-v2-2-d1251e0ee507@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent cd7a38c commit cfcdf39

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/regulator/core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5758,6 +5758,12 @@ regulator_register(struct device *dev,
57585758
goto wash;
57595759
}
57605760

5761+
if (regulator_desc->init_cb) {
5762+
ret = regulator_desc->init_cb(rdev, config);
5763+
if (ret < 0)
5764+
goto wash;
5765+
}
5766+
57615767
if ((rdev->supply_name && !rdev->supply) &&
57625768
(rdev->constraints->always_on ||
57635769
rdev->constraints->boot_on)) {

include/linux/regulator/driver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ struct regulator_desc {
365365
int (*of_parse_cb)(struct device_node *,
366366
const struct regulator_desc *,
367367
struct regulator_config *);
368+
int (*init_cb)(struct regulator_dev *,
369+
struct regulator_config *);
368370
int id;
369371
unsigned int continuous_voltage_range:1;
370372
unsigned n_voltages;

0 commit comments

Comments
 (0)