aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/mouse/logips2pp.c12
-rw-r--r--drivers/input/mouse/psmouse-base.c117
-rw-r--r--drivers/input/mouse/psmouse.h51
-rw-r--r--drivers/input/mouse/trackpoint.c183
4 files changed, 200 insertions, 163 deletions
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 48d2b20d2642..e65c2798a491 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -150,12 +150,12 @@ static void ps2pp_set_smartscroll(struct psmouse *psmouse, unsigned int smartscr
150 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); 150 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
151} 151}
152 152
153static ssize_t psmouse_attr_show_smartscroll(struct psmouse *psmouse, char *buf) 153static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse, void *data, char *buf)
154{ 154{
155 return sprintf(buf, "%d\n", psmouse->smartscroll ? 1 : 0); 155 return sprintf(buf, "%d\n", psmouse->smartscroll ? 1 : 0);
156} 156}
157 157
158static ssize_t psmouse_attr_set_smartscroll(struct psmouse *psmouse, const char *buf, size_t count) 158static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count)
159{ 159{
160 unsigned long value; 160 unsigned long value;
161 char *rest; 161 char *rest;
@@ -169,7 +169,8 @@ static ssize_t psmouse_attr_set_smartscroll(struct psmouse *psmouse, const char
169 return count; 169 return count;
170} 170}
171 171
172PSMOUSE_DEFINE_ATTR(smartscroll); 172PSMOUSE_DEFINE_ATTR(smartscroll, S_IWUSR | S_IRUGO, NULL,
173 ps2pp_attr_show_smartscroll, ps2pp_attr_set_smartscroll);
173 174
174/* 175/*
175 * Support 800 dpi resolution _only_ if the user wants it (there are good 176 * Support 800 dpi resolution _only_ if the user wants it (there are good
@@ -194,7 +195,7 @@ static void ps2pp_set_resolution(struct psmouse *psmouse, unsigned int resolutio
194 195
195static void ps2pp_disconnect(struct psmouse *psmouse) 196static void ps2pp_disconnect(struct psmouse *psmouse)
196{ 197{
197 device_remove_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll); 198 device_remove_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll.dattr);
198} 199}
199 200
200static struct ps2pp_info *get_model_info(unsigned char model) 201static struct ps2pp_info *get_model_info(unsigned char model)
@@ -379,7 +380,8 @@ int ps2pp_init(struct psmouse *psmouse, int set_properties)
379 psmouse->set_resolution = ps2pp_set_resolution; 380 psmouse->set_resolution = ps2pp_set_resolution;
380 psmouse->disconnect = ps2pp_disconnect; 381 psmouse->disconnect = ps2pp_disconnect;
381 382
382 device_create_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_smartscroll); 383 device_create_file(&psmouse->ps2dev.serio->dev,
384 &psmouse_attr_smartscroll.dattr);
383 } 385 }
384 } 386 }
385 387
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index b3508276785f..0830c6e13ef6 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -58,10 +58,30 @@ static unsigned int psmouse_resetafter;
58module_param_named(resetafter, psmouse_resetafter, uint, 0644); 58module_param_named(resetafter, psmouse_resetafter, uint, 0644);
59MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never)."); 59MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never).");
60 60
61PSMOUSE_DEFINE_ATTR(protocol); 61PSMOUSE_DEFINE_ATTR(protocol, S_IWUSR | S_IRUGO,
62PSMOUSE_DEFINE_ATTR(rate); 62 NULL,
63PSMOUSE_DEFINE_ATTR(resolution); 63 psmouse_attr_show_protocol, psmouse_attr_set_protocol);
64PSMOUSE_DEFINE_ATTR(resetafter); 64PSMOUSE_DEFINE_ATTR(rate, S_IWUSR | S_IRUGO,
65 (void *) offsetof(struct psmouse, rate),
66 psmouse_show_int_attr, psmouse_attr_set_rate);
67PSMOUSE_DEFINE_ATTR(resolution, S_IWUSR | S_IRUGO,
68 (void *) offsetof(struct psmouse, resolution),
69 psmouse_show_int_attr, psmouse_attr_set_resolution);
70PSMOUSE_DEFINE_ATTR(resetafter, S_IWUSR | S_IRUGO,
71 (void *) offsetof(struct psmouse, resetafter),
72 psmouse_show_int_attr, psmouse_set_int_attr);
73
74static struct attribute *psmouse_attributes[] = {
75 &psmouse_attr_protocol.dattr.attr,
76 &psmouse_attr_rate.dattr.attr,
77 &psmouse_attr_resolution.dattr.attr,
78 &psmouse_attr_resetafter.dattr.attr,
79 NULL
80};
81
82static struct attribute_group psmouse_attribute_group = {
83 .attrs = psmouse_attributes,
84};
65 85
66__obsolete_setup("psmouse_noext"); 86__obsolete_setup("psmouse_noext");
67__obsolete_setup("psmouse_resolution="); 87__obsolete_setup("psmouse_resolution=");
@@ -800,10 +820,7 @@ static void psmouse_disconnect(struct serio *serio)
800 820
801 psmouse = serio_get_drvdata(serio); 821 psmouse = serio_get_drvdata(serio);
802 822
803 device_remove_file(&serio->dev, &psmouse_attr_protocol); 823 sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group);
804 device_remove_file(&serio->dev, &psmouse_attr_rate);
805 device_remove_file(&serio->dev, &psmouse_attr_resolution);
806 device_remove_file(&serio->dev, &psmouse_attr_resetafter);
807 824
808 down(&psmouse_sem); 825 down(&psmouse_sem);
809 826
@@ -940,10 +957,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
940 if (parent && parent->pt_activate) 957 if (parent && parent->pt_activate)
941 parent->pt_activate(parent); 958 parent->pt_activate(parent);
942 959
943 device_create_file(&serio->dev, &psmouse_attr_protocol); 960 sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group);
944 device_create_file(&serio->dev, &psmouse_attr_rate);
945 device_create_file(&serio->dev, &psmouse_attr_resolution);
946 device_create_file(&serio->dev, &psmouse_attr_resetafter);
947 961
948 psmouse_activate(psmouse); 962 psmouse_activate(psmouse);
949 963
@@ -1040,10 +1054,12 @@ static struct serio_driver psmouse_drv = {
1040 .cleanup = psmouse_cleanup, 1054 .cleanup = psmouse_cleanup,
1041}; 1055};
1042 1056
1043ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, 1057ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *devattr,
1044 ssize_t (*handler)(struct psmouse *, char *)) 1058 char *buf)
1045{ 1059{
1046 struct serio *serio = to_serio_port(dev); 1060 struct serio *serio = to_serio_port(dev);
1061 struct psmouse_attribute *attr = to_psmouse_attr(devattr);
1062 struct psmouse *psmouse;
1047 int retval; 1063 int retval;
1048 1064
1049 retval = serio_pin_driver(serio); 1065 retval = serio_pin_driver(serio);
@@ -1055,19 +1071,21 @@ ssize_t psmouse_attr_show_helper(struct device *dev, char *buf,
1055 goto out; 1071 goto out;
1056 } 1072 }
1057 1073
1058 retval = handler(serio_get_drvdata(serio), buf); 1074 psmouse = serio_get_drvdata(serio);
1075
1076 retval = attr->show(psmouse, attr->data, buf);
1059 1077
1060out: 1078out:
1061 serio_unpin_driver(serio); 1079 serio_unpin_driver(serio);
1062 return retval; 1080 return retval;
1063} 1081}
1064 1082
1065ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t count, 1083ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *devattr,
1066 ssize_t (*handler)(struct psmouse *, const char *, size_t)) 1084 const char *buf, size_t count)
1067{ 1085{
1068 struct serio *serio = to_serio_port(dev); 1086 struct serio *serio = to_serio_port(dev);
1069 struct psmouse *psmouse = serio_get_drvdata(serio); 1087 struct psmouse_attribute *attr = to_psmouse_attr(devattr);
1070 struct psmouse *parent = NULL; 1088 struct psmouse *psmouse, *parent = NULL;
1071 int retval; 1089 int retval;
1072 1090
1073 retval = serio_pin_driver(serio); 1091 retval = serio_pin_driver(serio);
@@ -1083,6 +1101,8 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun
1083 if (retval) 1101 if (retval)
1084 goto out_unpin; 1102 goto out_unpin;
1085 1103
1104 psmouse = serio_get_drvdata(serio);
1105
1086 if (psmouse->state == PSMOUSE_IGNORE) { 1106 if (psmouse->state == PSMOUSE_IGNORE) {
1087 retval = -ENODEV; 1107 retval = -ENODEV;
1088 goto out_up; 1108 goto out_up;
@@ -1095,7 +1115,7 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun
1095 1115
1096 psmouse_deactivate(psmouse); 1116 psmouse_deactivate(psmouse);
1097 1117
1098 retval = handler(psmouse, buf, count); 1118 retval = attr->set(psmouse, attr->data, buf, count);
1099 1119
1100 if (retval != -ENODEV) 1120 if (retval != -ENODEV)
1101 psmouse_activate(psmouse); 1121 psmouse_activate(psmouse);
@@ -1110,12 +1130,34 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun
1110 return retval; 1130 return retval;
1111} 1131}
1112 1132
1113static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, char *buf) 1133static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char *buf)
1134{
1135 unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset);
1136
1137 return sprintf(buf, "%lu\n", *field);
1138}
1139
1140static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count)
1141{
1142 unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset);
1143 unsigned long value;
1144 char *rest;
1145
1146 value = simple_strtoul(buf, &rest, 10);
1147 if (*rest)
1148 return -EINVAL;
1149
1150 *field = value;
1151
1152 return count;
1153}
1154
1155static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, void *data, char *buf)
1114{ 1156{
1115 return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name); 1157 return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name);
1116} 1158}
1117 1159
1118static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, const char *buf, size_t count) 1160static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1119{ 1161{
1120 struct serio *serio = psmouse->ps2dev.serio; 1162 struct serio *serio = psmouse->ps2dev.serio;
1121 struct psmouse *parent = NULL; 1163 struct psmouse *parent = NULL;
@@ -1179,12 +1221,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, const char *bu
1179 return count; 1221 return count;
1180} 1222}
1181 1223
1182static ssize_t psmouse_attr_show_rate(struct psmouse *psmouse, char *buf) 1224static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1183{
1184 return sprintf(buf, "%d\n", psmouse->rate);
1185}
1186
1187static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, const char *buf, size_t count)
1188{ 1225{
1189 unsigned long value; 1226 unsigned long value;
1190 char *rest; 1227 char *rest;
@@ -1197,12 +1234,7 @@ static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, const char *buf, s
1197 return count; 1234 return count;
1198} 1235}
1199 1236
1200static ssize_t psmouse_attr_show_resolution(struct psmouse *psmouse, char *buf) 1237static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1201{
1202 return sprintf(buf, "%d\n", psmouse->resolution);
1203}
1204
1205static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, const char *buf, size_t count)
1206{ 1238{
1207 unsigned long value; 1239 unsigned long value;
1208 char *rest; 1240 char *rest;
@@ -1215,23 +1247,6 @@ static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, const char *
1215 return count; 1247 return count;
1216} 1248}
1217 1249
1218static ssize_t psmouse_attr_show_resetafter(struct psmouse *psmouse, char *buf)
1219{
1220 return sprintf(buf, "%d\n", psmouse->resetafter);
1221}
1222
1223static ssize_t psmouse_attr_set_resetafter(struct psmouse *psmouse, const char *buf, size_t count)
1224{
1225 unsigned long value;
1226 char *rest;
1227
1228 value = simple_strtoul(buf, &rest, 10);
1229 if (*rest)
1230 return -EINVAL;
1231
1232 psmouse->resetafter = value;
1233 return count;
1234}
1235 1250
1236static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) 1251static int psmouse_set_maxproto(const char *val, struct kernel_param *kp)
1237{ 1252{
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index e312a6b41681..45d2bd774f00 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -86,24 +86,37 @@ int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
86int psmouse_reset(struct psmouse *psmouse); 86int psmouse_reset(struct psmouse *psmouse);
87void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); 87void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
88 88
89ssize_t psmouse_attr_show_helper(struct device *dev, char *buf, 89
90 ssize_t (*handler)(struct psmouse *, char *)); 90struct psmouse_attribute {
91ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t count, 91 struct device_attribute dattr;
92 ssize_t (*handler)(struct psmouse *, const char *, size_t)); 92 void *data;
93 93 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf);
94#define PSMOUSE_DEFINE_ATTR(_name) \ 94 ssize_t (*set)(struct psmouse *psmouse, void *data,
95static ssize_t psmouse_attr_show_##_name(struct psmouse *, char *); \ 95 const char *buf, size_t count);
96static ssize_t psmouse_attr_set_##_name(struct psmouse *, const char *, size_t);\ 96};
97static ssize_t psmouse_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \ 97#define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
98{ \ 98
99 return psmouse_attr_show_helper(d, b, psmouse_attr_show_##_name); \ 99ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
100} \ 100 char *buf);
101static ssize_t psmouse_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s)\ 101ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr,
102{ \ 102 const char *buf, size_t count);
103 return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \ 103
104} \ 104#define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \
105static struct device_attribute psmouse_attr_##_name = \ 105static ssize_t _show(struct psmouse *, void *data, char *); \
106 __ATTR(_name, S_IWUSR | S_IRUGO, \ 106static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \
107 psmouse_do_show_##_name, psmouse_do_set_##_name); 107static struct psmouse_attribute psmouse_attr_##_name = { \
108 .dattr = { \
109 .attr = { \
110 .name = __stringify(_name), \
111 .mode = _mode, \
112 .owner = THIS_MODULE, \
113 }, \
114 .show = psmouse_attr_show_helper, \
115 .store = psmouse_attr_set_helper, \
116 }, \
117 .data = _data, \
118 .show = _show, \
119 .set = _set, \
120}
108 121
109#endif /* _PSMOUSE_H */ 122#endif /* _PSMOUSE_H */
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index aee3b24a9102..b4898d8a68e2 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -19,54 +19,6 @@
19#include "psmouse.h" 19#include "psmouse.h"
20#include "trackpoint.h" 20#include "trackpoint.h"
21 21
22PSMOUSE_DEFINE_ATTR(sensitivity);
23PSMOUSE_DEFINE_ATTR(speed);
24PSMOUSE_DEFINE_ATTR(inertia);
25PSMOUSE_DEFINE_ATTR(reach);
26PSMOUSE_DEFINE_ATTR(draghys);
27PSMOUSE_DEFINE_ATTR(mindrag);
28PSMOUSE_DEFINE_ATTR(thresh);
29PSMOUSE_DEFINE_ATTR(upthresh);
30PSMOUSE_DEFINE_ATTR(ztime);
31PSMOUSE_DEFINE_ATTR(jenks);
32PSMOUSE_DEFINE_ATTR(press_to_select);
33PSMOUSE_DEFINE_ATTR(skipback);
34PSMOUSE_DEFINE_ATTR(ext_dev);
35
36#define MAKE_ATTR_READ(_item) \
37 static ssize_t psmouse_attr_show_##_item(struct psmouse *psmouse, char *buf) \
38 { \
39 struct trackpoint_data *tp = psmouse->private; \
40 return sprintf(buf, "%lu\n", (unsigned long)tp->_item); \
41 }
42
43#define MAKE_ATTR_WRITE(_item, command) \
44 static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse, const char *buf, size_t count) \
45 { \
46 char *rest; \
47 unsigned long value; \
48 struct trackpoint_data *tp = psmouse->private; \
49 value = simple_strtoul(buf, &rest, 10); \
50 if (*rest) \
51 return -EINVAL; \
52 tp->_item = value; \
53 trackpoint_write(&psmouse->ps2dev, command, tp->_item); \
54 return count; \
55 }
56
57#define MAKE_ATTR_TOGGLE(_item, command, mask) \
58 static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse, const char *buf, size_t count) \
59 { \
60 unsigned char toggle; \
61 struct trackpoint_data *tp = psmouse->private; \
62 toggle = (buf[0] == '1') ? 1 : 0; \
63 if (toggle != tp->_item) { \
64 tp->_item = toggle; \
65 trackpoint_toggle_bit(&psmouse->ps2dev, command, mask); \
66 } \
67 return count; \
68 }
69
70/* 22/*
71 * Device IO: read, write and toggle bit 23 * Device IO: read, write and toggle bit
72 */ 24 */
@@ -108,59 +60,114 @@ static int trackpoint_toggle_bit(struct ps2dev *ps2dev, unsigned char loc, unsig
108 return 0; 60 return 0;
109} 61}
110 62
111MAKE_ATTR_WRITE(sensitivity, TP_SENS);
112MAKE_ATTR_READ(sensitivity);
113
114MAKE_ATTR_WRITE(speed, TP_SPEED);
115MAKE_ATTR_READ(speed);
116 63
117MAKE_ATTR_WRITE(inertia, TP_INERTIA); 64/*
118MAKE_ATTR_READ(inertia); 65 * Trackpoint-specific attributes
66 */
67struct trackpoint_attr_data {
68 size_t field_offset;
69 unsigned char command;
70 unsigned char mask;
71};
119 72
120MAKE_ATTR_WRITE(reach, TP_REACH); 73static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, void *data, char *buf)
121MAKE_ATTR_READ(reach); 74{
75 struct trackpoint_data *tp = psmouse->private;
76 struct trackpoint_attr_data *attr = data;
77 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
122 78
123MAKE_ATTR_WRITE(draghys, TP_DRAGHYS); 79 return sprintf(buf, "%u\n", *field);
124MAKE_ATTR_READ(draghys); 80}
125 81
126MAKE_ATTR_WRITE(mindrag, TP_MINDRAG); 82static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data,
127MAKE_ATTR_READ(mindrag); 83 const char *buf, size_t count)
84{
85 struct trackpoint_data *tp = psmouse->private;
86 struct trackpoint_attr_data *attr = data;
87 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
88 unsigned long value;
89 char *rest;
128 90
129MAKE_ATTR_WRITE(thresh, TP_THRESH); 91 value = simple_strtoul(buf, &rest, 10);
130MAKE_ATTR_READ(thresh); 92 if (*rest || value > 255)
93 return -EINVAL;
131 94
132MAKE_ATTR_WRITE(upthresh, TP_UP_THRESH); 95 *field = value;
133MAKE_ATTR_READ(upthresh); 96 trackpoint_write(&psmouse->ps2dev, attr->command, value);
134 97
135MAKE_ATTR_WRITE(ztime, TP_Z_TIME); 98 return count;
136MAKE_ATTR_READ(ztime); 99}
137 100
138MAKE_ATTR_WRITE(jenks, TP_JENKS_CURV); 101#define TRACKPOINT_INT_ATTR(_name, _command) \
139MAKE_ATTR_READ(jenks); 102 static struct trackpoint_attr_data trackpoint_attr_##_name = { \
103 .field_offset = offsetof(struct trackpoint_data, _name), \
104 .command = _command, \
105 }; \
106 PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \
107 &trackpoint_attr_##_name, \
108 trackpoint_show_int_attr, trackpoint_set_int_attr)
109
110static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data,
111 const char *buf, size_t count)
112{
113 struct trackpoint_data *tp = psmouse->private;
114 struct trackpoint_attr_data *attr = data;
115 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
116 unsigned long value;
117 char *rest;
118
119 value = simple_strtoul(buf, &rest, 10);
120 if (*rest || value > 1)
121 return -EINVAL;
122
123 if (*field != value) {
124 *field = value;
125 trackpoint_toggle_bit(&psmouse->ps2dev, attr->command, attr->mask);
126 }
140 127
141MAKE_ATTR_TOGGLE(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON); 128 return count;
142MAKE_ATTR_READ(press_to_select); 129}
143 130
144MAKE_ATTR_TOGGLE(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK);
145MAKE_ATTR_READ(skipback);
146 131
147MAKE_ATTR_TOGGLE(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); 132#define TRACKPOINT_BIT_ATTR(_name, _command, _mask) \
148MAKE_ATTR_READ(ext_dev); 133 static struct trackpoint_attr_data trackpoint_attr_##_name = { \
134 .field_offset = offsetof(struct trackpoint_data, _name), \
135 .command = _command, \
136 .mask = _mask, \
137 }; \
138 PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \
139 &trackpoint_attr_##_name, \
140 trackpoint_show_int_attr, trackpoint_set_bit_attr)
141
142TRACKPOINT_INT_ATTR(sensitivity, TP_SENS);
143TRACKPOINT_INT_ATTR(speed, TP_SPEED);
144TRACKPOINT_INT_ATTR(inertia, TP_INERTIA);
145TRACKPOINT_INT_ATTR(reach, TP_REACH);
146TRACKPOINT_INT_ATTR(draghys, TP_DRAGHYS);
147TRACKPOINT_INT_ATTR(mindrag, TP_MINDRAG);
148TRACKPOINT_INT_ATTR(thresh, TP_THRESH);
149TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH);
150TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME);
151TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV);
152
153TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON);
154TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK);
155TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV);
149 156
150static struct attribute *trackpoint_attrs[] = { 157static struct attribute *trackpoint_attrs[] = {
151 &psmouse_attr_sensitivity.attr, 158 &psmouse_attr_sensitivity.dattr.attr,
152 &psmouse_attr_speed.attr, 159 &psmouse_attr_speed.dattr.attr,
153 &psmouse_attr_inertia.attr, 160 &psmouse_attr_inertia.dattr.attr,
154 &psmouse_attr_reach.attr, 161 &psmouse_attr_reach.dattr.attr,
155 &psmouse_attr_draghys.attr, 162 &psmouse_attr_draghys.dattr.attr,
156 &psmouse_attr_mindrag.attr, 163 &psmouse_attr_mindrag.dattr.attr,
157 &psmouse_attr_thresh.attr, 164 &psmouse_attr_thresh.dattr.attr,
158 &psmouse_attr_upthresh.attr, 165 &psmouse_attr_upthresh.dattr.attr,
159 &psmouse_attr_ztime.attr, 166 &psmouse_attr_ztime.dattr.attr,
160 &psmouse_attr_jenks.attr, 167 &psmouse_attr_jenks.dattr.attr,
161 &psmouse_attr_press_to_select.attr, 168 &psmouse_attr_press_to_select.dattr.attr,
162 &psmouse_attr_skipback.attr, 169 &psmouse_attr_skipback.dattr.attr,
163 &psmouse_attr_ext_dev.attr, 170 &psmouse_attr_ext_dev.dattr.attr,
164 NULL 171 NULL
165}; 172};
166 173