diff options
author | Markus Pargmann <mpa@pengutronix.de> | 2014-10-08 09:47:05 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-10-20 07:23:45 -0400 |
commit | 76f439df50aba1838e06dd01e5f20dada7473f57 (patch) | |
tree | a35a98029f817fa4663b71dc62db7d4fe5ca1f4f /drivers/regulator/core.c | |
parent | f114040e3ea6e07372334ade75d1ee0775c355e1 (diff) |
regulator: Add ena_gpio_initialized to regulator_config
Most drivers do not set the ena_gpio field of struct regulator_config
before passing it to the regulator core. This is fine as long as the
gpio identifier that is passed is a positive integer. But the gpio
identifier 0 is also valid. So we are not able to decide wether we got a
real gpio identifier or not based on a 0 in ena_gpio.
To be able to decide if it is a valid gpio that got passed, this patch
adds a ena_gpio_initialized field that should be set if was initialized
with a correct value, either a gpio >= 0 or a negative error number. The
core then checks if ena_gpio or ena_gpio_initialized before handling it
as a gpio. This way we maintain backwards compatibility and fix the
behaviour for gpio number 0.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r-- | drivers/regulator/core.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index cd87c0c37034..55a87a2722d8 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -3650,7 +3650,8 @@ regulator_register(const struct regulator_desc *regulator_desc, | |||
3650 | 3650 | ||
3651 | dev_set_drvdata(&rdev->dev, rdev); | 3651 | dev_set_drvdata(&rdev->dev, rdev); |
3652 | 3652 | ||
3653 | if (config->ena_gpio && gpio_is_valid(config->ena_gpio)) { | 3653 | if ((config->ena_gpio || config->ena_gpio_initialized) && |
3654 | gpio_is_valid(config->ena_gpio)) { | ||
3654 | ret = regulator_ena_gpio_request(rdev, config); | 3655 | ret = regulator_ena_gpio_request(rdev, config); |
3655 | if (ret != 0) { | 3656 | if (ret != 0) { |
3656 | rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", | 3657 | rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", |