From 0378b3f1c49d48ed524eabda7e4340163d9483c9 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 19 Jan 2009 11:20:52 -0500 Subject: cfg80211: add PM hooks This should help implement suspend/resume in mac80211, these hooks will be run before the device is suspended and after it resumes. Therefore, they can touch the hardware as much as they want to. Signed-off-by: Johannes Berg Signed-off-by: Bob Copeland Signed-off-by: John W. Linville --- net/wireless/sysfs.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'net/wireless/sysfs.c') diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c index 79a38287764..26a72b0797a 100644 --- a/net/wireless/sysfs.c +++ b/net/wireless/sysfs.c @@ -55,6 +55,34 @@ static int wiphy_uevent(struct device *dev, struct kobj_uevent_env *env) } #endif +static int wiphy_suspend(struct device *dev, pm_message_t state) +{ + struct cfg80211_registered_device *rdev = dev_to_rdev(dev); + int ret = 0; + + if (rdev->ops->suspend) { + rtnl_lock(); + ret = rdev->ops->suspend(&rdev->wiphy); + rtnl_unlock(); + } + + return ret; +} + +static int wiphy_resume(struct device *dev) +{ + struct cfg80211_registered_device *rdev = dev_to_rdev(dev); + int ret = 0; + + if (rdev->ops->resume) { + rtnl_lock(); + ret = rdev->ops->resume(&rdev->wiphy); + rtnl_unlock(); + } + + return ret; +} + struct class ieee80211_class = { .name = "ieee80211", .owner = THIS_MODULE, @@ -63,6 +91,8 @@ struct class ieee80211_class = { #ifdef CONFIG_HOTPLUG .dev_uevent = wiphy_uevent, #endif + .suspend = wiphy_suspend, + .resume = wiphy_resume, }; int wiphy_sysfs_init(void) -- cgit From cb3a8eec0e66edfe8db7d3b3bf19d25745bae3c3 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 11 Feb 2009 17:14:43 -0500 Subject: cfg80211: age scan results on resume Scanned BSS entries are timestamped with jiffies, which doesn't increment across suspend and hibernate. On resume, every BSS in the scan list looks like it was scanned within the last 10 seconds, irregardless of how long the machine was actually asleep. Age scan results on resume with the time spent during sleep so userspace has a clue how old they really are. Signed-off-by: Dan Williams Signed-off-by: John W. Linville --- net/wireless/sysfs.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'net/wireless/sysfs.c') diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c index 26a72b0797a..15feaeb5ced 100644 --- a/net/wireless/sysfs.c +++ b/net/wireless/sysfs.c @@ -60,6 +60,8 @@ static int wiphy_suspend(struct device *dev, pm_message_t state) struct cfg80211_registered_device *rdev = dev_to_rdev(dev); int ret = 0; + rdev->suspend_at = get_seconds(); + if (rdev->ops->suspend) { rtnl_lock(); ret = rdev->ops->suspend(&rdev->wiphy); @@ -74,6 +76,11 @@ static int wiphy_resume(struct device *dev) struct cfg80211_registered_device *rdev = dev_to_rdev(dev); int ret = 0; + /* Age scan results with time spent in suspend */ + spin_lock_bh(&rdev->bss_lock); + cfg80211_bss_age(rdev, get_seconds() - rdev->suspend_at); + spin_unlock_bh(&rdev->bss_lock); + if (rdev->ops->resume) { rtnl_lock(); ret = rdev->ops->resume(&rdev->wiphy); -- cgit From b5850a7a4fd5bcab4f6a2c49e5b4ab9ebb1d5d44 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Sat, 21 Feb 2009 00:04:19 -0500 Subject: cfg80211: rename cfg80211_registered_device's idx to wiphy_idx Makes it clearer to read when comparing to ifidx Signed-off-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- net/wireless/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/wireless/sysfs.c') diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c index 15feaeb5ced..efe3c5c92b2 100644 --- a/net/wireless/sysfs.c +++ b/net/wireless/sysfs.c @@ -31,7 +31,7 @@ static ssize_t name ## _show(struct device *dev, \ return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \ } -SHOW_FMT(index, "%d", idx); +SHOW_FMT(index, "%d", wiphy_idx); SHOW_FMT(macaddress, "%pM", wiphy.perm_addr); static struct device_attribute ieee80211_dev_attrs[] = { -- cgit