]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/input/mouse/atarimouse.c
Merge branch 'hwmon-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6
[linux-2.6-omap-h63xx.git] / drivers / input / mouse / atarimouse.c
index 43ab6566fb65527a3f95e7191d814d5394eed43f..adf45b3040e90f036c685e37c72f83965499b5bb 100644 (file)
@@ -57,15 +57,12 @@ MODULE_AUTHOR("Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>");
 MODULE_DESCRIPTION("Atari mouse driver");
 MODULE_LICENSE("GPL");
 
-static int mouse_threshold[2] = {2,2};
+static int mouse_threshold[2] = {2, 2};
+module_param_array(mouse_threshold, int, NULL, 0);
 
-#ifdef __MODULE__
-MODULE_PARM(mouse_threshold, "2i");
-#endif
 #ifdef FIXED_ATARI_JOYSTICK
 extern int atari_mouse_buttons;
 #endif
-static int atamouse_used = 0;
 
 static struct input_dev *atamouse_dev;
 
@@ -73,14 +70,11 @@ static void atamouse_interrupt(char *buf)
 {
        int buttons, dx, dy;
 
-/*     ikbd_mouse_disable(); */
-
        buttons = (buf[0] & 1) | ((buf[0] & 2) << 1);
 #ifdef FIXED_ATARI_JOYSTICK
        buttons |= atari_mouse_buttons & 2;
        atari_mouse_buttons = buttons;
 #endif
-/*     ikbd_mouse_rel_pos(); */
 
        /* only relative events get here */
        dx =  buf[1];
@@ -100,9 +94,6 @@ static void atamouse_interrupt(char *buf)
 
 static int atamouse_open(struct input_dev *dev)
 {
-       if (atamouse_used++)
-               return 0;
-
 #ifdef FIXED_ATARI_JOYSTICK
        atari_mouse_buttons = 0;
 #endif
@@ -110,44 +101,51 @@ static int atamouse_open(struct input_dev *dev)
        ikbd_mouse_thresh(mouse_threshold[0], mouse_threshold[1]);
        ikbd_mouse_rel_pos();
        atari_input_mouse_interrupt_hook = atamouse_interrupt;
+
        return 0;
 }
 
 static void atamouse_close(struct input_dev *dev)
 {
-       if (!--atamouse_used) {
-               ikbd_mouse_disable();
-               atari_mouse_interrupt_hook = NULL;
-       }
+       ikbd_mouse_disable();
+       atari_mouse_interrupt_hook = NULL;
 }
 
 static int __init atamouse_init(void)
 {
+       int error;
+
        if (!MACH_IS_ATARI || !ATARIHW_PRESENT(ST_MFP))
                return -ENODEV;
 
-       if (!(atamouse_dev = input_allocate_device()))
-               return -ENOMEM;
-
-       if (!(atari_keyb_init()))
+       if (!atari_keyb_init())
                return -ENODEV;
 
+       atamouse_dev = input_allocate_device();
+       if (!atamouse_dev)
+               return -ENOMEM;
+
        atamouse_dev->name = "Atari mouse";
        atamouse_dev->phys = "atamouse/input0";
-       atamouse_dev->id.bustype = BUS_ATARI;
+       atamouse_dev->id.bustype = BUS_HOST;
        atamouse_dev->id.vendor = 0x0001;
        atamouse_dev->id.product = 0x0002;
        atamouse_dev->id.version = 0x0100;
 
-       atamouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
-       atamouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
-       atamouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
+       atamouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
+       atamouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
+       atamouse_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) |
+               BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
+
        atamouse_dev->open = atamouse_open;
        atamouse_dev->close = atamouse_close;
 
-       input_register_device(atamouse_dev);
+       error = input_register_device(atamouse_dev);
+       if (error) {
+               input_free_device(atamouse_dev);
+               return error;
+       }
 
-       printk(KERN_INFO "input: %s at keyboard ACIA\n", atamouse_dev->name);
        return 0;
 }