diff options
author | Joe Rouvier <joe@rouvier.org> | 2008-08-10 00:29:25 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-09-10 12:11:57 -0400 |
commit | 160f1fef7e52e974489b3c70fbd4e094c06965c2 (patch) | |
tree | 80423a45a9a57736e6ce6351da0801e1a5b02b8c /drivers/input | |
parent | 82a196f481661170b4982dc7e68a12e9253309d0 (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/input')
-rw-r--r-- | drivers/input/keyboard/atkbd.c | 20 | ||||
-rw-r--r-- | drivers/input/mouse/logips2pp.c | 4 | ||||
-rw-r--r-- | drivers/input/mouse/psmouse-base.c | 12 | ||||
-rw-r--r-- | drivers/input/mouse/trackpoint.c | 8 | ||||
-rw-r--r-- | drivers/input/tablet/aiptek.c | 53 | ||||
-rw-r--r-- | drivers/input/touchscreen/ads7846.c | 7 |
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, | |||
157 | static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count) | 157 | static 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 | |||
1549 | static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) | 1547 | static 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 | |||
1562 | static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) | 1558 | static 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 | if (strict_strtoul(buf, 10, &value) || value > 1) |
123 | if (*rest || value > 1) | ||
124 | return -EINVAL; | 120 | return -EINVAL; |
125 | 121 | ||
126 | if (attr->inverted) | 122 | if (attr->inverted) |
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c index 8f037a1d44a6..e53c838f1866 100644 --- a/drivers/input/tablet/aiptek.c +++ b/drivers/input/tablet/aiptek.c | |||
@@ -1202,16 +1202,22 @@ static ssize_t | |||
1202 | store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 1202 | store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
1203 | { | 1203 | { |
1204 | struct aiptek *aiptek = dev_get_drvdata(dev); | 1204 | struct aiptek *aiptek = dev_get_drvdata(dev); |
1205 | int x; | 1205 | long x; |
1206 | |||
1207 | if (strict_strtol(buf, 10, &x)) { | ||
1208 | size_t len = buf[count - 1] == '\n' ? count - 1 : count; | ||
1209 | |||
1210 | if (strncmp(buf, "disable", len)) | ||
1211 | return -EINVAL; | ||
1206 | 1212 | ||
1207 | if (strcmp(buf, "disable") == 0) { | ||
1208 | aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE; | 1213 | aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE; |
1209 | } else { | 1214 | } else { |
1210 | x = (int)simple_strtol(buf, NULL, 10); | 1215 | if (x < AIPTEK_TILT_MIN || x > AIPTEK_TILT_MAX) |
1211 | if (x >= AIPTEK_TILT_MIN && x <= AIPTEK_TILT_MAX) { | 1216 | return -EINVAL; |
1212 | aiptek->newSetting.xTilt = x; | 1217 | |
1213 | } | 1218 | aiptek->newSetting.xTilt = x; |
1214 | } | 1219 | } |
1220 | |||
1215 | return count; | 1221 | return count; |
1216 | } | 1222 | } |
1217 | 1223 | ||
@@ -1238,16 +1244,22 @@ static ssize_t | |||
1238 | store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 1244 | store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
1239 | { | 1245 | { |
1240 | struct aiptek *aiptek = dev_get_drvdata(dev); | 1246 | struct aiptek *aiptek = dev_get_drvdata(dev); |
1241 | int y; | 1247 | long y; |
1248 | |||
1249 | if (strict_strtol(buf, 10, &y)) { | ||
1250 | size_t len = buf[count - 1] == '\n' ? count - 1 : count; | ||
1251 | |||
1252 | if (strncmp(buf, "disable", len)) | ||
1253 | return -EINVAL; | ||
1242 | 1254 | ||
1243 | if (strcmp(buf, "disable") == 0) { | ||
1244 | aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE; | 1255 | aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE; |
1245 | } else { | 1256 | } else { |
1246 | y = (int)simple_strtol(buf, NULL, 10); | 1257 | if (y < AIPTEK_TILT_MIN || y > AIPTEK_TILT_MAX) |
1247 | if (y >= AIPTEK_TILT_MIN && y <= AIPTEK_TILT_MAX) { | 1258 | return -EINVAL; |
1248 | aiptek->newSetting.yTilt = y; | 1259 | |
1249 | } | 1260 | aiptek->newSetting.yTilt = y; |
1250 | } | 1261 | } |
1262 | |||
1251 | return count; | 1263 | return count; |
1252 | } | 1264 | } |
1253 | 1265 | ||
@@ -1269,8 +1281,12 @@ static ssize_t | |||
1269 | store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 1281 | store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
1270 | { | 1282 | { |
1271 | struct aiptek *aiptek = dev_get_drvdata(dev); | 1283 | struct aiptek *aiptek = dev_get_drvdata(dev); |
1284 | long j; | ||
1285 | |||
1286 | if (strict_strtol(buf, 10, &j)) | ||
1287 | return -EINVAL; | ||
1272 | 1288 | ||
1273 | aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, NULL, 10); | 1289 | aiptek->newSetting.jitterDelay = (int)j; |
1274 | return count; | 1290 | return count; |
1275 | } | 1291 | } |
1276 | 1292 | ||
@@ -1294,8 +1310,12 @@ static ssize_t | |||
1294 | store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 1310 | store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
1295 | { | 1311 | { |
1296 | struct aiptek *aiptek = dev_get_drvdata(dev); | 1312 | struct aiptek *aiptek = dev_get_drvdata(dev); |
1313 | long d; | ||
1297 | 1314 | ||
1298 | aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, NULL, 10); | 1315 | if (strict_strtol(buf, 10, &d)) |
1316 | return -EINVAL; | ||
1317 | |||
1318 | aiptek->newSetting.programmableDelay = (int)d; | ||
1299 | return count; | 1319 | return count; |
1300 | } | 1320 | } |
1301 | 1321 | ||
@@ -1541,8 +1561,11 @@ static ssize_t | |||
1541 | store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 1561 | store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
1542 | { | 1562 | { |
1543 | struct aiptek *aiptek = dev_get_drvdata(dev); | 1563 | struct aiptek *aiptek = dev_get_drvdata(dev); |
1564 | long w; | ||
1565 | |||
1566 | if (strict_strtol(buf, 10, &w)) return -EINVAL; | ||
1544 | 1567 | ||
1545 | aiptek->newSetting.wheel = (int)simple_strtol(buf, NULL, 10); | 1568 | aiptek->newSetting.wheel = (int)w; |
1546 | return count; | 1569 | return count; |
1547 | } | 1570 | } |
1548 | 1571 | ||
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index ce6f48c695f5..efbbbe48621a 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -461,10 +461,11 @@ static ssize_t ads7846_disable_store(struct device *dev, | |||
461 | const char *buf, size_t count) | 461 | const char *buf, size_t count) |
462 | { | 462 | { |
463 | struct ads7846 *ts = dev_get_drvdata(dev); | 463 | struct ads7846 *ts = dev_get_drvdata(dev); |
464 | char *endp; | 464 | long i; |
465 | int i; | 465 | |
466 | if (strict_strtoul(buf, 10, &i)) | ||
467 | return -EINVAL; | ||
466 | 468 | ||
467 | i = simple_strtoul(buf, &endp, 10); | ||
468 | spin_lock_irq(&ts->lock); | 469 | spin_lock_irq(&ts->lock); |
469 | 470 | ||
470 | if (i) | 471 | if (i) |