]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
regulator: core: add callback to perform runtime init
authorJerome Brunet <jbrunet@baylibre.com>
Tue, 8 Oct 2024 16:07:02 +0000 (18:07 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 22 Oct 2024 19:49:14 +0000 (20:49 +0100)
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>
drivers/regulator/core.c
include/linux/regulator/driver.h

index 24bb7f5b12e3e5d5ac0b74675e8aa591ea6cab9b..eecb05a0d08c8b814c5110f30ac79c7960b54b65 100644 (file)
@@ -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)) {
index f230a472ccd354e03adc69f570bbe64af5d769cb..d2f4427504f081e28a0c5102f329eda48324f163 100644 (file)
@@ -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;