diff options
Diffstat (limited to 'drivers/input/mouse/elantech.c')
-rw-r--r-- | drivers/input/mouse/elantech.c | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 112b4ee52ff2..232556a89c4a 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * Trademarks are the property of their respective owners. | 10 | * Trademarks are the property of their respective owners. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_BASENAME ": " fmt | ||
14 | |||
13 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
14 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
15 | #include <linux/module.h> | 17 | #include <linux/module.h> |
@@ -19,10 +21,10 @@ | |||
19 | #include "psmouse.h" | 21 | #include "psmouse.h" |
20 | #include "elantech.h" | 22 | #include "elantech.h" |
21 | 23 | ||
22 | #define elantech_debug(format, arg...) \ | 24 | #define elantech_debug(fmt, ...) \ |
23 | do { \ | 25 | do { \ |
24 | if (etd->debug) \ | 26 | if (etd->debug) \ |
25 | printk(KERN_DEBUG format, ##arg); \ | 27 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \ |
26 | } while (0) | 28 | } while (0) |
27 | 29 | ||
28 | static bool force_elantech; | 30 | static bool force_elantech; |
@@ -37,7 +39,7 @@ static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, | |||
37 | { | 39 | { |
38 | if (psmouse_sliced_command(psmouse, c) || | 40 | if (psmouse_sliced_command(psmouse, c) || |
39 | ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) { | 41 | ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) { |
40 | pr_err("elantech.c: synaptics_send_cmd query 0x%02x failed.\n", c); | 42 | pr_err("synaptics_send_cmd query 0x%02x failed.\n", c); |
41 | return -1; | 43 | return -1; |
42 | } | 44 | } |
43 | 45 | ||
@@ -60,13 +62,13 @@ static int elantech_ps2_command(struct psmouse *psmouse, | |||
60 | if (rc == 0) | 62 | if (rc == 0) |
61 | break; | 63 | break; |
62 | tries--; | 64 | tries--; |
63 | elantech_debug("elantech.c: retrying ps2 command 0x%02x (%d).\n", | 65 | elantech_debug("retrying ps2 command 0x%02x (%d).\n", |
64 | command, tries); | 66 | command, tries); |
65 | msleep(ETP_PS2_COMMAND_DELAY); | 67 | msleep(ETP_PS2_COMMAND_DELAY); |
66 | } while (tries > 0); | 68 | } while (tries > 0); |
67 | 69 | ||
68 | if (rc) | 70 | if (rc) |
69 | pr_err("elantech.c: ps2 command 0x%02x failed.\n", command); | 71 | pr_err("ps2 command 0x%02x failed.\n", command); |
70 | 72 | ||
71 | return rc; | 73 | return rc; |
72 | } | 74 | } |
@@ -108,7 +110,7 @@ static int elantech_read_reg(struct psmouse *psmouse, unsigned char reg, | |||
108 | } | 110 | } |
109 | 111 | ||
110 | if (rc) | 112 | if (rc) |
111 | pr_err("elantech.c: failed to read register 0x%02x.\n", reg); | 113 | pr_err("failed to read register 0x%02x.\n", reg); |
112 | else | 114 | else |
113 | *val = param[0]; | 115 | *val = param[0]; |
114 | 116 | ||
@@ -154,7 +156,7 @@ static int elantech_write_reg(struct psmouse *psmouse, unsigned char reg, | |||
154 | } | 156 | } |
155 | 157 | ||
156 | if (rc) | 158 | if (rc) |
157 | pr_err("elantech.c: failed to write register 0x%02x with value 0x%02x.\n", | 159 | pr_err("failed to write register 0x%02x with value 0x%02x.\n", |
158 | reg, val); | 160 | reg, val); |
159 | 161 | ||
160 | return rc; | 162 | return rc; |
@@ -167,7 +169,7 @@ static void elantech_packet_dump(unsigned char *packet, int size) | |||
167 | { | 169 | { |
168 | int i; | 170 | int i; |
169 | 171 | ||
170 | printk(KERN_DEBUG "elantech.c: PS/2 packet ["); | 172 | printk(KERN_DEBUG pr_fmt("PS/2 packet [")); |
171 | for (i = 0; i < size; i++) | 173 | for (i = 0; i < size; i++) |
172 | printk("%s0x%02x ", (i) ? ", " : " ", packet[i]); | 174 | printk("%s0x%02x ", (i) ? ", " : " ", packet[i]); |
173 | printk("]\n"); | 175 | printk("]\n"); |
@@ -203,7 +205,7 @@ static void elantech_report_absolute_v1(struct psmouse *psmouse) | |||
203 | if (etd->jumpy_cursor) { | 205 | if (etd->jumpy_cursor) { |
204 | /* Discard packets that are likely to have bogus coordinates */ | 206 | /* Discard packets that are likely to have bogus coordinates */ |
205 | if (fingers > old_fingers) { | 207 | if (fingers > old_fingers) { |
206 | elantech_debug("elantech.c: discarding packet\n"); | 208 | elantech_debug("discarding packet\n"); |
207 | goto discard_packet_v1; | 209 | goto discard_packet_v1; |
208 | } | 210 | } |
209 | } | 211 | } |
@@ -413,23 +415,21 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse) | |||
413 | if (rc == 0) | 415 | if (rc == 0) |
414 | break; | 416 | break; |
415 | tries--; | 417 | tries--; |
416 | elantech_debug("elantech.c: retrying read (%d).\n", | 418 | elantech_debug("retrying read (%d).\n", tries); |
417 | tries); | ||
418 | msleep(ETP_READ_BACK_DELAY); | 419 | msleep(ETP_READ_BACK_DELAY); |
419 | } while (tries > 0); | 420 | } while (tries > 0); |
420 | 421 | ||
421 | if (rc) { | 422 | if (rc) { |
422 | pr_err("elantech.c: failed to read back register 0x10.\n"); | 423 | pr_err("failed to read back register 0x10.\n"); |
423 | } else if (etd->hw_version == 1 && | 424 | } else if (etd->hw_version == 1 && |
424 | !(val & ETP_R10_ABSOLUTE_MODE)) { | 425 | !(val & ETP_R10_ABSOLUTE_MODE)) { |
425 | pr_err("elantech.c: touchpad refuses " | 426 | pr_err("touchpad refuses to switch to absolute mode.\n"); |
426 | "to switch to absolute mode.\n"); | ||
427 | rc = -1; | 427 | rc = -1; |
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | if (rc) | 431 | if (rc) |
432 | pr_err("elantech.c: failed to initialise registers.\n"); | 432 | pr_err("failed to initialise registers.\n"); |
433 | 433 | ||
434 | return rc; | 434 | return rc; |
435 | } | 435 | } |
@@ -590,7 +590,7 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties) | |||
590 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || | 590 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || |
591 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || | 591 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || |
592 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { | 592 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { |
593 | pr_debug("elantech.c: sending Elantech magic knock failed.\n"); | 593 | pr_debug("sending Elantech magic knock failed.\n"); |
594 | return -1; | 594 | return -1; |
595 | } | 595 | } |
596 | 596 | ||
@@ -599,8 +599,7 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties) | |||
599 | * set of magic numbers | 599 | * set of magic numbers |
600 | */ | 600 | */ |
601 | if (param[0] != 0x3c || param[1] != 0x03 || param[2] != 0xc8) { | 601 | if (param[0] != 0x3c || param[1] != 0x03 || param[2] != 0xc8) { |
602 | pr_debug("elantech.c: " | 602 | pr_debug("unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n", |
603 | "unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n", | ||
604 | param[0], param[1], param[2]); | 603 | param[0], param[1], param[2]); |
605 | return -1; | 604 | return -1; |
606 | } | 605 | } |
@@ -611,20 +610,20 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties) | |||
611 | * to Elantech magic knock and there might be more. | 610 | * to Elantech magic knock and there might be more. |
612 | */ | 611 | */ |
613 | if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) { | 612 | if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) { |
614 | pr_debug("elantech.c: failed to query firmware version.\n"); | 613 | pr_debug("failed to query firmware version.\n"); |
615 | return -1; | 614 | return -1; |
616 | } | 615 | } |
617 | 616 | ||
618 | pr_debug("elantech.c: Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n", | 617 | pr_debug("Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n", |
619 | param[0], param[1], param[2]); | 618 | param[0], param[1], param[2]); |
620 | 619 | ||
621 | if (param[0] == 0 || param[1] != 0) { | 620 | if (param[0] == 0 || param[1] != 0) { |
622 | if (!force_elantech) { | 621 | if (!force_elantech) { |
623 | pr_debug("elantech.c: Probably not a real Elantech touchpad. Aborting.\n"); | 622 | pr_debug("Probably not a real Elantech touchpad. Aborting.\n"); |
624 | return -1; | 623 | return -1; |
625 | } | 624 | } |
626 | 625 | ||
627 | pr_debug("elantech.c: Probably not a real Elantech touchpad. Enabling anyway due to force_elantech.\n"); | 626 | pr_debug("Probably not a real Elantech touchpad. Enabling anyway due to force_elantech.\n"); |
628 | } | 627 | } |
629 | 628 | ||
630 | if (set_properties) { | 629 | if (set_properties) { |
@@ -655,7 +654,7 @@ static int elantech_reconnect(struct psmouse *psmouse) | |||
655 | return -1; | 654 | return -1; |
656 | 655 | ||
657 | if (elantech_set_absolute_mode(psmouse)) { | 656 | if (elantech_set_absolute_mode(psmouse)) { |
658 | pr_err("elantech.c: failed to put touchpad back into absolute mode.\n"); | 657 | pr_err("failed to put touchpad back into absolute mode.\n"); |
659 | return -1; | 658 | return -1; |
660 | } | 659 | } |
661 | 660 | ||
@@ -683,7 +682,7 @@ int elantech_init(struct psmouse *psmouse) | |||
683 | * Do the version query again so we can store the result | 682 | * Do the version query again so we can store the result |
684 | */ | 683 | */ |
685 | if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) { | 684 | if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) { |
686 | pr_err("elantech.c: failed to query firmware version.\n"); | 685 | pr_err("failed to query firmware version.\n"); |
687 | goto init_fail; | 686 | goto init_fail; |
688 | } | 687 | } |
689 | 688 | ||
@@ -704,14 +703,14 @@ int elantech_init(struct psmouse *psmouse) | |||
704 | etd->paritycheck = 1; | 703 | etd->paritycheck = 1; |
705 | } | 704 | } |
706 | 705 | ||
707 | pr_info("elantech.c: assuming hardware version %d, firmware version %d.%d.%d\n", | 706 | pr_info("assuming hardware version %d, firmware version %d.%d.%d\n", |
708 | etd->hw_version, param[0], param[1], param[2]); | 707 | etd->hw_version, param[0], param[1], param[2]); |
709 | 708 | ||
710 | if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY, param)) { | 709 | if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY, param)) { |
711 | pr_err("elantech.c: failed to query capabilities.\n"); | 710 | pr_err("failed to query capabilities.\n"); |
712 | goto init_fail; | 711 | goto init_fail; |
713 | } | 712 | } |
714 | pr_info("elantech.c: Synaptics capabilities query result 0x%02x, 0x%02x, 0x%02x.\n", | 713 | pr_info("Synaptics capabilities query result 0x%02x, 0x%02x, 0x%02x.\n", |
715 | param[0], param[1], param[2]); | 714 | param[0], param[1], param[2]); |
716 | etd->capabilities = param[0]; | 715 | etd->capabilities = param[0]; |
717 | 716 | ||
@@ -721,13 +720,12 @@ int elantech_init(struct psmouse *psmouse) | |||
721 | * to jump. Enable a workaround. | 720 | * to jump. Enable a workaround. |
722 | */ | 721 | */ |
723 | if (etd->fw_version == 0x020022) { | 722 | if (etd->fw_version == 0x020022) { |
724 | pr_info("elantech.c: firmware version 2.0.34 detected, " | 723 | pr_info("firmware version 2.0.34 detected, enabling jumpy cursor workaround\n"); |
725 | "enabling jumpy cursor workaround\n"); | ||
726 | etd->jumpy_cursor = 1; | 724 | etd->jumpy_cursor = 1; |
727 | } | 725 | } |
728 | 726 | ||
729 | if (elantech_set_absolute_mode(psmouse)) { | 727 | if (elantech_set_absolute_mode(psmouse)) { |
730 | pr_err("elantech.c: failed to put touchpad into absolute mode.\n"); | 728 | pr_err("failed to put touchpad into absolute mode.\n"); |
731 | goto init_fail; | 729 | goto init_fail; |
732 | } | 730 | } |
733 | 731 | ||
@@ -736,8 +734,7 @@ int elantech_init(struct psmouse *psmouse) | |||
736 | error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj, | 734 | error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj, |
737 | &elantech_attr_group); | 735 | &elantech_attr_group); |
738 | if (error) { | 736 | if (error) { |
739 | pr_err("elantech.c: failed to create sysfs attributes, error: %d.\n", | 737 | pr_err("failed to create sysfs attributes, error: %d.\n", error); |
740 | error); | ||
741 | goto init_fail; | 738 | goto init_fail; |
742 | } | 739 | } |
743 | 740 | ||