[ARM] pxa: separate GPIOs and their mode definitions to pxa2xx-gpio.h
[linux-2.6.git] / drivers / input / keyboard / spitzkbd.c
index 8b18c00..0be74bf 100644 (file)
@@ -23,6 +23,7 @@
 #include <asm/arch/spitz.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/pxa-regs.h>
+#include <asm/arch/pxa2xx-gpio.h>
 
 #define KB_ROWS                        7
 #define KB_COLS                        11
@@ -257,7 +258,7 @@ static void spitzkbd_timer_callback(unsigned long data)
 {
        struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
 
-       spitzkbd_scankeyboard(spitzkbd_data, NULL);
+       spitzkbd_scankeyboard(spitzkbd_data);
 }
 
 /*
@@ -346,17 +347,12 @@ static int __init spitzkbd_probe(struct platform_device *dev)
 {
        struct spitzkbd *spitzkbd;
        struct input_dev *input_dev;
-       int i;
+       int i, err = -ENOMEM;
 
        spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL);
-       if (!spitzkbd)
-               return -ENOMEM;
-
        input_dev = input_allocate_device();
-       if (!input_dev) {
-               kfree(spitzkbd);
-               return -ENOMEM;
-       }
+       if (!spitzkbd || !input_dev)
+               goto fail;
 
        platform_set_drvdata(dev, spitzkbd);
        strcpy(spitzkbd->phys, "spitzkbd/input0");
@@ -377,17 +373,17 @@ static int __init spitzkbd_probe(struct platform_device *dev)
 
        spitzkbd->input = input_dev;
 
-       input_dev->private = spitzkbd;
        input_dev->name = "Spitz Keyboard";
        input_dev->phys = spitzkbd->phys;
-       input_dev->cdev.dev = &dev->dev;
+       input_dev->dev.parent = &dev->dev;
 
        input_dev->id.bustype = BUS_HOST;
        input_dev->id.vendor = 0x0001;
        input_dev->id.product = 0x0001;
        input_dev->id.version = 0x0100;
 
-       input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
+       input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
+               BIT_MASK(EV_PWR) | BIT_MASK(EV_SW);
        input_dev->keycode = spitzkbd->keycode;
        input_dev->keycodesize = sizeof(unsigned char);
        input_dev->keycodemax = ARRAY_SIZE(spitzkbd_keycode);
@@ -396,11 +392,14 @@ static int __init spitzkbd_probe(struct platform_device *dev)
        for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++)
                set_bit(spitzkbd->keycode[i], input_dev->keybit);
        clear_bit(0, input_dev->keybit);
+       set_bit(KEY_SUSPEND, input_dev->keybit);
        set_bit(SW_LID, input_dev->swbit);
        set_bit(SW_TABLET_MODE, input_dev->swbit);
        set_bit(SW_HEADPHONE_INSERT, input_dev->swbit);
 
-       input_register_device(input_dev);
+       err = input_register_device(input_dev);
+       if (err)
+               goto fail;
 
        mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
 
@@ -434,13 +433,15 @@ static int __init spitzkbd_probe(struct platform_device *dev)
        request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr,
                    IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
                    "Spitzkbd SWB", spitzkbd);
-       request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr,
+       request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr,
                    IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
                    "Spitzkbd HP", spitzkbd);
 
-       printk(KERN_INFO "input: Spitz Keyboard Registered\n");
-
        return 0;
+
+ fail: input_free_device(input_dev);
+       kfree(spitzkbd);
+       return err;
 }
 
 static int spitzkbd_remove(struct platform_device *dev)
@@ -474,6 +475,7 @@ static struct platform_driver spitzkbd_driver = {
        .resume         = spitzkbd_resume,
        .driver         = {
                .name   = "spitz-keyboard",
+               .owner  = THIS_MODULE,
        },
 };