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.
Unified · Split
| @@ -23,7 +23,6 @@ · 22 unmodified lines | ||
| 23 | 23 | #include <linux/mutex.h> |
| 24 | 24 | #include <linux/suspend.h> |
| 25 | 25 | #include <linux/delay.h> |
| 26 | −#include <linux/gpio.h> | |
| 27 | 26 | #include <linux/gpio/consumer.h> |
| 28 | 27 | #include <linux/of.h> |
| 29 | 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 | 2236 | struct regulator_enable_gpio *pin; |
| 2238 | 2237 | struct gpio_desc *gpiod; |
| 2239 | − int ret; | |
| 2240 | 2238 | |
| 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; | |
| 2245 | 2240 | |
| 2246 | 2241 | list_for_each_entry(pin, ®ulator_ena_gpio_list, list) { |
| 2247 | 2242 | 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"); | |
| 2250 | 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 | 2248 | 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) | |
| 2266 | 2250 | return -ENOMEM; |
| 2267 | − } | |
| 2268 | 2251 | |
| 2269 | 2252 | pin->gpiod = gpiod; |
| 2270 | 2253 | list_add(&pin->list, ®ulator_ena_gpio_list); |
| @@ -2287,7 +2270,6 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev) · 16 unmodified lines | ||
| 2287 | 2270 | if (pin->gpiod == rdev->ena_pin->gpiod) { |
| 2288 | 2271 | if (pin->request_count <= 1) { |
| 2289 | 2272 | pin->request_count = 0; |
| 2290 | − gpiod_put(pin->gpiod); | |
| 2291 | 2273 | list_del(&pin->list); |
| 2292 | 2274 | kfree(pin); |
| 2293 | 2275 | rdev->ena_pin = NULL; |
| @@ -4971,15 +4953,13 @@ regulator_register(const struct regulator_desc *regulator_desc, · 2677 unmodified lines | ||
| 4971 | 4953 | goto clean; |
| 4972 | 4954 | } |
| 4973 | 4955 | |
| 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) { | |
| 4977 | 4957 | mutex_lock(®ulator_list_mutex); |
| 4978 | 4958 | ret = regulator_ena_gpio_request(rdev, config); |
| 4979 | 4959 | mutex_unlock(®ulator_list_mutex); |
| 4980 | 4960 | 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); | |
| 4983 | 4963 | goto clean; |
| 4984 | 4964 | } |
| 4985 | 4965 | /* The regulator core took over the GPIO descriptor */ |
| @@ -401,13 +401,7 @@ struct regulator_desc { · 400 unmodified lines | ||
| 401 | 401 | * NULL). |
| 402 | 402 | * @regmap: regmap to use for core regmap helpers if dev_get_regmap() is |
| 403 | 403 | * 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. | |
| 411 | 405 | */ |
| 412 | 406 | struct regulator_config { |
| 413 | 407 | struct device *dev; |
| @@ -416,11 +410,7 @@ struct regulator_config { · 2 unmodified lines | ||
| 416 | 410 | struct device_node *of_node; |
| 417 | 411 | struct regmap *regmap; |
| 418 | 412 | |
| 419 | − bool ena_gpio_initialized; | |
| 420 | − int ena_gpio; | |
| 421 | 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 | /* |