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

timer: Remove init_timer_deferrable() in favor of timer_setup()

This refactors the only users of init_timer_deferrable() to use
the new timer_setup() and from_timer(). Removes definition of
init_timer_deferrable().

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: David S. Miller <davem@davemloft.net> # for networking parts
Acked-by: Sebastian Reichel <sre@kernel.org> # for drivers/hsi parts
Cc: linux-mips@linux-mips.org
Cc: Petr Mladek <pmladek@suse.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: linux1394-devel@lists.sourceforge.net
Cc: Chris Metcalf <cmetcalf@mellanox.com>
Cc: linux-s390@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: Wim Van Sebroeck <wim@iguana.be>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Ursula Braun <ubraun@linux.vnet.ibm.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Harish Patil <harish.patil@cavium.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Manish Chopra <manish.chopra@cavium.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-pm@vger.kernel.org
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Mark Gross <mark.gross@intel.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-watchdog@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-wireless@vger.kernel.org
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Michael Reed <mdr@sgi.com>
Cc: netdev@vger.kernel.org
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Link: https://lkml.kernel.org/r/1507159627-127660-6-git-send-email-keescook@chromium.org

authored by

Kees Cook and committed by
Thomas Gleixner
df7e828c 185981d5

+34 -40
+5 -7
arch/powerpc/mm/numa.c
··· 1453 1453 schedule_work(&topology_work); 1454 1454 } 1455 1455 1456 - static void topology_timer_fn(unsigned long ignored) 1456 + static void topology_timer_fn(struct timer_list *unused) 1457 1457 { 1458 1458 if (prrn_enabled && cpumask_weight(&cpu_associativity_changes_mask)) 1459 1459 topology_schedule_update(); ··· 1463 1463 reset_topology_timer(); 1464 1464 } 1465 1465 } 1466 - static struct timer_list topology_timer = 1467 - TIMER_INITIALIZER(topology_timer_fn, 0, 0); 1466 + static struct timer_list topology_timer; 1468 1467 1469 1468 static void reset_topology_timer(void) 1470 1469 { 1471 - topology_timer.data = 0; 1472 - topology_timer.expires = jiffies + 60 * HZ; 1473 - mod_timer(&topology_timer, topology_timer.expires); 1470 + mod_timer(&topology_timer, jiffies + 60 * HZ); 1474 1471 } 1475 1472 1476 1473 #ifdef CONFIG_SMP ··· 1527 1530 prrn_enabled = 0; 1528 1531 vphn_enabled = 1; 1529 1532 setup_cpu_associativity_change_counters(); 1530 - init_timer_deferrable(&topology_timer); 1533 + timer_setup(&topology_timer, topology_timer_fn, 1534 + TIMER_DEFERRABLE); 1531 1535 reset_topology_timer(); 1532 1536 } 1533 1537 }
+18 -14
drivers/hsi/clients/ssi_protocol.c
··· 464 464 hsi_async_read(cl, msg); 465 465 } 466 466 467 - static void ssip_keep_alive(unsigned long data) 467 + static void ssip_keep_alive(struct timer_list *t) 468 468 { 469 - struct hsi_client *cl = (struct hsi_client *)data; 470 - struct ssi_protocol *ssi = hsi_client_drvdata(cl); 469 + struct ssi_protocol *ssi = from_timer(ssi, t, keep_alive); 470 + struct hsi_client *cl = ssi->cl; 471 471 472 472 dev_dbg(&cl->device, "Keep alive kick in: m(%d) r(%d) s(%d)\n", 473 473 ssi->main_state, ssi->recv_state, ssi->send_state); ··· 490 490 spin_unlock(&ssi->lock); 491 491 } 492 492 493 - static void ssip_wd(unsigned long data) 493 + static void ssip_rx_wd(struct timer_list *t) 494 494 { 495 - struct hsi_client *cl = (struct hsi_client *)data; 495 + struct ssi_protocol *ssi = from_timer(ssi, t, rx_wd); 496 + struct hsi_client *cl = ssi->cl; 497 + 498 + dev_err(&cl->device, "Watchdog trigerred\n"); 499 + ssip_error(cl); 500 + } 501 + 502 + static void ssip_tx_wd(unsigned long data) 503 + { 504 + struct ssi_protocol *ssi = from_timer(ssi, t, tx_wd); 505 + struct hsi_client *cl = ssi->cl; 496 506 497 507 dev_err(&cl->device, "Watchdog trigerred\n"); 498 508 ssip_error(cl); ··· 1094 1084 } 1095 1085 1096 1086 spin_lock_init(&ssi->lock); 1097 - init_timer_deferrable(&ssi->rx_wd); 1098 - init_timer_deferrable(&ssi->tx_wd); 1099 - init_timer(&ssi->keep_alive); 1100 - ssi->rx_wd.data = (unsigned long)cl; 1101 - ssi->rx_wd.function = ssip_wd; 1102 - ssi->tx_wd.data = (unsigned long)cl; 1103 - ssi->tx_wd.function = ssip_wd; 1104 - ssi->keep_alive.data = (unsigned long)cl; 1105 - ssi->keep_alive.function = ssip_keep_alive; 1087 + timer_setup(&ssi->rx_wd, ssip_rx_wd, TIMER_DEFERRABLE); 1088 + timer_setup(&ssi->tx_wd, ssip_tx_wd, TIMER_DEFERRABLE); 1089 + timer_setup(&ssi->keep_alive, ssip_keep_alive, 0); 1106 1090 INIT_LIST_HEAD(&ssi->txqueue); 1107 1091 INIT_LIST_HEAD(&ssi->cmdqueue); 1108 1092 atomic_set(&ssi->tx_usecnt, 0);
+4 -7
drivers/net/ethernet/qlogic/qlge/qlge_main.c
··· 4725 4725 .ndo_vlan_rx_kill_vid = qlge_vlan_rx_kill_vid, 4726 4726 }; 4727 4727 4728 - static void ql_timer(unsigned long data) 4728 + static void ql_timer(struct timer_list *t) 4729 4729 { 4730 - struct ql_adapter *qdev = (struct ql_adapter *)data; 4730 + struct ql_adapter *qdev = from_timer(qdev, t, timer); 4731 4731 u32 var = 0; 4732 4732 4733 4733 var = ql_read32(qdev, STS); ··· 4806 4806 /* Start up the timer to trigger EEH if 4807 4807 * the bus goes dead 4808 4808 */ 4809 - init_timer_deferrable(&qdev->timer); 4810 - qdev->timer.data = (unsigned long)qdev; 4811 - qdev->timer.function = ql_timer; 4812 - qdev->timer.expires = jiffies + (5*HZ); 4813 - add_timer(&qdev->timer); 4809 + timer_setup(&qdev->timer, ql_timer, TIMER_DEFERRABLE); 4810 + mod_timer(&qdev->timer, jiffies + (5*HZ)); 4814 4811 ql_link_off(qdev); 4815 4812 ql_display_dev_info(ndev); 4816 4813 atomic_set(&qdev->lb_count, 0);
+3 -5
drivers/net/vxlan.c
··· 2325 2325 } 2326 2326 2327 2327 /* Walk the forwarding table and purge stale entries */ 2328 - static void vxlan_cleanup(unsigned long arg) 2328 + static void vxlan_cleanup(struct timer_list *t) 2329 2329 { 2330 - struct vxlan_dev *vxlan = (struct vxlan_dev *) arg; 2330 + struct vxlan_dev *vxlan = from_timer(vxlan, t, age_timer); 2331 2331 unsigned long next_timer = jiffies + FDB_AGE_INTERVAL; 2332 2332 unsigned int h; 2333 2333 ··· 2647 2647 INIT_LIST_HEAD(&vxlan->next); 2648 2648 spin_lock_init(&vxlan->hash_lock); 2649 2649 2650 - init_timer_deferrable(&vxlan->age_timer); 2651 - vxlan->age_timer.function = vxlan_cleanup; 2652 - vxlan->age_timer.data = (unsigned long) vxlan; 2650 + timer_setup(&vxlan->age_timer, vxlan_cleanup, TIMER_DEFERRABLE); 2653 2651 2654 2652 vxlan->dev = dev; 2655 2653
+4 -5
drivers/net/wireless/ath/ath6kl/recovery.c
··· 60 60 ar->fw_recovery.hb_pending = false; 61 61 } 62 62 63 - static void ath6kl_recovery_hb_timer(unsigned long data) 63 + static void ath6kl_recovery_hb_timer(struct timer_list *t) 64 64 { 65 - struct ath6kl *ar = (struct ath6kl *) data; 65 + struct ath6kl *ar = from_timer(ar, t, fw_recovery.hb_timer); 66 66 int err; 67 67 68 68 if (test_bit(RECOVERY_CLEANUP, &ar->flag) || ··· 104 104 recovery->seq_num = 0; 105 105 recovery->hb_misscnt = 0; 106 106 ar->fw_recovery.hb_pending = false; 107 - ar->fw_recovery.hb_timer.function = ath6kl_recovery_hb_timer; 108 - ar->fw_recovery.hb_timer.data = (unsigned long) ar; 109 - init_timer_deferrable(&ar->fw_recovery.hb_timer); 107 + timer_setup(&ar->fw_recovery.hb_timer, ath6kl_recovery_hb_timer, 108 + TIMER_DEFERRABLE); 110 109 111 110 if (ar->fw_recovery.hb_poll) 112 111 mod_timer(&ar->fw_recovery.hb_timer, jiffies +
-2
include/linux/timer.h
··· 128 128 129 129 #define init_timer(timer) \ 130 130 __init_timer((timer), 0) 131 - #define init_timer_deferrable(timer) \ 132 - __init_timer((timer), TIMER_DEFERRABLE) 133 131 134 132 #define __setup_timer(_timer, _fn, _data, _flags) \ 135 133 do { \