Commit e38de678 authored by Helge Deller's avatar Helge Deller Committed by Dmitry Torokhov

Input: constify psmouse driver

Signed-off-by: default avatarHelge Deller <deller@gmx.de>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent e2df452b
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#define ALPS_PASS 0x20 #define ALPS_PASS 0x20
#define ALPS_FW_BK_2 0x40 #define ALPS_FW_BK_2 0x40
static struct alps_model_info alps_model_data[] = { static const struct alps_model_info alps_model_data[] = {
{ { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */ { { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */
{ { 0x53, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, { { 0x53, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
{ { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, { { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 },
...@@ -209,10 +209,10 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse, struct pt_regs * ...@@ -209,10 +209,10 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse, struct pt_regs *
return PSMOUSE_GOOD_DATA; return PSMOUSE_GOOD_DATA;
} }
static struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version) static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version)
{ {
struct ps2dev *ps2dev = &psmouse->ps2dev; struct ps2dev *ps2dev = &psmouse->ps2dev;
unsigned char rates[] = { 0, 10, 20, 40, 60, 80, 100, 200 }; static const unsigned char rates[] = { 0, 10, 20, 40, 60, 80, 100, 200 };
unsigned char param[4]; unsigned char param[4];
int i; int i;
...@@ -504,7 +504,7 @@ int alps_init(struct psmouse *psmouse) ...@@ -504,7 +504,7 @@ int alps_init(struct psmouse *psmouse)
int alps_detect(struct psmouse *psmouse, int set_properties) int alps_detect(struct psmouse *psmouse, int set_properties)
{ {
int version; int version;
struct alps_model_info *model; const struct alps_model_info *model;
if (!(model = alps_get_model(psmouse, &version))) if (!(model = alps_get_model(psmouse, &version)))
return -1; return -1;
......
...@@ -25,7 +25,7 @@ struct alps_data { ...@@ -25,7 +25,7 @@ struct alps_data {
struct input_dev *dev2; /* Relative device */ struct input_dev *dev2; /* Relative device */
char name[32]; /* Name */ char name[32]; /* Name */
char phys[32]; /* Phys */ char phys[32]; /* Phys */
struct alps_model_info *i; /* Info */ const struct alps_model_info *i;/* Info */
int prev_fin; /* Finger bit from previous packet */ int prev_fin; /* Finger bit from previous packet */
}; };
......
...@@ -115,13 +115,15 @@ static int lifebook_absolute_mode(struct psmouse *psmouse) ...@@ -115,13 +115,15 @@ static int lifebook_absolute_mode(struct psmouse *psmouse)
static void lifebook_set_resolution(struct psmouse *psmouse, unsigned int resolution) static void lifebook_set_resolution(struct psmouse *psmouse, unsigned int resolution)
{ {
unsigned char params[] = { 0, 1, 2, 2, 3 }; static const unsigned char params[] = { 0, 1, 2, 2, 3 };
unsigned char p;
if (resolution == 0 || resolution > 400) if (resolution == 0 || resolution > 400)
resolution = 400; resolution = 400;
ps2_command(&psmouse->ps2dev, &params[resolution / 100], PSMOUSE_CMD_SETRES); p = params[resolution / 100];
psmouse->resolution = 50 << params[resolution / 100]; ps2_command(&psmouse->ps2dev, &p, PSMOUSE_CMD_SETRES);
psmouse->resolution = 50 << p;
} }
static void lifebook_disconnect(struct psmouse *psmouse) static void lifebook_disconnect(struct psmouse *psmouse)
......
...@@ -112,8 +112,8 @@ static struct workqueue_struct *kpsmoused_wq; ...@@ -112,8 +112,8 @@ static struct workqueue_struct *kpsmoused_wq;
struct psmouse_protocol { struct psmouse_protocol {
enum psmouse_type type; enum psmouse_type type;
char *name; const char *name;
char *alias; const char *alias;
int maxproto; int maxproto;
int (*detect)(struct psmouse *, int); int (*detect)(struct psmouse *, int);
int (*init)(struct psmouse *); int (*init)(struct psmouse *);
...@@ -514,15 +514,17 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties) ...@@ -514,15 +514,17 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties)
{ {
struct ps2dev *ps2dev = &psmouse->ps2dev; struct ps2dev *ps2dev = &psmouse->ps2dev;
unsigned char param[2]; unsigned char param[2];
unsigned char seq[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20, 0 }; static const unsigned char seq[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20 };
int i; int i;
param[0] = 10; param[0] = 10;
ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
param[0] = 0; param[0] = 0;
ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
for (i = 0; seq[i]; i++) for (i = 0; i < ARRAY_SIZE(seq); i++) {
ps2_command(ps2dev, seq + i, PSMOUSE_CMD_SETRATE); param[0] = seq[i];
ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
}
ps2_command(ps2dev, param, PSMOUSE_CMD_GETID); ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
if (param[0] != 2) if (param[0] != 2)
...@@ -659,7 +661,7 @@ static int psmouse_extensions(struct psmouse *psmouse, ...@@ -659,7 +661,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
return PSMOUSE_PS2; return PSMOUSE_PS2;
} }
static struct psmouse_protocol psmouse_protocols[] = { static const struct psmouse_protocol psmouse_protocols[] = {
{ {
.type = PSMOUSE_PS2, .type = PSMOUSE_PS2,
.name = "PS/2", .name = "PS/2",
...@@ -733,7 +735,7 @@ static struct psmouse_protocol psmouse_protocols[] = { ...@@ -733,7 +735,7 @@ static struct psmouse_protocol psmouse_protocols[] = {
}, },
}; };
static struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type) static const struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type)
{ {
int i; int i;
...@@ -745,9 +747,9 @@ static struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type) ...@@ -745,9 +747,9 @@ static struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type)
return &psmouse_protocols[0]; return &psmouse_protocols[0];
} }
static struct psmouse_protocol *psmouse_protocol_by_name(const char *name, size_t len) static const struct psmouse_protocol *psmouse_protocol_by_name(const char *name, size_t len)
{ {
struct psmouse_protocol *p; const struct psmouse_protocol *p;
int i; int i;
for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) { for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) {
...@@ -802,13 +804,15 @@ static int psmouse_probe(struct psmouse *psmouse) ...@@ -802,13 +804,15 @@ static int psmouse_probe(struct psmouse *psmouse)
void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution) void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution)
{ {
unsigned char params[] = { 0, 1, 2, 2, 3 }; static const unsigned char params[] = { 0, 1, 2, 2, 3 };
unsigned char p;
if (resolution == 0 || resolution > 200) if (resolution == 0 || resolution > 200)
resolution = 200; resolution = 200;
ps2_command(&psmouse->ps2dev, &params[resolution / 50], PSMOUSE_CMD_SETRES); p = params[resolution / 50];
psmouse->resolution = 25 << params[resolution / 50]; ps2_command(&psmouse->ps2dev, &p, PSMOUSE_CMD_SETRES);
psmouse->resolution = 25 << p;
} }
/* /*
...@@ -817,12 +821,14 @@ void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution) ...@@ -817,12 +821,14 @@ void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution)
static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate) static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate)
{ {
unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 }; static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 };
unsigned char r;
int i = 0; int i = 0;
while (rates[i] > rate) i++; while (rates[i] > rate) i++;
ps2_command(&psmouse->ps2dev, &rates[i], PSMOUSE_CMD_SETRATE); r = rates[i];
psmouse->rate = rates[i]; ps2_command(&psmouse->ps2dev, &r, PSMOUSE_CMD_SETRATE);
psmouse->rate = r;
} }
/* /*
...@@ -1038,7 +1044,7 @@ static void psmouse_disconnect(struct serio *serio) ...@@ -1038,7 +1044,7 @@ static void psmouse_disconnect(struct serio *serio)
mutex_unlock(&psmouse_mutex); mutex_unlock(&psmouse_mutex);
} }
static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto) static int psmouse_switch_protocol(struct psmouse *psmouse, const struct psmouse_protocol *proto)
{ {
struct input_dev *input_dev = psmouse->dev; struct input_dev *input_dev = psmouse->dev;
...@@ -1369,7 +1375,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co ...@@ -1369,7 +1375,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
struct serio *serio = psmouse->ps2dev.serio; struct serio *serio = psmouse->ps2dev.serio;
struct psmouse *parent = NULL; struct psmouse *parent = NULL;
struct input_dev *new_dev; struct input_dev *new_dev;
struct psmouse_protocol *proto; const struct psmouse_protocol *proto;
int retry = 0; int retry = 0;
if (!(proto = psmouse_protocol_by_name(buf, count))) 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,7 +1472,7 @@ static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data,
static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) static int psmouse_set_maxproto(const char *val, struct kernel_param *kp)
{ {
struct psmouse_protocol *proto; const struct psmouse_protocol *proto;
if (!val) if (!val)
return -EINVAL; return -EINVAL;
......
...@@ -42,7 +42,7 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); ...@@ -42,7 +42,7 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static char *sermouse_protocols[] = { "None", "Mouse Systems Mouse", "Sun Mouse", "Microsoft Mouse", static const char *sermouse_protocols[] = { "None", "Mouse Systems Mouse", "Sun Mouse", "Microsoft Mouse",
"Logitech M+ Mouse", "Microsoft MZ Mouse", "Logitech MZ+ Mouse", "Logitech M+ Mouse", "Microsoft MZ Mouse", "Logitech MZ+ Mouse",
"Logitech MZ++ Mouse"}; "Logitech MZ++ Mouse"};
......
...@@ -430,11 +430,11 @@ static void synaptics_process_packet(struct psmouse *psmouse) ...@@ -430,11 +430,11 @@ static void synaptics_process_packet(struct psmouse *psmouse)
static int synaptics_validate_byte(unsigned char packet[], int idx, unsigned char pkt_type) static int synaptics_validate_byte(unsigned char packet[], int idx, unsigned char pkt_type)
{ {
static unsigned char newabs_mask[] = { 0xC8, 0x00, 0x00, 0xC8, 0x00 }; static const unsigned char newabs_mask[] = { 0xC8, 0x00, 0x00, 0xC8, 0x00 };
static unsigned char newabs_rel_mask[] = { 0xC0, 0x00, 0x00, 0xC0, 0x00 }; static const unsigned char newabs_rel_mask[] = { 0xC0, 0x00, 0x00, 0xC0, 0x00 };
static unsigned char newabs_rslt[] = { 0x80, 0x00, 0x00, 0xC0, 0x00 }; static const unsigned char newabs_rslt[] = { 0x80, 0x00, 0x00, 0xC0, 0x00 };
static unsigned char oldabs_mask[] = { 0xC0, 0x60, 0x00, 0xC0, 0x60 }; static const unsigned char oldabs_mask[] = { 0xC0, 0x60, 0x00, 0xC0, 0x60 };
static unsigned char oldabs_rslt[] = { 0xC0, 0x00, 0x00, 0x80, 0x00 }; static const unsigned char oldabs_rslt[] = { 0xC0, 0x00, 0x00, 0x80, 0x00 };
if (idx < 0 || idx > 4) if (idx < 0 || idx > 4)
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment