diff options
author | Dan Williams <dcbw@redhat.com> | 2009-02-11 17:14:43 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-02-27 14:52:40 -0500 |
commit | cb3a8eec0e66edfe8db7d3b3bf19d25745bae3c3 (patch) | |
tree | b4eacfc01470617fca40779bccdca6625dba7716 /net/wireless/scan.c | |
parent | abd2fdb4c606f0e5cfec3647d57ebd20f03caafd (diff) |
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 <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/scan.c')
-rw-r--r-- | net/wireless/scan.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/net/wireless/scan.c b/net/wireless/scan.c index b1893c863b97..9fad1631d6cb 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c | |||
@@ -62,6 +62,18 @@ static void bss_release(struct kref *ref) | |||
62 | } | 62 | } |
63 | 63 | ||
64 | /* must hold dev->bss_lock! */ | 64 | /* must hold dev->bss_lock! */ |
65 | void cfg80211_bss_age(struct cfg80211_registered_device *dev, | ||
66 | unsigned long age_secs) | ||
67 | { | ||
68 | struct cfg80211_internal_bss *bss; | ||
69 | unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC); | ||
70 | |||
71 | list_for_each_entry(bss, &dev->bss_list, list) { | ||
72 | bss->ts -= age_jiffies; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | /* must hold dev->bss_lock! */ | ||
65 | void cfg80211_bss_expire(struct cfg80211_registered_device *dev) | 77 | void cfg80211_bss_expire(struct cfg80211_registered_device *dev) |
66 | { | 78 | { |
67 | struct cfg80211_internal_bss *bss, *tmp; | 79 | struct cfg80211_internal_bss *bss, *tmp; |
@@ -584,6 +596,15 @@ static void ieee80211_scan_add_ies(struct iw_request_info *info, | |||
584 | } | 596 | } |
585 | } | 597 | } |
586 | 598 | ||
599 | static inline unsigned int elapsed_jiffies_msecs(unsigned long start) | ||
600 | { | ||
601 | unsigned long end = jiffies; | ||
602 | |||
603 | if (end >= start) | ||
604 | return jiffies_to_msecs(end - start); | ||
605 | |||
606 | return jiffies_to_msecs(end + (MAX_JIFFY_OFFSET - start) + 1); | ||
607 | } | ||
587 | 608 | ||
588 | static char * | 609 | static char * |
589 | ieee80211_bss(struct iw_request_info *info, | 610 | ieee80211_bss(struct iw_request_info *info, |
@@ -763,8 +784,8 @@ ieee80211_bss(struct iw_request_info *info, | |||
763 | &iwe, buf); | 784 | &iwe, buf); |
764 | memset(&iwe, 0, sizeof(iwe)); | 785 | memset(&iwe, 0, sizeof(iwe)); |
765 | iwe.cmd = IWEVCUSTOM; | 786 | iwe.cmd = IWEVCUSTOM; |
766 | sprintf(buf, " Last beacon: %dms ago", | 787 | sprintf(buf, " Last beacon: %ums ago", |
767 | jiffies_to_msecs(jiffies - bss->ts)); | 788 | elapsed_jiffies_msecs(bss->ts)); |
768 | iwe.u.data.length = strlen(buf); | 789 | iwe.u.data.length = strlen(buf); |
769 | current_ev = iwe_stream_add_point(info, current_ev, | 790 | current_ev = iwe_stream_add_point(info, current_ev, |
770 | end_buf, &iwe, buf); | 791 | end_buf, &iwe, buf); |