Blame view
net/wireless/sysfs.c
3.82 KB
704232c27 [WIRELESS] cfg802... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
/* * This file provides /sys/class/ieee80211/<wiphy name>/ * and some default attributes. * * Copyright 2005-2006 Jiri Benc <jbenc@suse.cz> * Copyright 2006 Johannes Berg <johannes@sipsolutions.net> * * This file is GPLv2 as found in COPYING. */ #include <linux/device.h> #include <linux/module.h> #include <linux/netdevice.h> #include <linux/nl80211.h> #include <linux/rtnetlink.h> #include <net/cfg80211.h> #include "sysfs.h" #include "core.h" |
e35e4d28b cfg80211: add wra... |
19 |
#include "rdev-ops.h" |
704232c27 [WIRELESS] cfg802... |
20 21 22 23 24 25 |
static inline struct cfg80211_registered_device *dev_to_rdev( struct device *dev) { return container_of(dev, struct cfg80211_registered_device, wiphy.dev); } |
4f6d4d1e3 wireless: clean u... |
26 27 28 29 30 31 32 |
#define SHOW_FMT(name, fmt, member) \ static ssize_t name ## _show(struct device *dev, \ struct device_attribute *attr, \ char *buf) \ { \ return sprintf(buf, fmt " ", dev_to_rdev(dev)->member); \ |
f0bc99c84 net: wireless: co... |
33 34 |
} \ static DEVICE_ATTR_RO(name) |
704232c27 [WIRELESS] cfg802... |
35 |
|
b5850a7a4 cfg80211: rename ... |
36 |
SHOW_FMT(index, "%d", wiphy_idx); |
4f6d4d1e3 wireless: clean u... |
37 |
SHOW_FMT(macaddress, "%pM", wiphy.perm_addr); |
ef15aac60 cfg80211: export ... |
38 |
SHOW_FMT(address_mask, "%pM", wiphy.addr_mask); |
cfd8e12f4 wireless: Print w... |
39 40 41 42 43 44 45 |
static ssize_t name_show(struct device *dev, struct device_attribute *attr, char *buf) { struct wiphy *wiphy = &dev_to_rdev(dev)->wiphy; return sprintf(buf, "%s ", dev_name(&wiphy->dev)); } |
f0bc99c84 net: wireless: co... |
46 |
static DEVICE_ATTR_RO(name); |
cfd8e12f4 wireless: Print w... |
47 |
|
ef15aac60 cfg80211: export ... |
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
static ssize_t addresses_show(struct device *dev, struct device_attribute *attr, char *buf) { struct wiphy *wiphy = &dev_to_rdev(dev)->wiphy; char *start = buf; int i; if (!wiphy->addresses) return sprintf(buf, "%pM ", wiphy->perm_addr); for (i = 0; i < wiphy->n_addresses; i++) buf += sprintf(buf, "%pM ", &wiphy->addresses[i].addr); return buf - start; } |
f0bc99c84 net: wireless: co... |
66 67 68 69 70 71 72 73 74 |
static DEVICE_ATTR_RO(addresses); static struct attribute *ieee80211_attrs[] = { &dev_attr_index.attr, &dev_attr_macaddress.attr, &dev_attr_address_mask.attr, &dev_attr_addresses.attr, &dev_attr_name.attr, NULL, |
704232c27 [WIRELESS] cfg802... |
75 |
}; |
f0bc99c84 net: wireless: co... |
76 |
ATTRIBUTE_GROUPS(ieee80211); |
704232c27 [WIRELESS] cfg802... |
77 78 79 80 81 82 83 |
static void wiphy_dev_release(struct device *dev) { struct cfg80211_registered_device *rdev = dev_to_rdev(dev); cfg80211_dev_free(rdev); } |
7eff2e7a8 Driver core: chan... |
84 |
static int wiphy_uevent(struct device *dev, struct kobj_uevent_env *env) |
704232c27 [WIRELESS] cfg802... |
85 86 87 88 |
{ /* TODO, we probably need stuff here */ return 0; } |
a33d40261 cfg80211: fix com... |
89 |
#ifdef CONFIG_PM |
812569699 cfg80211/mac80211... |
90 91 92 93 94 95 96 |
static void cfg80211_leave_all(struct cfg80211_registered_device *rdev) { struct wireless_dev *wdev; list_for_each_entry(wdev, &rdev->wdev_list, list) cfg80211_leave(rdev, wdev); } |
0378b3f1c cfg80211: add PM ... |
97 98 99 100 |
static int wiphy_suspend(struct device *dev, pm_message_t state) { struct cfg80211_registered_device *rdev = dev_to_rdev(dev); int ret = 0; |
cb3a8eec0 cfg80211: age sca... |
101 |
rdev->suspend_at = get_seconds(); |
812569699 cfg80211/mac80211... |
102 103 |
rtnl_lock(); if (rdev->wiphy.registered) { |
6abb9cb99 cfg80211: make Wo... |
104 |
if (!rdev->wiphy.wowlan_config) |
812569699 cfg80211/mac80211... |
105 106 |
cfg80211_leave_all(rdev); if (rdev->ops->suspend) |
6abb9cb99 cfg80211: make Wo... |
107 |
ret = rdev_suspend(rdev, rdev->wiphy.wowlan_config); |
812569699 cfg80211/mac80211... |
108 109 110 111 112 |
if (ret == 1) { /* Driver refuse to configure wowlan */ cfg80211_leave_all(rdev); ret = rdev_suspend(rdev, NULL); } |
0378b3f1c cfg80211: add PM ... |
113 |
} |
812569699 cfg80211/mac80211... |
114 |
rtnl_unlock(); |
0378b3f1c cfg80211: add PM ... |
115 116 117 118 119 120 121 122 |
return ret; } static int wiphy_resume(struct device *dev) { struct cfg80211_registered_device *rdev = dev_to_rdev(dev); int ret = 0; |
cb3a8eec0 cfg80211: age sca... |
123 |
/* Age scan results with time spent in suspend */ |
cb3a8eec0 cfg80211: age sca... |
124 |
cfg80211_bss_age(rdev, get_seconds() - rdev->suspend_at); |
cb3a8eec0 cfg80211: age sca... |
125 |
|
0378b3f1c cfg80211: add PM ... |
126 127 |
if (rdev->ops->resume) { rtnl_lock(); |
ecb443355 mac80211: fix sus... |
128 |
if (rdev->wiphy.registered) |
e35e4d28b cfg80211: add wra... |
129 |
ret = rdev_resume(rdev); |
0378b3f1c cfg80211: add PM ... |
130 131 132 133 134 |
rtnl_unlock(); } return ret; } |
6abb9cb99 cfg80211: make Wo... |
135 |
#endif |
0378b3f1c cfg80211: add PM ... |
136 |
|
046007949 cfg80211: support... |
137 138 139 140 141 142 |
static const void *wiphy_namespace(struct device *d) { struct wiphy *wiphy = container_of(d, struct wiphy, dev); return wiphy_net(wiphy); } |
704232c27 [WIRELESS] cfg802... |
143 144 145 146 |
struct class ieee80211_class = { .name = "ieee80211", .owner = THIS_MODULE, .dev_release = wiphy_dev_release, |
f0bc99c84 net: wireless: co... |
147 |
.dev_groups = ieee80211_groups, |
704232c27 [WIRELESS] cfg802... |
148 |
.dev_uevent = wiphy_uevent, |
6abb9cb99 cfg80211: make Wo... |
149 |
#ifdef CONFIG_PM |
0378b3f1c cfg80211: add PM ... |
150 151 |
.suspend = wiphy_suspend, .resume = wiphy_resume, |
6abb9cb99 cfg80211: make Wo... |
152 |
#endif |
046007949 cfg80211: support... |
153 154 |
.ns_type = &net_ns_type_operations, .namespace = wiphy_namespace, |
704232c27 [WIRELESS] cfg802... |
155 156 157 158 159 160 161 162 163 164 165 |
}; int wiphy_sysfs_init(void) { return class_register(&ieee80211_class); } void wiphy_sysfs_exit(void) { class_unregister(&ieee80211_class); } |