aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/psmouse-base.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2009-09-09 22:13:20 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2009-09-11 01:11:38 -0400
commitb7802c5c1ea9563f3746bea09c214ccedc8600f4 (patch)
tree8feca41ff76258d05b8d4cc893b1a08e04a712f8 /drivers/input/mouse/psmouse-base.c
parentf81134163fc785622f58af27363079ba1de7c7aa (diff)
Input: psmouse - use boolean type
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/mouse/psmouse-base.c')
-rw-r--r--drivers/input/mouse/psmouse-base.c87
1 files changed, 46 insertions, 41 deletions
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index df318887ca09..690aed905436 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -109,10 +109,10 @@ static struct workqueue_struct *kpsmoused_wq;
109 109
110struct psmouse_protocol { 110struct psmouse_protocol {
111 enum psmouse_type type; 111 enum psmouse_type type;
112 bool maxproto;
112 const char *name; 113 const char *name;
113 const char *alias; 114 const char *alias;
114 int maxproto; 115 int (*detect)(struct psmouse *, bool);
115 int (*detect)(struct psmouse *, int);
116 int (*init)(struct psmouse *); 116 int (*init)(struct psmouse *);
117}; 117};
118 118
@@ -217,7 +217,7 @@ void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
217static inline void __psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) 217static inline void __psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state)
218{ 218{
219 psmouse->state = new_state; 219 psmouse->state = new_state;
220 psmouse->pktcnt = psmouse->out_of_sync = 0; 220 psmouse->pktcnt = psmouse->out_of_sync_cnt = 0;
221 psmouse->ps2dev.flags = 0; 221 psmouse->ps2dev.flags = 0;
222 psmouse->last = jiffies; 222 psmouse->last = jiffies;
223} 223}
@@ -250,7 +250,7 @@ static int psmouse_handle_byte(struct psmouse *psmouse)
250 if (psmouse->state == PSMOUSE_ACTIVATED) { 250 if (psmouse->state == PSMOUSE_ACTIVATED) {
251 printk(KERN_WARNING "psmouse.c: %s at %s lost sync at byte %d\n", 251 printk(KERN_WARNING "psmouse.c: %s at %s lost sync at byte %d\n",
252 psmouse->name, psmouse->phys, psmouse->pktcnt); 252 psmouse->name, psmouse->phys, psmouse->pktcnt);
253 if (++psmouse->out_of_sync == psmouse->resetafter) { 253 if (++psmouse->out_of_sync_cnt == psmouse->resetafter) {
254 __psmouse_set_state(psmouse, PSMOUSE_IGNORE); 254 __psmouse_set_state(psmouse, PSMOUSE_IGNORE);
255 printk(KERN_NOTICE "psmouse.c: issuing reconnect request\n"); 255 printk(KERN_NOTICE "psmouse.c: issuing reconnect request\n");
256 serio_reconnect(psmouse->ps2dev.serio); 256 serio_reconnect(psmouse->ps2dev.serio);
@@ -262,8 +262,8 @@ static int psmouse_handle_byte(struct psmouse *psmouse)
262 262
263 case PSMOUSE_FULL_PACKET: 263 case PSMOUSE_FULL_PACKET:
264 psmouse->pktcnt = 0; 264 psmouse->pktcnt = 0;
265 if (psmouse->out_of_sync) { 265 if (psmouse->out_of_sync_cnt) {
266 psmouse->out_of_sync = 0; 266 psmouse->out_of_sync_cnt = 0;
267 printk(KERN_NOTICE "psmouse.c: %s at %s - driver resynched.\n", 267 printk(KERN_NOTICE "psmouse.c: %s at %s - driver resynched.\n",
268 psmouse->name, psmouse->phys); 268 psmouse->name, psmouse->phys);
269 } 269 }
@@ -409,7 +409,7 @@ int psmouse_reset(struct psmouse *psmouse)
409/* 409/*
410 * Genius NetMouse magic init. 410 * Genius NetMouse magic init.
411 */ 411 */
412static int genius_detect(struct psmouse *psmouse, int set_properties) 412static int genius_detect(struct psmouse *psmouse, bool set_properties)
413{ 413{
414 struct ps2dev *ps2dev = &psmouse->ps2dev; 414 struct ps2dev *ps2dev = &psmouse->ps2dev;
415 unsigned char param[4]; 415 unsigned char param[4];
@@ -425,9 +425,9 @@ static int genius_detect(struct psmouse *psmouse, int set_properties)
425 return -1; 425 return -1;
426 426
427 if (set_properties) { 427 if (set_properties) {
428 set_bit(BTN_EXTRA, psmouse->dev->keybit); 428 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
429 set_bit(BTN_SIDE, psmouse->dev->keybit); 429 __set_bit(BTN_SIDE, psmouse->dev->keybit);
430 set_bit(REL_WHEEL, psmouse->dev->relbit); 430 __set_bit(REL_WHEEL, psmouse->dev->relbit);
431 431
432 psmouse->vendor = "Genius"; 432 psmouse->vendor = "Genius";
433 psmouse->name = "Mouse"; 433 psmouse->name = "Mouse";
@@ -440,7 +440,7 @@ static int genius_detect(struct psmouse *psmouse, int set_properties)
440/* 440/*
441 * IntelliMouse magic init. 441 * IntelliMouse magic init.
442 */ 442 */
443static int intellimouse_detect(struct psmouse *psmouse, int set_properties) 443static int intellimouse_detect(struct psmouse *psmouse, bool set_properties)
444{ 444{
445 struct ps2dev *ps2dev = &psmouse->ps2dev; 445 struct ps2dev *ps2dev = &psmouse->ps2dev;
446 unsigned char param[2]; 446 unsigned char param[2];
@@ -457,8 +457,8 @@ static int intellimouse_detect(struct psmouse *psmouse, int set_properties)
457 return -1; 457 return -1;
458 458
459 if (set_properties) { 459 if (set_properties) {
460 set_bit(BTN_MIDDLE, psmouse->dev->keybit); 460 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
461 set_bit(REL_WHEEL, psmouse->dev->relbit); 461 __set_bit(REL_WHEEL, psmouse->dev->relbit);
462 462
463 if (!psmouse->vendor) psmouse->vendor = "Generic"; 463 if (!psmouse->vendor) psmouse->vendor = "Generic";
464 if (!psmouse->name) psmouse->name = "Wheel Mouse"; 464 if (!psmouse->name) psmouse->name = "Wheel Mouse";
@@ -471,7 +471,7 @@ static int intellimouse_detect(struct psmouse *psmouse, int set_properties)
471/* 471/*
472 * Try IntelliMouse/Explorer magic init. 472 * Try IntelliMouse/Explorer magic init.
473 */ 473 */
474static int im_explorer_detect(struct psmouse *psmouse, int set_properties) 474static int im_explorer_detect(struct psmouse *psmouse, bool set_properties)
475{ 475{
476 struct ps2dev *ps2dev = &psmouse->ps2dev; 476 struct ps2dev *ps2dev = &psmouse->ps2dev;
477 unsigned char param[2]; 477 unsigned char param[2];
@@ -498,11 +498,11 @@ static int im_explorer_detect(struct psmouse *psmouse, int set_properties)
498 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); 498 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
499 499
500 if (set_properties) { 500 if (set_properties) {
501 set_bit(BTN_MIDDLE, psmouse->dev->keybit); 501 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
502 set_bit(REL_WHEEL, psmouse->dev->relbit); 502 __set_bit(REL_WHEEL, psmouse->dev->relbit);
503 set_bit(REL_HWHEEL, psmouse->dev->relbit); 503 __set_bit(REL_HWHEEL, psmouse->dev->relbit);
504 set_bit(BTN_SIDE, psmouse->dev->keybit); 504 __set_bit(BTN_SIDE, psmouse->dev->keybit);
505 set_bit(BTN_EXTRA, psmouse->dev->keybit); 505 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
506 506
507 if (!psmouse->vendor) psmouse->vendor = "Generic"; 507 if (!psmouse->vendor) psmouse->vendor = "Generic";
508 if (!psmouse->name) psmouse->name = "Explorer Mouse"; 508 if (!psmouse->name) psmouse->name = "Explorer Mouse";
@@ -515,7 +515,7 @@ static int im_explorer_detect(struct psmouse *psmouse, int set_properties)
515/* 515/*
516 * Kensington ThinkingMouse / ExpertMouse magic init. 516 * Kensington ThinkingMouse / ExpertMouse magic init.
517 */ 517 */
518static int thinking_detect(struct psmouse *psmouse, int set_properties) 518static int thinking_detect(struct psmouse *psmouse, bool set_properties)
519{ 519{
520 struct ps2dev *ps2dev = &psmouse->ps2dev; 520 struct ps2dev *ps2dev = &psmouse->ps2dev;
521 unsigned char param[2]; 521 unsigned char param[2];
@@ -536,7 +536,7 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties)
536 return -1; 536 return -1;
537 537
538 if (set_properties) { 538 if (set_properties) {
539 set_bit(BTN_EXTRA, psmouse->dev->keybit); 539 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
540 540
541 psmouse->vendor = "Kensington"; 541 psmouse->vendor = "Kensington";
542 psmouse->name = "ThinkingMouse"; 542 psmouse->name = "ThinkingMouse";
@@ -548,7 +548,7 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties)
548/* 548/*
549 * Bare PS/2 protocol "detection". Always succeeds. 549 * Bare PS/2 protocol "detection". Always succeeds.
550 */ 550 */
551static int ps2bare_detect(struct psmouse *psmouse, int set_properties) 551static int ps2bare_detect(struct psmouse *psmouse, bool set_properties)
552{ 552{
553 if (set_properties) { 553 if (set_properties) {
554 if (!psmouse->vendor) psmouse->vendor = "Generic"; 554 if (!psmouse->vendor) psmouse->vendor = "Generic";
@@ -562,12 +562,12 @@ static int ps2bare_detect(struct psmouse *psmouse, int set_properties)
562 * Cortron PS/2 protocol detection. There's no special way to detect it, so it 562 * Cortron PS/2 protocol detection. There's no special way to detect it, so it
563 * must be forced by sysfs protocol writing. 563 * must be forced by sysfs protocol writing.
564 */ 564 */
565static int cortron_detect(struct psmouse *psmouse, int set_properties) 565static int cortron_detect(struct psmouse *psmouse, bool set_properties)
566{ 566{
567 if (set_properties) { 567 if (set_properties) {
568 psmouse->vendor = "Cortron"; 568 psmouse->vendor = "Cortron";
569 psmouse->name = "PS/2 Trackball"; 569 psmouse->name = "PS/2 Trackball";
570 set_bit(BTN_SIDE, psmouse->dev->keybit); 570 __set_bit(BTN_SIDE, psmouse->dev->keybit);
571 } 571 }
572 572
573 return 0; 573 return 0;
@@ -579,9 +579,9 @@ static int cortron_detect(struct psmouse *psmouse, int set_properties)
579 */ 579 */
580 580
581static int psmouse_extensions(struct psmouse *psmouse, 581static int psmouse_extensions(struct psmouse *psmouse,
582 unsigned int max_proto, int set_properties) 582 unsigned int max_proto, bool set_properties)
583{ 583{
584 int synaptics_hardware = 0; 584 bool synaptics_hardware = true;
585 585
586/* 586/*
587 * We always check for lifebook because it does not disturb mouse 587 * We always check for lifebook because it does not disturb mouse
@@ -608,7 +608,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
608 * can reset it properly after probing for intellimouse. 608 * can reset it properly after probing for intellimouse.
609 */ 609 */
610 if (max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse, set_properties) == 0) { 610 if (max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse, set_properties) == 0) {
611 synaptics_hardware = 1; 611 synaptics_hardware = true;
612 612
613 if (max_proto > PSMOUSE_IMEX) { 613 if (max_proto > PSMOUSE_IMEX) {
614 if (!set_properties || synaptics_init(psmouse) == 0) 614 if (!set_properties || synaptics_init(psmouse) == 0)
@@ -733,7 +733,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
733 .type = PSMOUSE_PS2, 733 .type = PSMOUSE_PS2,
734 .name = "PS/2", 734 .name = "PS/2",
735 .alias = "bare", 735 .alias = "bare",
736 .maxproto = 1, 736 .maxproto = true,
737 .detect = ps2bare_detect, 737 .detect = ps2bare_detect,
738 }, 738 },
739#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP 739#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
@@ -760,14 +760,14 @@ static const struct psmouse_protocol psmouse_protocols[] = {
760 .type = PSMOUSE_IMPS, 760 .type = PSMOUSE_IMPS,
761 .name = "ImPS/2", 761 .name = "ImPS/2",
762 .alias = "imps", 762 .alias = "imps",
763 .maxproto = 1, 763 .maxproto = true,
764 .detect = intellimouse_detect, 764 .detect = intellimouse_detect,
765 }, 765 },
766 { 766 {
767 .type = PSMOUSE_IMEX, 767 .type = PSMOUSE_IMEX,
768 .name = "ImExPS/2", 768 .name = "ImExPS/2",
769 .alias = "exps", 769 .alias = "exps",
770 .maxproto = 1, 770 .maxproto = true,
771 .detect = im_explorer_detect, 771 .detect = im_explorer_detect,
772 }, 772 },
773#ifdef CONFIG_MOUSE_PS2_SYNAPTICS 773#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
@@ -848,7 +848,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
848 .type = PSMOUSE_AUTO, 848 .type = PSMOUSE_AUTO,
849 .name = "auto", 849 .name = "auto",
850 .alias = "any", 850 .alias = "any",
851 .maxproto = 1, 851 .maxproto = true,
852 }, 852 },
853}; 853};
854 854
@@ -1014,7 +1014,7 @@ static void psmouse_resync(struct work_struct *work)
1014 container_of(work, struct psmouse, resync_work.work); 1014 container_of(work, struct psmouse, resync_work.work);
1015 struct serio *serio = psmouse->ps2dev.serio; 1015 struct serio *serio = psmouse->ps2dev.serio;
1016 psmouse_ret_t rc = PSMOUSE_GOOD_DATA; 1016 psmouse_ret_t rc = PSMOUSE_GOOD_DATA;
1017 int failed = 0, enabled = 0; 1017 bool failed = false, enabled = false;
1018 int i; 1018 int i;
1019 1019
1020 mutex_lock(&psmouse_mutex); 1020 mutex_lock(&psmouse_mutex);
@@ -1041,9 +1041,9 @@ static void psmouse_resync(struct work_struct *work)
1041 1041
1042 if (ps2_sendbyte(&psmouse->ps2dev, PSMOUSE_CMD_DISABLE, 20)) { 1042 if (ps2_sendbyte(&psmouse->ps2dev, PSMOUSE_CMD_DISABLE, 20)) {
1043 if (psmouse->num_resyncs < 3 || psmouse->acks_disable_command) 1043 if (psmouse->num_resyncs < 3 || psmouse->acks_disable_command)
1044 failed = 1; 1044 failed = true;
1045 } else 1045 } else
1046 psmouse->acks_disable_command = 1; 1046 psmouse->acks_disable_command = true;
1047 1047
1048/* 1048/*
1049 * Poll the mouse. If it was reset the packet will be shorter than 1049 * Poll the mouse. If it was reset the packet will be shorter than
@@ -1054,7 +1054,7 @@ static void psmouse_resync(struct work_struct *work)
1054 */ 1054 */
1055 if (!failed) { 1055 if (!failed) {
1056 if (psmouse->poll(psmouse)) 1056 if (psmouse->poll(psmouse))
1057 failed = 1; 1057 failed = true;
1058 else { 1058 else {
1059 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 1059 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1060 for (i = 0; i < psmouse->pktsize; i++) { 1060 for (i = 0; i < psmouse->pktsize; i++) {
@@ -1064,7 +1064,7 @@ static void psmouse_resync(struct work_struct *work)
1064 break; 1064 break;
1065 } 1065 }
1066 if (rc != PSMOUSE_FULL_PACKET) 1066 if (rc != PSMOUSE_FULL_PACKET)
1067 failed = 1; 1067 failed = true;
1068 psmouse_set_state(psmouse, PSMOUSE_RESYNCING); 1068 psmouse_set_state(psmouse, PSMOUSE_RESYNCING);
1069 } 1069 }
1070 } 1070 }
@@ -1075,7 +1075,7 @@ static void psmouse_resync(struct work_struct *work)
1075 */ 1075 */
1076 for (i = 0; i < 5; i++) { 1076 for (i = 0; i < 5; i++) {
1077 if (!ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE)) { 1077 if (!ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE)) {
1078 enabled = 1; 1078 enabled = true;
1079 break; 1079 break;
1080 } 1080 }
1081 msleep(200); 1081 msleep(200);
@@ -1084,7 +1084,7 @@ static void psmouse_resync(struct work_struct *work)
1084 if (!enabled) { 1084 if (!enabled) {
1085 printk(KERN_WARNING "psmouse.c: failed to re-enable mouse on %s\n", 1085 printk(KERN_WARNING "psmouse.c: failed to re-enable mouse on %s\n",
1086 psmouse->ps2dev.serio->phys); 1086 psmouse->ps2dev.serio->phys);
1087 failed = 1; 1087 failed = true;
1088 } 1088 }
1089 1089
1090 if (failed) { 1090 if (failed) {
@@ -1211,7 +1211,8 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, const struct psmouse
1211 psmouse->type = proto->type; 1211 psmouse->type = proto->type;
1212 } 1212 }
1213 else 1213 else
1214 psmouse->type = psmouse_extensions(psmouse, psmouse_max_proto, 1); 1214 psmouse->type = psmouse_extensions(psmouse,
1215 psmouse_max_proto, true);
1215 1216
1216 /* 1217 /*
1217 * If mouse's packet size is 3 there is no point in polling the 1218 * If mouse's packet size is 3 there is no point in polling the
@@ -1366,8 +1367,10 @@ static int psmouse_reconnect(struct serio *serio)
1366 if (psmouse->reconnect(psmouse)) 1367 if (psmouse->reconnect(psmouse))
1367 goto out; 1368 goto out;
1368 } else if (psmouse_probe(psmouse) < 0 || 1369 } else if (psmouse_probe(psmouse) < 0 ||
1369 psmouse->type != psmouse_extensions(psmouse, psmouse_max_proto, 0)) 1370 psmouse->type != psmouse_extensions(psmouse,
1371 psmouse_max_proto, false)) {
1370 goto out; 1372 goto out;
1373 }
1371 1374
1372 /* ok, the device type (and capabilities) match the old one, 1375 /* ok, the device type (and capabilities) match the old one,
1373 * we can continue using it, complete intialization 1376 * we can continue using it, complete intialization
@@ -1552,7 +1555,9 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1552 1555
1553 while (serio->child) { 1556 while (serio->child) {
1554 if (++retry > 3) { 1557 if (++retry > 3) {
1555 printk(KERN_WARNING "psmouse: failed to destroy child port, protocol change aborted.\n"); 1558 printk(KERN_WARNING
1559 "psmouse: failed to destroy child port, "
1560 "protocol change aborted.\n");
1556 input_free_device(new_dev); 1561 input_free_device(new_dev);
1557 return -EIO; 1562 return -EIO;
1558 } 1563 }