gpio: remove gpiod_sysfs_set_active_low
Remove gpiod_sysfs_set_active_low (and gpio_sysfs_set_active_low) which allowed code to change the polarity of a gpio line even after it had been exported through sysfs. Drivers should not care, and generally does not know, about gpio-line polarity which is a hardware feature that needs to be described by firmware. It is currently possible to define gpio-line polarity in device-tree and acpi firmware or using platform data. Userspace can also change the polarity through sysfs. Note that drivers using the legacy gpio interface could still use GPIOF_ACTIVE_LOW to change the polarity before exporting the gpio. There are no in-kernel users of this interface. Cc: Jonathan Corbet <corbet@lwn.net> Cc: Harry Wei <harryxiyou@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: linux-doc@vger.kernel.org Cc: linux-kernel@zh-kernel.org Cc: linux-arch@vger.kernel.org Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:

committed by
Linus Walleij

parent
426577bd88
commit
166a85e442
@@ -308,8 +308,8 @@ static int sysfs_set_active_low(struct gpio_desc *desc, struct device *dev,
|
||||
clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
|
||||
|
||||
/* reconfigure poll(2) support if enabled on one edge only */
|
||||
if (dev != NULL && (!!test_bit(FLAG_TRIG_RISE, &desc->flags) ^
|
||||
!!test_bit(FLAG_TRIG_FALL, &desc->flags))) {
|
||||
if (!!test_bit(FLAG_TRIG_RISE, &desc->flags) ^
|
||||
!!test_bit(FLAG_TRIG_FALL, &desc->flags)) {
|
||||
unsigned long trigger_flags = desc->flags & GPIO_TRIGGER_MASK;
|
||||
|
||||
gpio_setup_irq(desc, dev, 0);
|
||||
@@ -680,50 +680,6 @@ int gpiod_export_link(struct device *dev, const char *name,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gpiod_export_link);
|
||||
|
||||
/**
|
||||
* gpiod_sysfs_set_active_low - set the polarity of gpio sysfs value
|
||||
* @gpio: gpio to change
|
||||
* @value: non-zero to use active low, i.e. inverted values
|
||||
*
|
||||
* Set the polarity of /sys/class/gpio/gpioN/value sysfs attribute.
|
||||
* The GPIO does not have to be exported yet. If poll(2) support has
|
||||
* been enabled for either rising or falling edge, it will be
|
||||
* reconfigured to follow the new polarity.
|
||||
*
|
||||
* Returns zero on success, else an error.
|
||||
*/
|
||||
int gpiod_sysfs_set_active_low(struct gpio_desc *desc, int value)
|
||||
{
|
||||
struct device *dev = NULL;
|
||||
int status = -EINVAL;
|
||||
|
||||
if (!desc) {
|
||||
pr_warn("%s: invalid GPIO\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&sysfs_lock);
|
||||
|
||||
if (test_bit(FLAG_EXPORT, &desc->flags)) {
|
||||
dev = class_find_device(&gpio_class, NULL, desc, match_export);
|
||||
if (dev == NULL) {
|
||||
status = -ENODEV;
|
||||
goto unlock;
|
||||
}
|
||||
}
|
||||
|
||||
status = sysfs_set_active_low(desc, dev, value);
|
||||
put_device(dev);
|
||||
unlock:
|
||||
mutex_unlock(&sysfs_lock);
|
||||
|
||||
if (status)
|
||||
gpiod_dbg(desc, "%s: status %d\n", __func__, status);
|
||||
|
||||
return status;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gpiod_sysfs_set_active_low);
|
||||
|
||||
/**
|
||||
* gpiod_unexport - reverse effect of gpio_export()
|
||||
* @gpio: gpio to make unavailable
|
||||
|
Reference in New Issue
Block a user