unsigned long irq_flags;
int ret, irq;
- if ((desc->flags & GPIO_TRIGGER_MASK) == gpio_flags)
- return 0;
-
irq = gpiod_to_irq(desc);
if (irq < 0)
return -EIO;
static ssize_t edge_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
+ struct gpiod_data *data = dev_get_drvdata(dev);
+ struct gpio_desc *desc = data->desc;
+ unsigned long flags;
ssize_t status;
int i;
return -EINVAL;
found:
+ flags = trigger_types[i].flags;
+
mutex_lock(&sysfs_lock);
- status = gpio_setup_irq(dev, trigger_types[i].flags);
+ if ((desc->flags & GPIO_TRIGGER_MASK) == flags) {
+ status = size;
+ goto out_unlock;
+ }
+
+ status = gpio_setup_irq(dev, flags);
if (!status)
status = size;
+out_unlock:
mutex_unlock(&sysfs_lock);
return status;
* Release irq after deregistration to prevent race with
* edge_store.
*/
- gpio_setup_irq(dev, 0);
+ if (desc->flags & GPIO_TRIGGER_MASK)
+ gpio_setup_irq(dev, 0);
put_device(dev);
kfree(data);
}