regulator: core: Only support passing enable GPIO descriptors
authorLinus Walleij <linus.walleij@linaro.org>
Tue, 29 Jan 2019 10:31:56 +0000 (11:31 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 6 Feb 2019 16:01:31 +0000 (16:01 +0000)
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: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c
include/linux/regulator/driver.h

index 1778c5d1b2d0e305e774c5be11332b918d86e9e7..4fb475a2e4f23690721b577aa649d399c4dd3bca 100644 (file)
@@ -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 */
index 795b38a06b6c2ec5644f79757f877fe4da5f90ce..7f8345bff4e126d915302bab098b9c54376182a6 100644 (file)
@@ -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;
 };
 
 /*