aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJoe Rouvier <joe@rouvier.org>2008-08-10 00:29:25 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2008-09-10 12:11:57 -0400
commit160f1fef7e52e974489b3c70fbd4e094c06965c2 (patch)
tree80423a45a9a57736e6ce6351da0801e1a5b02b8c /drivers
parent82a196f481661170b4982dc7e68a12e9253309d0 (diff)
Input: convert drivers to use strict_strtoul()
strict_strtoul() allows newline character at the end of the the input string and therefore is more user-friendly. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/keyboard/atkbd.c20
-rw-r--r--drivers/input/mouse/logips2pp.c4
-rw-r--r--drivers/input/mouse/psmouse-base.c12
-rw-r--r--drivers/input/mouse/trackpoint.c8
-rw-r--r--drivers/input/tablet/aiptek.c53
-rw-r--r--drivers/input/touchscreen/ads7846.c7
6 files changed, 53 insertions, 51 deletions
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index b1ce10f50bcf..44745727aea6 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -1207,15 +1207,13 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun
1207{ 1207{
1208 struct input_dev *old_dev, *new_dev; 1208 struct input_dev *old_dev, *new_dev;
1209 unsigned long value; 1209 unsigned long value;
1210 char *rest;
1211 int err; 1210 int err;
1212 unsigned char old_extra, old_set; 1211 unsigned char old_extra, old_set;
1213 1212
1214 if (!atkbd->write) 1213 if (!atkbd->write)
1215 return -EIO; 1214 return -EIO;
1216 1215
1217 value = simple_strtoul(buf, &rest, 10); 1216 if (strict_strtoul(buf, 10, &value) || value > 1)
1218 if (*rest || value > 1)
1219 return -EINVAL; 1217 return -EINVAL;
1220 1218
1221 if (atkbd->extra != value) { 1219 if (atkbd->extra != value) {
@@ -1264,12 +1262,10 @@ static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t cou
1264{ 1262{
1265 struct input_dev *old_dev, *new_dev; 1263 struct input_dev *old_dev, *new_dev;
1266 unsigned long value; 1264 unsigned long value;
1267 char *rest;
1268 int err; 1265 int err;
1269 unsigned char old_scroll; 1266 unsigned char old_scroll;
1270 1267
1271 value = simple_strtoul(buf, &rest, 10); 1268 if (strict_strtoul(buf, 10, &value) || value > 1)
1272 if (*rest || value > 1)
1273 return -EINVAL; 1269 return -EINVAL;
1274 1270
1275 if (atkbd->scroll != value) { 1271 if (atkbd->scroll != value) {
@@ -1310,15 +1306,13 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
1310{ 1306{
1311 struct input_dev *old_dev, *new_dev; 1307 struct input_dev *old_dev, *new_dev;
1312 unsigned long value; 1308 unsigned long value;
1313 char *rest;
1314 int err; 1309 int err;
1315 unsigned char old_set, old_extra; 1310 unsigned char old_set, old_extra;
1316 1311
1317 if (!atkbd->write) 1312 if (!atkbd->write)
1318 return -EIO; 1313 return -EIO;
1319 1314
1320 value = simple_strtoul(buf, &rest, 10); 1315 if (strict_strtoul(buf, 10, &value) || (value != 2 && value != 3))
1321 if (*rest || (value != 2 && value != 3))
1322 return -EINVAL; 1316 return -EINVAL;
1323 1317
1324 if (atkbd->set != value) { 1318 if (atkbd->set != value) {
@@ -1361,15 +1355,13 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t
1361{ 1355{
1362 struct input_dev *old_dev, *new_dev; 1356 struct input_dev *old_dev, *new_dev;
1363 unsigned long value; 1357 unsigned long value;
1364 char *rest;
1365 int err; 1358 int err;
1366 unsigned char old_softrepeat, old_softraw; 1359 unsigned char old_softrepeat, old_softraw;
1367 1360
1368 if (!atkbd->write) 1361 if (!atkbd->write)
1369 return -EIO; 1362 return -EIO;
1370 1363
1371 value = simple_strtoul(buf, &rest, 10); 1364 if (strict_strtoul(buf, 10, &value) || value > 1)
1372 if (*rest || value > 1)
1373 return -EINVAL; 1365 return -EINVAL;
1374 1366
1375 if (atkbd->softrepeat != value) { 1367 if (atkbd->softrepeat != value) {
@@ -1413,12 +1405,10 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co
1413{ 1405{
1414 struct input_dev *old_dev, *new_dev; 1406 struct input_dev *old_dev, *new_dev;
1415 unsigned long value; 1407 unsigned long value;
1416 char *rest;
1417 int err; 1408 int err;
1418 unsigned char old_softraw; 1409 unsigned char old_softraw;
1419 1410
1420 value = simple_strtoul(buf, &rest, 10); 1411 if (strict_strtoul(buf, 10, &value) || value > 1)
1421 if (*rest || value > 1)
1422 return -EINVAL; 1412 return -EINVAL;
1423 1413
1424 if (atkbd->softraw != value) { 1414 if (atkbd->softraw != value) {
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 0c5660d28caa..390f1dbb98a4 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -157,10 +157,8 @@ static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse, void *data,
157static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count) 157static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count)
158{ 158{
159 unsigned long value; 159 unsigned long value;
160 char *rest;
161 160
162 value = simple_strtoul(buf, &rest, 10); 161 if (strict_strtoul(buf, 10, &value) || value > 1)
163 if (*rest || value > 1)
164 return -EINVAL; 162 return -EINVAL;
165 163
166 ps2pp_set_smartscroll(psmouse, value); 164 ps2pp_set_smartscroll(psmouse, value);
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index f5a6be1d3c46..9fcb00b8e1a2 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -1433,10 +1433,8 @@ static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const
1433{ 1433{
1434 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); 1434 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
1435 unsigned long value; 1435 unsigned long value;
1436 char *rest;
1437 1436
1438 value = simple_strtoul(buf, &rest, 10); 1437 if (strict_strtoul(buf, 10, &value))
1439 if (*rest)
1440 return -EINVAL; 1438 return -EINVAL;
1441 1439
1442 if ((unsigned int)value != value) 1440 if ((unsigned int)value != value)
@@ -1549,10 +1547,8 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1549static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1547static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1550{ 1548{
1551 unsigned long value; 1549 unsigned long value;
1552 char *rest;
1553 1550
1554 value = simple_strtoul(buf, &rest, 10); 1551 if (strict_strtoul(buf, 10, &value))
1555 if (*rest)
1556 return -EINVAL; 1552 return -EINVAL;
1557 1553
1558 psmouse->set_rate(psmouse, value); 1554 psmouse->set_rate(psmouse, value);
@@ -1562,10 +1558,8 @@ static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const
1562static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1558static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1563{ 1559{
1564 unsigned long value; 1560 unsigned long value;
1565 char *rest;
1566 1561
1567 value = simple_strtoul(buf, &rest, 10); 1562 if (strict_strtoul(buf, 10, &value))
1568 if (*rest)
1569 return -EINVAL; 1563 return -EINVAL;
1570 1564
1571 psmouse->set_resolution(psmouse, value); 1565 psmouse->set_resolution(psmouse, value);
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index 26b845fc186a..e68c814c4361 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -89,10 +89,8 @@ static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data,
89 struct trackpoint_attr_data *attr = data; 89 struct trackpoint_attr_data *attr = data;
90 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 90 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
91 unsigned long value; 91 unsigned long value;
92 char *rest;
93 92
94 value = simple_strtoul(buf, &rest, 10); 93 if (strict_strtoul(buf, 10, &value) || value > 255)
95 if (*rest || value > 255)
96 return -EINVAL; 94 return -EINVAL;
97 95
98 *field = value; 96 *field = value;
@@ -117,10 +115,8 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data,
117 struct trackpoint_attr_data *attr = data; 115 struct trackpoint_attr_data *attr = data;
118 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 116 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
119 unsigned long value; 117 unsigned long value;
120 char *rest;
121 118
122 value = simple_strtoul(buf, &rest, 10); 119