1 --- a/net/wireless/sysfs.c
2 +++ b/net/wireless/sysfs.c
3 @@ -24,18 +24,35 @@ static inline struct cfg80211_registered
4 return container_of(dev, struct cfg80211_registered_device, wiphy.dev);
7 -#define SHOW_FMT(name, fmt, member) \
8 +#define SHOW_FMT(name, fmt, member, mode) \
9 static ssize_t name ## _show(struct device *dev, \
10 struct device_attribute *attr, \
13 return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \
15 -static DEVICE_ATTR_RO(name)
16 +static DEVICE_ATTR_##mode(name)
18 -SHOW_FMT(index, "%d", wiphy_idx);
19 -SHOW_FMT(macaddress, "%pM", wiphy.perm_addr);
20 -SHOW_FMT(address_mask, "%pM", wiphy.addr_mask);
21 +static ssize_t macaddress_store(struct device *dev,
22 + struct device_attribute *attr,
23 + const char *buf, size_t len)
27 + if (!mac_pton(buf, mac))
30 + if (buf[3 * ETH_ALEN - 1] && buf[3 * ETH_ALEN - 1] != '\n')
33 + memcpy(dev_to_rdev(dev)->wiphy.perm_addr, mac, ETH_ALEN);
35 + return strnlen(buf, len);
38 +SHOW_FMT(index, "%d", wiphy_idx, RO);
39 +SHOW_FMT(macaddress, "%pM", wiphy.perm_addr, RW);
40 +SHOW_FMT(address_mask, "%pM", wiphy.addr_mask, RO);
42 static ssize_t name_show(struct device *dev,
43 struct device_attribute *attr,