aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2015-05-04 11:10:40 -0400
committerLinus Walleij <linus.walleij@linaro.org>2015-05-12 04:47:23 -0400
commitb91e18076f0d3ff9b49322a5b8eee595a1e4c082 (patch)
tree7157afd79213f55aa2ed3d0a5fa63cf1f9014169
parenta08f5c21f4a069cd75eb8a6170e3fe8b96e964d6 (diff)
gpio: sysfs: only call irq helper if needed
Only call irq helper if actually reconfiguring interrupt state. This is a preparatory step in introducing separate gpio-irq request and free functions. Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/gpio/gpiolib-sysfs.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index bccba406fc22..201b757ad0db 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -139,9 +139,6 @@ static int gpio_setup_irq(struct device *dev, unsigned long gpio_flags)
139 unsigned long irq_flags; 139 unsigned long irq_flags;
140 int ret, irq; 140 int ret, irq;
141 141
142 if ((desc->flags & GPIO_TRIGGER_MASK) == gpio_flags)
143 return 0;
144
145 irq = gpiod_to_irq(desc); 142 irq = gpiod_to_irq(desc);
146 if (irq < 0) 143 if (irq < 0)
147 return -EIO; 144 return -EIO;
@@ -240,6 +237,9 @@ static ssize_t edge_show(struct device *dev,
240static ssize_t edge_store(struct device *dev, 237static ssize_t edge_store(struct device *dev,
241 struct device_attribute *attr, const char *buf, size_t size) 238 struct device_attribute *attr, const char *buf, size_t size)
242{ 239{
240 struct gpiod_data *data = dev_get_drvdata(dev);
241 struct gpio_desc *desc = data->desc;
242 unsigned long flags;
243 ssize_t status; 243 ssize_t status;
244 int i; 244 int i;
245 245
@@ -249,12 +249,20 @@ static ssize_t edge_store(struct device *dev,
249 return -EINVAL; 249 return -EINVAL;
250 250
251found: 251found:
252 flags = trigger_types[i].flags;
253
252 mutex_lock(&sysfs_lock); 254 mutex_lock(&sysfs_lock);
253 255
254 status = gpio_setup_irq(dev, trigger_types[i].flags); 256 if ((desc->flags & GPIO_TRIGGER_MASK) == flags) {
257 status = size;
258 goto out_unlock;
259 }
260
261 status = gpio_setup_irq(dev, flags);
255 if (!status) 262 if (!status)
256 status = size; 263 status = size;
257 264
265out_unlock:
258 mutex_unlock(&sysfs_lock); 266 mutex_unlock(&sysfs_lock);
259 267
260 return status; 268 return status;
@@ -690,7 +698,8 @@ void gpiod_unexport(struct gpio_desc *desc)
690 * Release irq after deregistration to prevent race with 698 * Release irq after deregistration to prevent race with
691 * edge_store. 699 * edge_store.
692 */ 700 */
693 gpio_setup_irq(dev, 0); 701 if (desc->flags & GPIO_TRIGGER_MASK)
702 gpio_setup_irq(dev, 0);
694 put_device(dev); 703 put_device(dev);
695 kfree(data); 704 kfree(data);
696 } 705 }