Messages in this thread Patch in this message | | | From | "Kim, Milo" <> | Subject | [PATCH 1/3] regulator-core: support multiple enable GPIO | Date | Thu, 10 Jan 2013 09:46:10 +0000 |
| |
This patch fixes a limitation in case of multiple enable pin usages. Several regulators can be enabled/disabled at the same time by one shared GPIO pin. If specific GPIO pin is already used, then skip requesting the GPIO.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> --- drivers/regulator/core.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index de47880..21b4247 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1456,6 +1456,23 @@ void devm_regulator_put(struct regulator *regulator) } EXPORT_SYMBOL_GPL(devm_regulator_put); +static int regulator_enable_gpio_request(struct regulator_dev *rdev, + const struct regulator_config *config) +{ + struct regulator_dev *r; + int gpio = config->ena_gpio; + + list_for_each_entry(r, ®ulator_list, list) { + if (r->ena_gpio == gpio) { + rdev_info(rdev, "GPIO %d is already used\n", gpio); + return 0; + } + } + + return gpio_request_one(gpio, GPIOF_DIR_OUT | config->ena_gpio_flags, + rdev_get_name(rdev)); +} + static int _regulator_do_enable(struct regulator_dev *rdev) { int ret, delay; @@ -3420,9 +3437,7 @@ regulator_register(const struct regulator_desc *regulator_desc, dev_set_drvdata(&rdev->dev, rdev); if (config->ena_gpio && gpio_is_valid(config->ena_gpio)) { - ret = gpio_request_one(config->ena_gpio, - GPIOF_DIR_OUT | config->ena_gpio_flags, - rdev_get_name(rdev)); + ret = regulator_enable_gpio_request(rdev, config); if (ret != 0) { rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", config->ena_gpio, ret); -- 1.7.9.5
Best Regards, Milo
| |