aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/psmouse-base.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/mouse/psmouse-base.c')
-rw-r--r--drivers/input/mouse/psmouse-base.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 343afa38f4c2..9fb7eb6b0f71 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -112,8 +112,8 @@ static struct workqueue_struct *kpsmoused_wq;
112 112
113struct psmouse_protocol { 113struct psmouse_protocol {
114 enum psmouse_type type; 114 enum psmouse_type type;
115 char *name; 115 const char *name;
116 char *alias; 116 const char *alias;
117 int maxproto; 117 int maxproto;
118 int (*detect)(struct psmouse *, int); 118 int (*detect)(struct psmouse *, int);
119 int (*init)(struct psmouse *); 119 int (*init)(struct psmouse *);
@@ -507,15 +507,17 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties)
507{ 507{
508 struct ps2dev *ps2dev = &psmouse->ps2dev; 508 struct ps2dev *ps2dev = &psmouse->ps2dev;
509 unsigned char param[2]; 509 unsigned char param[2];
510 unsigned char seq[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20, 0 }; 510 static const unsigned char seq[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20 };
511 int i; 511 int i;
512 512
513 param[0] = 10; 513 param[0] = 10;
514 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); 514 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
515 param[0] = 0; 515 param[0] = 0;
516 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); 516 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
517 for (i = 0; seq[i]; i++) 517 for (i = 0; i < ARRAY_SIZE(seq); i++) {
518 ps2_command(ps2dev, seq + i, PSMOUSE_CMD_SETRATE); 518 param[0] = seq[i];
519 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
520 }
519 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID); 521 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
520 522
521 if (param[0] != 2) 523 if (param[0] != 2)
@@ -652,7 +654,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
652 return PSMOUSE_PS2; 654 return PSMOUSE_PS2;
653} 655}
654 656
655static struct psmouse_protocol psmouse_protocols[] = { 657static const struct psmouse_protocol psmouse_protocols[] = {
656 { 658 {
657 .type = PSMOUSE_PS2, 659 .type = PSMOUSE_PS2,
658 .name = "PS/2", 660 .name = "PS/2",
@@ -726,7 +728,7 @@ static struct psmouse_protocol psmouse_protocols[] = {
726 }, 728 },
727}; 729};
728 730
729static struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type) 731static const struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type)
730{ 732{
731 int i; 733 int i;
732 734
@@ -738,9 +740,9 @@ static struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type)
738 return &psmouse_protocols[0]; 740 return &psmouse_protocols[0];
739} 741}
740 742
741static struct psmouse_protocol *psmouse_protocol_by_name(const char *name, size_t len) 743static const struct psmouse_protocol *psmouse_protocol_by_name(const char *name, size_t len)
742{ 744{
743 struct psmouse_protocol *p; 745 const struct psmouse_protocol *p;
744 int i; 746 int i;
745 747
746 for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) { 748 for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) {
@@ -795,13 +797,15 @@ static int psmouse_probe(struct psmouse *psmouse)
795 797
796void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution) 798void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution)
797{ 799{
798 unsigned char params[] = { 0, 1, 2, 2, 3 }; 800 static const unsigned char params[] = { 0, 1, 2, 2, 3 };
801 unsigned char p;
799 802
800 if (resolution == 0 || resolution > 200) 803 if (resolution == 0 || resolution > 200)
801 resolution = 200; 804 resolution = 200;
802 805
803 ps2_command(&psmouse->ps2dev, &params[resolution / 50], PSMOUSE_CMD_SETRES); 806 p = params[resolution / 50];
804 psmouse->resolution = 25 << params[resolution / 50]; 807 ps2_command(&psmouse->ps2dev, &p, PSMOUSE_CMD_SETRES);
808 psmouse->resolution = 25 << p;
805} 809}
806 810
807/* 811/*
@@ -810,12 +814,14 @@ void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution)
810 814
811static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate) 815static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate)
812{ 816{
813 unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 }; 817 static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 };
818 unsigned char r;
814 int i = 0; 819 int i = 0;
815 820
816 while (rates[i] > rate) i++; 821 while (rates[i] > rate) i++;
817 ps2_command(&psmouse->ps2dev, &rates[i], PSMOUSE_CMD_SETRATE); 822 r = rates[i];
818 psmouse->rate = rates[i]; 823 ps2_command(&psmouse->ps2dev, &r, PSMOUSE_CMD_SETRATE);
824 psmouse->rate = r;
819} 825}
820 826
821/* 827/*
@@ -1031,7 +1037,7 @@ static void psmouse_disconnect(struct serio *serio)
1031 mutex_unlock(&psmouse_mutex); 1037 mutex_unlock(&psmouse_mutex);
1032} 1038}
1033 1039
1034static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto) 1040static int psmouse_switch_protocol(struct psmouse *psmouse, const struct psmouse_protocol *proto)
1035{ 1041{
1036 struct input_dev *input_dev = psmouse->dev; 1042 struct input_dev *input_dev = psmouse->dev;
1037 1043
@@ -1362,7 +1368,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1362 struct serio *serio = psmouse->ps2dev.serio; 1368 struct serio *serio = psmouse->ps2dev.serio;
1363 struct psmouse *parent = NULL; 1369 struct psmouse *parent = NULL;
1364 struct input_dev *new_dev; 1370 struct input_dev *new_dev;
1365 struct psmouse_protocol *proto; 1371 const struct psmouse_protocol *proto;
1366 int retry = 0; 1372 int retry = 0;
1367 1373
1368 if (!(proto = psmouse_protocol_by_name(buf, count))) 1374 if (!(proto = psmouse_protocol_by_name(buf, count)))
@@ -1459,7 +1465,7 @@ static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data,
1459 1465
1460static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) 1466static int psmouse_set_maxproto(const char *val, struct kernel_param *kp)
1461{ 1467{
1462 struct psmouse_protocol *proto; 1468 const struct psmouse_protocol *proto;
1463 1469
1464 if (!val) 1470 if (!val)
1465 return -EINVAL; 1471 return -EINVAL;