History

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.

Linus Walleij committed 7 years ago

Commit 541d0521 parent d162d042 files · +7 −37Browse files

Unified · Split

2 files
  1. drivers/regulator/core.c +6 −26
  2. include/linux/regulator/driver.h +1 −11
drivers/regulator/core.c+6−26
@@ -23,7 +23,6 @@ · 22 unmodified lines
2323 #include <linux/mutex.h>
2424 #include <linux/suspend.h>
2525 #include <linux/delay.h>
26−#include <linux/gpio.h>
2726 #include <linux/gpio/consumer.h>
2827 #include <linux/of.h>
2928 #include <linux/regmap.h>
@@ -2236,35 +2235,19 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, · 2206 unmodified lines
22362235 {
22372236 struct regulator_enable_gpio *pin;
22382237 struct gpio_desc *gpiod;
2239− int ret;
22402238
2241− if (config->ena_gpiod)
2242− gpiod = config->ena_gpiod;
2243− else
2244− gpiod = gpio_to_desc(config->ena_gpio);
2239+ gpiod = config->ena_gpiod;
22452240
22462241 list_for_each_entry(pin, &regulator_ena_gpio_list, list) {
22472242 if (pin->gpiod == gpiod) {
2248− rdev_dbg(rdev, "GPIO %d is already used\n",
2249− config->ena_gpio);
2243+ rdev_dbg(rdev, "GPIO is already used\n");
22502244 goto update_ena_gpio_to_rdev;
22512245 }
22522246 }
22532247
2254− if (!config->ena_gpiod) {
2255− ret = gpio_request_one(config->ena_gpio,
2256− GPIOF_DIR_OUT | config->ena_gpio_flags,
2257− rdev_get_name(rdev));
2258− if (ret)
2259− return ret;
2260− }
2261−
22622248 pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL);
2263− if (pin == NULL) {
2264− if (!config->ena_gpiod)
2265− gpio_free(config->ena_gpio);
2249+ if (pin == NULL)
22662250 return -ENOMEM;
2267− }
22682251
22692252 pin->gpiod = gpiod;
22702253 list_add(&pin->list, &regulator_ena_gpio_list);
@@ -2287,7 +2270,6 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev) · 16 unmodified lines
22872270 if (pin->gpiod == rdev->ena_pin->gpiod) {
22882271 if (pin->request_count <= 1) {
22892272 pin->request_count = 0;
2290− gpiod_put(pin->gpiod);
22912273 list_del(&pin->list);
22922274 kfree(pin);
22932275 rdev->ena_pin = NULL;
@@ -4971,15 +4953,13 @@ regulator_register(const struct regulator_desc *regulator_desc, · 2677 unmodified lines
49714953 goto clean;
49724954 }
49734955
4974− if (config->ena_gpiod ||
4975− ((config->ena_gpio || config->ena_gpio_initialized) &&
4976− gpio_is_valid(config->ena_gpio))) {
4956+ if (config->ena_gpiod) {
49774957 mutex_lock(&regulator_list_mutex);
49784958 ret = regulator_ena_gpio_request(rdev, config);
49794959 mutex_unlock(&regulator_list_mutex);
49804960 if (ret != 0) {
4981− rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
4982− config->ena_gpio, ret);
4961+ rdev_err(rdev, "Failed to request enable GPIO: %d\n",
4962+ ret);
49834963 goto clean;
49844964 }
49854965 /* The regulator core took over the GPIO descriptor */
include/linux/regulator/driver.h+1−11
@@ -401,13 +401,7 @@ struct regulator_desc { · 400 unmodified lines
401401 * NULL).
402402 * @regmap: regmap to use for core regmap helpers if dev_get_regmap() is
403403 * insufficient.
404− * @ena_gpio_initialized: GPIO controlling regulator enable was properly
405− * initialized, meaning that >= 0 is a valid gpio
406− * identifier and < 0 is a non existent gpio.
407− * @ena_gpio: GPIO controlling regulator enable.
408− * @ena_gpiod: GPIO descriptor controlling regulator enable.
409− * @ena_gpio_invert: Sense for GPIO enable control.
410− * @ena_gpio_flags: Flags to use when calling gpio_request_one()
404+ * @ena_gpiod: GPIO controlling regulator enable.
411405 */
412406 struct regulator_config {
413407 struct device *dev;
@@ -416,11 +410,7 @@ struct regulator_config { · 2 unmodified lines
416410 struct device_node *of_node;
417411 struct regmap *regmap;
418412
419− bool ena_gpio_initialized;
420− int ena_gpio;
421413 struct gpio_desc *ena_gpiod;
422− unsigned int ena_gpio_invert:1;
423− unsigned int ena_gpio_flags;
424414 };
425415
426416 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t