aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max8952.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2018-05-14 10:06:29 +0200
committerMark Brown <broonie@kernel.org>2018-05-24 16:50:36 +0100
commitd7a261c2d1f233260c48651b4e68987ce1206139 (patch)
tree5d5cd25af4d10d2d180c7736dd507e03108438d9 /drivers/regulator/max8952.c
parentregulator: lp8788-ldo: Pass descriptor instead of GPIO number (diff)
downloadlinux-dev-d7a261c2d1f233260c48651b4e68987ce1206139.tar.xz
linux-dev-d7a261c2d1f233260c48651b4e68987ce1206139.zip
regulator: max8952: Pass descriptor instead of GPIO number
Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up with the standard devm_gpiod_get_optional() call. All users of this regulator use device tree so the transition is pretty smooth. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/max8952.c')
-rw-r--r--drivers/regulator/max8952.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c
index 1096546c05e9..f1e77ed5dfec 100644
--- a/drivers/regulator/max8952.c
+++ b/drivers/regulator/max8952.c
@@ -27,6 +27,7 @@
#include <linux/regulator/driver.h>
#include <linux/regulator/max8952.h>
#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/io.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
@@ -148,7 +149,6 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev)
pd->gpio_vid0 = of_get_named_gpio(np, "max8952,vid-gpios", 0);
pd->gpio_vid1 = of_get_named_gpio(np, "max8952,vid-gpios", 1);
- pd->gpio_en = of_get_named_gpio(np, "max8952,en-gpio", 0);
if (of_property_read_u32(np, "max8952,default-mode", &pd->default_mode))
dev_warn(dev, "Default mode not specified, assuming 0\n");
@@ -197,6 +197,8 @@ static int max8952_pmic_probe(struct i2c_client *client,
struct regulator_config config = { };
struct max8952_data *max8952;
struct regulator_dev *rdev;
+ struct gpio_desc *gpiod;
+ enum gpiod_flags gflags;
int ret = 0, err = 0;
@@ -224,11 +226,17 @@ static int max8952_pmic_probe(struct i2c_client *client,
config.driver_data = max8952;
config.of_node = client->dev.of_node;
- config.ena_gpio = pdata->gpio_en;
- if (client->dev.of_node)
- config.ena_gpio_initialized = true;
if (pdata->reg_data->constraints.boot_on)
- config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
+ gflags = GPIOD_OUT_HIGH;
+ else
+ gflags = GPIOD_OUT_LOW;
+ gpiod = devm_gpiod_get_optional(&client->dev,
+ "max8952,en",
+ gflags);
+ if (IS_ERR(gpiod))
+ return PTR_ERR(gpiod);
+ if (gpiod)
+ config.ena_gpiod = gpiod;
rdev = devm_regulator_register(&client->dev, &regulator, &config);
if (IS_ERR(rdev)) {