Commit 541d052d authored by Linus Walleij's avatar Linus Walleij Committed by Mark Brown

regulator: core: Only support passing enable GPIO descriptors

Now that we changed all providers to pass descriptors into the core
for enable GPIOs instead of a global GPIO number, delete the support
for passing GPIO numbers in, and we get a cleanup and size reduction
in the core, and from a GPIO point of view we use the modern, cleaner
interface.
Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent d162d041
......@@ -23,7 +23,6 @@
#include <linux/mutex.h>
#include <linux/suspend.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>
#include <linux/regmap.h>
......@@ -2236,35 +2235,19 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev,
{
struct regulator_enable_gpio *pin;
struct gpio_desc *gpiod;
int ret;
if (config->ena_gpiod)
gpiod = config->ena_gpiod;
else
gpiod = gpio_to_desc(config->ena_gpio);
gpiod = config->ena_gpiod;
list_for_each_entry(pin, &regulator_ena_gpio_list, list) {
if (pin->gpiod == gpiod) {
rdev_dbg(rdev, "GPIO %d is already used\n",
config->ena_gpio);
rdev_dbg(rdev, "GPIO is already used\n");
goto update_ena_gpio_to_rdev;
}
}
if (!config->ena_gpiod) {
ret = gpio_request_one(config->ena_gpio,
GPIOF_DIR_OUT | config->ena_gpio_flags,
rdev_get_name(rdev));
if (ret)
return ret;
}
pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL);
if (pin == NULL) {
if (!config->ena_gpiod)
gpio_free(config->ena_gpio);
if (pin == NULL)
return -ENOMEM;
}
pin->gpiod = gpiod;
list_add(&pin->list, &regulator_ena_gpio_list);
......@@ -2287,7 +2270,6 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev)
if (pin->gpiod == rdev->ena_pin->gpiod) {
if (pin->request_count <= 1) {
pin->request_count = 0;
gpiod_put(pin->gpiod);
list_del(&pin->list);
kfree(pin);
rdev->ena_pin = NULL;
......@@ -4971,15 +4953,13 @@ regulator_register(const struct regulator_desc *regulator_desc,
goto clean;
}
if (config->ena_gpiod ||
((config->ena_gpio || config->ena_gpio_initialized) &&
gpio_is_valid(config->ena_gpio))) {
if (config->ena_gpiod) {
mutex_lock(&regulator_list_mutex);
ret = regulator_ena_gpio_request(rdev, config);
mutex_unlock(&regulator_list_mutex);
if (ret != 0) {
rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
config->ena_gpio, ret);
rdev_err(rdev, "Failed to request enable GPIO: %d\n",
ret);
goto clean;
}
/* The regulator core took over the GPIO descriptor */
......
......@@ -401,13 +401,7 @@ struct regulator_desc {
* NULL).
* @regmap: regmap to use for core regmap helpers if dev_get_regmap() is
* insufficient.
* @ena_gpio_initialized: GPIO controlling regulator enable was properly
* initialized, meaning that >= 0 is a valid gpio
* identifier and < 0 is a non existent gpio.
* @ena_gpio: GPIO controlling regulator enable.
* @ena_gpiod: GPIO descriptor controlling regulator enable.
* @ena_gpio_invert: Sense for GPIO enable control.
* @ena_gpio_flags: Flags to use when calling gpio_request_one()
* @ena_gpiod: GPIO controlling regulator enable.
*/
struct regulator_config {
struct device *dev;
......@@ -416,11 +410,7 @@ struct regulator_config {
struct device_node *of_node;
struct regmap *regmap;
bool ena_gpio_initialized;
int ena_gpio;
struct gpio_desc *ena_gpiod;
unsigned int ena_gpio_invert:1;
unsigned int ena_gpio_flags;
};
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment