regulator: lm363x: Pass descriptor instead of GPIO number

Instead of passing a global GPIO number, pass a descriptor looked
up with the standard devm_gpiod_get_index_optional() call.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Linus Walleij 2018-05-14 10:06:27 +02:00 committed by Mark Brown
parent e7d2be696f
commit b2d751b7f6
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 10 additions and 10 deletions

View File

@ -16,7 +16,7 @@
#include <linux/mfd/ti-lmu-register.h> #include <linux/mfd/ti-lmu-register.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h> #include <linux/gpio/consumer.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
@ -219,7 +219,7 @@ static const struct regulator_desc lm363x_regulator_desc[] = {
}, },
}; };
static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id) static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev, int id)
{ {
/* /*
* Check LCM_EN1/2_GPIO is configured. * Check LCM_EN1/2_GPIO is configured.
@ -227,11 +227,11 @@ static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id)
*/ */
switch (id) { switch (id) {
case LM3632_LDO_POS: case LM3632_LDO_POS:
return of_get_named_gpio(np, "enable-gpios", 0); return devm_gpiod_get_index_optional(dev, "enable", 0, GPIOD_OUT_LOW);
case LM3632_LDO_NEG: case LM3632_LDO_NEG:
return of_get_named_gpio(np, "enable-gpios", 1); return devm_gpiod_get_index_optional(dev, "enable", 1, GPIOD_OUT_LOW);
default: default:
return -EINVAL; return NULL;
} }
} }
@ -243,7 +243,8 @@ static int lm363x_regulator_probe(struct platform_device *pdev)
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int id = pdev->id; int id = pdev->id;
int ret, ena_gpio; struct gpio_desc *gpiod;
int ret;
cfg.dev = dev; cfg.dev = dev;
cfg.regmap = regmap; cfg.regmap = regmap;
@ -252,10 +253,9 @@ static int lm363x_regulator_probe(struct platform_device *pdev)
* LM3632 LDOs can be controlled by external pin. * LM3632 LDOs can be controlled by external pin.
* Register update is required if the pin is used. * Register update is required if the pin is used.
*/ */
ena_gpio = lm363x_regulator_of_get_enable_gpio(dev->of_node, id); gpiod = lm363x_regulator_of_get_enable_gpio(dev, id);
if (gpio_is_valid(ena_gpio)) { if (gpiod) {
cfg.ena_gpio = ena_gpio; cfg.ena_gpiod = gpiod;
cfg.ena_gpio_flags = GPIOF_OUT_INIT_LOW;
ret = regmap_update_bits(regmap, LM3632_REG_BIAS_CONFIG, ret = regmap_update_bits(regmap, LM3632_REG_BIAS_CONFIG,
LM3632_EXT_EN_MASK, LM3632_EXT_EN_MASK,