Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: da9211: Pass descriptors instead of GPIO numbers

This augments the DA9211 regulator driver to fetch its GPIO descriptors
directly from the device tree using the newly exported
devm_get_gpiod_from_child().

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Linus Walleij and committed by
Mark Brown
11da04af 8d05560d

+14 -13
+11 -12
drivers/regulator/da9211-regulator.c
··· 15 15 */ 16 16 17 17 #include <linux/err.h> 18 - #include <linux/gpio.h> 19 18 #include <linux/i2c.h> 20 19 #include <linux/module.h> 21 20 #include <linux/init.h> ··· 24 25 #include <linux/regmap.h> 25 26 #include <linux/irq.h> 26 27 #include <linux/interrupt.h> 27 - #include <linux/of_gpio.h> 28 + #include <linux/gpio/consumer.h> 28 29 #include <linux/regulator/of_regulator.h> 29 30 #include <linux/regulator/da9211.h> 30 31 #include "da9211-regulator.h" ··· 293 294 294 295 pdata->init_data[n] = da9211_matches[i].init_data; 295 296 pdata->reg_node[n] = da9211_matches[i].of_node; 296 - pdata->gpio_ren[n] = 297 - of_get_named_gpio(da9211_matches[i].of_node, 298 - "enable-gpios", 0); 297 + pdata->gpiod_ren[n] = devm_gpiod_get_from_of_node(dev, 298 + da9211_matches[i].of_node, 299 + "enable", 300 + 0, 301 + GPIOD_OUT_HIGH, 302 + "da9211-enable"); 299 303 n++; 300 304 } 301 305 ··· 384 382 config.regmap = chip->regmap; 385 383 config.of_node = chip->pdata->reg_node[i]; 386 384 387 - if (gpio_is_valid(chip->pdata->gpio_ren[i])) { 388 - config.ena_gpio = chip->pdata->gpio_ren[i]; 389 - config.ena_gpio_initialized = true; 390 - } else { 391 - config.ena_gpio = -EINVAL; 392 - config.ena_gpio_initialized = false; 393 - } 385 + if (chip->pdata->gpiod_ren[i]) 386 + config.ena_gpiod = chip->pdata->gpiod_ren[i]; 387 + else 388 + config.ena_gpiod = NULL; 394 389 395 390 chip->rdev[i] = devm_regulator_register(chip->dev, 396 391 &da9211_regulators[i], &config);
+3 -1
include/linux/regulator/da9211.h
··· 21 21 22 22 #define DA9211_MAX_REGULATORS 2 23 23 24 + struct gpio_desc; 25 + 24 26 enum da9211_chip_id { 25 27 DA9211, 26 28 DA9212, ··· 41 39 * 2 : 2 phase 2 buck 42 40 */ 43 41 int num_buck; 44 - int gpio_ren[DA9211_MAX_REGULATORS]; 42 + struct gpio_desc *gpiod_ren[DA9211_MAX_REGULATORS]; 45 43 struct device_node *reg_node[DA9211_MAX_REGULATORS]; 46 44 struct regulator_init_data *init_data[DA9211_MAX_REGULATORS]; 47 45 };