Commit 20171251 authored by Johannes Berg's avatar Johannes Berg

wifi: mac80211: move scan work to wiphy work

Move the scan work to wiphy work, which also simplifies
the way we handle the work vs. the scan configuration.
Reviewed-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 228e4f93
...@@ -1496,7 +1496,7 @@ struct ieee80211_local { ...@@ -1496,7 +1496,7 @@ struct ieee80211_local {
unsigned long leave_oper_channel_time; unsigned long leave_oper_channel_time;
enum mac80211_scan_state next_scan_state; enum mac80211_scan_state next_scan_state;
struct delayed_work scan_work; struct wiphy_delayed_work scan_work;
struct ieee80211_sub_if_data __rcu *scan_sdata; struct ieee80211_sub_if_data __rcu *scan_sdata;
/* For backward compatibility only -- do not use */ /* For backward compatibility only -- do not use */
struct cfg80211_chan_def _oper_chandef; struct cfg80211_chan_def _oper_chandef;
...@@ -1935,7 +1935,7 @@ int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata, ...@@ -1935,7 +1935,7 @@ int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata,
u64 *changed); u64 *changed);
/* scan/BSS handling */ /* scan/BSS handling */
void ieee80211_scan_work(struct work_struct *work); void ieee80211_scan_work(struct wiphy *wiphy, struct wiphy_work *work);
int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata, int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
const u8 *ssid, u8 ssid_len, const u8 *ssid, u8 ssid_len,
struct ieee80211_channel **channels, struct ieee80211_channel **channels,
......
...@@ -690,7 +690,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do ...@@ -690,7 +690,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
ieee80211_recalc_ps(local); ieee80211_recalc_ps(local);
if (cancel_scan) if (cancel_scan)
flush_delayed_work(&local->scan_work); wiphy_delayed_work_flush(local->hw.wiphy, &local->scan_work);
if (local->open_count == 0) { if (local->open_count == 0) {
ieee80211_stop_device(local); ieee80211_stop_device(local);
......
...@@ -335,9 +335,7 @@ static void ieee80211_restart_work(struct work_struct *work) ...@@ -335,9 +335,7 @@ static void ieee80211_restart_work(struct work_struct *work)
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
int ret; int ret;
/* wait for scan work complete */
flush_workqueue(local->workqueue); flush_workqueue(local->workqueue);
flush_work(&local->sched_scan_stopped_work);
rtnl_lock(); rtnl_lock();
/* we might do interface manipulations, so need both */ /* we might do interface manipulations, so need both */
...@@ -809,7 +807,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len, ...@@ -809,7 +807,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
INIT_LIST_HEAD(&local->chanctx_list); INIT_LIST_HEAD(&local->chanctx_list);
mutex_init(&local->chanctx_mtx); mutex_init(&local->chanctx_mtx);
INIT_DELAYED_WORK(&local->scan_work, ieee80211_scan_work); wiphy_delayed_work_init(&local->scan_work, ieee80211_scan_work);
INIT_WORK(&local->restart_work, ieee80211_restart_work); INIT_WORK(&local->restart_work, ieee80211_restart_work);
......
...@@ -275,7 +275,7 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb) ...@@ -275,7 +275,7 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb)
* to active scan * to active scan
*/ */
set_bit(SCAN_BEACON_DONE, &local->scanning); set_bit(SCAN_BEACON_DONE, &local->scanning);
ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0); wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0);
} }
if (ieee80211_is_probe_resp(mgmt->frame_control)) { if (ieee80211_is_probe_resp(mgmt->frame_control)) {
...@@ -505,7 +505,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, ...@@ -505,7 +505,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw,
memcpy(&local->scan_info, info, sizeof(*info)); memcpy(&local->scan_info, info, sizeof(*info));
ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0); wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0);
} }
EXPORT_SYMBOL(ieee80211_scan_completed); EXPORT_SYMBOL(ieee80211_scan_completed);
...@@ -545,8 +545,7 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local, ...@@ -545,8 +545,7 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local,
/* We need to set power level at maximum rate for scanning. */ /* We need to set power level at maximum rate for scanning. */
ieee80211_hw_config(local, 0); ieee80211_hw_config(local, 0);
ieee80211_queue_delayed_work(&local->hw, wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0);
&local->scan_work, 0);
return 0; return 0;
} }
...@@ -603,7 +602,7 @@ void ieee80211_run_deferred_scan(struct ieee80211_local *local) ...@@ -603,7 +602,7 @@ void ieee80211_run_deferred_scan(struct ieee80211_local *local)
lockdep_is_held(&local->mtx)))) lockdep_is_held(&local->mtx))))
return; return;
ieee80211_queue_delayed_work(&local->hw, &local->scan_work, wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work,
round_jiffies_relative(0)); round_jiffies_relative(0));
} }
...@@ -795,7 +794,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, ...@@ -795,7 +794,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
} }
/* Now, just wait a bit and we are all done! */ /* Now, just wait a bit and we are all done! */
ieee80211_queue_delayed_work(&local->hw, &local->scan_work, wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work,
next_delay); next_delay);
return 0; return 0;
} else { } else {
...@@ -1043,7 +1042,7 @@ static void ieee80211_scan_state_resume(struct ieee80211_local *local, ...@@ -1043,7 +1042,7 @@ static void ieee80211_scan_state_resume(struct ieee80211_local *local,
local->next_scan_state = SCAN_SET_CHANNEL; local->next_scan_state = SCAN_SET_CHANNEL;
} }
void ieee80211_scan_work(struct work_struct *work) void ieee80211_scan_work(struct wiphy *wiphy, struct wiphy_work *work)
{ {
struct ieee80211_local *local = struct ieee80211_local *local =
container_of(work, struct ieee80211_local, scan_work.work); container_of(work, struct ieee80211_local, scan_work.work);
...@@ -1137,7 +1136,8 @@ void ieee80211_scan_work(struct work_struct *work) ...@@ -1137,7 +1136,8 @@ void ieee80211_scan_work(struct work_struct *work)
} }
} while (next_delay == 0); } while (next_delay == 0);
ieee80211_queue_delayed_work(&local->hw, &local->scan_work, next_delay); wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work,
next_delay);
goto out; goto out;
out_complete: out_complete:
...@@ -1280,12 +1280,7 @@ void ieee80211_scan_cancel(struct ieee80211_local *local) ...@@ -1280,12 +1280,7 @@ void ieee80211_scan_cancel(struct ieee80211_local *local)
goto out; goto out;
} }
/* wiphy_delayed_work_cancel(local->hw.wiphy, &local->scan_work);
* If the work is currently running, it must be blocked on
* the mutex, but we'll set scan_sdata = NULL and it'll
* simply exit once it acquires the mutex.
*/
cancel_delayed_work(&local->scan_work);
/* and clean up */ /* and clean up */
memset(&local->scan_info, 0, sizeof(local->scan_info)); memset(&local->scan_info, 0, sizeof(local->scan_info));
__ieee80211_scan_completed(&local->hw, true); __ieee80211_scan_completed(&local->hw, true);
......
...@@ -2341,8 +2341,8 @@ static void ieee80211_flush_completed_scan(struct ieee80211_local *local, ...@@ -2341,8 +2341,8 @@ static void ieee80211_flush_completed_scan(struct ieee80211_local *local,
*/ */
if (aborted) if (aborted)
set_bit(SCAN_ABORTED, &local->scanning); set_bit(SCAN_ABORTED, &local->scanning);
ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0); wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0);
flush_delayed_work(&local->scan_work); wiphy_delayed_work_flush(local->hw.wiphy, &local->scan_work);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment