Commit 34f11cd3 authored by Kees Cook's avatar Kees Cook Committed by Johannes Berg

mac80211: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 32a72bbd
...@@ -1711,10 +1711,10 @@ void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata) ...@@ -1711,10 +1711,10 @@ void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata)
sdata_unlock(sdata); sdata_unlock(sdata);
} }
static void ieee80211_ibss_timer(unsigned long data) static void ieee80211_ibss_timer(struct timer_list *t)
{ {
struct ieee80211_sub_if_data *sdata = struct ieee80211_sub_if_data *sdata =
(struct ieee80211_sub_if_data *) data; from_timer(sdata, t, u.ibss.timer);
ieee80211_queue_work(&sdata->local->hw, &sdata->work); ieee80211_queue_work(&sdata->local->hw, &sdata->work);
} }
...@@ -1723,8 +1723,7 @@ void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata) ...@@ -1723,8 +1723,7 @@ void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata)
{ {
struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
setup_timer(&ifibss->timer, ieee80211_ibss_timer, timer_setup(&ifibss->timer, ieee80211_ibss_timer, 0);
(unsigned long) sdata);
INIT_LIST_HEAD(&ifibss->incomplete_stations); INIT_LIST_HEAD(&ifibss->incomplete_stations);
spin_lock_init(&ifibss->incomplete_lock); spin_lock_init(&ifibss->incomplete_lock);
INIT_WORK(&ifibss->csa_connection_drop_work, INIT_WORK(&ifibss->csa_connection_drop_work,
......
...@@ -1057,6 +1057,7 @@ struct tpt_led_trigger { ...@@ -1057,6 +1057,7 @@ struct tpt_led_trigger {
const struct ieee80211_tpt_blink *blink_table; const struct ieee80211_tpt_blink *blink_table;
unsigned int blink_table_len; unsigned int blink_table_len;
struct timer_list timer; struct timer_list timer;
struct ieee80211_local *local;
unsigned long prev_traffic; unsigned long prev_traffic;
unsigned long tx_bytes, rx_bytes; unsigned long tx_bytes, rx_bytes;
unsigned int active, want; unsigned int active, want;
...@@ -1932,7 +1933,7 @@ static inline int ieee80211_ac_from_tid(int tid) ...@@ -1932,7 +1933,7 @@ static inline int ieee80211_ac_from_tid(int tid)
void ieee80211_dynamic_ps_enable_work(struct work_struct *work); void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
void ieee80211_dynamic_ps_disable_work(struct work_struct *work); void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
void ieee80211_dynamic_ps_timer(unsigned long data); void ieee80211_dynamic_ps_timer(struct timer_list *t);
void ieee80211_send_nullfunc(struct ieee80211_local *local, void ieee80211_send_nullfunc(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata, struct ieee80211_sub_if_data *sdata,
bool powersave); bool powersave);
......
...@@ -248,10 +248,10 @@ static unsigned long tpt_trig_traffic(struct ieee80211_local *local, ...@@ -248,10 +248,10 @@ static unsigned long tpt_trig_traffic(struct ieee80211_local *local,
return DIV_ROUND_UP(delta, 1024 / 8); return DIV_ROUND_UP(delta, 1024 / 8);
} }
static void tpt_trig_timer(unsigned long data) static void tpt_trig_timer(struct timer_list *t)
{ {
struct ieee80211_local *local = (void *)data; struct tpt_led_trigger *tpt_trig = from_timer(tpt_trig, t, timer);
struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger; struct ieee80211_local *local = tpt_trig->local;
struct led_classdev *led_cdev; struct led_classdev *led_cdev;
unsigned long on, off, tpt; unsigned long on, off, tpt;
int i; int i;
...@@ -306,8 +306,9 @@ __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw, ...@@ -306,8 +306,9 @@ __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
tpt_trig->blink_table = blink_table; tpt_trig->blink_table = blink_table;
tpt_trig->blink_table_len = blink_table_len; tpt_trig->blink_table_len = blink_table_len;
tpt_trig->want = flags; tpt_trig->want = flags;
tpt_trig->local = local;
setup_timer(&tpt_trig->timer, tpt_trig_timer, (unsigned long)local); timer_setup(&tpt_trig->timer, tpt_trig_timer, 0);
local->tpt_led_trigger = tpt_trig; local->tpt_led_trigger = tpt_trig;
...@@ -326,7 +327,7 @@ static void ieee80211_start_tpt_led_trig(struct ieee80211_local *local) ...@@ -326,7 +327,7 @@ static void ieee80211_start_tpt_led_trig(struct ieee80211_local *local)
tpt_trig_traffic(local, tpt_trig); tpt_trig_traffic(local, tpt_trig);
tpt_trig->running = true; tpt_trig->running = true;
tpt_trig_timer((unsigned long)local); tpt_trig_timer(&tpt_trig->timer);
mod_timer(&tpt_trig->timer, round_jiffies(jiffies + HZ)); mod_timer(&tpt_trig->timer, round_jiffies(jiffies + HZ));
} }
......
...@@ -633,8 +633,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len, ...@@ -633,8 +633,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
ieee80211_dynamic_ps_enable_work); ieee80211_dynamic_ps_enable_work);
INIT_WORK(&local->dynamic_ps_disable_work, INIT_WORK(&local->dynamic_ps_disable_work,
ieee80211_dynamic_ps_disable_work); ieee80211_dynamic_ps_disable_work);
setup_timer(&local->dynamic_ps_timer, timer_setup(&local->dynamic_ps_timer, ieee80211_dynamic_ps_timer, 0);
ieee80211_dynamic_ps_timer, (unsigned long) local);
INIT_WORK(&local->sched_scan_stopped_work, INIT_WORK(&local->sched_scan_stopped_work,
ieee80211_sched_scan_stopped_work); ieee80211_sched_scan_stopped_work);
......
...@@ -37,9 +37,10 @@ void ieee80211s_stop(void) ...@@ -37,9 +37,10 @@ void ieee80211s_stop(void)
kmem_cache_destroy(rm_cache); kmem_cache_destroy(rm_cache);
} }
static void ieee80211_mesh_housekeeping_timer(unsigned long data) static void ieee80211_mesh_housekeeping_timer(struct timer_list *t)
{ {
struct ieee80211_sub_if_data *sdata = (void *) data; struct ieee80211_sub_if_data *sdata =
from_timer(sdata, t, u.mesh.housekeeping_timer);
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
...@@ -528,18 +529,18 @@ int mesh_add_vht_oper_ie(struct ieee80211_sub_if_data *sdata, ...@@ -528,18 +529,18 @@ int mesh_add_vht_oper_ie(struct ieee80211_sub_if_data *sdata,
return 0; return 0;
} }
static void ieee80211_mesh_path_timer(unsigned long data) static void ieee80211_mesh_path_timer(struct timer_list *t)
{ {
struct ieee80211_sub_if_data *sdata = struct ieee80211_sub_if_data *sdata =
(struct ieee80211_sub_if_data *) data; from_timer(sdata, t, u.mesh.mesh_path_timer);
ieee80211_queue_work(&sdata->local->hw, &sdata->work); ieee80211_queue_work(&sdata->local->hw, &sdata->work);
} }
static void ieee80211_mesh_path_root_timer(unsigned long data) static void ieee80211_mesh_path_root_timer(struct timer_list *t)
{ {
struct ieee80211_sub_if_data *sdata = struct ieee80211_sub_if_data *sdata =
(struct ieee80211_sub_if_data *) data; from_timer(sdata, t, u.mesh.mesh_path_root_timer);
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags); set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags);
...@@ -1442,9 +1443,8 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata) ...@@ -1442,9 +1443,8 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
static u8 zero_addr[ETH_ALEN] = {}; static u8 zero_addr[ETH_ALEN] = {};
setup_timer(&ifmsh->housekeeping_timer, timer_setup(&ifmsh->housekeeping_timer,
ieee80211_mesh_housekeeping_timer, ieee80211_mesh_housekeeping_timer, 0);
(unsigned long) sdata);
ifmsh->accepting_plinks = true; ifmsh->accepting_plinks = true;
atomic_set(&ifmsh->mpaths, 0); atomic_set(&ifmsh->mpaths, 0);
...@@ -1458,12 +1458,9 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata) ...@@ -1458,12 +1458,9 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
mesh_pathtbl_init(sdata); mesh_pathtbl_init(sdata);
setup_timer(&ifmsh->mesh_path_timer, timer_setup(&ifmsh->mesh_path_timer, ieee80211_mesh_path_timer, 0);
ieee80211_mesh_path_timer, timer_setup(&ifmsh->mesh_path_root_timer,
(unsigned long) sdata); ieee80211_mesh_path_root_timer, 0);
setup_timer(&ifmsh->mesh_path_root_timer,
ieee80211_mesh_path_root_timer,
(unsigned long) sdata);
INIT_LIST_HEAD(&ifmsh->preq_queue.list); INIT_LIST_HEAD(&ifmsh->preq_queue.list);
skb_queue_head_init(&ifmsh->ps.bc_buf); skb_queue_head_init(&ifmsh->ps.bc_buf);
spin_lock_init(&ifmsh->mesh_preq_queue_lock); spin_lock_init(&ifmsh->mesh_preq_queue_lock);
......
...@@ -296,7 +296,7 @@ void mesh_path_tx_pending(struct mesh_path *mpath); ...@@ -296,7 +296,7 @@ void mesh_path_tx_pending(struct mesh_path *mpath);
int mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata); int mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata);
void mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata); void mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata);
int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr); int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr);
void mesh_path_timer(unsigned long data); void mesh_path_timer(struct timer_list *t);
void mesh_path_flush_by_nexthop(struct sta_info *sta); void mesh_path_flush_by_nexthop(struct sta_info *sta);
void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata, void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata,
struct sk_buff *skb); struct sk_buff *skb);
......
...@@ -1194,9 +1194,9 @@ int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata, ...@@ -1194,9 +1194,9 @@ int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata,
return err; return err;
} }
void mesh_path_timer(unsigned long data) void mesh_path_timer(struct timer_list *t)
{ {
struct mesh_path *mpath = (void *) data; struct mesh_path *mpath = from_timer(mpath, t, timer);
struct ieee80211_sub_if_data *sdata = mpath->sdata; struct ieee80211_sub_if_data *sdata = mpath->sdata;
int ret; int ret;
......
...@@ -399,8 +399,7 @@ struct mesh_path *mesh_path_new(struct ieee80211_sub_if_data *sdata, ...@@ -399,8 +399,7 @@ struct mesh_path *mesh_path_new(struct ieee80211_sub_if_data *sdata,
skb_queue_head_init(&new_mpath->frame_queue); skb_queue_head_init(&new_mpath->frame_queue);
new_mpath->exp_time = jiffies; new_mpath->exp_time = jiffies;
spin_lock_init(&new_mpath->state_lock); spin_lock_init(&new_mpath->state_lock);
setup_timer(&new_mpath->timer, mesh_path_timer, timer_setup(&new_mpath->timer, mesh_path_timer, 0);
(unsigned long) new_mpath);
return new_mpath; return new_mpath;
} }
......
...@@ -1066,10 +1066,10 @@ void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success) ...@@ -1066,10 +1066,10 @@ void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success)
} }
EXPORT_SYMBOL(ieee80211_chswitch_done); EXPORT_SYMBOL(ieee80211_chswitch_done);
static void ieee80211_chswitch_timer(unsigned long data) static void ieee80211_chswitch_timer(struct timer_list *t)
{ {
struct ieee80211_sub_if_data *sdata = struct ieee80211_sub_if_data *sdata =
(struct ieee80211_sub_if_data *) data; from_timer(sdata, t, u.mgd.chswitch_timer);
ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work); ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work);
} }
...@@ -1577,9 +1577,9 @@ void ieee80211_dynamic_ps_enable_work(struct work_struct *work) ...@@ -1577,9 +1577,9 @@ void ieee80211_dynamic_ps_enable_work(struct work_struct *work)
} }
} }
void ieee80211_dynamic_ps_timer(unsigned long data) void ieee80211_dynamic_ps_timer(struct timer_list *t)
{ {
struct ieee80211_local *local = (void *) data; struct ieee80211_local *local = from_timer(local, t, dynamic_ps_timer);
ieee80211_queue_work(&local->hw, &local->dynamic_ps_enable_work); ieee80211_queue_work(&local->hw, &local->dynamic_ps_enable_work);
} }
...@@ -3711,10 +3711,10 @@ void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, ...@@ -3711,10 +3711,10 @@ void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
sdata_unlock(sdata); sdata_unlock(sdata);
} }
static void ieee80211_sta_timer(unsigned long data) static void ieee80211_sta_timer(struct timer_list *t)
{ {
struct ieee80211_sub_if_data *sdata = struct ieee80211_sub_if_data *sdata =
(struct ieee80211_sub_if_data *) data; from_timer(sdata, t, u.mgd.timer);
ieee80211_queue_work(&sdata->local->hw, &sdata->work); ieee80211_queue_work(&sdata->local->hw, &sdata->work);
} }
...@@ -3991,10 +3991,10 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata) ...@@ -3991,10 +3991,10 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata)
sdata_unlock(sdata); sdata_unlock(sdata);
} }
static void ieee80211_sta_bcn_mon_timer(unsigned long data) static void ieee80211_sta_bcn_mon_timer(struct timer_list *t)
{ {
struct ieee80211_sub_if_data *sdata = struct ieee80211_sub_if_data *sdata =
(struct ieee80211_sub_if_data *) data; from_timer(sdata, t, u.mgd.bcn_mon_timer);
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
if (sdata->vif.csa_active && !ifmgd->csa_waiting_bcn) if (sdata->vif.csa_active && !ifmgd->csa_waiting_bcn)
...@@ -4005,10 +4005,10 @@ static void ieee80211_sta_bcn_mon_timer(unsigned long data) ...@@ -4005,10 +4005,10 @@ static void ieee80211_sta_bcn_mon_timer(unsigned long data)
&sdata->u.mgd.beacon_connection_loss_work); &sdata->u.mgd.beacon_connection_loss_work);
} }
static void ieee80211_sta_conn_mon_timer(unsigned long data) static void ieee80211_sta_conn_mon_timer(struct timer_list *t)
{ {
struct ieee80211_sub_if_data *sdata = struct ieee80211_sub_if_data *sdata =
(struct ieee80211_sub_if_data *) data; from_timer(sdata, t, u.mgd.conn_mon_timer);
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
...@@ -4139,14 +4139,10 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) ...@@ -4139,14 +4139,10 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
INIT_WORK(&ifmgd->request_smps_work, ieee80211_request_smps_mgd_work); INIT_WORK(&ifmgd->request_smps_work, ieee80211_request_smps_mgd_work);
INIT_DELAYED_WORK(&ifmgd->tdls_peer_del_work, INIT_DELAYED_WORK(&ifmgd->tdls_peer_del_work,
ieee80211_tdls_peer_del_work); ieee80211_tdls_peer_del_work);
setup_timer(&ifmgd->timer, ieee80211_sta_timer, timer_setup(&ifmgd->timer, ieee80211_sta_timer, 0);
(unsigned long) sdata); timer_setup(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer, 0);
setup_timer(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer, timer_setup(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, 0);
(unsigned long) sdata); timer_setup(&ifmgd->chswitch_timer, ieee80211_chswitch_timer, 0);
setup_timer(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer,
(unsigned long) sdata);
setup_timer(&ifmgd->chswitch_timer, ieee80211_chswitch_timer,
(unsigned long) sdata);
INIT_DELAYED_WORK(&ifmgd->tx_tspec_wk, INIT_DELAYED_WORK(&ifmgd->tx_tspec_wk,
ieee80211_sta_handle_tspec_ac_params_wk); ieee80211_sta_handle_tspec_ac_params_wk);
......
...@@ -150,9 +150,10 @@ void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata) ...@@ -150,9 +150,10 @@ void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata)
sdata_unlock(sdata); sdata_unlock(sdata);
} }
static void ieee80211_ocb_housekeeping_timer(unsigned long data) static void ieee80211_ocb_housekeeping_timer(struct timer_list *t)
{ {
struct ieee80211_sub_if_data *sdata = (void *)data; struct ieee80211_sub_if_data *sdata =
from_timer(sdata, t, u.ocb.housekeeping_timer);
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
struct ieee80211_if_ocb *ifocb = &sdata->u.ocb; struct ieee80211_if_ocb *ifocb = &sdata->u.ocb;
...@@ -165,9 +166,8 @@ void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata) ...@@ -165,9 +166,8 @@ void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata)
{ {
struct ieee80211_if_ocb *ifocb = &sdata->u.ocb; struct ieee80211_if_ocb *ifocb = &sdata->u.ocb;
setup_timer(&ifocb->housekeeping_timer, timer_setup(&ifocb->housekeeping_timer,
ieee80211_ocb_housekeeping_timer, ieee80211_ocb_housekeeping_timer, 0);
(unsigned long)sdata);
INIT_LIST_HEAD(&ifocb->incomplete_stations); INIT_LIST_HEAD(&ifocb->incomplete_stations);
spin_lock_init(&ifocb->incomplete_lock); spin_lock_init(&ifocb->incomplete_lock);
} }
......
...@@ -1064,9 +1064,9 @@ int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata, ...@@ -1064,9 +1064,9 @@ int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata,
return ret; return ret;
} }
static void sta_info_cleanup(unsigned long data) static void sta_info_cleanup(struct timer_list *t)
{ {
struct ieee80211_local *local = (struct ieee80211_local *) data; struct ieee80211_local *local = from_timer(local, t, sta_cleanup);
struct sta_info *sta; struct sta_info *sta;
bool timer_needed = false; bool timer_needed = false;
...@@ -1098,8 +1098,7 @@ int sta_info_init(struct ieee80211_local *local) ...@@ -1098,8 +1098,7 @@ int sta_info_init(struct ieee80211_local *local)
mutex_init(&local->sta_mtx); mutex_init(&local->sta_mtx);
INIT_LIST_HEAD(&local->sta_list); INIT_LIST_HEAD(&local->sta_list);
setup_timer(&local->sta_cleanup, sta_info_cleanup, timer_setup(&local->sta_cleanup, sta_info_cleanup, 0);
(unsigned long)local);
return 0; return 0;
} }
......
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