mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-23 06:44:03 +00:00
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: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
d162d04103
commit
541d052d72
2 changed files with 7 additions and 37 deletions
|
@ -23,7 +23,6 @@
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/suspend.h>
|
#include <linux/suspend.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/gpio.h>
|
|
||||||
#include <linux/gpio/consumer.h>
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/regmap.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 regulator_enable_gpio *pin;
|
||||||
struct gpio_desc *gpiod;
|
struct gpio_desc *gpiod;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (config->ena_gpiod)
|
gpiod = config->ena_gpiod;
|
||||||
gpiod = config->ena_gpiod;
|
|
||||||
else
|
|
||||||
gpiod = gpio_to_desc(config->ena_gpio);
|
|
||||||
|
|
||||||
list_for_each_entry(pin, ®ulator_ena_gpio_list, list) {
|
list_for_each_entry(pin, ®ulator_ena_gpio_list, list) {
|
||||||
if (pin->gpiod == gpiod) {
|
if (pin->gpiod == gpiod) {
|
||||||
rdev_dbg(rdev, "GPIO %d is already used\n",
|
rdev_dbg(rdev, "GPIO is already used\n");
|
||||||
config->ena_gpio);
|
|
||||||
goto update_ena_gpio_to_rdev;
|
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);
|
pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL);
|
||||||
if (pin == NULL) {
|
if (pin == NULL)
|
||||||
if (!config->ena_gpiod)
|
|
||||||
gpio_free(config->ena_gpio);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
pin->gpiod = gpiod;
|
pin->gpiod = gpiod;
|
||||||
list_add(&pin->list, ®ulator_ena_gpio_list);
|
list_add(&pin->list, ®ulator_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->gpiod == rdev->ena_pin->gpiod) {
|
||||||
if (pin->request_count <= 1) {
|
if (pin->request_count <= 1) {
|
||||||
pin->request_count = 0;
|
pin->request_count = 0;
|
||||||
gpiod_put(pin->gpiod);
|
|
||||||
list_del(&pin->list);
|
list_del(&pin->list);
|
||||||
kfree(pin);
|
kfree(pin);
|
||||||
rdev->ena_pin = NULL;
|
rdev->ena_pin = NULL;
|
||||||
|
@ -4971,15 +4953,13 @@ regulator_register(const struct regulator_desc *regulator_desc,
|
||||||
goto clean;
|
goto clean;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->ena_gpiod ||
|
if (config->ena_gpiod) {
|
||||||
((config->ena_gpio || config->ena_gpio_initialized) &&
|
|
||||||
gpio_is_valid(config->ena_gpio))) {
|
|
||||||
mutex_lock(®ulator_list_mutex);
|
mutex_lock(®ulator_list_mutex);
|
||||||
ret = regulator_ena_gpio_request(rdev, config);
|
ret = regulator_ena_gpio_request(rdev, config);
|
||||||
mutex_unlock(®ulator_list_mutex);
|
mutex_unlock(®ulator_list_mutex);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
|
rdev_err(rdev, "Failed to request enable GPIO: %d\n",
|
||||||
config->ena_gpio, ret);
|
ret);
|
||||||
goto clean;
|
goto clean;
|
||||||
}
|
}
|
||||||
/* The regulator core took over the GPIO descriptor */
|
/* The regulator core took over the GPIO descriptor */
|
||||||
|
|
|
@ -401,13 +401,7 @@ struct regulator_desc {
|
||||||
* NULL).
|
* NULL).
|
||||||
* @regmap: regmap to use for core regmap helpers if dev_get_regmap() is
|
* @regmap: regmap to use for core regmap helpers if dev_get_regmap() is
|
||||||
* insufficient.
|
* insufficient.
|
||||||
* @ena_gpio_initialized: GPIO controlling regulator enable was properly
|
* @ena_gpiod: GPIO controlling regulator enable.
|
||||||
* 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()
|
|
||||||
*/
|
*/
|
||||||
struct regulator_config {
|
struct regulator_config {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
@ -416,11 +410,7 @@ struct regulator_config {
|
||||||
struct device_node *of_node;
|
struct device_node *of_node;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
|
|
||||||
bool ena_gpio_initialized;
|
|
||||||
int ena_gpio;
|
|
||||||
struct gpio_desc *ena_gpiod;
|
struct gpio_desc *ena_gpiod;
|
||||||
unsigned int ena_gpio_invert:1;
|
|
||||||
unsigned int ena_gpio_flags;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue