]> err.no Git - linux-2.6/commitdiff
cris gpio: undo locks before returning
authorRoel Kluin <12o3l@tiscali.nl>
Thu, 15 Nov 2007 01:00:06 +0000 (17:00 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 15 Nov 2007 02:45:42 +0000 (18:45 -0800)
Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
Cc: Mikael Starvik <starvik@axis.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/cris/arch-v10/drivers/gpio.c

index f389ed6998fe4f92ec9fc28b95ce2cc8cbd65e34..0d347a7058355c0d9ff7e90cbd0e73a0b535b6af 100644 (file)
@@ -297,8 +297,10 @@ gpio_poll(struct file *file,
                data = *R_PORT_PB_DATA;
        else if (priv->minor == GPIO_MINOR_G)
                data = *R_PORT_G_DATA;
-       else
+       else {
+               spin_unlock(&gpio_lock);
                return 0;
+       }
        
        if ((data & priv->highalarm) ||
            (~data & priv->lowalarm)) {
@@ -381,18 +383,21 @@ static ssize_t gpio_write(struct file * file, const char * buf, size_t count,
 
        ssize_t retval = count;
        if (priv->minor !=GPIO_MINOR_A && priv->minor != GPIO_MINOR_B) {
-               return -EFAULT;
+               retval = -EFAULT;
+               goto out;
        }
     
        if (!access_ok(VERIFY_READ, buf, count)) {
-               return -EFAULT;
+               retval = -EFAULT;
+               goto out;
        }
        clk_mask = priv->clk_mask;
        data_mask = priv->data_mask;
        /* It must have been configured using the IO_CFG_WRITE_MODE */
        /* Perhaps a better error code? */
        if (clk_mask == 0 || data_mask == 0) {
-               return -EPERM;
+               retval = -EPERM;
+               goto out;
        }
        write_msb = priv->write_msb;
        D(printk("gpio_write: %lu to data 0x%02X clk 0x%02X msb: %i\n",count, data_mask, clk_mask, write_msb));
@@ -425,6 +430,7 @@ static ssize_t gpio_write(struct file * file, const char * buf, size_t count,
                        }
                }
        }
+out:
        spin_unlock(&gpio_lock);
        return retval;
 }
@@ -506,6 +512,7 @@ gpio_release(struct inode *inode, struct file *filp)
        while (p) {
                if (p->highalarm | p->lowalarm) {
                        gpio_some_alarms = 1;
+                       spin_unlock(&gpio_lock);
                        return 0;
                }
                p = p->next;