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>
This commit is contained in:
parent
102402a73b
commit
e142dc1ecc
|
@ -5,6 +5,7 @@
|
||||||
menuconfig UWB
|
menuconfig UWB
|
||||||
tristate "Ultra Wideband devices"
|
tristate "Ultra Wideband devices"
|
||||||
default n
|
default n
|
||||||
|
select GENERIC_NET_UTILS
|
||||||
help
|
help
|
||||||
UWB is a high-bandwidth, low-power, point-to-point radio
|
UWB is a high-bandwidth, low-power, point-to-point radio
|
||||||
technology using a wide spectrum (3.1-10.6GHz). It is
|
technology using a wide spectrum (3.1-10.6GHz). It is
|
||||||
|
|
|
@ -336,23 +336,17 @@ static ssize_t uwb_rc_mac_addr_store(struct device *dev,
|
||||||
struct uwb_mac_addr addr;
|
struct uwb_mac_addr addr;
|
||||||
ssize_t result;
|
ssize_t result;
|
||||||
|
|
||||||
result = sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx\n",
|
if (!mac_pton(buf, addr.data))
|
||||||
&addr.data[0], &addr.data[1], &addr.data[2],
|
return -EINVAL;
|
||||||
&addr.data[3], &addr.data[4], &addr.data[5]);
|
|
||||||
if (result != 6) {
|
|
||||||
result = -EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (is_multicast_ether_addr(addr.data)) {
|
if (is_multicast_ether_addr(addr.data)) {
|
||||||
dev_err(&rc->uwb_dev.dev, "refusing to set multicast "
|
dev_err(&rc->uwb_dev.dev, "refusing to set multicast "
|
||||||
"MAC address %s\n", buf);
|
"MAC address %s\n", buf);
|
||||||
result = -EINVAL;
|
return -EINVAL;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
result = uwb_rc_mac_addr_set(rc, &addr);
|
result = uwb_rc_mac_addr_set(rc, &addr);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
rc->uwb_dev.mac_addr = addr;
|
rc->uwb_dev.mac_addr = addr;
|
||||||
out:
|
|
||||||
return result < 0 ? result : size;
|
return result < 0 ? result : size;
|
||||||
}
|
}
|
||||||
DEVICE_ATTR(mac_address, S_IRUGO | S_IWUSR, uwb_rc_mac_addr_show, uwb_rc_mac_addr_store);
|
DEVICE_ATTR(mac_address, S_IRUGO | S_IWUSR, uwb_rc_mac_addr_show, uwb_rc_mac_addr_store);
|
||||||
|
|
Loading…
Reference in a new issue