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/tablet | |
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/tablet')
-rw-r--r-- | drivers/input/tablet/aiptek.c | 53 |
1 files changed, 38 insertions, 15 deletions
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 | ||