浏览代码

[PATCH] softmac: return -EAGAIN from getscan while scanning

Below patch was developed after discussion with Daniel Drake who
mentioned to me that wireless tools expect an EAGAIN return from getscan
so that they can wait for the scan to finish before printing out the
results.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
johannes@sipsolutions.net 19 年之前
父节点
当前提交
ba2f8c1875
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      net/ieee80211/softmac/ieee80211softmac_wx.c

+ 10 - 0
net/ieee80211/softmac/ieee80211softmac_wx.c

@@ -41,13 +41,23 @@ ieee80211softmac_wx_trigger_scan(struct net_device *net_dev,
 EXPORT_SYMBOL_GPL(ieee80211softmac_wx_trigger_scan);
 EXPORT_SYMBOL_GPL(ieee80211softmac_wx_trigger_scan);
 
 
 
 
+/* if we're still scanning, return -EAGAIN so that userspace tools
+ * can get the complete scan results, otherwise return 0. */
 int
 int
 ieee80211softmac_wx_get_scan_results(struct net_device *net_dev,
 ieee80211softmac_wx_get_scan_results(struct net_device *net_dev,
 				     struct iw_request_info *info,
 				     struct iw_request_info *info,
 				     union iwreq_data *data,
 				     union iwreq_data *data,
 				     char *extra)
 				     char *extra)
 {
 {
+	unsigned long flags;
 	struct ieee80211softmac_device *sm = ieee80211_priv(net_dev);
 	struct ieee80211softmac_device *sm = ieee80211_priv(net_dev);
+
+	spin_lock_irqsave(&sm->lock, flags);
+	if (sm->scanning) {
+		spin_unlock_irqrestore(&sm->lock, flags);
+		return -EAGAIN;
+	}
+	spin_unlock_irqrestore(&sm->lock, flags);
 	return ieee80211_wx_get_scan(sm->ieee, info, data, extra);
 	return ieee80211_wx_get_scan(sm->ieee, info, data, extra);
 }
 }
 EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_scan_results);
 EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_scan_results);