aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/wireless/sysfs.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c
index 29f820e18251..79a382877641 100644
--- a/net/wireless/sysfs.c
+++ b/net/wireless/sysfs.c
@@ -23,25 +23,20 @@ static inline struct cfg80211_registered_device *dev_to_rdev(
23 return container_of(dev, struct cfg80211_registered_device, wiphy.dev); 23 return container_of(dev, struct cfg80211_registered_device, wiphy.dev);
24} 24}
25 25
26static ssize_t _show_index(struct device *dev, struct device_attribute *attr, 26#define SHOW_FMT(name, fmt, member) \
27 char *buf) 27static ssize_t name ## _show(struct device *dev, \
28{ 28 struct device_attribute *attr, \
29 return sprintf(buf, "%d\n", dev_to_rdev(dev)->idx); 29 char *buf) \
30{ \
31 return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \
30} 32}
31 33
32static ssize_t _show_permaddr(struct device *dev, 34SHOW_FMT(index, "%d", idx);
33 struct device_attribute *attr, 35SHOW_FMT(macaddress, "%pM", wiphy.perm_addr);
34 char *buf)
35{
36 unsigned char *addr = dev_to_rdev(dev)->wiphy.perm_addr;
37
38 return sprintf(buf, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
39 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
40}
41 36
42static struct device_attribute ieee80211_dev_attrs[] = { 37static struct device_attribute ieee80211_dev_attrs[] = {
43 __ATTR(index, S_IRUGO, _show_index, NULL), 38 __ATTR_RO(index),
44 __ATTR(macaddress, S_IRUGO, _show_permaddr, NULL), 39 __ATTR_RO(macaddress),
45 {} 40 {}
46}; 41};
47 42