Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Kees Cook <keescook@chromium.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Kees Cook and committed by
Johannes Berg
34f11cd3 32a72bbd

+50 -59
+3 -4
net/mac80211/ibss.c
··· 1711 1711 sdata_unlock(sdata); 1712 1712 } 1713 1713 1714 - static void ieee80211_ibss_timer(unsigned long data) 1714 + static void ieee80211_ibss_timer(struct timer_list *t) 1715 1715 { 1716 1716 struct ieee80211_sub_if_data *sdata = 1717 - (struct ieee80211_sub_if_data *) data; 1717 + from_timer(sdata, t, u.ibss.timer); 1718 1718 1719 1719 ieee80211_queue_work(&sdata->local->hw, &sdata->work); 1720 1720 } ··· 1723 1723 { 1724 1724 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 1725 1725 1726 - setup_timer(&ifibss->timer, ieee80211_ibss_timer, 1727 - (unsigned long) sdata); 1726 + timer_setup(&ifibss->timer, ieee80211_ibss_timer, 0); 1728 1727 INIT_LIST_HEAD(&ifibss->incomplete_stations); 1729 1728 spin_lock_init(&ifibss->incomplete_lock); 1730 1729 INIT_WORK(&ifibss->csa_connection_drop_work,
+2 -1
net/mac80211/ieee80211_i.h
··· 1057 1057 const struct ieee80211_tpt_blink *blink_table; 1058 1058 unsigned int blink_table_len; 1059 1059 struct timer_list timer; 1060 + struct ieee80211_local *local; 1060 1061 unsigned long prev_traffic; 1061 1062 unsigned long tx_bytes, rx_bytes; 1062 1063 unsigned int active, want; ··· 1933 1932 1934 1933 void ieee80211_dynamic_ps_enable_work(struct work_struct *work); 1935 1934 void ieee80211_dynamic_ps_disable_work(struct work_struct *work); 1936 - void ieee80211_dynamic_ps_timer(unsigned long data); 1935 + void ieee80211_dynamic_ps_timer(struct timer_list *t); 1937 1936 void ieee80211_send_nullfunc(struct ieee80211_local *local, 1938 1937 struct ieee80211_sub_if_data *sdata, 1939 1938 bool powersave);
+6 -5
net/mac80211/led.c
··· 248 248 return DIV_ROUND_UP(delta, 1024 / 8); 249 249 } 250 250 251 - static void tpt_trig_timer(unsigned long data) 251 + static void tpt_trig_timer(struct timer_list *t) 252 252 { 253 - struct ieee80211_local *local = (void *)data; 254 - struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger; 253 + struct tpt_led_trigger *tpt_trig = from_timer(tpt_trig, t, timer); 254 + struct ieee80211_local *local = tpt_trig->local; 255 255 struct led_classdev *led_cdev; 256 256 unsigned long on, off, tpt; 257 257 int i; ··· 306 306 tpt_trig->blink_table = blink_table; 307 307 tpt_trig->blink_table_len = blink_table_len; 308 308 tpt_trig->want = flags; 309 + tpt_trig->local = local; 309 310 310 - setup_timer(&tpt_trig->timer, tpt_trig_timer, (unsigned long)local); 311 + timer_setup(&tpt_trig->timer, tpt_trig_timer, 0); 311 312 312 313 local->tpt_led_trigger = tpt_trig; 313 314 ··· 327 326 tpt_trig_traffic(local, tpt_trig); 328 327 tpt_trig->running = true; 329 328 330 - tpt_trig_timer((unsigned long)local); 329 + tpt_trig_timer(&tpt_trig->timer); 331 330 mod_timer(&tpt_trig->timer, round_jiffies(jiffies + HZ)); 332 331 } 333 332
+1 -2
net/mac80211/main.c
··· 633 633 ieee80211_dynamic_ps_enable_work); 634 634 INIT_WORK(&local->dynamic_ps_disable_work, 635 635 ieee80211_dynamic_ps_disable_work); 636 - setup_timer(&local->dynamic_ps_timer, 637 - ieee80211_dynamic_ps_timer, (unsigned long) local); 636 + timer_setup(&local->dynamic_ps_timer, ieee80211_dynamic_ps_timer, 0); 638 637 639 638 INIT_WORK(&local->sched_scan_stopped_work, 640 639 ieee80211_sched_scan_stopped_work);
+12 -15
net/mac80211/mesh.c
··· 37 37 kmem_cache_destroy(rm_cache); 38 38 } 39 39 40 - static void ieee80211_mesh_housekeeping_timer(unsigned long data) 40 + static void ieee80211_mesh_housekeeping_timer(struct timer_list *t) 41 41 { 42 - struct ieee80211_sub_if_data *sdata = (void *) data; 42 + struct ieee80211_sub_if_data *sdata = 43 + from_timer(sdata, t, u.mesh.housekeeping_timer); 43 44 struct ieee80211_local *local = sdata->local; 44 45 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 45 46 ··· 529 528 return 0; 530 529 } 531 530 532 - static void ieee80211_mesh_path_timer(unsigned long data) 531 + static void ieee80211_mesh_path_timer(struct timer_list *t) 533 532 { 534 533 struct ieee80211_sub_if_data *sdata = 535 - (struct ieee80211_sub_if_data *) data; 534 + from_timer(sdata, t, u.mesh.mesh_path_timer); 536 535 537 536 ieee80211_queue_work(&sdata->local->hw, &sdata->work); 538 537 } 539 538 540 - static void ieee80211_mesh_path_root_timer(unsigned long data) 539 + static void ieee80211_mesh_path_root_timer(struct timer_list *t) 541 540 { 542 541 struct ieee80211_sub_if_data *sdata = 543 - (struct ieee80211_sub_if_data *) data; 542 + from_timer(sdata, t, u.mesh.mesh_path_root_timer); 544 543 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 545 544 546 545 set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags); ··· 1443 1442 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 1444 1443 static u8 zero_addr[ETH_ALEN] = {}; 1445 1444 1446 - setup_timer(&ifmsh->housekeeping_timer, 1447 - ieee80211_mesh_housekeeping_timer, 1448 - (unsigned long) sdata); 1445 + timer_setup(&ifmsh->housekeeping_timer, 1446 + ieee80211_mesh_housekeeping_timer, 0); 1449 1447 1450 1448 ifmsh->accepting_plinks = true; 1451 1449 atomic_set(&ifmsh->mpaths, 0); ··· 1458 1458 1459 1459 mesh_pathtbl_init(sdata); 1460 1460 1461 - setup_timer(&ifmsh->mesh_path_timer, 1462 - ieee80211_mesh_path_timer, 1463 - (unsigned long) sdata); 1464 - setup_timer(&ifmsh->mesh_path_root_timer, 1465 - ieee80211_mesh_path_root_timer, 1466 - (unsigned long) sdata); 1461 + timer_setup(&ifmsh->mesh_path_timer, ieee80211_mesh_path_timer, 0); 1462 + timer_setup(&ifmsh->mesh_path_root_timer, 1463 + ieee80211_mesh_path_root_timer, 0); 1467 1464 INIT_LIST_HEAD(&ifmsh->preq_queue.list); 1468 1465 skb_queue_head_init(&ifmsh->ps.bc_buf); 1469 1466 spin_lock_init(&ifmsh->mesh_preq_queue_lock);
+1 -1
net/mac80211/mesh.h
··· 296 296 int mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata); 297 297 void mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata); 298 298 int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr); 299 - void mesh_path_timer(unsigned long data); 299 + void mesh_path_timer(struct timer_list *t); 300 300 void mesh_path_flush_by_nexthop(struct sta_info *sta); 301 301 void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata, 302 302 struct sk_buff *skb);
+2 -2
net/mac80211/mesh_hwmp.c
··· 1194 1194 return err; 1195 1195 } 1196 1196 1197 - void mesh_path_timer(unsigned long data) 1197 + void mesh_path_timer(struct timer_list *t) 1198 1198 { 1199 - struct mesh_path *mpath = (void *) data; 1199 + struct mesh_path *mpath = from_timer(mpath, t, timer); 1200 1200 struct ieee80211_sub_if_data *sdata = mpath->sdata; 1201 1201 int ret; 1202 1202
+1 -2
net/mac80211/mesh_pathtbl.c
··· 399 399 skb_queue_head_init(&new_mpath->frame_queue); 400 400 new_mpath->exp_time = jiffies; 401 401 spin_lock_init(&new_mpath->state_lock); 402 - setup_timer(&new_mpath->timer, mesh_path_timer, 403 - (unsigned long) new_mpath); 402 + timer_setup(&new_mpath->timer, mesh_path_timer, 0); 404 403 405 404 return new_mpath; 406 405 }
+14 -18
net/mac80211/mlme.c
··· 1066 1066 } 1067 1067 EXPORT_SYMBOL(ieee80211_chswitch_done); 1068 1068 1069 - static void ieee80211_chswitch_timer(unsigned long data) 1069 + static void ieee80211_chswitch_timer(struct timer_list *t) 1070 1070 { 1071 1071 struct ieee80211_sub_if_data *sdata = 1072 - (struct ieee80211_sub_if_data *) data; 1072 + from_timer(sdata, t, u.mgd.chswitch_timer); 1073 1073 1074 1074 ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work); 1075 1075 } ··· 1577 1577 } 1578 1578 } 1579 1579 1580 - void ieee80211_dynamic_ps_timer(unsigned long data) 1580 + void ieee80211_dynamic_ps_timer(struct timer_list *t) 1581 1581 { 1582 - struct ieee80211_local *local = (void *) data; 1582 + struct ieee80211_local *local = from_timer(local, t, dynamic_ps_timer); 1583 1583 1584 1584 ieee80211_queue_work(&local->hw, &local->dynamic_ps_enable_work); 1585 1585 } ··· 3711 3711 sdata_unlock(sdata); 3712 3712 } 3713 3713 3714 - static void ieee80211_sta_timer(unsigned long data) 3714 + static void ieee80211_sta_timer(struct timer_list *t) 3715 3715 { 3716 3716 struct ieee80211_sub_if_data *sdata = 3717 - (struct ieee80211_sub_if_data *) data; 3717 + from_timer(sdata, t, u.mgd.timer); 3718 3718 3719 3719 ieee80211_queue_work(&sdata->local->hw, &sdata->work); 3720 3720 } ··· 3991 3991 sdata_unlock(sdata); 3992 3992 } 3993 3993 3994 - static void ieee80211_sta_bcn_mon_timer(unsigned long data) 3994 + static void ieee80211_sta_bcn_mon_timer(struct timer_list *t) 3995 3995 { 3996 3996 struct ieee80211_sub_if_data *sdata = 3997 - (struct ieee80211_sub_if_data *) data; 3997 + from_timer(sdata, t, u.mgd.bcn_mon_timer); 3998 3998 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 3999 3999 4000 4000 if (sdata->vif.csa_active && !ifmgd->csa_waiting_bcn) ··· 4005 4005 &sdata->u.mgd.beacon_connection_loss_work); 4006 4006 } 4007 4007 4008 - static void ieee80211_sta_conn_mon_timer(unsigned long data) 4008 + static void ieee80211_sta_conn_mon_timer(struct timer_list *t) 4009 4009 { 4010 4010 struct ieee80211_sub_if_data *sdata = 4011 - (struct ieee80211_sub_if_data *) data; 4011 + from_timer(sdata, t, u.mgd.conn_mon_timer); 4012 4012 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 4013 4013 struct ieee80211_local *local = sdata->local; 4014 4014 ··· 4139 4139 INIT_WORK(&ifmgd->request_smps_work, ieee80211_request_smps_mgd_work); 4140 4140 INIT_DELAYED_WORK(&ifmgd->tdls_peer_del_work, 4141 4141 ieee80211_tdls_peer_del_work); 4142 - setup_timer(&ifmgd->timer, ieee80211_sta_timer, 4143 - (unsigned long) sdata); 4144 - setup_timer(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer, 4145 - (unsigned long) sdata); 4146 - setup_timer(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, 4147 - (unsigned long) sdata); 4148 - setup_timer(&ifmgd->chswitch_timer, ieee80211_chswitch_timer, 4149 - (unsigned long) sdata); 4142 + timer_setup(&ifmgd->timer, ieee80211_sta_timer, 0); 4143 + timer_setup(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer, 0); 4144 + timer_setup(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, 0); 4145 + timer_setup(&ifmgd->chswitch_timer, ieee80211_chswitch_timer, 0); 4150 4146 INIT_DELAYED_WORK(&ifmgd->tx_tspec_wk, 4151 4147 ieee80211_sta_handle_tspec_ac_params_wk); 4152 4148
+5 -5
net/mac80211/ocb.c
··· 150 150 sdata_unlock(sdata); 151 151 } 152 152 153 - static void ieee80211_ocb_housekeeping_timer(unsigned long data) 153 + static void ieee80211_ocb_housekeeping_timer(struct timer_list *t) 154 154 { 155 - struct ieee80211_sub_if_data *sdata = (void *)data; 155 + struct ieee80211_sub_if_data *sdata = 156 + from_timer(sdata, t, u.ocb.housekeeping_timer); 156 157 struct ieee80211_local *local = sdata->local; 157 158 struct ieee80211_if_ocb *ifocb = &sdata->u.ocb; 158 159 ··· 166 165 { 167 166 struct ieee80211_if_ocb *ifocb = &sdata->u.ocb; 168 167 169 - setup_timer(&ifocb->housekeeping_timer, 170 - ieee80211_ocb_housekeeping_timer, 171 - (unsigned long)sdata); 168 + timer_setup(&ifocb->housekeeping_timer, 169 + ieee80211_ocb_housekeeping_timer, 0); 172 170 INIT_LIST_HEAD(&ifocb->incomplete_stations); 173 171 spin_lock_init(&ifocb->incomplete_lock); 174 172 }
+3 -4
net/mac80211/sta_info.c
··· 1064 1064 return ret; 1065 1065 } 1066 1066 1067 - static void sta_info_cleanup(unsigned long data) 1067 + static void sta_info_cleanup(struct timer_list *t) 1068 1068 { 1069 - struct ieee80211_local *local = (struct ieee80211_local *) data; 1069 + struct ieee80211_local *local = from_timer(local, t, sta_cleanup); 1070 1070 struct sta_info *sta; 1071 1071 bool timer_needed = false; 1072 1072 ··· 1098 1098 mutex_init(&local->sta_mtx); 1099 1099 INIT_LIST_HEAD(&local->sta_list); 1100 1100 1101 - setup_timer(&local->sta_cleanup, sta_info_cleanup, 1102 - (unsigned long)local); 1101 + timer_setup(&local->sta_cleanup, sta_info_cleanup, 0); 1103 1102 return 0; 1104 1103 } 1105 1104