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 8bc9f51ae6c2..ec0119459bc6 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 *);
@@ -514,15 +514,17 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties)
514{ 514{
515 struct ps2dev *ps2dev = &psmouse->ps2dev; 515 struct ps2dev *ps2dev = &psmouse->ps2dev;
516 unsigned char param[2]; 516 unsigned char param[2];
517 unsigned char seq[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20, 0 }; 517 static const unsigned char seq[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20 };
518 int i; 518 int i;
519 519
520 param[0] = 10; 520 param[0] = 10;
521 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); 521 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
522 param[0] = 0; 522 param[0] = 0;
523 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); 523 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
524 for (i = 0; seq[i]; i++) 524 for (i = 0; i < ARRAY_SIZE(seq); i++) {
525 ps2_command(ps2dev, seq + i, PSMOUSE_CMD_SETRATE); 525 param[0] = seq[i];
526 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
527 }
526 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID); 528 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
527 529
528 if (param[0] != 2) 530 if (param[0] != 2)
@@ -659,7 +661,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
659 return PSMOUSE_PS2; 661 return PSMOUSE_PS2;
660} 662}
661 663
662static struct psmouse_protocol psmouse_protocols[] = { 664static const struct psmouse_protocol psmouse_protocols[] = {
663 { 665 {
664 .type = PSMOUSE_PS2, 666 .type = PSMOUSE_PS2,
665 .name = "PS/2", 667 .name = "PS/2",
@@ -733,7 +735,7 @@ static struct psmouse_protocol psmouse_protocols[] = {
733 }, 735 },
734}; 736};
735 737
736static struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type) 738static const struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type)
737{ 739{
738 int i; 740 int i;
739 741
@@ -745,9 +747,9 @@ static struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type)
745 return &psmouse_protocols[0]; 747 return &psmouse_protocols[0];
746} 748}
747 749
748static struct psmouse_protocol *psmouse_protocol_by_name(const char *name, size_t len) 750static const struct psmouse_protocol *psmouse_protocol_by_name(const char *name, size_t len)
749{ 751{
750 struct psmouse_protocol *p; 752 const struct psmouse_protocol *p;
751 int i; 753 int i;
752 754
753 for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) { 755 for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) {
@@ -802,13 +804,15 @@ static int psmouse_probe(struct psmouse *psmouse)
802 804
803void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution) 805void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution)
804{ 806{
805 unsigned char params[] = { 0, 1, 2, 2, 3 }; 807 static const unsigned char params[] = { 0, 1, 2, 2, 3 };
808 unsigned char p;
806 809
807 if (resolution == 0 || resolution > 200) 810 if (resolution == 0 || resolution > 200)
808 resolution = 200; 811 resolution = 200;
809 812
810 ps2_command(&psmouse->ps2dev, &params[resolution / 50], PSMOUSE_CMD_SETRES); 813 p = params[resolution / 50];
811 psmouse->resolution = 25 << params[resolution / 50]; 814 ps2_command(&psmouse->ps2dev, &p, PSMOUSE_CMD_SETRES);
815 psmouse->resolution = 25 << p;
812} 816}
813 817
814/* 818/*
@@ -817,12 +821,14 @@ void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution)
817 821
818static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate) 822static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate)
819{ 823{
820 unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 }; 824 static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 };
825 unsigned char r;
821 int i = 0; 826 int i = 0;
822 827
823 while (rates[i] > rate) i++; 828 while (rates[i] > rate) i++;
824 ps2_command(&psmouse->ps2dev, &rates[i], PSMOUSE_CMD_SETRATE); 829 r = rates[i];
825 psmouse->rate = rates[i]; 830 ps2_command(&psmouse->ps2dev, &r, PSMOUSE_CMD_SETRATE);
831 psmouse->rate = r;
826} 832}
827 833
828/* 834/*
@@ -1038,7 +1044,7 @@ static void psmouse_disconnect(struct serio *serio)
1038 mutex_unlock(&psmouse_mutex); 1044 mutex_unlock(&psmouse_mutex);
1039} 1045}
1040 1046
1041static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto) 1047static int psmouse_switch_protocol(struct psmouse *psmouse, const struct psmouse_protocol *proto)
1042{ 1048{
1043 struct input_dev *input_dev = psmouse->dev; 1049 struct input_dev *input_dev = psmouse->dev;
1044 1050
@@ -1369,7 +1375,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1369 struct serio *serio = psmouse->ps2dev.serio; 1375 struct serio *serio = psmouse->ps2dev.serio;
1370 struct psmouse *parent = NULL; 1376 struct psmouse *parent = NULL;
1371 struct input_dev *new_dev; 1377 struct input_dev *new_dev;
1372 struct psmouse_protocol *proto; 1378 const struct psmouse_protocol *proto;
1373 int retry = 0; 1379 int retry = 0;
1374 1380
1375 if (!(proto = psmouse_protocol_by_name(buf, count))) 1381 if (!(proto = psmouse_protocol_by_name(buf, count)))
@@ -1466,7 +1472,7 @@ static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data,
1466 1472
1467static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) 1473static int psmouse_set_maxproto(const char *val, struct kernel_param *kp)
1468{ 1474{
1469 struct psmouse_protocol *proto; 1475 const struct psmouse_protocol *proto;
1470 1476
1471 if (!val) 1477 if (!val)
1472 return -EINVAL; 1478 return -EINVAL;