1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 11 Dec 2014 00:00:00 +0100
3 Subject: [PATCH] cfg80211: add support for changing the device mac address via
7 net/wireless/sysfs.c | 27 ++++++++++++++++++++++-----
8 1 file changed, 22 insertions(+), 5 deletions(-)
10 --- a/net/wireless/sysfs.c
11 +++ b/net/wireless/sysfs.c
12 @@ -24,18 +24,35 @@ static inline struct cfg80211_registered
13 return container_of(dev, struct cfg80211_registered_device, wiphy.dev);
16 -#define SHOW_FMT(name, fmt, member) \
17 +#define SHOW_FMT(name, fmt, member, mode) \
18 static ssize_t name ## _show(struct device *dev, \
19 struct device_attribute *attr, \
22 return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \
24 -static DEVICE_ATTR_RO(name)
25 +static DEVICE_ATTR_##mode(name)
27 -SHOW_FMT(index, "%d", wiphy_idx);
28 -SHOW_FMT(macaddress, "%pM", wiphy.perm_addr);
29 -SHOW_FMT(address_mask, "%pM", wiphy.addr_mask);
30 +static ssize_t macaddress_store(struct device *dev,
31 + struct device_attribute *attr,
32 + const char *buf, size_t len)
36 + if (!mac_pton(buf, mac))
39 + if (buf[3 * ETH_ALEN - 1] && buf[3 * ETH_ALEN - 1] != '\n')
42 + memcpy(dev_to_rdev(dev)->wiphy.perm_addr, mac, ETH_ALEN);
44 + return strnlen(buf, len);
47 +SHOW_FMT(index, "%d", wiphy_idx, RO);
48 +SHOW_FMT(macaddress, "%pM", wiphy.perm_addr, RW);
49 +SHOW_FMT(address_mask, "%pM", wiphy.addr_mask, RO);
51 static ssize_t name_show(struct device *dev,
52 struct device_attribute *attr,