Merge tag 'gpio-v4.21-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO updates from Linus Walleij:
"This is the bulk of GPIO changes for the v4.21 kernel series.
Core changes:
- Some core changes are already in outside of this pull request as
they came through the regulator tree, most notably
devm_gpiod_unhinge() that removes devres refcount management from a
GPIO descriptor. This is needed in subsystems such as regulators
where the regulator core need to take over the reference counting
and lifecycle management for a GPIO descriptor.
- We dropped devm_gpiochip_remove() and devm_gpio_chip_match() as
nothing needs it. We can bring it back if need be.
- Add a global TODO so people see where we are going. This helps
setting the direction now that we are two GPIO maintainers.
- Handle the MMC CD/WP properties in the device tree core. (The bulk
of patches activating this code is already merged through the
MMC/SD tree.)
- Augment gpiochip_request_own_desc() to pass a flag so we as
gpiochips can request lines as active low or open drain etc even
from ourselves.
New drivers:
- New driver for Cadence GPIO blocks.
- New driver for Atmel SAMA5D2 PIOBU GPIO lines.
Driver improvements:
- A major refactoring of the PCA953x driver - this driver has been
around for ages, and is now modernized to reduce code duplication
that has stacked up and is using regmap to read write and cache
registers.
- Intel drivers are now maintained in a separate tree and start with
a round of cleanups and unifications"
* tag 'gpio-v4.21-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (99 commits)
gpio: sama5d2-piobu: Depend on OF_GPIO
gpio: Add Cadence GPIO driver
dt-bindings: gpio: Add bindings for Cadence GPIO
gpiolib-acpi: remove unused variable 'err', cleans up build warning
gpio: mxs: read pin level directly instead of using .get
gpio: aspeed: remove duplicated statement
gpio: add driver for SAMA5D2 PIOBU pins
dt-bindings: arm: atmel: describe SECUMOD usage as a GPIO controller
gpio/mmc/of: Respect polarity in the device tree
dt-bindings: gpio: rcar: Add r8a774c0 (RZ/G2E) support
memory: omap-gpmc: Get the header of the enum
ARM: omap1: Fix new user of gpiochip_request_own_desc()
gpio: pca953x: Add regmap dependency for PCA953x driver
gpio: raspberrypi-exp: decrease refcount on firmware dt node
gpiolib: Fix return value of gpio_to_desc() stub if !GPIOLIB
gpio: pca953x: Restore registers after suspend/resume cycle
gpio: pca953x: Zap single use of pca953x_read_single()
gpio: pca953x: Zap ad-hoc reg_output cache
gpio: pca953x: Zap ad-hoc reg_direction cache
gpio: pca953x: Perform basic regmap conversion
...
This commit is contained in:
@@ -1512,19 +1512,6 @@ static void devm_gpio_chip_release(struct device *dev, void *res)
|
||||
gpiochip_remove(chip);
|
||||
}
|
||||
|
||||
static int devm_gpio_chip_match(struct device *dev, void *res, void *data)
|
||||
|
||||
{
|
||||
struct gpio_chip **r = res;
|
||||
|
||||
if (!r || !*r) {
|
||||
WARN_ON(!r || !*r);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return *r == data;
|
||||
}
|
||||
|
||||
/**
|
||||
* devm_gpiochip_add_data() - Resource manager gpiochip_add_data()
|
||||
* @dev: pointer to the device that gpio_chip belongs to.
|
||||
@@ -1564,23 +1551,6 @@ int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *chip,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_gpiochip_add_data);
|
||||
|
||||
/**
|
||||
* devm_gpiochip_remove() - Resource manager of gpiochip_remove()
|
||||
* @dev: device for which which resource was allocated
|
||||
* @chip: the chip to remove
|
||||
*
|
||||
* A gpio_chip with any GPIOs still requested may not be removed.
|
||||
*/
|
||||
void devm_gpiochip_remove(struct device *dev, struct gpio_chip *chip)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = devres_release(dev, devm_gpio_chip_release,
|
||||
devm_gpio_chip_match, chip);
|
||||
WARN_ON(ret);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_gpiochip_remove);
|
||||
|
||||
/**
|
||||
* gpiochip_find() - iterator for locating a specific gpio_chip
|
||||
* @data: data to pass to match function
|
||||
@@ -2299,6 +2269,12 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
||||
unsigned long flags;
|
||||
unsigned offset;
|
||||
|
||||
if (label) {
|
||||
label = kstrdup_const(label, GFP_KERNEL);
|
||||
if (!label)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&gpio_lock, flags);
|
||||
|
||||
/* NOTE: gpio_request() can be called in early boot,
|
||||
@@ -2309,6 +2285,7 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
||||
desc_set_label(desc, label ? : "?");
|
||||
status = 0;
|
||||
} else {
|
||||
kfree_const(label);
|
||||
status = -EBUSY;
|
||||
goto done;
|
||||
}
|
||||
@@ -2325,6 +2302,7 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
||||
|
||||
if (status < 0) {
|
||||
desc_set_label(desc, NULL);
|
||||
kfree_const(label);
|
||||
clear_bit(FLAG_REQUESTED, &desc->flags);
|
||||
goto done;
|
||||
}
|
||||
@@ -2420,6 +2398,7 @@ static bool gpiod_free_commit(struct gpio_desc *desc)
|
||||
chip->free(chip, gpio_chip_hwgpio(desc));
|
||||
spin_lock_irqsave(&gpio_lock, flags);
|
||||
}
|
||||
kfree_const(desc->label);
|
||||
desc_set_label(desc, NULL);
|
||||
clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
|
||||
clear_bit(FLAG_REQUESTED, &desc->flags);
|
||||
@@ -2476,6 +2455,7 @@ EXPORT_SYMBOL_GPL(gpiochip_is_requested);
|
||||
* @chip: GPIO chip
|
||||
* @hwnum: hardware number of the GPIO for which to request the descriptor
|
||||
* @label: label for the GPIO
|
||||
* @flags: flags for this GPIO or 0 if default
|
||||
*
|
||||
* Function allows GPIO chip drivers to request and use their own GPIO
|
||||
* descriptors via gpiolib API. Difference to gpiod_request() is that this
|
||||
@@ -2488,7 +2468,8 @@ EXPORT_SYMBOL_GPL(gpiochip_is_requested);
|
||||
* code on failure.
|
||||
*/
|
||||
struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum,
|
||||
const char *label)
|
||||
const char *label,
|
||||
enum gpiod_flags flags)
|
||||
{
|
||||
struct gpio_desc *desc = gpiochip_get_desc(chip, hwnum);
|
||||
int err;
|
||||
@@ -2502,6 +2483,13 @@ struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum,
|
||||
if (err < 0)
|
||||
return ERR_PTR(err);
|
||||
|
||||
err = gpiod_configure_flags(desc, label, 0, flags);
|
||||
if (err) {
|
||||
chip_err(chip, "setup of own GPIO %s failed\n", label);
|
||||
gpiod_free_commit(desc);
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gpiochip_request_own_desc);
|
||||
@@ -3375,11 +3363,19 @@ EXPORT_SYMBOL_GPL(gpiod_cansleep);
|
||||
* @desc: gpio to set the consumer name on
|
||||
* @name: the new consumer name
|
||||
*/
|
||||
void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name)
|
||||
int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name)
|
||||
{
|
||||
VALIDATE_DESC_VOID(desc);
|
||||
/* Just overwrite whatever the previous name was */
|
||||
desc->label = name;
|
||||
VALIDATE_DESC(desc);
|
||||
if (name) {
|
||||
name = kstrdup_const(name, GFP_KERNEL);
|
||||
if (!name)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
kfree_const(desc->label);
|
||||
desc_set_label(desc, name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gpiod_set_consumer_name);
|
||||
|
||||
@@ -4348,7 +4344,15 @@ int gpiod_hog(struct gpio_desc *desc, const char *name,
|
||||
chip = gpiod_to_chip(desc);
|
||||
hwnum = gpio_chip_hwgpio(desc);
|
||||
|
||||
local_desc = gpiochip_request_own_desc(chip, hwnum, name);
|
||||
/*
|
||||
* FIXME: not very elegant that we call gpiod_configure_flags()
|
||||
* twice here (once inside gpiochip_request_own_desc() and
|
||||
* again here), but the gpiochip_request_own_desc() is external
|
||||
* and cannot really pass the lflags so this is the lesser evil
|
||||
* at the moment. Pass zero as dflags on this first call so we
|
||||
* don't screw anything up.
|
||||
*/
|
||||
local_desc = gpiochip_request_own_desc(chip, hwnum, name, 0);
|
||||
if (IS_ERR(local_desc)) {
|
||||
status = PTR_ERR(local_desc);
|
||||
pr_err("requesting hog GPIO %s (chip %s, offset %d) failed, %d\n",
|
||||
|
||||
Reference in New Issue
Block a user