]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/input/keyboard/omap-keypad.c
[PATCH] ARM: OMAP2: Fix H4 keypad
[linux-2.6-omap-h63xx.git] / drivers / input / keyboard / omap-keypad.c
index c7cbd855efd59aa2532883dd9cb401a96e435f55..98bbe976c8d1c39b5ddb19eb879518198041f141 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
+#include <linux/mutex.h>
 #include <asm/arch/irqs.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/hardware.h>
@@ -48,14 +49,14 @@ static void omap_kp_tasklet(unsigned long);
 static void omap_kp_timer(unsigned long);
 
 static unsigned char keypad_state[8];
-static DECLARE_MUTEX(kp_enable_mutex);
+static DEFINE_MUTEX(kp_enable_mutex);
 static int kp_enable = 1;
 static int kp_cur_group = -1;
 
 struct omap_kp {
        struct input_dev *input;
        struct timer_list timer;
-       unsigned int irq;
+       int irq;
        unsigned int rows;
        unsigned int cols;
 };
@@ -83,7 +84,7 @@ static u8 get_row_gpio_val(struct omap_kp *omap_kp)
        int row;
        u8 value = 0;
 
-       for (row = 0; row < omap_kp->cols; row++) {
+       for (row = 0; row < omap_kp->rows; row++) {
                if (omap_get_gpio_datain(row_gpios[row]))
                        value |= (1 << row);
        }
@@ -250,7 +251,7 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
        if ((state != 1) && (state != 0))
                return -EINVAL;
 
-       down(&kp_enable_mutex);
+       mutex_lock(&kp_enable_mutex);
        if (state != kp_enable) {
                if (state)
                        enable_irq(INT_KEYBOARD);
@@ -258,7 +259,7 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
                        disable_irq(INT_KEYBOARD);
                kp_enable = state;
        }
-       up(&kp_enable_mutex);
+       mutex_unlock(&kp_enable_mutex);
 
        return strnlen(buf, count);
 }
@@ -357,7 +358,7 @@ static int __init omap_kp_probe(struct platform_device *pdev)
        kp_tasklet.data = (unsigned long) omap_kp;
 
        omap_kp->irq = platform_get_irq(pdev, 0);
-       if (omap_kp->irq) {
+       if (omap_kp->irq >= 0) {
                if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
                                "omap-keypad", omap_kp) < 0)
                        return -EINVAL;