aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/alps.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-09-15 03:01:44 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 12:52:52 -0400
commit2e5b636bb5f8dacbb91d08544e2c41ebcad5dace (patch)
tree059a2078d7b11713cad4675a9d8a062337957102 /drivers/input/mouse/alps.c
parentd19fbe8a763634395d4bef40fc88cdb61c4a6274 (diff)
[PATCH] drivers/input/mouse: convert to dynamic input_dev allocation
Input: convert drivers/input/mouse to dynamic input_dev allocation This is required for input_dev sysfs integration Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/input/mouse/alps.c')
-rw-r--r--drivers/input/mouse/alps.c63
1 files changed, 33 insertions, 30 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}