aboutsummaryrefslogtreecommitdiff
path: root/drivers/input/tablet
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/input/tablet
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/input/tablet')
-rw-r--r--drivers/input/tablet/aiptek.c53
1 files changed, 38 insertions, 15 deletions
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
index 8f037a1d44a..e53c838f186 100644
--- a/drivers/input/tablet/aiptek.c
+++ b/drivers/input/tablet/aiptek.c
@@ -1202,16 +1202,22 @@ static ssize_t
store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct aiptek *aiptek = dev_get_drvdata(dev);
- int x;
+ long x;
+
+ if (strict_strtol(buf, 10, &x)) {
+ size_t len = buf[count - 1] == '\n' ? count - 1 : count;
+
+ if (strncmp(buf, "disable", len))
+ return -EINVAL;
- if (strcmp(buf, "disable") == 0) {
aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE;
} else {
- x = (int)simple_strtol(buf, NULL, 10);
- if (x >= AIPTEK_TILT_MIN && x <= AIPTEK_TILT_MAX) {
- aiptek->newSetting.xTilt = x;
- }
+ if (x < AIPTEK_TILT_MIN || x > AIPTEK_TILT_MAX)
+ return -EINVAL;
+
+ aiptek->newSetting.xTilt = x;
}
+
return count;
}
@@ -1238,16 +1244,22 @@ static ssize_t
store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct aiptek *aiptek = dev_get_drvdata(dev);
- int y;
+ long y;
+
+ if (strict_strtol(buf, 10, &y)) {
+ size_t len = buf[count - 1] == '\n' ? count - 1 : count;
+
+ if (strncmp(buf, "disable", len))
+ return -EINVAL;
- if (strcmp(buf, "disable") == 0) {
aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE;
} else {
- y = (int)simple_strtol(buf, NULL, 10);
- if (y >= AIPTEK_TILT_MIN && y <= AIPTEK_TILT_MAX) {
- aiptek->newSetting.yTilt = y;
- }
+ if (y < AIPTEK_TILT_MIN || y > AIPTEK_TILT_MAX)
+ return -EINVAL;
+
+ aiptek->newSetting.yTilt = y;
}
+
return count;
}
@@ -1269,8 +1281,12 @@ static ssize_t
store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct aiptek *aiptek = dev_get_drvdata(dev);
+ long j;
+
+ if (strict_strtol(buf, 10, &j))
+ return -EINVAL;
- aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, NULL, 10);
+ aiptek->newSetting.jitterDelay = (int)j;
return count;
}
@@ -1294,8 +1310,12 @@ static ssize_t
store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct aiptek *aiptek = dev_get_drvdata(dev);
+ long d;
- aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, NULL, 10);
+ if (strict_strtol(buf, 10, &d))
+ return -EINVAL;
+
+ aiptek->newSetting.programmableDelay = (int)d;
return count;
}
@@ -1541,8 +1561,11 @@ static ssize_t
store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct aiptek *aiptek = dev_get_drvdata(dev);
+ long w;
+
+ if (strict_strtol(buf, 10, &w)) return -EINVAL;
- aiptek->newSetting.wheel = (int)simple_strtol(buf, NULL, 10);
+ aiptek->newSetting.wheel = (int)w;
return count;
}