summaryrefslogtreecommitdiffstats
path: root/drivers/uwb/address.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2017-12-19 20:16:05 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-01-09 16:15:20 +0100
commite142dc1ecc555c77826ee2706dd86f329d35597e (patch)
tree7501930d25f0dfff07cd760fe744139887f32069 /drivers/uwb/address.c
parent102402a73bbeb8b2e0785a3653f37ce480a18614 (diff)
downloadlinux-e142dc1ecc555c77826ee2706dd86f329d35597e.tar.bz2
uwb: Replace mac address parsing
Replace sscanf() with mac_pton(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/uwb/address.c')
-rw-r--r--drivers/uwb/address.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/uwb/address.c b/drivers/uwb/address.c
index 8739c4f4d015..2833be9cbc2a 100644
--- a/drivers/uwb/address.c
+++ b/drivers/uwb/address.c
@@ -336,23 +336,17 @@ static ssize_t uwb_rc_mac_addr_store(struct device *dev,
struct uwb_mac_addr addr;
ssize_t result;
- result = sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx\n",
- &addr.data[0], &addr.data[1], &addr.data[2],
- &addr.data[3], &addr.data[4], &addr.data[5]);
- if (result != 6) {
- result = -EINVAL;
- goto out;
- }
+ if (!mac_pton(buf, addr.data))
+ return -EINVAL;
if (is_multicast_ether_addr(addr.data)) {
dev_err(&rc->uwb_dev.dev, "refusing to set multicast "
"MAC address %s\n", buf);
- result = -EINVAL;
- goto out;
+ return -EINVAL;
}
result = uwb_rc_mac_addr_set(rc, &addr);
if (result == 0)
rc->uwb_dev.mac_addr = addr;
-out:
+
return result < 0 ? result : size;
}
DEVICE_ATTR(mac_address, S_IRUGO | S_IWUSR, uwb_rc_mac_addr_show, uwb_rc_mac_addr_store);