Skip to content

Commit

Permalink
regulator: core: add callback to perform runtime init
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jerome Brunet authored and Mark Brown committed Oct 22, 2024
1 parent cd7a38c commit cfcdf39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5758,6 +5758,12 @@ regulator_register(struct device *dev,
goto wash;
}

if (regulator_desc->init_cb) {
ret = regulator_desc->init_cb(rdev, config);
if (ret < 0)
goto wash;
}

if ((rdev->supply_name && !rdev->supply) &&
(rdev->constraints->always_on ||
rdev->constraints->boot_on)) {
Expand Down
2 changes: 2 additions & 0 deletions include/linux/regulator/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ struct regulator_desc {
int (*of_parse_cb)(struct device_node *,
const struct regulator_desc *,
struct regulator_config *);
int (*init_cb)(struct regulator_dev *,
struct regulator_config *);
int id;
unsigned int continuous_voltage_range:1;
unsigned n_voltages;
Expand Down

0 comments on commit cfcdf39

Please sign in to comment.