Commit 31a3da41 authored by Marek Belisko's avatar Marek Belisko Committed by Greg Kroah-Hartman

staging: olpc_dcon: Remove _strtoul() function.

olpc_dcon driver use self invented _strtoul  function
which make similar check like strict_strtoul just extend
for space checking at last string place. Normally access
to sys file looks echo 1024 > /sys/... so space could be considered
as error character and we could simplify code using just strict_strtoul
function instead self invented.
Signed-off-by: default avatarMarek Belisko <marek.belisko@open-nandra.com>
Signed-off-by: default avatarAndres Salomon <dilinger@queued.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 45bfe972
...@@ -549,48 +549,33 @@ static ssize_t dcon_resumeline_show(struct device *dev, ...@@ -549,48 +549,33 @@ static ssize_t dcon_resumeline_show(struct device *dev,
return sprintf(buf, "%d\n", resumeline); return sprintf(buf, "%d\n", resumeline);
} }
static int _strtoul(const char *buf, int len, unsigned int *val)
{
char *endp;
unsigned int output = simple_strtoul(buf, &endp, 0);
int size = endp - buf;
if (*endp && isspace(*endp))
size++;
if (size != len)
return -EINVAL;
*val = output;
return 0;
}
static ssize_t dcon_mono_store(struct device *dev, static ssize_t dcon_mono_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
int enable_mono; unsigned long enable_mono;
int rc = -EINVAL; int rc;
if (_strtoul(buf, count, &enable_mono)) rc = strict_strtoul(buf, 10, &enable_mono);
return -EINVAL; if (rc)
return rc;
dcon_set_mono_mode(dev_get_drvdata(dev), enable_mono ? true : false); dcon_set_mono_mode(dev_get_drvdata(dev), enable_mono ? true : false);
rc = count;
return rc; return count;
} }
static ssize_t dcon_freeze_store(struct device *dev, static ssize_t dcon_freeze_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct dcon_priv *dcon = dev_get_drvdata(dev); struct dcon_priv *dcon = dev_get_drvdata(dev);
int output; unsigned long output;
int ret;
if (_strtoul(buf, count, &output)) ret = strict_strtoul(buf, 10, &output);
return -EINVAL; if (ret)
return ret;
printk(KERN_INFO "dcon_freeze_store: %d\n", output); printk(KERN_INFO "dcon_freeze_store: %lu\n", output);
switch (output) { switch (output) {
case 0: case 0:
...@@ -612,26 +597,28 @@ static ssize_t dcon_freeze_store(struct device *dev, ...@@ -612,26 +597,28 @@ static ssize_t dcon_freeze_store(struct device *dev,
static ssize_t dcon_resumeline_store(struct device *dev, static ssize_t dcon_resumeline_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
int rl; unsigned long rl;
int rc = -EINVAL; int rc;
if (_strtoul(buf, count, &rl)) rc = strict_strtoul(buf, 10, &rl);
if (rc)
return rc; return rc;
resumeline = rl; resumeline = rl;
dcon_write(dev_get_drvdata(dev), DCON_REG_SCAN_INT, resumeline); dcon_write(dev_get_drvdata(dev), DCON_REG_SCAN_INT, resumeline);
rc = count;
return rc; return count;
} }
static ssize_t dcon_sleep_store(struct device *dev, static ssize_t dcon_sleep_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
int output; unsigned long output;
int ret;
if (_strtoul(buf, count, &output)) ret = strict_strtoul(buf, 10, &output);
return -EINVAL; if (ret)
return ret;
dcon_sleep(dev_get_drvdata(dev), output ? true : false); dcon_sleep(dev_get_drvdata(dev), output ? true : false);
return count; return count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment