aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-10-28 16:09:47 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-28 16:09:47 -0400
commit84860bf0644d7c45afe7ddbd30731c3e3c371fae (patch)
treed6c4b98a9c3fd9981e7fcc5d7729c9e01e327767 /drivers/input/mouse
parent8caf89157d64f1eedba37113afb4b303b2b3e301 (diff)
parent6fbfddcb52d8d9fa2cd209f5ac2a1c87497d55b5 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r--drivers/input/mouse/alps.c63
-rw-r--r--drivers/input/mouse/alps.h2
-rw-r--r--drivers/input/mouse/amimouse.c49
-rw-r--r--drivers/input/mouse/inport.c96
-rw-r--r--drivers/input/mouse/lifebook.c16
-rw-r--r--drivers/input/mouse/logibm.c88
-rw-r--r--drivers/input/mouse/logips2pp.c20
-rw-r--r--drivers/input/mouse/maplemouse.c10
-rw-r--r--drivers/input/mouse/pc110pad.c64
-rw-r--r--drivers/input/mouse/psmouse-base.c99
-rw-r--r--drivers/input/mouse/psmouse.h2
-rw-r--r--drivers/input/mouse/rpcmouse.c43
-rw-r--r--drivers/input/mouse/sermouse.c82
-rw-r--r--drivers/input/mouse/synaptics.c6
-rw-r--r--drivers/input/mouse/vsxxxaa.c84
15 files changed, 363 insertions, 361 deletions
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index b20783f9748a..4acc7fd4cd0f 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -79,8 +79,8 @@ static void alps_process_packet(struct psmouse *psmouse, struct pt_regs *regs)
79{ 79{
80 struct alps_data *priv = psmouse->private; 80 struct alps_data *priv = psmouse->private;
81 unsigned char *packet = psmouse->packet; 81 unsigned char *packet = psmouse->packet;
82 struct input_dev *dev = &psmouse->dev; 82 struct input_dev *dev = psmouse->dev;
83 struct input_dev *dev2 = &priv->dev2; 83 struct input_dev *dev2 = priv->dev2;
84 int x, y, z, ges, fin, left, right, middle; 84 int x, y, z, ges, fin, left, right, middle;
85 int back = 0, forward = 0; 85 int back = 0, forward = 0;
86 86
@@ -379,20 +379,24 @@ static int alps_reconnect(struct psmouse *psmouse)
379static void alps_disconnect(struct psmouse *psmouse) 379static void alps_disconnect(struct psmouse *psmouse)
380{ 380{
381 struct alps_data *priv = psmouse->private; 381 struct alps_data *priv = psmouse->private;
382
382 psmouse_reset(psmouse); 383 psmouse_reset(psmouse);
383 input_unregister_device(&priv->dev2); 384 input_unregister_device(priv->dev2);
384 kfree(priv); 385 kfree(priv);
385} 386}
386 387
387int alps_init(struct psmouse *psmouse) 388int alps_init(struct psmouse *psmouse)
388{ 389{
389 struct alps_data *priv; 390 struct alps_data *priv;
391 struct input_dev *dev1 = psmouse->dev, *dev2;
390 int version; 392 int version;
391 393
392 psmouse->private = priv = kmalloc(sizeof(struct alps_data), GFP_KERNEL); 394 psmouse->private = priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL);
393 if (!priv) 395 dev2 = input_allocate_device();
396 if (!priv || !dev2)
394 goto init_fail; 397 goto init_fail;
395 memset(priv, 0, sizeof(struct alps_data)); 398
399 priv->dev2 = dev2;
396 400
397 if (!(priv->i = alps_get_model(psmouse, &version))) 401 if (!(priv->i = alps_get_model(psmouse, &version)))
398 goto init_fail; 402 goto init_fail;
@@ -411,41 +415,39 @@ int alps_init(struct psmouse *psmouse)
411 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0)) 415 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0))
412 goto init_fail; 416 goto init_fail;
413 417
414 psmouse->dev.evbit[LONG(EV_KEY)] |= BIT(EV_KEY); 418 dev1->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
415 psmouse->dev.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH); 419 dev1->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
416 psmouse->dev.keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER); 420 dev1->keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER);
417 psmouse->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 421 dev1->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
418 422
419 psmouse->dev.evbit[LONG(EV_ABS)] |= BIT(EV_ABS); 423 dev1->evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
420 input_set_abs_params(&psmouse->dev, ABS_X, 0, 1023, 0, 0); 424 input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0);
421 input_set_abs_params(&psmouse->dev, ABS_Y, 0, 767, 0, 0); 425 input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0);
422 input_set_abs_params(&psmouse->dev, ABS_PRESSURE, 0, 127, 0, 0); 426 input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0);
423 427
424 if (priv->i->flags & ALPS_WHEEL) { 428 if (priv->i->flags & ALPS_WHEEL) {
425 psmouse->dev.evbit[LONG(EV_REL)] |= BIT(EV_REL); 429 dev1->evbit[LONG(EV_REL)] |= BIT(EV_REL);
426 psmouse->dev.relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL); 430 dev1->relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL);
427 } 431 }
428 432
429 if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { 433 if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) {
430 psmouse->dev.keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD); 434 dev1->keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD);
431 psmouse->dev.keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); 435 dev1->keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK);
432 } 436 }
433 437
434 sprintf(priv->phys, "%s/input1", psmouse->ps2dev.serio->phys); 438 sprintf(priv->phys, "%s/input1", psmouse->ps2dev.serio->phys);
435 priv->dev2.phys = priv->phys; 439 dev2->phys = priv->phys;
436 priv->dev2.name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse"; 440 dev2->name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse";
437 priv->dev2.id.bustype = BUS_I8042; 441 dev2->id.bustype = BUS_I8042;
438 priv->dev2.id.vendor = 0x0002; 442 dev2->id.vendor = 0x0002;
439 priv->dev2.id.product = PSMOUSE_ALPS; 443 dev2->id.product = PSMOUSE_ALPS;
440 priv->dev2.id.version = 0x0000; 444 dev2->id.version = 0x0000;
441
442 priv->dev2.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
443 priv->dev2.relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y);
444 priv->dev2.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
445 445
446 input_register_device(&priv->dev2); 446 dev2->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
447 dev2->relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y);
448 dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
447 449
448 printk(KERN_INFO "input: %s on %s\n", priv->dev2.name, psmouse->ps2dev.serio->phys); 450 input_register_device(priv->dev2);
449 451
450 psmouse->protocol_handler = alps_process_byte; 452 psmouse->protocol_handler = alps_process_byte;
451 psmouse->disconnect = alps_disconnect; 453 psmouse->disconnect = alps_disconnect;
@@ -455,6 +457,7 @@ int alps_init(struct psmouse *psmouse)
455 return 0; 457 return 0;
456 458
457init_fail: 459init_fail:
460 input_free_device(dev2);
458 kfree(priv); 461 kfree(priv);
459 return -1; 462 return -1;
460} 463}
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index aba103dd65b7..e428f8d5d12e 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -22,7 +22,7 @@ struct alps_model_info {
22}; 22};
23 23
24struct alps_data { 24struct alps_data {
25 struct input_dev dev2; /* Relative device */ 25 struct input_dev *dev2; /* Relative device */
26 char name[32]; /* Name */ 26 char name[32]; /* Name */
27 char phys[32]; /* Phys */ 27 char phys[32]; /* Phys */
28 struct alps_model_info *i; /* Info */ 28 struct alps_model_info *i; /* Info */
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c
index e994849efb8f..d13d4c8fe3c5 100644
--- a/drivers/input/mouse/amimouse.c
+++ b/drivers/input/mouse/amimouse.c
@@ -34,10 +34,7 @@ MODULE_DESCRIPTION("Amiga mouse driver");
34MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
35 35
36static int amimouse_lastx, amimouse_lasty; 36static int amimouse_lastx, amimouse_lasty;
37static struct input_dev amimouse_dev; 37static struct input_dev *amimouse_dev;
38
39static char *amimouse_name = "Amiga mouse";
40static char *amimouse_phys = "amimouse/input0";
41 38
42static irqreturn_t amimouse_interrupt(int irq, void *dummy, struct pt_regs *fp) 39static irqreturn_t amimouse_interrupt(int irq, void *dummy, struct pt_regs *fp)
43{ 40{
@@ -62,16 +59,16 @@ static irqreturn_t amimouse_interrupt(int irq, void *dummy, struct pt_regs *fp)
62 59
63 potgor = custom.potgor; 60 potgor = custom.potgor;
64 61
65 input_regs(&amimouse_dev, fp); 62 input_regs(amimouse_dev, fp);
66 63
67 input_report_rel(&amimouse_dev, REL_X, dx); 64 input_report_rel(amimouse_dev, REL_X, dx);
68 input_report_rel(&amimouse_dev, REL_Y, dy); 65 input_report_rel(amimouse_dev, REL_Y, dy);
69 66
70 input_report_key(&amimouse_dev, BTN_LEFT, ciaa.pra & 0x40); 67 input_report_key(amimouse_dev, BTN_LEFT, ciaa.pra & 0x40);
71 input_report_key(&amimouse_dev, BTN_MIDDLE, potgor & 0x0100); 68 input_report_key(amimouse_dev, BTN_MIDDLE, potgor & 0x0100);
72 input_report_key(&amimouse_dev, BTN_RIGHT, potgor & 0x0400); 69 input_report_key(amimouse_dev, BTN_RIGHT, potgor & 0x0400);
73 70
74 input_sync(&amimouse_dev); 71 input_sync(amimouse_dev);
75 72
76 return IRQ_HANDLED; 73 return IRQ_HANDLED;
77} 74}
@@ -103,28 +100,30 @@ static int __init amimouse_init(void)
103 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE)) 100 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE))
104 return -ENODEV; 101 return -ENODEV;
105 102
106 amimouse_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 103 if (!(amimouse_dev = input_allocate_device()))
107 amimouse_dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); 104 return -ENOMEM;
108 amimouse_dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 105
109 amimouse_dev.open = amimouse_open; 106 amimouse_dev->name = "Amiga mouse";
110 amimouse_dev.close = amimouse_close; 107 amimouse_dev->phys = "amimouse/input0";
108 amimouse_dev->id.bustype = BUS_AMIGA;
109 amimouse_dev->id.vendor = 0x0001;
110 amimouse_dev->id.product = 0x0002;
111 amimouse_dev->id.version = 0x0100;
111 112
112 amimouse_dev.name = amimouse_name; 113 amimouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
113 amimouse_dev.phys = amimouse_phys; 114 amimouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
114 amimouse_dev.id.bustype = BUS_AMIGA; 115 amimouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
115 amimouse_dev.id.vendor = 0x0001; 116 amimouse_dev->open = amimouse_open;
116 amimouse_dev.id.product = 0x0002; 117 amimouse_dev->close = amimouse_close;
117 amimouse_dev.id.version = 0x0100;
118 118
119 input_register_device(&amimouse_dev); 119 input_register_device(amimouse_dev);
120 120
121 printk(KERN_INFO "input: %s at joy0dat\n", amimouse_name);
122 return 0; 121 return 0;
123} 122}
124 123
125static void __exit amimouse_exit(void) 124static void __exit amimouse_exit(void)
126{ 125{
127 input_unregister_device(&amimouse_dev); 126 input_unregister_device(amimouse_dev);
128} 127}
129 128
130module_init(amimouse_init); 129module_init(amimouse_init);
diff --git a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c
index 1f62c0134010..afc66f56df43 100644
--- a/drivers/input/mouse/inport.c
+++ b/drivers/input/mouse/inport.c
@@ -87,40 +87,7 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)");
87 87
88__obsolete_setup("inport_irq="); 88__obsolete_setup("inport_irq=");
89 89
90static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs); 90static struct input_dev *inport_dev;
91
92static int inport_open(struct input_dev *dev)
93{
94 if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL))
95 return -EBUSY;
96 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
97 outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
98
99 return 0;
100}
101
102static void inport_close(struct input_dev *dev)
103{
104 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
105 outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
106 free_irq(inport_irq, NULL);
107}
108
109static struct input_dev inport_dev = {
110 .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
111 .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
112 .relbit = { BIT(REL_X) | BIT(REL_Y) },
113 .open = inport_open,
114 .close = inport_close,
115 .name = INPORT_NAME,
116 .phys = "isa023c/input0",
117 .id = {
118 .bustype = BUS_ISA,
119 .vendor = INPORT_VENDOR,
120 .product = 0x0001,
121 .version = 0x0100,
122 },
123};
124 91
125static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs) 92static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs)
126{ 93{
@@ -129,31 +96,48 @@ static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs)
129 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 96 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
130 outb(INPORT_MODE_HOLD | INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); 97 outb(INPORT_MODE_HOLD | INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
131 98
132 input_regs(&inport_dev, regs); 99 input_regs(inport_dev, regs);
133 100
134 outb(INPORT_REG_X, INPORT_CONTROL_PORT); 101 outb(INPORT_REG_X, INPORT_CONTROL_PORT);
135 input_report_rel(&inport_dev, REL_X, inb(INPORT_DATA_PORT)); 102 input_report_rel(inport_dev, REL_X, inb(INPORT_DATA_PORT));
136 103
137 outb(INPORT_REG_Y, INPORT_CONTROL_PORT); 104 outb(INPORT_REG_Y, INPORT_CONTROL_PORT);
138 input_report_rel(&inport_dev, REL_Y, inb(INPORT_DATA_PORT)); 105 input_report_rel(inport_dev, REL_Y, inb(INPORT_DATA_PORT));
139 106
140 outb(INPORT_REG_BTNS, INPORT_CONTROL_PORT); 107 outb(INPORT_REG_BTNS, INPORT_CONTROL_PORT);
141 buttons = inb(INPORT_DATA_PORT); 108 buttons = inb(INPORT_DATA_PORT);
142 109
143 input_report_key(&inport_dev, BTN_MIDDLE, buttons & 1); 110 input_report_key(inport_dev, BTN_MIDDLE, buttons & 1);
144 input_report_key(&inport_dev, BTN_LEFT, buttons & 2); 111 input_report_key(inport_dev, BTN_LEFT, buttons & 2);
145 input_report_key(&inport_dev, BTN_RIGHT, buttons & 4); 112 input_report_key(inport_dev, BTN_RIGHT, buttons & 4);
146 113
147 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 114 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
148 outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); 115 outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
149 116
150 input_sync(&inport_dev); 117 input_sync(inport_dev);
151 return IRQ_HANDLED; 118 return IRQ_HANDLED;
152} 119}
153 120
121static int inport_open(struct input_dev *dev)
122{
123 if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL))
124 return -EBUSY;
125 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
126 outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
127
128 return 0;
129}
130
131static void inport_close(struct input_dev *dev)
132{
133 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
134 outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
135 free_irq(inport_irq, NULL);
136}
137
154static int __init inport_init(void) 138static int __init inport_init(void)
155{ 139{
156 unsigned char a,b,c; 140 unsigned char a, b, c;
157 141
158 if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) { 142 if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) {
159 printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE); 143 printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE);
@@ -163,26 +147,44 @@ static int __init inport_init(void)
163 a = inb(INPORT_SIGNATURE_PORT); 147 a = inb(INPORT_SIGNATURE_PORT);
164 b = inb(INPORT_SIGNATURE_PORT); 148 b = inb(INPORT_SIGNATURE_PORT);
165 c = inb(INPORT_SIGNATURE_PORT); 149 c = inb(INPORT_SIGNATURE_PORT);
166 if (( a == b ) || ( a != c )) { 150 if (a == b || a != c) {
167 release_region(INPORT_BASE, INPORT_EXTENT); 151 release_region(INPORT_BASE, INPORT_EXTENT);
168 printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE); 152 printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE);
169 return -ENODEV; 153 return -ENODEV;
170 } 154 }
171 155
156 if (!(inport_dev = input_allocate_device())) {
157 printk(KERN_ERR "inport.c: Not enough memory for input device\n");
158 release_region(INPORT_BASE, INPORT_EXTENT);
159 return -ENOMEM;
160 }
161
162 inport_dev->name = INPORT_NAME;
163 inport_dev->phys = "isa023c/input0";
164 inport_dev->id.bustype = BUS_ISA;
165 inport_dev->id.vendor = INPORT_VENDOR;
166 inport_dev->id.product = 0x0001;
167 inport_dev->id.version = 0x0100;
168
169 inport_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
170 inport_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
171 inport_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
172
173 inport_dev->open = inport_open;
174 inport_dev->close = inport_close;
175
172 outb(INPORT_RESET, INPORT_CONTROL_PORT); 176 outb(INPORT_RESET, INPORT_CONTROL_PORT);
173 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 177 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
174 outb(INPORT_MODE_BASE, INPORT_DATA_PORT); 178 outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
175 179
176 input_register_device(&inport_dev); 180 input_register_device(inport_dev);
177
178 printk(KERN_INFO "input: " INPORT_NAME " at %#x irq %d\n", INPORT_BASE, inport_irq);
179 181
180 return 0; 182 return 0;
181} 183}
182 184
183static void __exit inport_exit(void) 185static void __exit inport_exit(void)
184{ 186{
185 input_unregister_device(&inport_dev); 187 input_unregister_device(inport_dev);
186 release_region(INPORT_BASE, INPORT_EXTENT); 188 release_region(INPORT_BASE, INPORT_EXTENT);
187} 189}
188 190
diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c
index bd9df9b28325..55991424ac91 100644
--- a/drivers/input/mouse/lifebook.c
+++ b/drivers/input/mouse/lifebook.c
@@ -34,7 +34,7 @@ static struct dmi_system_id lifebook_dmi_table[] = {
34static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse, struct pt_regs *regs) 34static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
35{ 35{
36 unsigned char *packet = psmouse->packet; 36 unsigned char *packet = psmouse->packet;
37 struct input_dev *dev = &psmouse->dev; 37 struct input_dev *dev = psmouse->dev;
38 38
39 if (psmouse->pktcnt != 3) 39 if (psmouse->pktcnt != 3)
40 return PSMOUSE_GOOD_DATA; 40 return PSMOUSE_GOOD_DATA;
@@ -113,15 +113,17 @@ int lifebook_detect(struct psmouse *psmouse, int set_properties)
113 113
114int lifebook_init(struct psmouse *psmouse) 114int lifebook_init(struct psmouse *psmouse)
115{ 115{
116 struct input_dev *input_dev = psmouse->dev;
117
116 if (lifebook_absolute_mode(psmouse)) 118 if (lifebook_absolute_mode(psmouse))
117 return -1; 119 return -1;
118 120
119 psmouse->dev.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); 121 input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL);
120 psmouse->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 122 input_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
121 psmouse->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 123 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
122 psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); 124 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
123 input_set_abs_params(&psmouse->dev, ABS_X, 0, 1024, 0, 0); 125 input_set_abs_params(input_dev, ABS_X, 0, 1024, 0, 0);
124 input_set_abs_params(&psmouse->dev, ABS_Y, 0, 1024, 0, 0); 126 input_set_abs_params(input_dev, ABS_Y, 0, 1024, 0, 0);
125 127
126 psmouse->protocol_handler = lifebook_process_byte; 128 psmouse->protocol_handler = lifebook_process_byte;
127 psmouse->set_resolution = lifebook_set_resolution; 129 psmouse->set_resolution = lifebook_set_resolution;
diff --git a/drivers/input/mouse/logibm.c b/drivers/input/mouse/logibm.c
index 8b5243167227..9c7ce38806d7 100644
--- a/drivers/input/mouse/logibm.c
+++ b/drivers/input/mouse/logibm.c
@@ -77,39 +77,7 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)");
77 77
78__obsolete_setup("logibm_irq="); 78__obsolete_setup("logibm_irq=");
79 79
80static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs); 80static struct input_dev *logibm_dev;
81
82static int logibm_open(struct input_dev *dev)
83{
84 if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) {
85 printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq);
86 return -EBUSY;
87 }
88 outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT);
89 return 0;
90}
91
92static void logibm_close(struct input_dev *dev)
93{
94 outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
95 free_irq(logibm_irq, NULL);
96}
97
98static struct input_dev logibm_dev = {
99 .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
100 .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
101 .relbit = { BIT(REL_X) | BIT(REL_Y) },
102 .open = logibm_open,
103 .close = logibm_close,
104 .name = "Logitech bus mouse",
105 .phys = "isa023c/input0",
106 .id = {
107 .bustype = BUS_ISA,
108 .vendor = 0x0003,
109 .product = 0x0001,
110 .version = 0x0100,
111 },
112};
113 81
114static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs) 82static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
115{ 83{
@@ -127,18 +95,34 @@ static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
127 dy |= (buttons & 0xf) << 4; 95 dy |= (buttons & 0xf) << 4;
128 buttons = ~buttons >> 5; 96 buttons = ~buttons >> 5;
129 97
130 input_regs(&logibm_dev, regs); 98 input_regs(logibm_dev, regs);
131 input_report_rel(&logibm_dev, REL_X, dx); 99 input_report_rel(logibm_dev, REL_X, dx);
132 input_report_rel(&logibm_dev, REL_Y, dy); 100 input_report_rel(logibm_dev, REL_Y, dy);
133 input_report_key(&logibm_dev, BTN_RIGHT, buttons & 1); 101 input_report_key(logibm_dev, BTN_RIGHT, buttons & 1);
134 input_report_key(&logibm_dev, BTN_MIDDLE, buttons & 2); 102 input_report_key(logibm_dev, BTN_MIDDLE, buttons & 2);
135 input_report_key(&logibm_dev, BTN_LEFT, buttons & 4); 103 input_report_key(logibm_dev, BTN_LEFT, buttons & 4);
136 input_sync(&logibm_dev); 104 input_sync(logibm_dev);
137 105
138 outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT); 106 outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT);
139 return IRQ_HANDLED; 107 return IRQ_HANDLED;
140} 108}
141 109
110static int logibm_open(struct input_dev *dev)
111{
112 if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) {
113 printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq);
114 return -EBUSY;
115 }
116 outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT);
117 return 0;
118}
119
120static void logibm_close(struct input_dev *dev)
121{
122 outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
123 free_irq(logibm_irq, NULL);
124}
125
142static int __init logibm_init(void) 126static int __init logibm_init(void)
143{ 127{
144 if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) { 128 if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) {
@@ -159,16 +143,34 @@ static int __init logibm_init(void)
159 outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT); 143 outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT);
160 outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); 144 outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
161 145
162 input_register_device(&logibm_dev); 146 if (!(logibm_dev = input_allocate_device())) {
147 printk(KERN_ERR "logibm.c: Not enough memory for input device\n");
148 release_region(LOGIBM_BASE, LOGIBM_EXTENT);
149 return -ENOMEM;
150 }
151
152 logibm_dev->name = "Logitech bus mouse";
153 logibm_dev->phys = "isa023c/input0";
154 logibm_dev->id.bustype = BUS_ISA;
155 logibm_dev->id.vendor = 0x0003;
156 logibm_dev->id.product = 0x0001;
157 logibm_dev->id.version = 0x0100;
158
159 logibm_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
160 logibm_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
161 logibm_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
162
163 logibm_dev->open = logibm_open;
164 logibm_dev->close = logibm_close;
163 165
164 printk(KERN_INFO "input: Logitech bus mouse at %#x irq %d\n", LOGIBM_BASE, logibm_irq); 166 input_register_device(logibm_dev);
165 167
166 return 0; 168 return 0;
167} 169}
168 170
169static void __exit logibm_exit(void) 171static void __exit logibm_exit(void)
170{ 172{
171 input_unregister_device(&logibm_dev); 173 input_unregister_device(logibm_dev);
172 release_region(LOGIBM_BASE, LOGIBM_EXTENT); 174 release_region(LOGIBM_BASE, LOGIBM_EXTENT);
173} 175}
174 176
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 7df96525222e..0f69ff46c1ae 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -40,7 +40,7 @@ struct ps2pp_info {
40 40
41static psmouse_ret_t ps2pp_process_byte(struct psmouse *psmouse, struct pt_regs *regs) 41static psmouse_ret_t ps2pp_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
42{ 42{
43 struct input_dev *dev = &psmouse->dev; 43 struct input_dev *dev = psmouse->dev;
44 unsigned char *packet = psmouse->packet; 44 unsigned char *packet = psmouse->packet;
45 45
46 if (psmouse->pktcnt < 3) 46 if (psmouse->pktcnt < 3)
@@ -257,25 +257,27 @@ static struct ps2pp_info *get_model_info(unsigned char model)
257static void ps2pp_set_model_properties(struct psmouse *psmouse, struct ps2pp_info *model_info, 257static void ps2pp_set_model_properties(struct psmouse *psmouse, struct ps2pp_info *model_info,
258 int using_ps2pp) 258 int using_ps2pp)
259{ 259{
260 struct input_dev *input_dev = psmouse->dev;
261
260 if (model_info->features & PS2PP_SIDE_BTN) 262 if (model_info->features & PS2PP_SIDE_BTN)
261 set_bit(BTN_SIDE, psmouse->dev.keybit); 263 set_bit(BTN_SIDE, input_dev->keybit);
262 264
263 if (model_info->features & PS2PP_EXTRA_BTN) 265 if (model_info->features & PS2PP_EXTRA_BTN)
264 set_bit(BTN_EXTRA, psmouse->dev.keybit); 266 set_bit(BTN_EXTRA, input_dev->keybit);
265 267
266 if (model_info->features & PS2PP_TASK_BTN) 268 if (model_info->features & PS2PP_TASK_BTN)
267 set_bit(BTN_TASK, psmouse->dev.keybit); 269 set_bit(BTN_TASK, input_dev->keybit);
268 270
269 if (model_info->features & PS2PP_NAV_BTN) { 271 if (model_info->features & PS2PP_NAV_BTN) {
270 set_bit(BTN_FORWARD, psmouse->dev.keybit); 272 set_bit(BTN_FORWARD, input_dev->keybit);
271 set_bit(BTN_BACK, psmouse->dev.keybit); 273 set_bit(BTN_BACK, input_dev->keybit);
272 } 274 }
273 275
274 if (model_info->features & PS2PP_WHEEL) 276 if (model_info->features & PS2PP_WHEEL)
275 set_bit(REL_WHEEL, psmouse->dev.relbit); 277 set_bit(REL_WHEEL, input_dev->relbit);
276 278
277 if (model_info->features & PS2PP_HWHEEL) 279 if (model_info->features & PS2PP_HWHEEL)
278 set_bit(REL_HWHEEL, psmouse->dev.relbit); 280 set_bit(REL_HWHEEL, input_dev->relbit);
279 281
280 switch (model_info->kind) { 282 switch (model_info->kind) {
281 case PS2PP_KIND_WHEEL: 283 case PS2PP_KIND_WHEEL:
@@ -387,7 +389,7 @@ int ps2pp_init(struct psmouse *psmouse, int set_properties)
387 } 389 }
388 390
389 if (buttons < 3) 391 if (buttons < 3)
390 clear_bit(BTN_MIDDLE, psmouse->dev.keybit); 392 clear_bit(BTN_MIDDLE, psmouse->dev->keybit);
391 393
392 if (model_info) 394 if (model_info)
393 ps2pp_set_model_properties(psmouse, model_info, use_ps2pp); 395 ps2pp_set_model_properties(psmouse, model_info, use_ps2pp);
diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c
index e90c60cbbf05..b5b34fe4fee8 100644
--- a/drivers/input/mouse/maplemouse.c
+++ b/drivers/input/mouse/maplemouse.c
@@ -41,13 +41,12 @@ static int dc_mouse_connect(struct maple_device *dev)
41 unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); 41 unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
42 struct input_dev *input_dev; 42 struct input_dev *input_dev;
43 43
44 if (!(input_dev = kmalloc(sizeof(struct input_dev), GFP_KERNEL))) 44 dev->private_data = input_dev = input_allocate_device();
45 return -1; 45 if (!input_dev)
46 return -ENOMEM;
46 47
47 dev->private_data = input_dev; 48 dev->private_data = input_dev;
48 49
49 memset(input_dev, 0, sizeof(struct dc_mouse));
50 init_input_dev(input_dev);
51 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 50 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
52 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 51 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
53 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); 52 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
@@ -59,8 +58,6 @@ static int dc_mouse_connect(struct maple_device *dev)
59 58
60 maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); 59 maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE);
61 60
62 printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, input_dev->name);
63
64 return 0; 61 return 0;
65} 62}
66 63
@@ -70,7 +67,6 @@ static void dc_mouse_disconnect(struct maple_device *dev)
70 struct input_dev *input_dev = dev->private_data; 67 struct input_dev *input_dev = dev->private_data;
71 68
72 input_unregister_device(input_dev); 69 input_unregister_device(input_dev);
73 kfree(input_dev);
74} 70}
75 71
76 72
diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c
index 93393d5c0078..d284ea712151 100644
--- a/drivers/input/mouse/pc110pad.c
+++ b/drivers/input/mouse/pc110pad.c
@@ -53,13 +53,10 @@ MODULE_LICENSE("GPL");
53static int pc110pad_irq = 10; 53static int pc110pad_irq = 10;
54static int pc110pad_io = 0x15e0; 54static int pc110pad_io = 0x15e0;
55 55
56static struct input_dev pc110pad_dev; 56static struct input_dev *pc110pad_dev;
57static int pc110pad_data[3]; 57static int pc110pad_data[3];
58static int pc110pad_count; 58static int pc110pad_count;
59 59
60static char *pc110pad_name = "IBM PC110 TouchPad";
61static char *pc110pad_phys = "isa15e0/input0";
62
63static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs) 60static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs)
64{ 61{
65 int value = inb_p(pc110pad_io); 62 int value = inb_p(pc110pad_io);
@@ -74,14 +71,14 @@ static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs)
74 if (pc110pad_count < 3) 71 if (pc110pad_count < 3)
75 return IRQ_HANDLED; 72 return IRQ_HANDLED;
76 73
77 input_regs(&pc110pad_dev, regs); 74 input_regs(pc110pad_dev, regs);
78 input_report_key(&pc110pad_dev, BTN_TOUCH, 75 input_report_key(pc110pad_dev, BTN_TOUCH,
79 pc110pad_data[0] & 0x01); 76 pc110pad_data[0] & 0x01);
80 input_report_abs(&pc110pad_dev, ABS_X, 77 input_report_abs(pc110pad_dev, ABS_X,
81 pc110pad_data[1] | ((pc110pad_data[0] << 3) & 0x80) | ((pc110pad_data[0] << 1) & 0x100)); 78 pc110pad_data[1] | ((pc110pad_data[0] << 3) & 0x80) | ((pc110pad_data[0] << 1) & 0x100));
82 input_report_abs(&pc110pad_dev, ABS_Y, 79 input_report_abs(pc110pad_dev, ABS_Y,
83 pc110pad_data[2] | ((pc110pad_data[0] << 4) & 0x80)); 80 pc110pad_data[2] | ((pc110pad_data[0] << 4) & 0x80));
84 input_sync(&pc110pad_dev); 81 input_sync(pc110pad_dev);
85 82
86 pc110pad_count = 0; 83 pc110pad_count = 0;
87 return IRQ_HANDLED; 84 return IRQ_HANDLED;
@@ -94,9 +91,9 @@ static void pc110pad_close(struct input_dev *dev)
94 91
95static int pc110pad_open(struct input_dev *dev) 92static int pc110pad_open(struct input_dev *dev)
96{ 93{
97 pc110pad_interrupt(0,NULL,NULL); 94 pc110pad_interrupt(0, NULL, NULL);
98 pc110pad_interrupt(0,NULL,NULL); 95 pc110pad_interrupt(0, NULL, NULL);
99 pc110pad_interrupt(0,NULL,NULL); 96 pc110pad_interrupt(0, NULL, NULL);
100 outb(PC110PAD_ON, pc110pad_io + 2); 97 outb(PC110PAD_ON, pc110pad_io + 2);
101 pc110pad_count = 0; 98 pc110pad_count = 0;
102 99
@@ -127,45 +124,46 @@ static int __init pc110pad_init(void)
127 124
128 outb(PC110PAD_OFF, pc110pad_io + 2); 125 outb(PC110PAD_OFF, pc110pad_io + 2);
129 126
130 if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) 127 if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) {
131 {
132 release_region(pc110pad_io, 4); 128 release_region(pc110pad_io, 4);
133 printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq); 129 printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq);
134 return -EBUSY; 130 return -EBUSY;
135 } 131 }
136 132
137 pc110pad_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 133 if (!(pc110pad_dev = input_allocate_device())) {
138 pc110pad_dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); 134 free_irq(pc110pad_irq, NULL);
139 pc110pad_dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 135 release_region(pc110pad_io, 4);
136 printk(KERN_ERR "pc110pad: Not enough memory.\n");
137 return -ENOMEM;
138 }
140 139
141 pc110pad_dev.absmax[ABS_X] = 0x1ff; 140 pc110pad_dev->name = "IBM PC110 TouchPad";
142 pc110pad_dev.absmax[ABS_Y] = 0x0ff; 141 pc110pad_dev->phys = "isa15e0/input0";
142 pc110pad_dev->id.bustype = BUS_ISA;
143 pc110pad_dev->id.vendor = 0x0003;
144 pc110pad_dev->id.product = 0x0001;
145 pc110pad_dev->id.version = 0x0100;
143 146
144 pc110pad_dev.open = pc110pad_open; 147 pc110pad_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
145 pc110pad_dev.close = pc110pad_close; 148 pc110pad_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
149 pc110pad_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
146 150
147 pc110pad_dev.name = pc110pad_name; 151 pc110pad_dev->absmax[ABS_X] = 0x1ff;
148 pc110pad_dev.phys = pc110pad_phys; 152 pc110pad_dev->absmax[ABS_Y] = 0x0ff;
149 pc110pad_dev.id.bustype = BUS_ISA;
150 pc110pad_dev.id.vendor = 0x0003;
151 pc110pad_dev.id.product = 0x0001;
152 pc110pad_dev.id.version = 0x0100;
153 153
154 input_register_device(&pc110pad_dev); 154 pc110pad_dev->open = pc110pad_open;
155 pc110pad_dev->close = pc110pad_close;
155 156
156 printk(KERN_INFO "input: %s at %#x irq %d\n", 157 input_register_device(pc110pad_dev);
157 pc110pad_name, pc110pad_io, pc110pad_irq);
158 158
159 return 0; 159 return 0;
160} 160}
161 161
162static void __exit pc110pad_exit(void) 162static void __exit pc110pad_exit(void)
163{ 163{
164 input_unregister_device(&pc110pad_dev);
165
166 outb(PC110PAD_OFF, pc110pad_io + 2); 164 outb(PC110PAD_OFF, pc110pad_io + 2);
167
168 free_irq(pc110pad_irq, NULL); 165 free_irq(pc110pad_irq, NULL);
166 input_unregister_device(pc110pad_dev);
169 release_region(pc110pad_io, 4); 167 release_region(pc110pad_io, 4);
170} 168}
171 169
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index af24313ff5bb..6ee9999a2eaa 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -114,7 +114,7 @@ struct psmouse_protocol {
114 114
115static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse, struct pt_regs *regs) 115static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
116{ 116{
117 struct input_dev *dev = &psmouse->dev; 117 struct input_dev *dev = psmouse->dev;
118 unsigned char *packet = psmouse->packet; 118 unsigned char *packet = psmouse->packet;
119 119
120 if (psmouse->pktcnt < psmouse->pktsize) 120 if (psmouse->pktcnt < psmouse->pktsize)
@@ -333,12 +333,11 @@ static int genius_detect(struct psmouse *psmouse, int set_properties)
333 return -1; 333 return -1;
334 334
335 if (set_properties) { 335 if (set_properties) {
336 set_bit(BTN_EXTRA, psmouse->dev.keybit); 336 set_bit(BTN_EXTRA, psmouse->dev->keybit);
337 set_bit(BTN_SIDE, psmouse->dev.keybit); 337 set_bit(BTN_SIDE, psmouse->dev->keybit);
338 set_bit(REL_WHEEL, psmouse->dev.relbit); 338 set_bit(REL_WHEEL, psmouse->dev->relbit);
339 339
340 psmouse->vendor = "Genius"; 340 psmouse->vendor = "Genius";
341 psmouse->name = "Wheel Mouse";
342 psmouse->pktsize = 4; 341 psmouse->pktsize = 4;
343 } 342 }
344 343
@@ -365,8 +364,8 @@ static int intellimouse_detect(struct psmouse *psmouse, int set_properties)
365 return -1; 364 return -1;
366 365
367 if (set_properties) { 366 if (set_properties) {
368 set_bit(BTN_MIDDLE, psmouse->dev.keybit); 367 set_bit(BTN_MIDDLE, psmouse->dev->keybit);
369 set_bit(REL_WHEEL, psmouse->dev.relbit); 368 set_bit(REL_WHEEL, psmouse->dev->relbit);
370 369
371 if (!psmouse->vendor) psmouse->vendor = "Generic"; 370 if (!psmouse->vendor) psmouse->vendor = "Generic";
372 if (!psmouse->name) psmouse->name = "Wheel Mouse"; 371 if (!psmouse->name) psmouse->name = "Wheel Mouse";
@@ -398,10 +397,10 @@ static int im_explorer_detect(struct psmouse *psmouse, int set_properties)
398 return -1; 397 return -1;
399 398
400 if (set_properties) { 399 if (set_properties) {
401 set_bit(BTN_MIDDLE, psmouse->dev.keybit); 400 set_bit(BTN_MIDDLE, psmouse->dev->keybit);
402 set_bit(REL_WHEEL, psmouse->dev.relbit); 401 set_bit(REL_WHEEL, psmouse->dev->relbit);
403 set_bit(BTN_SIDE, psmouse->dev.keybit); 402 set_bit(BTN_SIDE, psmouse->dev->keybit);
404 set_bit(BTN_EXTRA, psmouse->dev.keybit); 403 set_bit(BTN_EXTRA, psmouse->dev->keybit);
405 404
406 if (!psmouse->vendor) psmouse->vendor = "Generic"; 405 if (!psmouse->vendor) psmouse->vendor = "Generic";
407 if (!psmouse->name) psmouse->name = "Explorer Mouse"; 406 if (!psmouse->name) psmouse->name = "Explorer Mouse";
@@ -433,7 +432,7 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties)
433 return -1; 432 return -1;
434 433
435 if (set_properties) { 434 if (set_properties) {
436 set_bit(BTN_EXTRA, psmouse->dev.keybit); 435 set_bit(BTN_EXTRA, psmouse->dev->keybit);
437 436
438 psmouse->vendor = "Kensington"; 437 psmouse->vendor = "Kensington";
439 psmouse->name = "ThinkingMouse"; 438 psmouse->name = "ThinkingMouse";
@@ -839,9 +838,9 @@ static void psmouse_disconnect(struct serio *serio)
839 838
840 psmouse_set_state(psmouse, PSMOUSE_IGNORE); 839 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
841 840
842 input_unregister_device(&psmouse->dev);
843 serio_close(serio); 841 serio_close(serio);
844 serio_set_drvdata(serio, NULL); 842 serio_set_drvdata(serio, NULL);
843 input_unregister_device(psmouse->dev);
845 kfree(psmouse); 844 kfree(psmouse);
846 845
847 if (parent) 846 if (parent)
@@ -852,16 +851,14 @@ static void psmouse_disconnect(struct serio *serio)
852 851
853static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto) 852static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto)
854{ 853{
855 memset(&psmouse->dev, 0, sizeof(struct input_dev)); 854 struct input_dev *input_dev = psmouse->dev;
856 855
857 init_input_dev(&psmouse->dev); 856 input_dev->private = psmouse;
857 input_dev->cdev.dev = &psmouse->ps2dev.serio->dev;
858 858
859 psmouse->dev.private = psmouse; 859 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
860 psmouse->dev.dev = &psmouse->ps2dev.serio->dev; 860 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
861 861 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
862 psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
863 psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
864 psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
865 862
866 psmouse->set_rate = psmouse_set_rate; 863 psmouse->set_rate = psmouse_set_rate;
867 psmouse->set_resolution = psmouse_set_resolution; 864 psmouse->set_resolution = psmouse_set_resolution;
@@ -883,12 +880,12 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_proto
883 sprintf(psmouse->devname, "%s %s %s", 880 sprintf(psmouse->devname, "%s %s %s",
884 psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name); 881 psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name);
885 882
886 psmouse->dev.name = psmouse->devname; 883 input_dev->name = psmouse->devname;
887 psmouse->dev.phys = psmouse->phys; 884 input_dev->phys = psmouse->phys;
888 psmouse->dev.id.bustype = BUS_I8042; 885 input_dev->id.bustype = BUS_I8042;
889 psmouse->dev.id.vendor = 0x0002; 886 input_dev->id.vendor = 0x0002;
890 psmouse->dev.id.product = psmouse->type; 887 input_dev->id.product = psmouse->type;
891 psmouse->dev.id.version = psmouse->model; 888 input_dev->id.version = psmouse->model;
892 889
893 return 0; 890 return 0;
894} 891}
@@ -900,7 +897,8 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_proto
900static int psmouse_connect(struct serio *serio, struct serio_driver *drv) 897static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
901{ 898{
902 struct psmouse *psmouse, *parent = NULL; 899 struct psmouse *psmouse, *parent = NULL;
903 int retval; 900 struct input_dev *input_dev;
901 int retval = -ENOMEM;
904 902
905 down(&psmouse_sem); 903 down(&psmouse_sem);
906 904
@@ -913,12 +911,13 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
913 psmouse_deactivate(parent); 911 psmouse_deactivate(parent);
914 } 912 }
915 913
916 if (!(psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL))) { 914 psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL);
917 retval = -ENOMEM; 915 input_dev = input_allocate_device();
916 if (!psmouse || !input_dev)
918 goto out; 917 goto out;
919 }
920 918
921 ps2_init(&psmouse->ps2dev, serio); 919 ps2_init(&psmouse->ps2dev, serio);
920 psmouse->dev = input_dev;
922 sprintf(psmouse->phys, "%s/input0", serio->phys); 921 sprintf(psmouse->phys, "%s/input0", serio->phys);
923 922
924 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); 923 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
@@ -926,16 +925,11 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
926 serio_set_drvdata(serio, psmouse); 925 serio_set_drvdata(serio, psmouse);
927 926
928 retval = serio_open(serio, drv); 927 retval = serio_open(serio, drv);
929 if (retval) { 928 if (retval)
930 serio_set_drvdata(serio, NULL);
931 kfree(psmouse);
932 goto out; 929 goto out;
933 }
934 930
935 if (psmouse_probe(psmouse) < 0) { 931 if (psmouse_probe(psmouse) < 0) {
936 serio_close(serio); 932 serio_close(serio);
937 serio_set_drvdata(serio, NULL);
938 kfree(psmouse);
939 retval = -ENODEV; 933 retval = -ENODEV;
940 goto out; 934 goto out;
941 } 935 }
@@ -947,13 +941,11 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
947 941
948 psmouse_switch_protocol(psmouse, NULL); 942 psmouse_switch_protocol(psmouse, NULL);
949 943
950 input_register_device(&psmouse->dev);
951 printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys);
952
953 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 944 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
954
955 psmouse_initialize(psmouse); 945 psmouse_initialize(psmouse);
956 946
947 input_register_device(psmouse->dev);
948
957 if (parent && parent->pt_activate) 949 if (parent && parent->pt_activate)
958 parent->pt_activate(parent); 950 parent->pt_activate(parent);
959 951
@@ -964,6 +956,12 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
964 retval = 0; 956 retval = 0;
965 957
966out: 958out:
959 if (retval) {
960 serio_set_drvdata(serio, NULL);
961 input_free_device(input_dev);
962 kfree(psmouse);
963 }
964
967 /* If this is a pass-through port the parent needs to be re-activated */ 965 /* If this is a pass-through port the parent needs to be re-activated */
968 if (parent) 966 if (parent)
969 psmouse_activate(parent); 967 psmouse_activate(parent);
@@ -1161,6 +1159,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1161{ 1159{
1162 struct serio *serio = psmouse->ps2dev.serio; 1160 struct serio *serio = psmouse->ps2dev.serio;
1163 struct psmouse *parent = NULL; 1161 struct psmouse *parent = NULL;
1162 struct input_dev *new_dev;
1164 struct psmouse_protocol *proto; 1163 struct psmouse_protocol *proto;
1165 int retry = 0; 1164 int retry = 0;
1166 1165
@@ -1170,9 +1169,13 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1170 if (psmouse->type == proto->type) 1169 if (psmouse->type == proto->type)
1171 return count; 1170 return count;
1172 1171
1172 if (!(new_dev = input_allocate_device()))
1173 return -ENOMEM;
1174
1173 while (serio->child) { 1175 while (serio->child) {
1174 if (++retry > 3) { 1176 if (++retry > 3) {
1175 printk(KERN_WARNING "psmouse: failed to destroy child port, protocol change aborted.\n"); 1177 printk(KERN_WARNING "psmouse: failed to destroy child port, protocol change aborted.\n");
1178 input_free_device(new_dev);
1176 return -EIO; 1179 return -EIO;
1177 } 1180 }
1178 1181
@@ -1182,11 +1185,15 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1182 serio_pin_driver_uninterruptible(serio); 1185 serio_pin_driver_uninterruptible(serio);
1183 down(&psmouse_sem); 1186 down(&psmouse_sem);
1184 1187
1185 if (serio->drv != &psmouse_drv) 1188 if (serio->drv != &psmouse_drv) {
1189 input_free_device(new_dev);
1186 return -ENODEV; 1190 return -ENODEV;
1191 }
1187 1192
1188 if (psmouse->type == proto->type) 1193 if (psmouse->type == proto->type) {
1194 input_free_device(new_dev);
1189 return count; /* switched by other thread */ 1195 return count; /* switched by other thread */
1196 }
1190 } 1197 }
1191 1198
1192 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1199 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
@@ -1199,8 +1206,9 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1199 psmouse->disconnect(psmouse); 1206 psmouse->disconnect(psmouse);
1200 1207
1201 psmouse_set_state(psmouse, PSMOUSE_IGNORE); 1208 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1202 input_unregister_device(&psmouse->dev); 1209 input_unregister_device(psmouse->dev);
1203 1210
1211 psmouse->dev = new_dev;
1204 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); 1212 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1205 1213
1206 if (psmouse_switch_protocol(psmouse, proto) < 0) { 1214 if (psmouse_switch_protocol(psmouse, proto) < 0) {
@@ -1212,8 +1220,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1212 psmouse_initialize(psmouse); 1220 psmouse_initialize(psmouse);
1213 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 1221 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1214 1222
1215 input_register_device(&psmouse->dev); 1223 input_register_device(psmouse->dev);
1216 printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys);
1217 1224
1218 if (parent && parent->pt_activate) 1225 if (parent && parent->pt_activate)
1219 parent->pt_activate(parent); 1226 parent->pt_activate(parent);
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index 45d2bd774f00..7c4192bd1279 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -36,7 +36,7 @@ typedef enum {
36 36
37struct psmouse { 37struct psmouse {
38 void *private; 38 void *private;
39 struct input_dev dev; 39 struct input_dev *dev;
40 struct ps2dev ps2dev; 40 struct ps2dev ps2dev;
41 char *vendor; 41 char *vendor;
42 char *name; 42 char *name;
diff --git a/drivers/input/mouse/rpcmouse.c b/drivers/input/mouse/rpcmouse.c
index 8fe1212b8fd7..09b6ffdb7582 100644
--- a/drivers/input/mouse/rpcmouse.c
+++ b/drivers/input/mouse/rpcmouse.c
@@ -34,20 +34,7 @@ MODULE_DESCRIPTION("Acorn RiscPC mouse driver");
34MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
35 35
36static short rpcmouse_lastx, rpcmouse_lasty; 36static short rpcmouse_lastx, rpcmouse_lasty;
37 37static struct input_dev *rpcmouse_dev;
38static struct input_dev rpcmouse_dev = {
39 .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
40 .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
41 .relbit = { BIT(REL_X) | BIT(REL_Y) },
42 .name = "Acorn RiscPC Mouse",
43 .phys = "rpcmouse/input0",
44 .id = {
45 .bustype = BUS_HOST,
46 .vendor = 0x0005,
47 .product = 0x0001,
48 .version = 0x0100,
49 },
50};
51 38
52static irqreturn_t rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs) 39static irqreturn_t rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs)
53{ 40{
@@ -78,29 +65,41 @@ static irqreturn_t rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs)
78 return IRQ_HANDLED; 65 return IRQ_HANDLED;
79} 66}
80 67
68
81static int __init rpcmouse_init(void) 69static int __init rpcmouse_init(void)
82{ 70{
83 init_input_dev(&rpcmouse_dev); 71 if (!(rpcmouse_dev = input_allocate_device()))
72 return -ENOMEM;
73
74 rpcmouse_dev->name = "Acorn RiscPC Mouse";
75 rpcmouse_dev->phys = "rpcmouse/input0";
76 rpcmouse_dev->id.bustype = BUS_HOST;
77 rpcmouse_dev->id.vendor = 0x0005;
78 rpcmouse_dev->id.product = 0x0001;
79 rpcmouse_dev->id.version = 0x0100;
80
81 rpcmouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
82 rpcmouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
83 rpcmouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
84 84
85 rpcmouse_lastx = (short) iomd_readl(IOMD_MOUSEX); 85 rpcmouse_lastx = (short) iomd_readl(IOMD_MOUSEX);
86 rpcmouse_lasty = (short) iomd_readl(IOMD_MOUSEY); 86 rpcmouse_lasty = (short) iomd_readl(IOMD_MOUSEY);
87 87
88 if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, SA_SHIRQ, "rpcmouse", &rpcmouse_dev)) { 88 if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, SA_SHIRQ, "rpcmouse", rpcmouse_dev)) {
89 printk(KERN_ERR "rpcmouse: unable to allocate VSYNC interrupt\n"); 89 printk(KERN_ERR "rpcmouse: unable to allocate VSYNC interrupt\n");
90 return -1; 90 input_free_device(rpcmouse_dev);
91 return -EBUSY;
91 } 92 }
92 93
93 input_register_device(&rpcmouse_dev); 94 input_register_device(rpcmouse_dev);
94
95 printk(KERN_INFO "input: Acorn RiscPC mouse\n");
96 95
97 return 0; 96 return 0;
98} 97}
99 98
100static void __exit rpcmouse_exit(void) 99static void __exit rpcmouse_exit(void)
101{ 100{
102 input_unregister_device(&rpcmouse_dev); 101 free_irq(IRQ_VSYNCPULSE, rpcmouse_dev);
103 free_irq(IRQ_VSYNCPULSE, &rpcmouse_dev); 102 input_unregister_device(rpcmouse_dev);
104} 103}
105 104
106module_init(rpcmouse_init); 105module_init(rpcmouse_init);
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
index d12b93ae3900..4bf584364d28 100644
--- a/drivers/input/mouse/sermouse.c
+++ b/drivers/input/mouse/sermouse.c
@@ -48,7 +48,7 @@ static char *sermouse_protocols[] = { "None", "Mouse Systems Mouse", "Sun Mouse"
48 "Logitech MZ++ Mouse"}; 48 "Logitech MZ++ Mouse"};
49 49
50struct sermouse { 50struct sermouse {
51 struct input_dev dev; 51 struct input_dev *dev;
52 signed char buf[8]; 52 signed char buf[8];
53 unsigned char count; 53 unsigned char count;
54 unsigned char type; 54 unsigned char type;
@@ -64,7 +64,7 @@ struct sermouse {
64 64
65static void sermouse_process_msc(struct sermouse *sermouse, signed char data, struct pt_regs *regs) 65static void sermouse_process_msc(struct sermouse *sermouse, signed char data, struct pt_regs *regs)
66{ 66{
67 struct input_dev *dev = &sermouse->dev; 67 struct input_dev *dev = sermouse->dev;
68 signed char *buf = sermouse->buf; 68 signed char *buf = sermouse->buf;
69 69
70 input_regs(dev, regs); 70 input_regs(dev, regs);
@@ -107,7 +107,7 @@ static void sermouse_process_msc(struct sermouse *sermouse, signed char data, st
107 107
108static void sermouse_process_ms(struct sermouse *sermouse, signed char data, struct pt_regs *regs) 108static void sermouse_process_ms(struct sermouse *sermouse, signed char data, struct pt_regs *regs)
109{ 109{
110 struct input_dev *dev = &sermouse->dev; 110 struct input_dev *dev = sermouse->dev;
111 signed char *buf = sermouse->buf; 111 signed char *buf = sermouse->buf;
112 112
113 if (data & 0x40) sermouse->count = 0; 113 if (data & 0x40) sermouse->count = 0;
@@ -230,9 +230,9 @@ static void sermouse_disconnect(struct serio *serio)
230{ 230{
231 struct sermouse *sermouse = serio_get_drvdata(serio); 231 struct sermouse *sermouse = serio_get_drvdata(serio);
232 232
233 input_unregister_device(&sermouse->dev);
234 serio_close(serio); 233 serio_close(serio);
235 serio_set_drvdata(serio, NULL); 234 serio_set_drvdata(serio, NULL);
235 input_unregister_device(sermouse->dev);
236 kfree(sermouse); 236 kfree(sermouse);
237} 237}
238 238
@@ -244,56 +244,52 @@ static void sermouse_disconnect(struct serio *serio)
244static int sermouse_connect(struct serio *serio, struct serio_driver *drv) 244static int sermouse_connect(struct serio *serio, struct serio_driver *drv)
245{ 245{
246 struct sermouse *sermouse; 246 struct sermouse *sermouse;
247 unsigned char c; 247 struct input_dev *input_dev;
248 int err; 248 unsigned char c = serio->id.extra;
249 int err = -ENOMEM;
249 250
250 if (!serio->id.proto || serio->id.proto > SERIO_MZPP) 251 sermouse = kzalloc(sizeof(struct sermouse), GFP_KERNEL);
251 return -ENODEV; 252 input_dev = input_allocate_device();
252 253 if (!sermouse || !input_dev)
253 if (!(sermouse = kmalloc(sizeof(struct sermouse), GFP_KERNEL))) 254 goto fail;
254 return -ENOMEM;
255
256 memset(sermouse, 0, sizeof(struct sermouse));
257
258 init_input_dev(&sermouse->dev);
259 sermouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
260 sermouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
261 sermouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
262 sermouse->dev.private = sermouse;
263
264 sermouse->type = serio->id.proto;
265 c = serio->id.extra;
266
267 if (c & 0x01) set_bit(BTN_MIDDLE, sermouse->dev.keybit);
268 if (c & 0x02) set_bit(BTN_SIDE, sermouse->dev.keybit);
269 if (c & 0x04) set_bit(BTN_EXTRA, sermouse->dev.keybit);
270 if (c & 0x10) set_bit(REL_WHEEL, sermouse->dev.relbit);
271 if (c & 0x20) set_bit(REL_HWHEEL, sermouse->dev.relbit);
272 255
256 sermouse->dev = input_dev;
273 sprintf(sermouse->phys, "%s/input0", serio->phys); 257 sprintf(sermouse->phys, "%s/input0", serio->phys);
258 sermouse->type = serio->id.proto;
274 259
275 sermouse->dev.name = sermouse_protocols[sermouse->type]; 260 input_dev->name = sermouse_protocols[sermouse->type];
276 sermouse->dev.phys = sermouse->phys; 261 input_dev->phys = sermouse->phys;
277 sermouse->dev.id.bustype = BUS_RS232; 262 input_dev->id.bustype = BUS_RS232;
278 sermouse->dev.id.vendor = sermouse->type; 263 input_dev->id.vendor = sermouse->type;
279 sermouse->dev.id.product = c; 264 input_dev->id.product = c;
280 sermouse->dev.id.version = 0x0100; 265 input_dev->id.version = 0x0100;
281 sermouse->dev.dev = &serio->dev; 266 input_dev->cdev.dev = &serio->dev;
267
268 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
269 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
270 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
271 input_dev->private = sermouse;
272
273 if (c & 0x01) set_bit(BTN_MIDDLE, input_dev->keybit);
274 if (c & 0x02) set_bit(BTN_SIDE, input_dev->keybit);
275 if (c & 0x04) set_bit(BTN_EXTRA, input_dev->keybit);
276 if (c & 0x10) set_bit(REL_WHEEL, input_dev->relbit);
277 if (c & 0x20) set_bit(REL_HWHEEL, input_dev->relbit);
282 278
283 serio_set_drvdata(serio, sermouse); 279 serio_set_drvdata(serio, sermouse);
284 280
285 err = serio_open(serio, drv); 281 err = serio_open(serio, drv);
286 if (err) { 282 if (err)
287 serio_set_drvdata(serio, NULL); 283 goto fail;
288 kfree(sermouse);
289 return err;
290 }
291
292 input_register_device(&sermouse->dev);
293 284
294 printk(KERN_INFO "input: %s on %s\n", sermouse_protocols[sermouse->type], serio->phys); 285 input_register_device(sermouse->dev);
295 286
296 return 0; 287 return 0;
288
289 fail: serio_set_drvdata(serio, NULL);
290 input_free_device(input_dev);
291 kfree(sermouse);
292 return err;
297} 293}
298 294
299static struct serio_device_id sermouse_serio_ids[] = { 295static struct serio_device_id sermouse_serio_ids[] = {
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 029309422409..97cdfd6acaca 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -342,7 +342,7 @@ static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data
342 */ 342 */
343static void synaptics_process_packet(struct psmouse *psmouse) 343static void synaptics_process_packet(struct psmouse *psmouse)
344{ 344{
345 struct input_dev *dev = &psmouse->dev; 345 struct input_dev *dev = psmouse->dev;
346 struct synaptics_data *priv = psmouse->private; 346 struct synaptics_data *priv = psmouse->private;
347 struct synaptics_hw_state hw; 347 struct synaptics_hw_state hw;
348 int num_fingers; 348 int num_fingers;
@@ -473,7 +473,7 @@ static unsigned char synaptics_detect_pkt_type(struct psmouse *psmouse)
473 473
474static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs) 474static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
475{ 475{
476 struct input_dev *dev = &psmouse->dev; 476 struct input_dev *dev = psmouse->dev;
477 struct synaptics_data *priv = psmouse->private; 477 struct synaptics_data *priv = psmouse->private;
478 478
479 input_regs(dev, regs); 479 input_regs(dev, regs);
@@ -645,7 +645,7 @@ int synaptics_init(struct psmouse *psmouse)
645 SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity), 645 SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity),
646 priv->model_id, priv->capabilities, priv->ext_cap); 646 priv->model_id, priv->capabilities, priv->ext_cap);
647 647
648 set_input_params(&psmouse->dev, priv); 648 set_input_params(psmouse->dev, priv);
649 649
650 psmouse->protocol_handler = synaptics_process_byte; 650 psmouse->protocol_handler = synaptics_process_byte;
651 psmouse->set_rate = synaptics_set_rate; 651 psmouse->set_rate = synaptics_set_rate;
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
index f024be9b44d2..36e9442a16b2 100644
--- a/drivers/input/mouse/vsxxxaa.c
+++ b/drivers/input/mouse/vsxxxaa.c
@@ -112,7 +112,7 @@ MODULE_LICENSE ("GPL");
112 112
113 113
114struct vsxxxaa { 114struct vsxxxaa {
115 struct input_dev dev; 115 struct input_dev *dev;
116 struct serio *serio; 116 struct serio *serio;
117#define BUFLEN 15 /* At least 5 is needed for a full tablet packet */ 117#define BUFLEN 15 /* At least 5 is needed for a full tablet packet */
118 unsigned char buf[BUFLEN]; 118 unsigned char buf[BUFLEN];
@@ -211,7 +211,7 @@ vsxxxaa_smells_like_packet (struct vsxxxaa *mouse, unsigned char type, size_t le
211static void 211static void
212vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs) 212vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
213{ 213{
214 struct input_dev *dev = &mouse->dev; 214 struct input_dev *dev = mouse->dev;
215 unsigned char *buf = mouse->buf; 215 unsigned char *buf = mouse->buf;
216 int left, middle, right; 216 int left, middle, right;
217 int dx, dy; 217 int dx, dy;
@@ -269,7 +269,7 @@ vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
269static void 269static void
270vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs) 270vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
271{ 271{
272 struct input_dev *dev = &mouse->dev; 272 struct input_dev *dev = mouse->dev;
273 unsigned char *buf = mouse->buf; 273 unsigned char *buf = mouse->buf;
274 int left, middle, right, touch; 274 int left, middle, right, touch;
275 int x, y; 275 int x, y;
@@ -323,7 +323,7 @@ vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
323static void 323static void
324vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse, struct pt_regs *regs) 324vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
325{ 325{
326 struct input_dev *dev = &mouse->dev; 326 struct input_dev *dev = mouse->dev;
327 unsigned char *buf = mouse->buf; 327 unsigned char *buf = mouse->buf;
328 int left, middle, right; 328 int left, middle, right;
329 unsigned char error; 329 unsigned char error;
@@ -483,9 +483,9 @@ vsxxxaa_disconnect (struct serio *serio)
483{ 483{
484 struct vsxxxaa *mouse = serio_get_drvdata (serio); 484 struct vsxxxaa *mouse = serio_get_drvdata (serio);
485 485
486 input_unregister_device (&mouse->dev);
487 serio_close (serio); 486 serio_close (serio);
488 serio_set_drvdata (serio, NULL); 487 serio_set_drvdata (serio, NULL);
488 input_unregister_device (mouse->dev);
489 kfree (mouse); 489 kfree (mouse);
490} 490}
491 491
@@ -493,61 +493,57 @@ static int
493vsxxxaa_connect (struct serio *serio, struct serio_driver *drv) 493vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
494{ 494{
495 struct vsxxxaa *mouse; 495 struct vsxxxaa *mouse;
496 int err; 496 struct input_dev *input_dev;
497 int err = -ENOMEM;
497 498
498 if (!(mouse = kmalloc (sizeof (struct vsxxxaa), GFP_KERNEL))) 499 mouse = kzalloc (sizeof (struct vsxxxaa), GFP_KERNEL);
499 return -ENOMEM; 500 input_dev = input_allocate_device ();
500 501 if (!mouse || !input_dev)
501 memset (mouse, 0, sizeof (struct vsxxxaa)); 502 goto fail;
502
503 init_input_dev (&mouse->dev);
504 set_bit (EV_KEY, mouse->dev.evbit); /* We have buttons */
505 set_bit (EV_REL, mouse->dev.evbit);
506 set_bit (EV_ABS, mouse->dev.evbit);
507 set_bit (BTN_LEFT, mouse->dev.keybit); /* We have 3 buttons */
508 set_bit (BTN_MIDDLE, mouse->dev.keybit);
509 set_bit (BTN_RIGHT, mouse->dev.keybit);
510 set_bit (BTN_TOUCH, mouse->dev.keybit); /* ...and Tablet */
511 set_bit (REL_X, mouse->dev.relbit);
512 set_bit (REL_Y, mouse->dev.relbit);
513 set_bit (ABS_X, mouse->dev.absbit);
514 set_bit (ABS_Y, mouse->dev.absbit);
515
516 mouse->dev.absmin[ABS_X] = 0;
517 mouse->dev.absmax[ABS_X] = 1023;
518 mouse->dev.absmin[ABS_Y] = 0;
519 mouse->dev.absmax[ABS_Y] = 1023;
520
521 mouse->dev.private = mouse;
522 503
504 mouse->dev = input_dev;
505 mouse->serio = serio;
523 sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer"); 506 sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer");
524 sprintf (mouse->phys, "%s/input0", serio->phys); 507 sprintf (mouse->phys, "%s/input0", serio->phys);
525 mouse->dev.name = mouse->name; 508
526 mouse->dev.phys = mouse->phys; 509 input_dev->name = mouse->name;
527 mouse->dev.id.bustype = BUS_RS232; 510 input_dev->phys = mouse->phys;
528 mouse->dev.dev = &serio->dev; 511 input_dev->id.bustype = BUS_RS232;
529 mouse->serio = serio; 512 input_dev->cdev.dev = &serio->dev;
513 input_dev->private = mouse;
514
515 set_bit (EV_KEY, input_dev->evbit); /* We have buttons */
516 set_bit (EV_REL, input_dev->evbit);
517 set_bit (EV_ABS, input_dev->evbit);
518 set_bit (BTN_LEFT, input_dev->keybit); /* We have 3 buttons */
519 set_bit (BTN_MIDDLE, input_dev->keybit);
520 set_bit (BTN_RIGHT, input_dev->keybit);
521 set_bit (BTN_TOUCH, input_dev->keybit); /* ...and Tablet */
522 set_bit (REL_X, input_dev->relbit);
523 set_bit (REL_Y, input_dev->relbit);
524 input_set_abs_params (input_dev, ABS_X, 0, 1023, 0, 0);
525 input_set_abs_params (input_dev, ABS_Y, 0, 1023, 0, 0);
530 526
531 serio_set_drvdata (serio, mouse); 527 serio_set_drvdata (serio, mouse);
532 528
533 err = serio_open (serio, drv); 529 err = serio_open (serio, drv);
534 if (err) { 530 if (err)
535 serio_set_drvdata (serio, NULL); 531 goto fail;
536 kfree (mouse);
537 return err;
538 }
539 532
540 /* 533 /*
541 * Request selftest. Standard packet format and differential 534 * Request selftest. Standard packet format and differential
542 * mode will be requested after the device ID'ed successfully. 535 * mode will be requested after the device ID'ed successfully.
543 */ 536 */
544 mouse->serio->write (mouse->serio, 'T'); /* Test */ 537 serio->write (serio, 'T'); /* Test */
545
546 input_register_device (&mouse->dev);
547 538
548 printk (KERN_INFO "input: %s on %s\n", mouse->name, mouse->phys); 539 input_register_device (input_dev);
549 540
550 return 0; 541 return 0;
542
543 fail: serio_set_drvdata (serio, NULL);
544 input_free_device (input_dev);
545 kfree (mouse);
546 return err;
551} 547}
552 548
553static struct serio_device_id vsxxaa_serio_ids[] = { 549static struct serio_device_id vsxxaa_serio_ids[] = {