aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Aaberg <jonas.aberg@stericsson.com>2011-06-20 12:09:38 +0200
committerPhilippe Langlais <philippe.langlais@linaro.org>2011-07-22 15:52:06 +0200
commit372405b942a8184e4f95b2446a74e03d54bbe618 (patch)
treed10dd1a53279095498560b095f4b59acdf75661d
parent1b7f01ec226b4da0621ba3b856f962d0de2cfb24 (diff)
ARM: ux500: hwreg: Tiny code clean-up
ST-Ericsson Linux next: Not tested, ask SSM for ER ST-Ericsson ID: - ST-Ericsson FOSS-OUT ID: Trivial Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com> Change-Id: I5b7331fade22ae99dc2600d67b41bf286179cee8 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/25489 Reviewed-by: QATEST Reviewed-by: Linus WALLEIJ <linus.walleij@stericsson.com>
-rw-r--r--arch/arm/mach-ux500/hwreg.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/arch/arm/mach-ux500/hwreg.c b/arch/arm/mach-ux500/hwreg.c
index 7ba3e0f2911..1a47e60ed46 100644
--- a/arch/arm/mach-ux500/hwreg.c
+++ b/arch/arm/mach-ux500/hwreg.c
@@ -300,23 +300,19 @@ static int hwreg_address_open(struct inode *inode, struct file *file)
static ssize_t hwreg_address_write(struct file *file,
const char __user *user_buf, size_t count, loff_t *ppos)
{
- char buf[32];
- int buf_size;
+ int err;
unsigned long user_address;
- /* Get userspace string and assure termination */
- buf_size = min(count, (sizeof(buf) - 1));
- if (copy_from_user(buf, user_buf, buf_size))
- return -EFAULT;
- buf[buf_size] = 0;
+ err = kstrtoul_from_user(user_buf, count, 0, &user_address);
+
+ if (err)
+ return err;
- if(strict_strtoul(buf, 0, &user_address))
- return -EINVAL;
if (hwreg_io_ptov(user_address)==NULL)
return -EADDRNOTAVAIL;
debug_address = user_address;
- return buf_size;
+ return count;
}
static int hwreg_value_print(struct seq_file *s, void *p)
@@ -338,24 +334,19 @@ static int hwreg_value_open(struct inode *inode, struct file *file)
static ssize_t hwreg_value_write(struct file *file,
const char __user *user_buf, size_t count, loff_t *ppos)
{
- char buf[32];
- int buf_size;
+ int err;
unsigned long user_val;
void *ptr;
- /* Get userspace string and assure termination */
- buf_size = min(count, (sizeof(buf)-1));
- if (copy_from_user(buf, user_buf, buf_size))
- return -EFAULT;
- buf[buf_size] = 0;
+ err = kstrtoul_from_user(user_buf, count, 0, &user_val);
- if (strict_strtoul(buf, 0, &user_val))
- return -EINVAL;
+ if (err)
+ return err;
if ((ptr = hwreg_io_ptov(debug_address)) == NULL)
return -EFAULT;
writel(user_val, ptr);
- return buf_size;
+ return count;
}
static const struct file_operations hwreg_address_fops = {