isdn/hysdn: Convert to kstrtoul_from_user
This patch replaces the code for getting an number from a userspace buffer by a simple call to kstroul_from_user. This makes it easier to read and less error prone. Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
cf22f9a2b8
commit
8831a3f2c9
@@ -156,17 +156,9 @@ static ssize_t
|
|||||||
hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t *off)
|
hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t *off)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
unsigned char valbuf[128];
|
|
||||||
hysdn_card *card = file->private_data;
|
hysdn_card *card = file->private_data;
|
||||||
|
|
||||||
if (count > (sizeof(valbuf) - 1))
|
rc = kstrtoul_from_user(buf, count, 0, &card->debug_flags);
|
||||||
count = sizeof(valbuf) - 1; /* limit length */
|
|
||||||
if (copy_from_user(valbuf, buf, count))
|
|
||||||
return (-EFAULT); /* copy failed */
|
|
||||||
|
|
||||||
valbuf[count] = 0; /* terminating 0 */
|
|
||||||
|
|
||||||
rc = kstrtoul(valbuf, 0, &card->debug_flags);
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return rc;
|
return rc;
|
||||||
hysdn_addlog(card, "debug set to 0x%lx", card->debug_flags);
|
hysdn_addlog(card, "debug set to 0x%lx", card->debug_flags);
|
||||||
|
Reference in New Issue
Block a user