diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-10-28 09:00:54 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-11-21 11:08:19 -0500 |
commit | 4f6d4d1e36f30ac05bc39bcbfdba09e64e0f918c (patch) | |
tree | 8a19adc28972d45ce9353b205c62303526bf1a6d /net/wireless/sysfs.c | |
parent | 96dd603f3817c5289a906539cb85bddae9536868 (diff) |
wireless: clean up sysfs code using %pM
Remove converting the MAC address to a string by a direct byte
conversion and use %pM instead, since the code is now boilerplate
use a macro to define the show functions, and also use the shorter
__ATTR_RO macro to define the attributes.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/sysfs.c')
-rw-r--r-- | net/wireless/sysfs.c | 25 |
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 | ||
26 | static ssize_t _show_index(struct device *dev, struct device_attribute *attr, | 26 | #define SHOW_FMT(name, fmt, member) \ |
27 | char *buf) | 27 | static 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 | ||
32 | static ssize_t _show_permaddr(struct device *dev, | 34 | SHOW_FMT(index, "%d", idx); |
33 | struct device_attribute *attr, | 35 | SHOW_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 | ||
42 | static struct device_attribute ieee80211_dev_attrs[] = { | 37 | static 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 | ||