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
23#include <linux/mutex.h>23#include <linux/mutex.h>
24#include <linux/suspend.h>24#include <linux/suspend.h>
25#include <linux/delay.h>25#include <linux/delay.h>
26#include <linux/gpio.h>
27#include <linux/gpio/consumer.h>26#include <linux/gpio/consumer.h>
28#include <linux/of.h>27#include <linux/of.h>
29#include <linux/regmap.h>28#include <linux/regmap.h>
@@ -2236,35 +2235,19 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, · 2206 unmodified lines
2236{2235{
2237 struct regulator_enable_gpio *pin;2236 struct regulator_enable_gpio *pin;
2238 struct gpio_desc *gpiod;2237 struct gpio_desc *gpiod;
2239 int ret;
2240 2238
2241 if (config->ena_gpiod)2239 gpiod = config->ena_gpiod;
2242 gpiod = config->ena_gpiod;
2243 else
2244 gpiod = gpio_to_desc(config->ena_gpio);
2245 2240
2246 list_for_each_entry(pin, &regulator_ena_gpio_list, list) {2241 list_for_each_entry(pin, &regulator_ena_gpio_list, list) {
2247 if (pin->gpiod == gpiod) {2242 if (pin->gpiod == gpiod) {
2248 rdev_dbg(rdev, "GPIO %d is already used\n",2243 rdev_dbg(rdev, "GPIO is already used\n");
2249 config->ena_gpio);
2250 goto update_ena_gpio_to_rdev;2244 goto update_ena_gpio_to_rdev;
2251 }2245 }
2252 }2246 }
2253 2247
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
2262 pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL);2248 pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL);
2263 if (pin == NULL) {2249 if (pin == NULL)
2264 if (!config->ena_gpiod)
2265 gpio_free(config->ena_gpio);
2266 return -ENOMEM;2250 return -ENOMEM;
2267 }
2268 2251
2269 pin->gpiod = gpiod;2252 pin->gpiod = gpiod;
2270 list_add(&pin->list, &regulator_ena_gpio_list);2253 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
2287 if (pin->gpiod == rdev->ena_pin->gpiod) {2270 if (pin->gpiod == rdev->ena_pin->gpiod) {
2288 if (pin->request_count <= 1) {2271 if (pin->request_count <= 1) {
2289 pin->request_count = 0;2272 pin->request_count = 0;
2290 gpiod_put(pin->gpiod);
2291 list_del(&pin->list);2273 list_del(&pin->list);
2292 kfree(pin);2274 kfree(pin);
2293 rdev->ena_pin = NULL;2275 rdev->ena_pin = NULL;
@@ -4971,15 +4953,13 @@ regulator_register(const struct regulator_desc *regulator_desc, · 2677 unmodified lines
4971 goto clean;4953 goto clean;
4972 }4954 }
4973 4955
4974 if (config->ena_gpiod ||4956 if (config->ena_gpiod) {
4975 ((config->ena_gpio || config->ena_gpio_initialized) &&
4976 gpio_is_valid(config->ena_gpio))) {
4977 mutex_lock(&regulator_list_mutex);4957 mutex_lock(&regulator_list_mutex);
4978 ret = regulator_ena_gpio_request(rdev, config);4958 ret = regulator_ena_gpio_request(rdev, config);
4979 mutex_unlock(&regulator_list_mutex);4959 mutex_unlock(&regulator_list_mutex);
4980 if (ret != 0) {4960 if (ret != 0) {
4981 rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",4961 rdev_err(rdev, "Failed to request enable GPIO: %d\n",
4982 config->ena_gpio, ret);4962 ret);
4983 goto clean;4963 goto clean;
4984 }4964 }
4985 /* The regulator core took over the GPIO descriptor */4965 /* 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
401 * NULL).401 * NULL).
402 * @regmap: regmap to use for core regmap helpers if dev_get_regmap() is402 * @regmap: regmap to use for core regmap helpers if dev_get_regmap() is
403 * insufficient.403 * insufficient.
404 * @ena_gpio_initialized: GPIO controlling regulator enable was properly404 * @ena_gpiod: GPIO controlling regulator enable.
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()
411 */405 */
412struct regulator_config {406struct regulator_config {
413 struct device *dev;407 struct device *dev;
@@ -416,11 +410,7 @@ struct regulator_config { · 2 unmodified lines
416 struct device_node *of_node;410 struct device_node *of_node;
417 struct regmap *regmap;411 struct regmap *regmap;
418 412
419 bool ena_gpio_initialized;
420 int ena_gpio;
421 struct gpio_desc *ena_gpiod;413 struct gpio_desc *ena_gpiod;
422 unsigned int ena_gpio_invert:1;
423 unsigned int ena_gpio_flags;
424};414};
425 415
426/*416/*

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