]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
Merge remote-tracking branch 'tip/timers/core' into afs-next
authorDavid Howells <dhowells@redhat.com>
Mon, 13 Nov 2017 15:36:33 +0000 (15:36 +0000)
committerDavid Howells <dhowells@redhat.com>
Mon, 13 Nov 2017 15:36:33 +0000 (15:36 +0000)
These AFS patches need the timer_reduce() patch from timers/core.

Signed-off-by: David Howells <dhowells@redhat.com>
251 files changed:
Documentation/devicetree/bindings/timer/renesas,cmt.txt
MAINTAINERS
arch/arm/mach-footbridge/dc21285.c
arch/arm/mach-ixp4xx/dsmg600-setup.c
arch/arm/mach-ixp4xx/nas100d-setup.c
arch/arm/mach-pxa/lubbock.c
arch/arm/mach-pxa/sharpsl_pm.c
arch/ia64/include/asm/sn/bte.h
arch/ia64/kernel/mca.c
arch/ia64/kernel/salinfo.c
arch/ia64/sn/kernel/bte.c
arch/ia64/sn/kernel/bte_error.c
arch/ia64/sn/kernel/huberror.c
arch/ia64/sn/kernel/mca.c
arch/m68k/amiga/amisound.c
arch/m68k/mac/macboing.c
arch/mips/mti-malta/malta-display.c
arch/mips/sgi-ip22/ip22-reset.c
arch/mips/sgi-ip32/ip32-reset.c
arch/parisc/kernel/pdc_cons.c
arch/powerpc/kernel/watchdog.c
arch/powerpc/mm/numa.c
arch/s390/kernel/lgr.c
arch/s390/kernel/topology.c
arch/s390/mm/cmm.c
arch/sparc/kernel/led.c
arch/x86/kernel/pci-calgary_64.c
arch/xtensa/platforms/iss/console.c
arch/xtensa/platforms/iss/network.c
drivers/acpi/apei/ghes.c
drivers/ata/ahci.h
drivers/ata/libahci.c
drivers/ata/libata-core.c
drivers/ata/libata-eh.c
drivers/ata/libata.h
drivers/atm/idt77105.c
drivers/atm/iphase.c
drivers/auxdisplay/img-ascii-lcd.c
drivers/auxdisplay/panel.c
drivers/base/power/main.c
drivers/block/amiflop.c
drivers/block/aoe/aoemain.c
drivers/block/ataflop.c
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_receiver.c
drivers/block/drbd/drbd_req.c
drivers/block/drbd/drbd_req.h
drivers/block/drbd/drbd_worker.c
drivers/char/dtlk.c
drivers/char/hangcheck-timer.c
drivers/char/hw_random/xgene-rng.c
drivers/char/nwbutton.c
drivers/char/rtc.c
drivers/char/tlclk.c
drivers/clocksource/Kconfig
drivers/clocksource/arm_arch_timer.c
drivers/clocksource/mips-gic-timer.c
drivers/clocksource/owl-timer.c
drivers/clocksource/rockchip_timer.c
drivers/clocksource/sh_cmt.c
drivers/clocksource/timer-fttmr010.c
drivers/clocksource/timer-of.c
drivers/clocksource/timer-of.h
drivers/cpufreq/powernv-cpufreq.c
drivers/crypto/axis/artpec6_crypto.c
drivers/crypto/mv_cesa.c
drivers/crypto/picoxcell_crypto.c
drivers/firewire/core-transaction.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
drivers/gpu/drm/gma500/psb_lid.c
drivers/hsi/clients/ssi_protocol.c
drivers/ide/ide-io.c
drivers/ide/ide-probe.c
drivers/input/touchscreen/s3c2410_ts.c
drivers/macintosh/smu.c
drivers/mailbox/mailbox-altera.c
drivers/media/usb/pvrusb2/pvrusb2-hdw.c
drivers/memstick/host/jmb38x_ms.c
drivers/memstick/host/r592.c
drivers/memstick/host/tifm_ms.c
drivers/misc/sgi-xp/xpc_main.c
drivers/misc/sgi-xp/xpc_sn2.c
drivers/net/cris/eth_v10.c
drivers/net/ethernet/qlogic/qlge/qlge_main.c
drivers/net/ethernet/tile/tilepro.c
drivers/net/hamradio/yam.c
drivers/net/vxlan.c
drivers/net/wireless/ath/ath6kl/recovery.c
drivers/net/wireless/atmel/at76c50x-usb.c
drivers/parport/ieee1284.c
drivers/pcmcia/bcm63xx_pcmcia.c
drivers/pcmcia/bfin_cf_pcmcia.c
drivers/pcmcia/i82365.c
drivers/pcmcia/omap_cf.c
drivers/pcmcia/pd6729.c
drivers/pcmcia/soc_common.c
drivers/pcmcia/tcic.c
drivers/pcmcia/yenta_socket.c
drivers/ras/cec.c
drivers/rtc/class.c
drivers/rtc/systohc.c
drivers/s390/char/tape.h
drivers/s390/char/tape_std.c
drivers/s390/net/lcs.c
drivers/s390/net/lcs.h
drivers/scsi/aic7xxx/aic79xx.h
drivers/scsi/aic7xxx/aic79xx_core.c
drivers/scsi/aic7xxx/aic79xx_osm.h
drivers/scsi/aic94xx/aic94xx_hwi.c
drivers/scsi/aic94xx/aic94xx_hwi.h
drivers/scsi/aic94xx/aic94xx_scb.c
drivers/scsi/aic94xx/aic94xx_tmf.c
drivers/scsi/be2iscsi/be_main.c
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
drivers/scsi/bnx2i/bnx2i.h
drivers/scsi/bnx2i/bnx2i_hwi.c
drivers/scsi/bnx2i/bnx2i_iscsi.c
drivers/scsi/csiostor/csio_hw.c
drivers/scsi/csiostor/csio_mb.c
drivers/scsi/csiostor/csio_mb.h
drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
drivers/scsi/cxgbi/libcxgbi.c
drivers/scsi/dc395x.c
drivers/scsi/fcoe/fcoe.c
drivers/scsi/fcoe/fcoe_transport.c
drivers/scsi/gdth.c
drivers/scsi/hisi_sas/hisi_sas.h
drivers/scsi/hisi_sas/hisi_sas_main.c
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
drivers/scsi/ibmvscsi/ibmvfc.c
drivers/scsi/ibmvscsi/ibmvscsi.c
drivers/scsi/ipr.c
drivers/scsi/isci/host.c
drivers/scsi/isci/isci.h
drivers/scsi/isci/phy.c
drivers/scsi/isci/port.c
drivers/scsi/isci/port_config.c
drivers/scsi/libfc/fc_fcp.c
drivers/scsi/libiscsi.c
drivers/scsi/libsas/sas_expander.c
drivers/scsi/libsas/sas_init.c
drivers/scsi/libsas/sas_scsi_host.c
drivers/scsi/lpfc/lpfc_crtn.h
drivers/scsi/lpfc/lpfc_ct.c
drivers/scsi/lpfc/lpfc_els.c
drivers/scsi/lpfc/lpfc_hbadisc.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_scsi.c
drivers/scsi/lpfc/lpfc_sli.c
drivers/scsi/megaraid/megaraid_ioctl.h
drivers/scsi/megaraid/megaraid_mbox.c
drivers/scsi/megaraid/megaraid_mm.c
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/megaraid/megaraid_sas_fusion.c
drivers/scsi/mvsas/mv_init.c
drivers/scsi/mvsas/mv_sas.c
drivers/scsi/mvsas/mv_sas.h
drivers/scsi/pm8001/pm8001_sas.c
drivers/scsi/pmcraid.c
drivers/scsi/qla1280.c
drivers/scsi/qla1280.h
drivers/scsi/qla2xxx/qla_gbl.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_inline.h
drivers/scsi/qla2xxx/qla_mid.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla4xxx/ql4_os.c
drivers/scsi/smartpqi/smartpqi_init.c
drivers/staging/speakup/main.c
drivers/staging/speakup/synth.c
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
drivers/target/iscsi/iscsi_target.c
drivers/target/iscsi/iscsi_target_erl0.c
drivers/target/iscsi/iscsi_target_erl0.h
drivers/target/iscsi/iscsi_target_erl1.c
drivers/target/iscsi/iscsi_target_erl1.h
drivers/target/iscsi/iscsi_target_login.c
drivers/target/iscsi/iscsi_target_login.h
drivers/target/iscsi/iscsi_target_nego.c
drivers/target/iscsi/iscsi_target_util.c
drivers/target/iscsi/iscsi_target_util.h
drivers/tty/cyclades.c
drivers/tty/isicom.c
drivers/tty/moxa.c
drivers/tty/rocket.c
drivers/tty/vt/keyboard.c
drivers/tty/vt/vt.c
drivers/usb/misc/usbtest.c
drivers/watchdog/alim7101_wdt.c
drivers/watchdog/cpwd.c
drivers/watchdog/lpc18xx_wdt.c
drivers/watchdog/machzwd.c
drivers/watchdog/mixcomwd.c
drivers/watchdog/sbc60xxwdt.c
drivers/watchdog/sc520_wdt.c
drivers/watchdog/via_wdt.c
drivers/watchdog/w83877f_wdt.c
drivers/xen/grant-table.c
fs/ncpfs/inode.c
fs/ncpfs/ncp_fs_sb.h
fs/ncpfs/sock.c
fs/pstore/platform.c
include/linux/ide.h
include/linux/kthread.h
include/linux/ktime.h
include/linux/parport.h
include/linux/rtc.h
include/linux/time.h
include/linux/time32.h [new file with mode: 0644]
include/linux/time64.h
include/linux/timekeeper_internal.h
include/linux/timekeeping.h
include/linux/timekeeping32.h [new file with mode: 0644]
include/linux/timer.h
include/linux/workqueue.h
include/scsi/libfcoe.h
include/scsi/libsas.h
kernel/irq/spurious.c
kernel/kthread.c
kernel/rcu/rcutorture.c
kernel/rcu/tree_plugin.h
kernel/time/Kconfig
kernel/time/clockevents.c
kernel/time/ntp.c
kernel/time/ntp_internal.h
kernel/time/posix-stubs.c
kernel/time/tick-oneshot.c
kernel/time/time.c
kernel/time/timekeeping.c
kernel/time/timekeeping.h
kernel/time/timer.c
kernel/workqueue.c
lib/random32.c
net/atm/mpc.c
net/decnet/dn_route.c
net/ipv6/ip6_flowlabel.c
net/netfilter/ipvs/ip_vs_conn.c
net/netfilter/ipvs/ip_vs_ctl.c
net/netfilter/ipvs/ip_vs_est.c
net/netfilter/ipvs/ip_vs_lblc.c
net/netfilter/ipvs/ip_vs_lblcr.c
net/netrom/nr_loopback.c
security/keys/gc.c
sound/oss/midibuf.c
sound/oss/soundcard.c
sound/oss/sys_timer.c
sound/oss/uart6850.c

index 6ca6b9e582a0e803ee85ef15972448a5be2cfda5..d740989eb56981cbce66e2cd6930481d452f1f97 100644 (file)
@@ -20,16 +20,16 @@ Required Properties:
                (CMT1 on sh73a0 and r8a7740)
                This is a fallback for the above renesas,cmt-48-* entries.
 
-    - "renesas,cmt0-r8a73a4" for the 32-bit CMT0 device included in r8a73a4.
-    - "renesas,cmt1-r8a73a4" for the 48-bit CMT1 device included in r8a73a4.
-    - "renesas,cmt0-r8a7790" for the 32-bit CMT0 device included in r8a7790.
-    - "renesas,cmt1-r8a7790" for the 48-bit CMT1 device included in r8a7790.
-    - "renesas,cmt0-r8a7791" for the 32-bit CMT0 device included in r8a7791.
-    - "renesas,cmt1-r8a7791" for the 48-bit CMT1 device included in r8a7791.
-    - "renesas,cmt0-r8a7793" for the 32-bit CMT0 device included in r8a7793.
-    - "renesas,cmt1-r8a7793" for the 48-bit CMT1 device included in r8a7793.
-    - "renesas,cmt0-r8a7794" for the 32-bit CMT0 device included in r8a7794.
-    - "renesas,cmt1-r8a7794" for the 48-bit CMT1 device included in r8a7794.
+    - "renesas,r8a73a4-cmt0" for the 32-bit CMT0 device included in r8a73a4.
+    - "renesas,r8a73a4-cmt1" for the 48-bit CMT1 device included in r8a73a4.
+    - "renesas,r8a7790-cmt0" for the 32-bit CMT0 device included in r8a7790.
+    - "renesas,r8a7790-cmt1" for the 48-bit CMT1 device included in r8a7790.
+    - "renesas,r8a7791-cmt0" for the 32-bit CMT0 device included in r8a7791.
+    - "renesas,r8a7791-cmt1" for the 48-bit CMT1 device included in r8a7791.
+    - "renesas,r8a7793-cmt0" for the 32-bit CMT0 device included in r8a7793.
+    - "renesas,r8a7793-cmt1" for the 48-bit CMT1 device included in r8a7793.
+    - "renesas,r8a7794-cmt0" for the 32-bit CMT0 device included in r8a7794.
+    - "renesas,r8a7794-cmt1" for the 48-bit CMT1 device included in r8a7794.
 
     - "renesas,rcar-gen2-cmt0" for 32-bit CMT0 devices included in R-Car Gen2.
     - "renesas,rcar-gen2-cmt1" for 48-bit CMT1 devices included in R-Car Gen2.
@@ -46,7 +46,7 @@ Required Properties:
 Example: R8A7790 (R-Car H2) CMT0 and CMT1 nodes
 
        cmt0: timer@ffca0000 {
-               compatible = "renesas,cmt0-r8a7790", "renesas,rcar-gen2-cmt0";
+               compatible = "renesas,r8a7790-cmt0", "renesas,rcar-gen2-cmt0";
                reg = <0 0xffca0000 0 0x1004>;
                interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
                             <0 142 IRQ_TYPE_LEVEL_HIGH>;
@@ -55,7 +55,7 @@ Example: R8A7790 (R-Car H2) CMT0 and CMT1 nodes
        };
 
        cmt1: timer@e6130000 {
-               compatible = "renesas,cmt1-r8a7790", "renesas,rcar-gen2-cmt1";
+               compatible = "renesas,r8a7790-cmt1", "renesas,rcar-gen2-cmt1";
                reg = <0 0xe6130000 0 0x1004>;
                interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
                             <0 121 IRQ_TYPE_LEVEL_HIGH>,
index 29aa89a1837bcd089db9388180cc19fb68324562..170d46bd569244a3b9f6aa74450bff2a8b16cc71 100644 (file)
@@ -3450,7 +3450,8 @@ M:        Thomas Gleixner <tglx@linutronix.de>
 L:     linux-kernel@vger.kernel.org
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/core
 S:     Supported
-F:     drivers/clocksource
+F:     drivers/clocksource/
+F:     Documentation/devicetree/bindings/timer/
 
 CMPC ACPI DRIVER
 M:     Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
index 96a3d73ef4bf43eeab172bd5c3df4457b7023931..e7b350f18f5f82b993f36e5f1f258c3e58836c16 100644 (file)
@@ -136,19 +136,14 @@ struct pci_ops dc21285_ops = {
 static struct timer_list serr_timer;
 static struct timer_list perr_timer;
 
-static void dc21285_enable_error(unsigned long __data)
+static void dc21285_enable_error(struct timer_list *timer)
 {
-       switch (__data) {
-       case IRQ_PCI_SERR:
-               del_timer(&serr_timer);
-               break;
-
-       case IRQ_PCI_PERR:
-               del_timer(&perr_timer);
-               break;
-       }
+       del_timer(timer);
 
-       enable_irq(__data);
+       if (timer == &serr_timer)
+               enable_irq(IRQ_PCI_SERR);
+       else if (timer == &perr_timer)
+               enable_irq(IRQ_PCI_PERR);
 }
 
 /*
@@ -323,13 +318,8 @@ void __init dc21285_preinit(void)
                *CSR_PCICMD = (*CSR_PCICMD & 0xffff) | PCICMD_ERROR_BITS;
        }
 
-       init_timer(&serr_timer);
-       init_timer(&perr_timer);
-
-       serr_timer.data = IRQ_PCI_SERR;
-       serr_timer.function = dc21285_enable_error;
-       perr_timer.data = IRQ_PCI_PERR;
-       perr_timer.function = dc21285_enable_error;
+       timer_setup(&serr_timer, dc21285_enable_error, 0);
+       timer_setup(&perr_timer, dc21285_enable_error, 0);
 
        /*
         * We don't care if these fail.
index db488ecc98b54ea6f832bcba1b5e45d4edafd4f0..19839bba7f17e0092d682bb284d10c496073ada7 100644 (file)
@@ -175,7 +175,7 @@ static int power_button_countdown;
 #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
 
 static void dsmg600_power_handler(unsigned long data);
-static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
+static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler);
 
 static void dsmg600_power_handler(unsigned long data)
 {
index 1b8170d65c748c06f4f300057b11706785701f1c..b6d73124131727ce2923d1c990ba33d684be0eb5 100644 (file)
@@ -198,7 +198,7 @@ static int power_button_countdown;
 #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
 
 static void nas100d_power_handler(unsigned long data);
-static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0);
+static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler);
 
 static void nas100d_power_handler(unsigned long data)
 {
index d6159f8ef0c245405d5b0c00d32497562f280a05..df45682e99a54e0b44d4c34cd2632e7b7f78c358 100644 (file)
@@ -381,14 +381,11 @@ static struct pxafb_mach_info sharp_lm8v31 = {
 
 #define        MMC_POLL_RATE           msecs_to_jiffies(1000)
 
-static void lubbock_mmc_poll(unsigned long);
 static irq_handler_t mmc_detect_int;
+static void *mmc_detect_int_data;
+static struct timer_list mmc_timer;
 
-static struct timer_list mmc_timer = {
-       .function       = lubbock_mmc_poll,
-};
-
-static void lubbock_mmc_poll(unsigned long data)
+static void lubbock_mmc_poll(struct timer_list *unused)
 {
        unsigned long flags;
 
@@ -401,7 +398,7 @@ static void lubbock_mmc_poll(unsigned long data)
        if (LUB_IRQ_SET_CLR & (1 << 0))
                mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
        else {
-               (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data);
+               (void) mmc_detect_int(LUBBOCK_SD_IRQ, mmc_detect_int_data);
                enable_irq(LUBBOCK_SD_IRQ);
        }
 }
@@ -421,8 +418,8 @@ static int lubbock_mci_init(struct device *dev,
 {
        /* detect card insert/eject */
        mmc_detect_int = detect_int;
-       init_timer(&mmc_timer);
-       mmc_timer.data = (unsigned long) data;
+       mmc_detect_int_data = data;
+       timer_setup(&mmc_timer, lubbock_mmc_poll, 0);
        return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
                           0, "lubbock-sd-detect", data);
 }
index 249b7bd5fbc4cf1c2b4b94dbb7a163f9b62a9b39..398ba9ba26327c9cb415282ca94bfb88802dbebf 100644 (file)
@@ -341,7 +341,7 @@ static void sharpsl_charge_toggle(struct work_struct *private_)
        sharpsl_pm.charge_start_time = jiffies;
 }
 
-static void sharpsl_ac_timer(unsigned long data)
+static void sharpsl_ac_timer(struct timer_list *unused)
 {
        int acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
 
@@ -366,7 +366,7 @@ static irqreturn_t sharpsl_ac_isr(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-static void sharpsl_chrg_full_timer(unsigned long data)
+static void sharpsl_chrg_full_timer(struct timer_list *unused)
 {
        dev_dbg(sharpsl_pm.dev, "Charge Full at time: %lx\n", jiffies);
 
@@ -841,9 +841,9 @@ static int sharpsl_pm_probe(struct platform_device *pdev)
        sharpsl_pm.charge_mode = CHRG_OFF;
        sharpsl_pm.flags = 0;
 
-       setup_timer(&sharpsl_pm.ac_timer, sharpsl_ac_timer, 0UL);
+       timer_setup(&sharpsl_pm.ac_timer, sharpsl_ac_timer, 0);
 
-       setup_timer(&sharpsl_pm.chrg_full_timer, sharpsl_chrg_full_timer, 0UL);
+       timer_setup(&sharpsl_pm.chrg_full_timer, sharpsl_chrg_full_timer, 0);
 
        led_trigger_register_simple("sharpsl-charge", &sharpsl_charge_led_trigger);
 
index cc6c4dbf53af47b3faed582db57de62d32837a46..cd71ab5faf627f4f744150e05cb053f85b2bb10a 100644 (file)
@@ -17,6 +17,8 @@
 #include <asm/sn/types.h>
 #include <asm/sn/shub_mmr.h>
 
+struct nodepda_s;
+
 #define IBCT_NOTIFY             (0x1UL << 4)
 #define IBCT_ZFIL_MODE          (0x1UL << 0)
 
@@ -210,7 +212,7 @@ struct bteinfo_s {
  */
 extern bte_result_t bte_copy(u64, u64, u64, u64, void *);
 extern bte_result_t bte_unaligned_copy(u64, u64, u64, u64);
-extern void bte_error_handler(unsigned long);
+extern void bte_error_handler(struct nodepda_s *);
 
 #define bte_zero(dest, len, mode, notification) \
        bte_copy(0, dest, len, ((mode) | BTE_ZERO_FILL), notification)
index 555b11180156086bd394389b1036bac8e5be995b..6115464d5f03d3f8a62d1d7593a2c355eecaa516 100644 (file)
@@ -1513,7 +1513,7 @@ ia64_mca_cmc_int_caller(int cmc_irq, void *arg)
  *
  */
 static void
-ia64_mca_cmc_poll (unsigned long dummy)
+ia64_mca_cmc_poll (struct timer_list *unused)
 {
        /* Trigger a CMC interrupt cascade  */
        platform_send_ipi(cpumask_first(cpu_online_mask), IA64_CMCP_VECTOR,
@@ -1590,7 +1590,7 @@ ia64_mca_cpe_int_caller(int cpe_irq, void *arg)
  *
  */
 static void
-ia64_mca_cpe_poll (unsigned long dummy)
+ia64_mca_cpe_poll (struct timer_list *unused)
 {
        /* Trigger a CPE interrupt cascade  */
        platform_send_ipi(cpumask_first(cpu_online_mask), IA64_CPEP_VECTOR,
@@ -2098,7 +2098,7 @@ ia64_mca_late_init(void)
                return 0;
 
        /* Setup the CMCI/P vector and handler */
-       setup_timer(&cmc_poll_timer, ia64_mca_cmc_poll, 0UL);
+       timer_setup(&cmc_poll_timer, ia64_mca_cmc_poll, 0);
 
        /* Unmask/enable the vector */
        cmc_polling_enabled = 0;
@@ -2109,7 +2109,7 @@ ia64_mca_late_init(void)
 #ifdef CONFIG_ACPI
        /* Setup the CPEI/P vector and handler */
        cpe_vector = acpi_request_vector(ACPI_INTERRUPT_CPEI);
-       setup_timer(&cpe_poll_timer, ia64_mca_cpe_poll, 0UL);
+       timer_setup(&cpe_poll_timer, ia64_mca_cpe_poll, 0);
 
        {
                unsigned int irq;
index 63dc9cdc95c53827d2df180c4c115bc5c290585e..52c404b08904cce1802d100896c9a036dae41230 100644 (file)
@@ -263,7 +263,7 @@ salinfo_timeout_check(struct salinfo_data *data)
 }
 
 static void
-salinfo_timeout (unsigned long arg)
+salinfo_timeout(struct timer_list *unused)
 {
        ia64_mlogbuf_dump();
        salinfo_timeout_check(salinfo_data + SAL_INFO_TYPE_MCA);
@@ -623,9 +623,8 @@ salinfo_init(void)
 
        *sdir++ = salinfo_dir;
 
-       init_timer(&salinfo_timer);
+       timer_setup(&salinfo_timer, salinfo_timeout, 0);
        salinfo_timer.expires = jiffies + SALINFO_TIMER_DELAY;
-       salinfo_timer.function = &salinfo_timeout;
        add_timer(&salinfo_timer);
 
        i = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "ia64/salinfo:online",
index b2eb48490754225196824eac6b9825118ead7ecc..9146192b86f5532e44b681a807fe77fa84d55223 100644 (file)
@@ -219,7 +219,7 @@ retry_bteop:
                                BTE_LNSTAT_LOAD(bte), *bte->most_rcnt_na) );
                        bte->bte_error_count++;
                        bte->bh_error = IBLS_ERROR;
-                       bte_error_handler((unsigned long)NODEPDA(bte->bte_cnode));
+                       bte_error_handler(NODEPDA(bte->bte_cnode));
                        *bte->most_rcnt_na = BTE_WORD_AVAILABLE;
                        goto retry_bteop;
                }
@@ -414,6 +414,12 @@ EXPORT_SYMBOL(bte_unaligned_copy);
  * Block Transfer Engine initialization functions.
  *
  ***********************************************************************/
+static void bte_recovery_timeout(struct timer_list *t)
+{
+       struct nodepda_s *nodepda = from_timer(nodepda, t, bte_recovery_timer);
+
+       bte_error_handler(nodepda);
+}
 
 /*
  * bte_init_node(nodepda, cnode)
@@ -436,9 +442,7 @@ void bte_init_node(nodepda_t * mynodepda, cnodeid_t cnode)
         * will point at this one bte_recover structure to get the lock.
         */
        spin_lock_init(&mynodepda->bte_recovery_lock);
-       init_timer(&mynodepda->bte_recovery_timer);
-       mynodepda->bte_recovery_timer.function = bte_error_handler;
-       mynodepda->bte_recovery_timer.data = (unsigned long)mynodepda;
+       timer_setup(&mynodepda->bte_recovery_timer, bte_recovery_timeout, 0);
 
        for (i = 0; i < BTES_PER_NODE; i++) {
                u64 *base_addr;
index 4cb09f3f1efc636b9090adcfd2fe80e07e278760..d92786c09b344d05ff048979d24597787cae4e57 100644 (file)
  * transfers to be queued.
  */
 
-void bte_error_handler(unsigned long);
-
 /*
  * Wait until all BTE related CRBs are completed
  * and then reset the interfaces.
  */
-int shub1_bte_error_handler(unsigned long _nodepda)
+static int shub1_bte_error_handler(struct nodepda_s *err_nodepda)
 {
-       struct nodepda_s *err_nodepda = (struct nodepda_s *)_nodepda;
        struct timer_list *recovery_timer = &err_nodepda->bte_recovery_timer;
        nasid_t nasid;
        int i;
@@ -131,9 +128,8 @@ int shub1_bte_error_handler(unsigned long _nodepda)
  * Wait until all BTE related CRBs are completed
  * and then reset the interfaces.
  */
-int shub2_bte_error_handler(unsigned long _nodepda)
+static int shub2_bte_error_handler(struct nodepda_s *err_nodepda)
 {
-       struct nodepda_s *err_nodepda = (struct nodepda_s *)_nodepda;
        struct timer_list *recovery_timer = &err_nodepda->bte_recovery_timer;
        struct bteinfo_s *bte;
        nasid_t nasid;
@@ -170,9 +166,8 @@ int shub2_bte_error_handler(unsigned long _nodepda)
  * Wait until all BTE related CRBs are completed
  * and then reset the interfaces.
  */
-void bte_error_handler(unsigned long _nodepda)
+void bte_error_handler(struct nodepda_s *err_nodepda)
 {
-       struct nodepda_s *err_nodepda = (struct nodepda_s *)_nodepda;
        spinlock_t *recovery_lock = &err_nodepda->bte_recovery_lock;
        int i;
        unsigned long irq_flags;
@@ -199,12 +194,12 @@ void bte_error_handler(unsigned long _nodepda)
        }
 
        if (is_shub1()) {
-               if (shub1_bte_error_handler(_nodepda)) {
+               if (shub1_bte_error_handler(err_nodepda)) {
                        spin_unlock_irqrestore(recovery_lock, irq_flags);
                        return;
                }
        } else {
-               if (shub2_bte_error_handler(_nodepda)) {
+               if (shub2_bte_error_handler(err_nodepda)) {
                        spin_unlock_irqrestore(recovery_lock, irq_flags);
                        return;
                }
@@ -255,6 +250,6 @@ bte_crb_error_handler(cnodeid_t cnode, int btenum,
 
        BTE_PRINTK(("Got an error on cnode %d bte %d: HW error type 0x%x\n",
                bte->bte_cnode, bte->bte_num, ioe->ie_errortype));
-       bte_error_handler((unsigned long) NODEPDA(cnode));
+       bte_error_handler(NODEPDA(cnode));
 }
 
index f925dec2da920461069fa72537021f1c43594c37..97fa56dddf50ab23c22d94e74cd6b7ce9fb151c0 100644 (file)
@@ -50,7 +50,7 @@ static irqreturn_t hub_eint_handler(int irq, void *arg)
                        if ((int)ret_stuff.v0)
                                panic("%s: Fatal TIO Error", __func__);
                } else
-                       bte_error_handler((unsigned long)NODEPDA(nasid_to_cnodeid(nasid)));
+                       bte_error_handler(NODEPDA(nasid_to_cnodeid(nasid)));
 
        return IRQ_HANDLED;
 }
index 5b799d4deb747c481f3ad7a47d1c75374fa92715..bc3bd930c74cf9003acb60f53c43f19390d61ce0 100644 (file)
@@ -72,7 +72,7 @@ static void sn_cpei_handler(int irq, void *devid, struct pt_regs *regs)
        ia64_sn_plat_cpei_handler();
 }
 
-static void sn_cpei_timer_handler(unsigned long dummy)
+static void sn_cpei_timer_handler(struct timer_list *unused)
 {
        sn_cpei_handler(-1, NULL, NULL);
        mod_timer(&sn_cpei_timer, jiffies + CPEI_INTERVAL);
@@ -80,9 +80,8 @@ static void sn_cpei_timer_handler(unsigned long dummy)
 
 void sn_init_cpei_timer(void)
 {
-       init_timer(&sn_cpei_timer);
+       timer_setup(&sn_cpei_timer, sn_cpei_timer_handler, 0);
        sn_cpei_timer.expires = jiffies + CPEI_INTERVAL;
-       sn_cpei_timer.function = sn_cpei_timer_handler;
        add_timer(&sn_cpei_timer);
 }
 
index 90a60d758f8b95f9ce637fbcd045723f0c482a44..a23f48181fd6a4c39fa672bc9c2757ffd18e384b 100644 (file)
@@ -66,7 +66,7 @@ void __init amiga_init_sound(void)
 }
 
 static void nosound( unsigned long ignored );
-static DEFINE_TIMER(sound_timer, nosound, 0, 0);
+static DEFINE_TIMER(sound_timer, nosound);
 
 void amiga_mksound( unsigned int hz, unsigned int ticks )
 {
index fa2b9604fd24331415a0e8d29250028ff4216b43..d176686496410a5131047d02d345b40b8e4065b2 100644 (file)
@@ -57,7 +57,7 @@ static void ( *mac_special_bell )( unsigned int, unsigned int, unsigned int );
 /*
  * our timer to start/continue/stop the bell
  */
-static DEFINE_TIMER(mac_sound_timer, mac_nosound, 0, 0);
+static DEFINE_TIMER(mac_sound_timer, mac_nosound);
 
 /*
  * Sort of initialize the sound chip (called from mac_mksound on the first
index d4f807191ecd74694075ba3ca2748ff0b80bcbb1..063de44675cefbd256dde16690f6070fac0725f7 100644 (file)
@@ -36,10 +36,10 @@ void mips_display_message(const char *str)
        }
 }
 
-static void scroll_display_message(unsigned long data);
-static DEFINE_TIMER(mips_scroll_timer, scroll_display_message, HZ, 0);
+static void scroll_display_message(unsigned long unused);
+static DEFINE_TIMER(mips_scroll_timer, scroll_display_message);
 
-static void scroll_display_message(unsigned long data)
+static void scroll_display_message(unsigned long unused)
 {
        mips_display_message(&display_string[display_count++]);
        if (display_count == max_display_count)
index 03a39ac5ead92e50d53cb4b0046686a568b68842..c374f3ceec38cf6ae5040e16665521ea69cefecf 100644 (file)
@@ -38,6 +38,7 @@
 #define PANIC_FREQ             (HZ / 8)
 
 static struct timer_list power_timer, blink_timer, debounce_timer;
+static unsigned long blink_timer_timeout;
 
 #define MACHINE_PANICED                1
 #define MACHINE_SHUTTING_DOWN  2
@@ -81,21 +82,21 @@ static void __noreturn sgi_machine_halt(void)
        ArcEnterInteractiveMode();
 }
 
-static void power_timeout(unsigned long data)
+static void power_timeout(struct timer_list *unused)
 {
        sgi_machine_power_off();
 }
 
-static void blink_timeout(unsigned long data)
+static void blink_timeout(struct timer_list *unused)
 {
        /* XXX fix this for fullhouse  */
        sgi_ioc_reset ^= (SGIOC_RESET_LC0OFF|SGIOC_RESET_LC1OFF);
        sgioc->reset = sgi_ioc_reset;
 
-       mod_timer(&blink_timer, jiffies + data);
+       mod_timer(&blink_timer, jiffies + blink_timer_timeout);
 }
 
-static void debounce(unsigned long data)
+static void debounce(struct timer_list *unused)
 {
        del_timer(&debounce_timer);
        if (sgint->istat1 & SGINT_ISTAT1_PWR) {
@@ -128,11 +129,10 @@ static inline void power_button(void)
        }
 
        machine_state |= MACHINE_SHUTTING_DOWN;
-       blink_timer.data = POWERDOWN_FREQ;
-       blink_timeout(POWERDOWN_FREQ);
+       blink_timer_timeout = POWERDOWN_FREQ;
+       blink_timeout(&blink_timer);
 
-       init_timer(&power_timer);
-       power_timer.function = power_timeout;
+       timer_setup(&power_timer, power_timeout, 0);
        power_timer.expires = jiffies + POWERDOWN_TIMEOUT * HZ;
        add_timer(&power_timer);
 }
@@ -147,8 +147,7 @@ static irqreturn_t panel_int(int irq, void *dev_id)
        if (sgint->istat1 & SGINT_ISTAT1_PWR) {
                /* Wait until interrupt goes away */
                disable_irq_nosync(SGI_PANEL_IRQ);
-               init_timer(&debounce_timer);
-               debounce_timer.function = debounce;
+               timer_setup(&debounce_timer, debounce, 0);
                debounce_timer.expires = jiffies + 5;
                add_timer(&debounce_timer);
        }
@@ -171,8 +170,8 @@ static int panic_event(struct notifier_block *this, unsigned long event,
                return NOTIFY_DONE;
        machine_state |= MACHINE_PANICED;
 
-       blink_timer.data = PANIC_FREQ;
-       blink_timeout(PANIC_FREQ);
+       blink_timer_timeout = PANIC_FREQ;
+       blink_timeout(&blink_timer);
 
        return NOTIFY_DONE;
 }
@@ -195,8 +194,7 @@ static int __init reboot_setup(void)
                return res;
        }
 
-       init_timer(&blink_timer);
-       blink_timer.function = blink_timeout;
+       timer_setup(&blink_timer, blink_timeout, 0);
        atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
 
        return 0;
index b3b442def42383794289c6c07ea9a44ee5c4a873..20d8637340be40b4b96aa09f9c5f4b6d61436273 100644 (file)
@@ -38,6 +38,7 @@
 extern struct platform_device ip32_rtc_device;
 
 static struct timer_list power_timer, blink_timer;
+static unsigned long blink_timer_timeout;
 static int has_panicked, shutting_down;
 
 static __noreturn void ip32_poweroff(void *data)
@@ -71,11 +72,11 @@ static void ip32_machine_restart(char *cmd)
        unreachable();
 }
 
-static void blink_timeout(unsigned long data)
+static void blink_timeout(struct timer_list *unused)
 {
        unsigned long led = mace->perif.ctrl.misc ^ MACEISA_LED_RED;
        mace->perif.ctrl.misc = led;
-       mod_timer(&blink_timer, jiffies + data);
+       mod_timer(&blink_timer, jiffies + blink_timer_timeout);
 }
 
 static void ip32_machine_halt(void)
@@ -83,7 +84,7 @@ static void ip32_machine_halt(void)
        ip32_poweroff(&ip32_rtc_device);
 }
 
-static void power_timeout(unsigned long data)
+static void power_timeout(struct timer_list *unused)
 {
        ip32_poweroff(&ip32_rtc_device);
 }
@@ -99,11 +100,10 @@ void ip32_prepare_poweroff(void)
        }
 
        shutting_down = 1;
-       blink_timer.data = POWERDOWN_FREQ;
-       blink_timeout(POWERDOWN_FREQ);
+       blink_timer_timeout = POWERDOWN_FREQ;
+       blink_timeout(&blink_timer);
 
-       init_timer(&power_timer);
-       power_timer.function = power_timeout;
+       timer_setup(&power_timer, power_timeout, 0);
        power_timer.expires = jiffies + POWERDOWN_TIMEOUT * HZ;
        add_timer(&power_timer);
 }
@@ -121,8 +121,8 @@ static int panic_event(struct notifier_block *this, unsigned long event,
        led = mace->perif.ctrl.misc | MACEISA_LED_GREEN;
        mace->perif.ctrl.misc = led;
 
-       blink_timer.data = PANIC_FREQ;
-       blink_timeout(PANIC_FREQ);
+       blink_timer_timeout = PANIC_FREQ;
+       blink_timeout(&blink_timer);
 
        return NOTIFY_DONE;
 }
@@ -143,8 +143,7 @@ static __init int ip32_reboot_setup(void)
        _machine_halt = ip32_machine_halt;
        pm_power_off = ip32_machine_halt;
 
-       init_timer(&blink_timer);
-       blink_timer.function = blink_timeout;
+       timer_setup(&blink_timer, blink_timeout, 0);
        atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
 
        return 0;
index 10a5ae9553fd657211524e4af5257958815e134a..27a2dd616a7d1732dc27dc332fcbd162375a7caf 100644 (file)
@@ -92,7 +92,7 @@ static int pdc_console_setup(struct console *co, char *options)
 #define PDC_CONS_POLL_DELAY (30 * HZ / 1000)
 
 static void pdc_console_poll(unsigned long unused);
-static DEFINE_TIMER(pdc_console_timer, pdc_console_poll, 0, 0);
+static DEFINE_TIMER(pdc_console_timer, pdc_console_poll);
 static struct tty_port tty_port;
 
 static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
index 57190f384f633e75170cff96dffc26fa540ef976..1d89163d67f2b5449d02bf683e6bc872df31f1a0 100644 (file)
@@ -262,9 +262,8 @@ static void wd_timer_reset(unsigned int cpu, struct timer_list *t)
        add_timer_on(t, cpu);
 }
 
-static void wd_timer_fn(unsigned long data)
+static void wd_timer_fn(struct timer_list *t)
 {
-       struct timer_list *t = this_cpu_ptr(&wd_timer);
        int cpu = smp_processor_id();
 
        watchdog_timer_interrupt(cpu);
@@ -288,7 +287,7 @@ static void start_watchdog_timer_on(unsigned int cpu)
 
        per_cpu(wd_timer_tb, cpu) = get_tb();
 
-       setup_pinned_timer(t, wd_timer_fn, 0);
+       timer_setup(t, wd_timer_fn, TIMER_PINNED);
        wd_timer_reset(cpu, t);
 }
 
index a51df9ef529d9356cb54c75721510e50cfa69b8d..73016451f33005844ad13b31f22a31011ccaccaa 100644 (file)
@@ -1452,7 +1452,7 @@ static void topology_schedule_update(void)
        schedule_work(&topology_work);
 }
 
-static void topology_timer_fn(unsigned long ignored)
+static void topology_timer_fn(struct timer_list *unused)
 {
        if (prrn_enabled && cpumask_weight(&cpu_associativity_changes_mask))
                topology_schedule_update();
@@ -1462,14 +1462,11 @@ static void topology_timer_fn(unsigned long ignored)
                reset_topology_timer();
        }
 }
-static struct timer_list topology_timer =
-       TIMER_INITIALIZER(topology_timer_fn, 0, 0);
+static struct timer_list topology_timer;
 
 static void reset_topology_timer(void)
 {
-       topology_timer.data = 0;
-       topology_timer.expires = jiffies + 60 * HZ;
-       mod_timer(&topology_timer, topology_timer.expires);
+       mod_timer(&topology_timer, jiffies + 60 * HZ);
 }
 
 #ifdef CONFIG_SMP
@@ -1529,7 +1526,8 @@ int start_topology_update(void)
                        prrn_enabled = 0;
                        vphn_enabled = 1;
                        setup_cpu_associativity_change_counters();
-                       init_timer_deferrable(&topology_timer);
+                       timer_setup(&topology_timer, topology_timer_fn,
+                                   TIMER_DEFERRABLE);
                        reset_topology_timer();
                }
        }
index ae7dff110054fd33d1c231feae3eab27933b0748..bf9622f0e6b16aa291037d880f8ffe3ec75c1046 100644 (file)
@@ -153,14 +153,13 @@ static void lgr_timer_set(void);
 /*
  * LGR timer callback
  */
-static void lgr_timer_fn(unsigned long ignored)
+static void lgr_timer_fn(struct timer_list *unused)
 {
        lgr_info_log();
        lgr_timer_set();
 }
 
-static struct timer_list lgr_timer =
-       TIMER_DEFERRED_INITIALIZER(lgr_timer_fn, 0, 0);
+static struct timer_list lgr_timer;
 
 /*
  * Setup next LGR timer
@@ -181,6 +180,7 @@ static int __init lgr_init(void)
        debug_register_view(lgr_dbf, &debug_hex_ascii_view);
        lgr_info_get(&lgr_info_last);
        debug_event(lgr_dbf, 1, &lgr_info_last, sizeof(lgr_info_last));
+       timer_setup(&lgr_timer, lgr_timer_fn, TIMER_DEFERRABLE);
        lgr_timer_set();
        return 0;
 }
index ed0bdd220e1a643788655fbefaef328dd38c7951..d7ece9888c29d4336e561c8094a6e4b37ee12fa8 100644 (file)
@@ -320,15 +320,14 @@ static void topology_flush_work(void)
        flush_work(&topology_work);
 }
 
-static void topology_timer_fn(unsigned long ignored)
+static void topology_timer_fn(struct timer_list *unused)
 {
        if (ptf(PTF_CHECK))
                topology_schedule_update();
        set_topology_timer();
 }
 
-static struct timer_list topology_timer =
-       TIMER_DEFERRED_INITIALIZER(topology_timer_fn, 0, 0);
+static struct timer_list topology_timer;
 
 static atomic_t topology_poll = ATOMIC_INIT(0);
 
@@ -597,6 +596,7 @@ static struct ctl_table topology_dir_table[] = {
 
 static int __init topology_init(void)
 {
+       timer_setup(&topology_timer, topology_timer_fn, TIMER_DEFERRABLE);
        if (MACHINE_HAS_TOPOLOGY)
                set_topology_timer();
        else
index 829c63dbc81af344d816bf2183d937d9f1cd4724..2dbdcd85b68f200762846ce0c59dc39438d0f9e0 100644 (file)
@@ -56,7 +56,7 @@ static DEFINE_SPINLOCK(cmm_lock);
 
 static struct task_struct *cmm_thread_ptr;
 static DECLARE_WAIT_QUEUE_HEAD(cmm_thread_wait);
-static DEFINE_TIMER(cmm_timer, NULL, 0, 0);
+static DEFINE_TIMER(cmm_timer, NULL);
 
 static void cmm_timer_fn(unsigned long);
 static void cmm_set_timer(void);
index e278bf52963b58e834ca21015ac59c2a84fe6ec0..519f5ba7ed7e7e61609c3f4d2ed20d9fc56a23ba 100644 (file)
@@ -31,19 +31,20 @@ static inline void led_toggle(void)
 }
 
 static struct timer_list led_blink_timer;
+static unsigned long led_blink_timer_timeout;
 
-static void led_blink(unsigned long timeout)
+static void led_blink(struct timer_list *unused)
 {
+       unsigned long timeout = led_blink_timer_timeout;
+
        led_toggle();
 
        /* reschedule */
        if (!timeout) { /* blink according to load */
                led_blink_timer.expires = jiffies +
                        ((1 + (avenrun[0] >> FSHIFT)) * HZ);
-               led_blink_timer.data = 0;
        } else { /* blink at user specified interval */
                led_blink_timer.expires = jiffies + (timeout * HZ);
-               led_blink_timer.data = timeout;
        }
        add_timer(&led_blink_timer);
 }
@@ -88,9 +89,11 @@ static ssize_t led_proc_write(struct file *file, const char __user *buffer,
        } else if (!strcmp(buf, "toggle")) {
                led_toggle();
        } else if ((*buf > '0') && (*buf <= '9')) {
-               led_blink(simple_strtoul(buf, NULL, 10));
+               led_blink_timer_timeout = simple_strtoul(buf, NULL, 10);
+               led_blink(&led_blink_timer);
        } else if (!strcmp(buf, "load")) {
-               led_blink(0);
+               led_blink_timer_timeout = 0;
+               led_blink(&led_blink_timer);
        } else {
                auxio_set_led(AUXIO_LED_OFF);
        }
@@ -115,8 +118,7 @@ static struct proc_dir_entry *led;
 
 static int __init led_init(void)
 {
-       init_timer(&led_blink_timer);
-       led_blink_timer.function = led_blink;
+       timer_setup(&led_blink_timer, led_blink, 0);
 
        led = proc_create("led", 0, NULL, &led_proc_fops);
        if (!led)
index 5286a4a92cf78dced0613577828a2d7cef17fee5..35c461f218153019b49825898379582718b099b6 100644 (file)
@@ -898,10 +898,9 @@ static void calioc2_dump_error_regs(struct iommu_table *tbl)
               PHB_ROOT_COMPLEX_STATUS);
 }
 
-static void calgary_watchdog(unsigned long data)
+static void calgary_watchdog(struct timer_list *t)
 {
-       struct pci_dev *dev = (struct pci_dev *)data;
-       struct iommu_table *tbl = pci_iommu(dev->bus);
+       struct iommu_table *tbl = from_timer(tbl, t, watchdog_timer);
        void __iomem *bbar = tbl->bbar;
        u32 val32;
        void __iomem *target;
@@ -1016,8 +1015,7 @@ static void __init calgary_enable_translation(struct pci_dev *dev)
        writel(cpu_to_be32(val32), target);
        readl(target); /* flush */
 
-       setup_timer(&tbl->watchdog_timer, &calgary_watchdog,
-                   (unsigned long)dev);
+       timer_setup(&tbl->watchdog_timer, calgary_watchdog, 0);
        mod_timer(&tbl->watchdog_timer, jiffies);
 }
 
index 0140a22551c84155e083abaeed8ee15f39ebc3d3..464c2684c4f15fd04bd84760a3c14642a87373f6 100644 (file)
@@ -47,15 +47,14 @@ static char *serial_name = "ISS serial driver";
  * initialization for the tty structure.
  */
 
-static void rs_poll(unsigned long);
+static void rs_poll(struct timer_list *);
 
 static int rs_open(struct tty_struct *tty, struct file * filp)
 {
        tty->port = &serial_port;
        spin_lock_bh(&timer_lock);
        if (tty->count == 1) {
-               setup_timer(&serial_timer, rs_poll,
-                               (unsigned long)&serial_port);
+               timer_setup(&serial_timer, rs_poll, 0);
                mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE);
        }
        spin_unlock_bh(&timer_lock);
@@ -92,9 +91,9 @@ static int rs_write(struct tty_struct * tty,
        return count;
 }
 
-static void rs_poll(unsigned long priv)
+static void rs_poll(struct timer_list *unused)
 {
-       struct tty_port *port = (struct tty_port *)priv;
+       struct tty_port *port = &serial_port;
        int i = 0;
        int rd = 1;
        unsigned char c;
index 66a5d15a9e0e27b613a0fa4694b46f96aaadf9d1..6363b18e5b8c457fbe2f95932ed4d16f722da905 100644 (file)
@@ -349,9 +349,9 @@ static int iss_net_poll(void)
 }
 
 
-static void iss_net_timer(unsigned long priv)
+static void iss_net_timer(struct timer_list *t)
 {
-       struct iss_net_private *lp = (struct iss_net_private *)priv;
+       struct iss_net_private *lp = from_timer(lp, t, timer);
 
        iss_net_poll();
        spin_lock(&lp->lock);
@@ -386,10 +386,8 @@ static int iss_net_open(struct net_device *dev)
        spin_unlock_bh(&opened_lock);
        spin_lock_bh(&lp->lock);
 
-       init_timer(&lp->timer);
+       timer_setup(&lp->timer, iss_net_timer, 0);
        lp->timer_val = ISS_NET_TIMER_VALUE;
-       lp->timer.data = (unsigned long) lp;
-       lp->timer.function = iss_net_timer;
        mod_timer(&lp->timer, jiffies + lp->timer_val);
 
 out:
@@ -482,7 +480,7 @@ static int iss_net_change_mtu(struct net_device *dev, int new_mtu)
        return -EINVAL;
 }
 
-void iss_net_user_timer_expire(unsigned long _conn)
+void iss_net_user_timer_expire(struct timer_list *unused)
 {
 }
 
@@ -582,8 +580,7 @@ static int iss_net_configure(int index, char *init)
                return 1;
        }
 
-       init_timer(&lp->tl);
-       lp->tl.function = iss_net_user_timer_expire;
+       timer_setup(&lp->tl, iss_net_user_timer_expire, 0);
 
        return 0;
 
index 3c3a37b8503bd43db4200230309ddeff96eb4e00..ebaa51ba8a225ef14108854bfe21d151293c2269 100644 (file)
@@ -774,9 +774,9 @@ static void ghes_add_timer(struct ghes *ghes)
        add_timer(&ghes->timer);
 }
 
-static void ghes_poll_func(unsigned long data)
+static void ghes_poll_func(struct timer_list *t)
 {
-       struct ghes *ghes = (void *)data;
+       struct ghes *ghes = from_timer(ghes, t, timer);
 
        ghes_proc(ghes);
        if (!(ghes->flags & GHES_EXITING))
@@ -1147,8 +1147,7 @@ static int ghes_probe(struct platform_device *ghes_dev)
 
        switch (generic->notify.type) {
        case ACPI_HEST_NOTIFY_POLLED:
-               setup_deferrable_timer(&ghes->timer, ghes_poll_func,
-                                      (unsigned long)ghes);
+               timer_setup(&ghes->timer, ghes_poll_func, TIMER_DEFERRABLE);
                ghes_add_timer(ghes);
                break;
        case ACPI_HEST_NOTIFY_EXTERNAL:
index 8b61123d2c3c1cd55489feb389b68735077219d5..749fd94441b034104bc9ac87738785c43337c876 100644 (file)
@@ -303,6 +303,7 @@ struct ahci_em_priv {
        unsigned long saved_activity;
        unsigned long activity;
        unsigned long led_state;
+       struct ata_link *link;
 };
 
 struct ahci_port_priv {
index 3e286d86ab42acbc54c84488e74ffc37f13dff65..a0de7a38430c954b31c7b4e6e01a790ee98e85c2 100644 (file)
@@ -968,12 +968,12 @@ static void ahci_sw_activity(struct ata_link *link)
                mod_timer(&emp->timer, jiffies + msecs_to_jiffies(10));
 }
 
-static void ahci_sw_activity_blink(unsigned long arg)
+static void ahci_sw_activity_blink(struct timer_list *t)
 {
-       struct ata_link *link = (struct ata_link *)arg;
+       struct ahci_em_priv *emp = from_timer(emp, t, timer);
+       struct ata_link *link = emp->link;
        struct ata_port *ap = link->ap;
-       struct ahci_port_priv *pp = ap->private_data;
-       struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
+
        unsigned long led_message = emp->led_state;
        u32 activity_led_state;
        unsigned long flags;
@@ -1020,7 +1020,8 @@ static void ahci_init_sw_activity(struct ata_link *link)
 
        /* init activity stats, setup timer */
        emp->saved_activity = emp->activity = 0;
-       setup_timer(&emp->timer, ahci_sw_activity_blink, (unsigned long)link);
+       emp->link = link;
+       timer_setup(&emp->timer, ahci_sw_activity_blink, 0);
 
        /* check our blink policy and set flag for link if it's enabled */
        if (emp->blink_policy)
index ee4c1ec9dca0ef9e51f4abf56924aab2112d9f77..b8ac4902d3122d138e050511648e6c7a81b7c938 100644 (file)
@@ -5979,9 +5979,8 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
        INIT_LIST_HEAD(&ap->eh_done_q);
        init_waitqueue_head(&ap->eh_wait_q);
        init_completion(&ap->park_req_pending);
-       setup_deferrable_timer(&ap->fastdrain_timer,
-                              ata_eh_fastdrain_timerfn,
-                              (unsigned long)ap);
+       timer_setup(&ap->fastdrain_timer, ata_eh_fastdrain_timerfn,
+                   TIMER_DEFERRABLE);
 
        ap->cbl = ATA_CBL_NONE;
 
index e4effef0c83f2bcea57bf5dda123b1c8ce4ed939..ece6fd91a947674f6f9c8cb46e46f5c4c22a1a86 100644 (file)
@@ -879,9 +879,9 @@ static int ata_eh_nr_in_flight(struct ata_port *ap)
        return nr;
 }
 
-void ata_eh_fastdrain_timerfn(unsigned long arg)
+void ata_eh_fastdrain_timerfn(struct timer_list *t)
 {
-       struct ata_port *ap = (void *)arg;
+       struct ata_port *ap = from_timer(ap, t, fastdrain_timer);
        unsigned long flags;
        int cnt;
 
index 839d487394b7be5ed8966c25571f75fe5b16a8b5..08a245b76417b14aec139f1b2f94833d7443002e 100644 (file)
@@ -154,7 +154,7 @@ extern void ata_internal_cmd_timed_out(struct ata_device *dev, u8 cmd);
 extern void ata_eh_acquire(struct ata_port *ap);
 extern void ata_eh_release(struct ata_port *ap);
 extern void ata_scsi_error(struct Scsi_Host *host);
-extern void ata_eh_fastdrain_timerfn(unsigned long arg);
+extern void ata_eh_fastdrain_timerfn(struct timer_list *t);
 extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc);
 extern void ata_dev_disable(struct ata_device *dev);
 extern void ata_eh_detach_dev(struct ata_device *dev);
index d781b3f87693855b0b8d07634ab07d11f868669b..909744eb7bab419eec2dc71e2c79c87231812ce3 100644 (file)
@@ -49,8 +49,8 @@ static void idt77105_stats_timer_func(unsigned long);
 static void idt77105_restart_timer_func(unsigned long);
 
 
-static DEFINE_TIMER(stats_timer, idt77105_stats_timer_func, 0, 0);
-static DEFINE_TIMER(restart_timer, idt77105_restart_timer_func, 0, 0);
+static DEFINE_TIMER(stats_timer, idt77105_stats_timer_func);
+static DEFINE_TIMER(restart_timer, idt77105_restart_timer_func);
 static int start_timer = 1;
 static struct idt77105_priv *idt77105_all = NULL;
 
index a785c6e697579579e2009a1a1cdc32eeae5bcca4..12f646760b6827e3ddf8a63290cfb22a08e51d0b 100644 (file)
@@ -76,7 +76,7 @@ static IADEV *ia_dev[8];
 static struct atm_dev *_ia_dev[8];
 static int iadev_count;
 static void ia_led_timer(unsigned long arg);
-static DEFINE_TIMER(ia_timer, ia_led_timer, 0, 0);
+static DEFINE_TIMER(ia_timer, ia_led_timer);
 static int IA_TX_BUF = DFL_TX_BUFFERS, IA_TX_BUF_SZ = DFL_TX_BUF_SZ;
 static int IA_RX_BUF = DFL_RX_BUFFERS, IA_RX_BUF_SZ = DFL_RX_BUF_SZ;
 static uint IADebugFlag = /* IF_IADBG_ERR | IF_IADBG_CBR| IF_IADBG_INIT_ADAPTER
index a9020f82eea7139dbc0e3961c20c4e32f40dbb3a..db040b37822448fb75d1598d8d3a2657e9835644 100644 (file)
@@ -229,9 +229,9 @@ MODULE_DEVICE_TABLE(of, img_ascii_lcd_matches);
  * Scroll the current message along the LCD by one character, rearming the
  * timer if required.
  */
-static void img_ascii_lcd_scroll(unsigned long arg)
+static void img_ascii_lcd_scroll(struct timer_list *t)
 {
-       struct img_ascii_lcd_ctx *ctx = (struct img_ascii_lcd_ctx *)arg;
+       struct img_ascii_lcd_ctx *ctx = from_timer(ctx, t, timer);
        unsigned int i, ch = ctx->scroll_pos;
        unsigned int num_chars = ctx->cfg->num_chars;
 
@@ -299,7 +299,7 @@ static int img_ascii_lcd_display(struct img_ascii_lcd_ctx *ctx,
        ctx->scroll_pos = 0;
 
        /* update the LCD */
-       img_ascii_lcd_scroll((unsigned long)ctx);
+       img_ascii_lcd_scroll(&ctx->timer);
 
        return 0;
 }
@@ -395,9 +395,7 @@ static int img_ascii_lcd_probe(struct platform_device *pdev)
        ctx->scroll_rate = HZ / 2;
 
        /* initialise a timer for scrolling the message */
-       init_timer(&ctx->timer);
-       ctx->timer.function = img_ascii_lcd_scroll;
-       ctx->timer.data = (unsigned long)ctx;
+       timer_setup(&ctx->timer, img_ascii_lcd_scroll, 0);
 
        platform_set_drvdata(pdev, ctx);
 
index 6911acd896d935946b3c805d07c88bc03bf41918..ea7869c0d7f9f638ffb33f61d7b2b7437cd3bf41 100644 (file)
@@ -1396,7 +1396,7 @@ static void panel_process_inputs(void)
        }
 }
 
-static void panel_scan_timer(void)
+static void panel_scan_timer(struct timer_list *unused)
 {
        if (keypad.enabled && keypad_initialized) {
                if (spin_trylock_irq(&pprt_lock)) {
@@ -1421,7 +1421,7 @@ static void init_scan_timer(void)
        if (scan_timer.function)
                return;         /* already started */
 
-       setup_timer(&scan_timer, (void *)&panel_scan_timer, 0);
+       timer_setup(&scan_timer, panel_scan_timer, 0);
        scan_timer.expires = jiffies + INPUT_POLL_TIME;
        add_timer(&scan_timer);
 }
index 770b1539a083d111ba1a65b569d3a75eaa81dd38..ae47b2ec84b47ddfc7ef5d0f562025b515514349 100644 (file)
@@ -478,9 +478,9 @@ struct dpm_watchdog {
  * There's not much we can do here to recover so panic() to
  * capture a crash-dump in pstore.
  */
-static void dpm_watchdog_handler(unsigned long data)
+static void dpm_watchdog_handler(struct timer_list *t)
 {
-       struct dpm_watchdog *wd = (void *)data;
+       struct dpm_watchdog *wd = from_timer(wd, t, timer);
 
        dev_emerg(wd->dev, "**** DPM device timeout ****\n");
        show_stack(wd->tsk, NULL);
@@ -500,11 +500,9 @@ static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
        wd->dev = dev;
        wd->tsk = current;
 
-       init_timer_on_stack(timer);
+       timer_setup_on_stack(timer, dpm_watchdog_handler, 0);
        /* use same timeout value for both suspend and resume */
        timer->expires = jiffies + HZ * CONFIG_DPM_WATCHDOG_TIMEOUT;
-       timer->function = dpm_watchdog_handler;
-       timer->data = (unsigned long)wd;
        add_timer(timer);
 }
 
index 49908c74bfcb0fae9eb30f84d969a4c520192e39..4e3fb9f104aff36a575828d17d72cabf5ed5ea00 100644 (file)
@@ -323,7 +323,7 @@ static void fd_deselect (int drive)
 
 }
 
-static void motor_on_callback(unsigned long nr)
+static void motor_on_callback(unsigned long ignored)
 {
        if (!(ciaa.pra & DSKRDY) || --on_attempts == 0) {
                complete_all(&motor_on_completion);
@@ -344,7 +344,6 @@ static int fd_motor_on(int nr)
                fd_select(nr);
 
                reinit_completion(&motor_on_completion);
-               motor_on_timer.data = nr;
                mod_timer(&motor_on_timer, jiffies + HZ/2);
 
                on_attempts = 10;
index 4b987c2fefbe5ececb3ded4002c3075167a3082c..25148206697775f3444d677b29302a35e0fe5a04 100644 (file)
@@ -15,49 +15,19 @@ MODULE_AUTHOR("Sam Hopkins <sah@coraid.com>");
 MODULE_DESCRIPTION("AoE block/char driver for 2.6.2 and newer 2.6 kernels");
 MODULE_VERSION(VERSION);
 
-enum { TINIT, TRUN, TKILL };
+static struct timer_list timer;
 
-static void
-discover_timer(ulong vp)
+static void discover_timer(struct timer_list *t)
 {
-       static struct timer_list t;
-       static volatile ulong die;
-       static spinlock_t lock;
-       ulong flags;
-       enum { DTIMERTICK = HZ * 60 }; /* one minute */
-
-       switch (vp) {
-       case TINIT:
-               init_timer(&t);
-               spin_lock_init(&lock);
-               t.data = TRUN;
-               t.function = discover_timer;
-               die = 0;
-       case TRUN:
-               spin_lock_irqsave(&lock, flags);
-               if (!die) {
-                       t.expires = jiffies + DTIMERTICK;
-                       add_timer(&t);
-               }
-               spin_unlock_irqrestore(&lock, flags);
-
-               aoecmd_cfg(0xffff, 0xff);
-               return;
-       case TKILL:
-               spin_lock_irqsave(&lock, flags);
-               die = 1;
-               spin_unlock_irqrestore(&lock, flags);
+       mod_timer(t, jiffies + HZ * 60); /* one minute */
 
-               del_timer_sync(&t);
-       default:
-               return;
-       }
+       aoecmd_cfg(0xffff, 0xff);
 }
 
 static void
 aoe_exit(void)
 {
-       discover_timer(TKILL);
+       del_timer_sync(&timer);
 
        aoenet_exit();
        unregister_blkdev(AOE_MAJOR, DEVICE_NAME);
@@ -93,7 +63,9 @@ aoe_init(void)
                goto blkreg_fail;
        }
        printk(KERN_INFO "aoe: AoE v%s initialised.\n", VERSION);
-       discover_timer(TINIT);
+
+       timer_setup(&timer, discover_timer, 0);
+       discover_timer(&timer);
        return 0;
  blkreg_fail:
        aoecmd_exit();
index 92da886180aa10a994e01139c53d94130672343c..ae596e55bcb67c18594477b7f8b27ec02d82fcc6 100644 (file)
@@ -373,10 +373,10 @@ static void floppy_release(struct gendisk *disk, fmode_t mode);
 
 /************************* End of Prototypes **************************/
 
-static DEFINE_TIMER(motor_off_timer, fd_motor_off_timer, 0, 0);
-static DEFINE_TIMER(readtrack_timer, fd_readtrack_check, 0, 0);
-static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0);
-static DEFINE_TIMER(fd_timer, check_change, 0, 0);
+static DEFINE_TIMER(motor_off_timer, fd_motor_off_timer);
+static DEFINE_TIMER(readtrack_timer, fd_readtrack_check);
+static DEFINE_TIMER(timeout_timer, fd_times_out);
+static DEFINE_TIMER(fd_timer, check_change);
        
 static void fd_end_request_cur(blk_status_t err)
 {
index 7e8589ce631c72d9e023abb63cbe5680938c8f49..06ecee1b528ec1b457cc04124d34626eb3477878 100644 (file)
@@ -1551,8 +1551,8 @@ extern int w_restart_disk_io(struct drbd_work *, int);
 extern int w_send_out_of_sync(struct drbd_work *, int);
 extern int w_start_resync(struct drbd_work *, int);
 
-extern void resync_timer_fn(unsigned long data);
-extern void start_resync_timer_fn(unsigned long data);
+extern void resync_timer_fn(struct timer_list *t);
+extern void start_resync_timer_fn(struct timer_list *t);
 
 extern void drbd_endio_write_sec_final(struct drbd_peer_request *peer_req);
 
index 8cb3791898ae935065f5581aec1dec3a46290988..4b4697a1f96386831fc764276545c03ebf18d6eb 100644 (file)
@@ -64,7 +64,7 @@
 static DEFINE_MUTEX(drbd_main_mutex);
 static int drbd_open(struct block_device *bdev, fmode_t mode);
 static void drbd_release(struct gendisk *gd, fmode_t mode);
-static void md_sync_timer_fn(unsigned long data);
+static void md_sync_timer_fn(struct timer_list *t);
 static int w_bitmap_io(struct drbd_work *w, int unused);
 
 MODULE_AUTHOR("Philipp Reisner <phil@linbit.com>, "
@@ -2023,14 +2023,10 @@ void drbd_init_set_defaults(struct drbd_device *device)
        device->unplug_work.cb  = w_send_write_hint;
        device->bm_io_work.w.cb = w_bitmap_io;
 
-       setup_timer(&device->resync_timer, resync_timer_fn,
-                       (unsigned long)device);
-       setup_timer(&device->md_sync_timer, md_sync_timer_fn,
-                       (unsigned long)device);
-       setup_timer(&device->start_resync_timer, start_resync_timer_fn,
-                       (unsigned long)device);
-       setup_timer(&device->request_timer, request_timer_fn,
-                       (unsigned long)device);
+       timer_setup(&device->resync_timer, resync_timer_fn, 0);
+       timer_setup(&device->md_sync_timer, md_sync_timer_fn, 0);
+       timer_setup(&device->start_resync_timer, start_resync_timer_fn, 0);
+       timer_setup(&device->request_timer, request_timer_fn, 0);
 
        init_waitqueue_head(&device->misc_wait);
        init_waitqueue_head(&device->state_wait);
@@ -3721,9 +3717,9 @@ int drbd_md_test_flag(struct drbd_backing_dev *bdev, int flag)
        return (bdev->md.flags & flag) != 0;
 }
 
-static void md_sync_timer_fn(unsigned long data)
+static void md_sync_timer_fn(struct timer_list *t)
 {
-       struct drbd_device *device = (struct drbd_device *) data;
+       struct drbd_device *device = from_timer(device, t, md_sync_timer);
        drbd_device_post_work(device, MD_SYNC);
 }
 
index 796eaf347dc096fb8e56b860c1b530c9cf9da8a2..cb2fa63f6bc057e7038ef3ef7ae9b7c4a2a63711 100644 (file)
@@ -5056,7 +5056,7 @@ static int drbd_disconnected(struct drbd_peer_device *peer_device)
        wake_up(&device->misc_wait);
 
        del_timer_sync(&device->resync_timer);
-       resync_timer_fn((unsigned long)device);
+       resync_timer_fn(&device->resync_timer);
 
        /* wait for all w_e_end_data_req, w_e_end_rsdata_req, w_send_barrier,
         * w_make_resync_request etc. which may still be on the worker queue
index de8566e5533499b6170c669a08c2aa8688e67057..a500e738d9299bb85bb911e4eb7086258f97ca21 100644 (file)
@@ -1714,9 +1714,9 @@ static bool net_timeout_reached(struct drbd_request *net_req,
  * to expire twice (worst case) to become effective. Good enough.
  */
 
-void request_timer_fn(unsigned long data)
+void request_timer_fn(struct timer_list *t)
 {
-       struct drbd_device *device = (struct drbd_device *) data;
+       struct drbd_device *device = from_timer(device, t, request_timer);
        struct drbd_connection *connection = first_peer_device(device)->connection;
        struct drbd_request *req_read, *req_write, *req_peer; /* oldest request */
        struct net_conf *nc;
index a2254f825601890fad999d9f7876b704b4a43c4d..cb97b3b30962b3bfe9cb7b5615e7977a26380d9e 100644 (file)
@@ -294,7 +294,7 @@ extern int __req_mod(struct drbd_request *req, enum drbd_req_event what,
                struct bio_and_error *m);
 extern void complete_master_bio(struct drbd_device *device,
                struct bio_and_error *m);
-extern void request_timer_fn(unsigned long data);
+extern void request_timer_fn(struct timer_list *t);
 extern void tl_restart(struct drbd_connection *connection, enum drbd_req_event what);
 extern void _tl_restart(struct drbd_connection *connection, enum drbd_req_event what);
 extern void tl_abort_disk_io(struct drbd_device *device);
index 03471b3fce86c7660617f7871bf63c78a3f6c585..1476cb3439f46e53a8f42a9397fb6b19afd8ff95 100644 (file)
@@ -457,9 +457,9 @@ int w_resync_timer(struct drbd_work *w, int cancel)
        return 0;
 }
 
-void resync_timer_fn(unsigned long data)
+void resync_timer_fn(struct timer_list *t)
 {
-       struct drbd_device *device = (struct drbd_device *) data;
+       struct drbd_device *device = from_timer(device, t, resync_timer);
 
        drbd_queue_work_if_unqueued(
                &first_peer_device(device)->connection->sender_work,
@@ -1705,9 +1705,9 @@ void drbd_rs_controller_reset(struct drbd_device *device)
        rcu_read_unlock();
 }
 
-void start_resync_timer_fn(unsigned long data)
+void start_resync_timer_fn(struct timer_list *t)
 {
-       struct drbd_device *device = (struct drbd_device *) data;
+       struct drbd_device *device = from_timer(device, t, start_resync_timer);
        drbd_device_post_work(device, RS_START);
 }
 
index 58471394beb92077617ae15b3dd80d4471c511fe..1a0385ed64171c2e62cc16c36b9a546a9bc24ed1 100644 (file)
@@ -84,7 +84,7 @@ static int dtlk_has_indexing;
 static unsigned int dtlk_portlist[] =
 {0x25e, 0x29e, 0x2de, 0x31e, 0x35e, 0x39e, 0};
 static wait_queue_head_t dtlk_process_list;
-static DEFINE_TIMER(dtlk_timer, dtlk_timer_tick, 0, 0);
+static DEFINE_TIMER(dtlk_timer, dtlk_timer_tick);
 
 /* prototypes for file_operations struct */
 static ssize_t dtlk_read(struct file *, char __user *,
index 5406b90bf626fdeea71eab3a6dab36ead644d236..5b8db2ed844d337ad51cc1868d2d34213f03dfe8 100644 (file)
@@ -124,7 +124,7 @@ static unsigned long long hangcheck_tsc, hangcheck_tsc_margin;
 
 static void hangcheck_fire(unsigned long);
 
-static DEFINE_TIMER(hangcheck_ticktock, hangcheck_fire, 0, 0);
+static DEFINE_TIMER(hangcheck_ticktock, hangcheck_fire);
 
 static void hangcheck_fire(unsigned long data)
 {
index 3c77645405e52019f01304ee2ee5c985f9a90865..71755790c32b2e7bfc8e65c614208099ce9627a1 100644 (file)
@@ -100,9 +100,9 @@ struct xgene_rng_dev {
        struct clk *clk;
 };
 
-static void xgene_rng_expired_timer(unsigned long arg)
+static void xgene_rng_expired_timer(struct timer_list *t)
 {
-       struct xgene_rng_dev *ctx = (struct xgene_rng_dev *) arg;
+       struct xgene_rng_dev *ctx = from_timer(ctx, t, failure_timer);
 
        /* Clear failure counter as timer expired */
        disable_irq(ctx->irq);
@@ -113,8 +113,6 @@ static void xgene_rng_expired_timer(unsigned long arg)
 
 static void xgene_rng_start_timer(struct xgene_rng_dev *ctx)
 {
-       ctx->failure_timer.data = (unsigned long) ctx;
-       ctx->failure_timer.function = xgene_rng_expired_timer;
        ctx->failure_timer.expires = jiffies + 120 * HZ;
        add_timer(&ctx->failure_timer);
 }
@@ -292,7 +290,7 @@ static int xgene_rng_init(struct hwrng *rng)
        struct xgene_rng_dev *ctx = (struct xgene_rng_dev *) rng->priv;
 
        ctx->failure_cnt = 0;
-       init_timer(&ctx->failure_timer);
+       timer_setup(&ctx->failure_timer, xgene_rng_expired_timer, 0);
 
        ctx->revision = readl(ctx->csr_base + RNG_EIP_REV);
 
index e6d0d271c58c83073e3acb71c788867d4edfc846..44006ed9558f20690bb71b9f96a0ca382a996d93 100644 (file)
@@ -27,7 +27,7 @@ static void button_sequence_finished (unsigned long parameters);
 
 static int button_press_count;         /* The count of button presses */
 /* Times for the end of a sequence */
-static DEFINE_TIMER(button_timer, button_sequence_finished, 0, 0);
+static DEFINE_TIMER(button_timer, button_sequence_finished);
 static DECLARE_WAIT_QUEUE_HEAD(button_wait_queue); /* Used for blocking read */
 static char button_output_buffer[32];  /* Stores data to write out of device */
 static int bcount;                     /* The number of bytes in the buffer */
index 974d48927b07768b2fce005032ef6d9ae6e5ef84..616871e68e0901e147686ca6b3028151636fa8f8 100644 (file)
@@ -137,7 +137,7 @@ static DECLARE_WAIT_QUEUE_HEAD(rtc_wait);
 #ifdef RTC_IRQ
 static void rtc_dropped_irq(unsigned long data);
 
-static DEFINE_TIMER(rtc_irq_timer, rtc_dropped_irq, 0, 0);
+static DEFINE_TIMER(rtc_irq_timer, rtc_dropped_irq);
 #endif
 
 static ssize_t rtc_read(struct file *file, char __user *buf,
index 6210bff46341e88b2eb2b19028f41004849cf2bc..8eeb4190207d1ac7ac024433f043ae59f2b0cd71 100644 (file)
@@ -184,9 +184,8 @@ static unsigned int telclk_interrupt;
 static int int_events;         /* Event that generate a interrupt */
 static int got_event;          /* if events processing have been done */
 
-static void switchover_timeout(unsigned long data);
-static struct timer_list switchover_timer =
-       TIMER_INITIALIZER(switchover_timeout , 0, 0);
+static void switchover_timeout(struct timer_list *t);
+static struct timer_list switchover_timer;
 static unsigned long tlclk_timer_data;
 
 static struct tlclk_alarms *alarm_events;
@@ -805,7 +804,7 @@ static int __init tlclk_init(void)
                goto out3;
        }
 
-       init_timer(&switchover_timer);
+       timer_setup(&switchover_timer, switchover_timeout, 0);
 
        ret = misc_register(&tlclk_miscdev);
        if (ret < 0) {
@@ -855,9 +854,9 @@ static void __exit tlclk_cleanup(void)
 
 }
 
-static void switchover_timeout(unsigned long data)
+static void switchover_timeout(struct timer_list *unused)
 {
-       unsigned long flags = *(unsigned long *) data;
+       unsigned long flags = tlclk_timer_data;
 
        if ((flags & 1)) {
                if ((inb(TLCLK_REG1) & 0x08) != (flags & 0x08))
@@ -922,7 +921,6 @@ static irqreturn_t tlclk_interrupt(int irq, void *dev_id)
                /* TIMEOUT in ~10ms */
                switchover_timer.expires = jiffies + msecs_to_jiffies(10);
                tlclk_timer_data = inb(TLCLK_REG1);
-               switchover_timer.data = (unsigned long) &tlclk_timer_data;
                mod_timer(&switchover_timer, switchover_timer.expires);
        } else {
                got_event = 1;
index cc6062049170eb0b5a8001955497ed59cfa8c639..c729a88007d0fa7b0c5132ad36dec959e396607a 100644 (file)
@@ -1,9 +1,8 @@
 menu "Clock Source drivers"
-       depends on !ARCH_USES_GETTIMEOFFSET
+       depends on GENERIC_CLOCKEVENTS
 
 config TIMER_OF
        bool
-       depends on GENERIC_CLOCKEVENTS
        select TIMER_PROBE
 
 config TIMER_ACPI
@@ -30,21 +29,18 @@ config CLKSRC_MMIO
 
 config BCM2835_TIMER
        bool "BCM2835 timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        help
          Enables the support for the BCM2835 timer driver.
 
 config BCM_KONA_TIMER
        bool "BCM mobile timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        help
          Enables the support for the BCM Kona mobile timer driver.
 
 config DIGICOLOR_TIMER
        bool "Digicolor timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        depends on HAS_IOMEM
        help
@@ -52,7 +48,6 @@ config DIGICOLOR_TIMER
 
 config DW_APB_TIMER
        bool "DW APB timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        help
          Enables the support for the dw_apb timer.
 
@@ -63,7 +58,6 @@ config DW_APB_TIMER_OF
 
 config FTTMR010_TIMER
        bool "Faraday Technology timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on HAS_IOMEM
        select CLKSRC_MMIO
        select TIMER_OF
@@ -90,7 +84,6 @@ config ARMADA_370_XP_TIMER
 
 config MESON6_TIMER
        bool "Meson6 timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        help
          Enables the support for the Meson6 timer driver.
@@ -105,14 +98,12 @@ config ORION_TIMER
 
 config OWL_TIMER
        bool "Owl timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        help
          Enables the support for the Actions Semi Owl timer driver.
 
 config SUN4I_TIMER
        bool "Sun4i timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on HAS_IOMEM
        select CLKSRC_MMIO
        select TIMER_OF
@@ -135,7 +126,6 @@ config TEGRA_TIMER
 
 config VT8500_TIMER
        bool "VT8500 timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on HAS_IOMEM
        help
          Enables support for the VT8500 driver.
@@ -148,7 +138,6 @@ config CADENCE_TTC_TIMER
 
 config ASM9260_TIMER
        bool "ASM9260 timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        select TIMER_OF
        help
@@ -171,28 +160,24 @@ config CLKSRC_NOMADIK_MTU_SCHED_CLOCK
 
 config CLKSRC_DBX500_PRCMU
        bool "Clocksource PRCMU Timer" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on HAS_IOMEM
        help
          Use the always on PRCMU Timer as clocksource
 
 config CLPS711X_TIMER
        bool "Cirrus logic timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        help
          Enables support for the Cirrus Logic PS711 timer.
 
 config ATLAS7_TIMER
        bool "Atlas7 timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        help
          Enables support for the Atlas7 timer.
 
 config MXS_TIMER
        bool "Mxs timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        select STMP_DEVICE
        help
@@ -200,14 +185,12 @@ config MXS_TIMER
 
 config PRIMA2_TIMER
        bool "Prima2 timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        help
          Enables support for the Prima2 timer.
 
 config U300_TIMER
        bool "U300 timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on ARM
        select CLKSRC_MMIO
        help
@@ -215,14 +198,12 @@ config U300_TIMER
 
 config NSPIRE_TIMER
        bool "NSpire timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        help
          Enables support for the Nspire timer.
 
 config KEYSTONE_TIMER
        bool "Keystone timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on ARM || ARM64
        select CLKSRC_MMIO
        help
@@ -230,7 +211,6 @@ config KEYSTONE_TIMER
 
 config INTEGRATOR_AP_TIMER
        bool "Integrator-ap timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        help
          Enables support for the Integrator-ap timer.
@@ -253,7 +233,7 @@ config CLKSRC_EFM32
 
 config CLKSRC_LPC32XX
        bool "Clocksource for LPC32XX" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS && HAS_IOMEM
+       depends on HAS_IOMEM
        depends on ARM
        select CLKSRC_MMIO
        select TIMER_OF
@@ -262,7 +242,7 @@ config CLKSRC_LPC32XX
 
 config CLKSRC_PISTACHIO
        bool "Clocksource for Pistachio SoC" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS && HAS_IOMEM
+       depends on HAS_IOMEM
        select TIMER_OF
        help
          Enables the clocksource for the Pistachio SoC.
@@ -298,7 +278,6 @@ config CLKSRC_MPS2
 
 config ARC_TIMERS
        bool "Support for 32-bit TIMERn counters in ARC Cores" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select TIMER_OF
        help
          These are legacy 32-bit TIMER0 and TIMER1 counters found on all ARC cores
@@ -307,7 +286,6 @@ config ARC_TIMERS
 
 config ARC_TIMERS_64BIT
        bool "Support for 64-bit counters in ARC HS38 cores" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on ARC_TIMERS
        select TIMER_OF
        help
@@ -407,7 +385,6 @@ config ATMEL_PIT
 
 config ATMEL_ST
        bool "Atmel ST timer support" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select TIMER_OF
        select MFD_SYSCON
        help
@@ -426,7 +403,6 @@ config CLKSRC_EXYNOS_MCT
 
 config CLKSRC_SAMSUNG_PWM
        bool "PWM timer driver for Samsung S3C, S5P" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on HAS_IOMEM
        help
          This is a new clocksource driver for the PWM timer found in
@@ -436,7 +412,6 @@ config CLKSRC_SAMSUNG_PWM
 
 config FSL_FTM_TIMER
        bool "Freescale FlexTimer Module driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on HAS_IOMEM
        select CLKSRC_MMIO
        help
@@ -450,7 +425,6 @@ config VF_PIT_TIMER
 
 config OXNAS_RPS_TIMER
        bool "Oxford Semiconductor OXNAS RPS Timers driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select TIMER_OF
        select CLKSRC_MMIO
        help
@@ -461,7 +435,7 @@ config SYS_SUPPORTS_SH_CMT
 
 config MTK_TIMER
        bool "Mediatek timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS && HAS_IOMEM
+       depends on HAS_IOMEM
        select TIMER_OF
        select CLKSRC_MMIO
        help
@@ -479,7 +453,6 @@ config SYS_SUPPORTS_EM_STI
 config CLKSRC_JCORE_PIT
        bool "J-Core PIT timer driver" if COMPILE_TEST
        depends on OF
-       depends on GENERIC_CLOCKEVENTS
        depends on HAS_IOMEM
        select CLKSRC_MMIO
        help
@@ -488,7 +461,6 @@ config CLKSRC_JCORE_PIT
 
 config SH_TIMER_CMT
        bool "Renesas CMT timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on HAS_IOMEM
        default SYS_SUPPORTS_SH_CMT
        help
@@ -498,7 +470,6 @@ config SH_TIMER_CMT
 
 config SH_TIMER_MTU2
        bool "Renesas MTU2 timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on HAS_IOMEM
        default SYS_SUPPORTS_SH_MTU2
        help
@@ -508,14 +479,12 @@ config SH_TIMER_MTU2
 
 config RENESAS_OSTM
        bool "Renesas OSTM timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        select CLKSRC_MMIO
        help
          Enables the support for the Renesas OSTM.
 
 config SH_TIMER_TMU
        bool "Renesas TMU timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on HAS_IOMEM
        default SYS_SUPPORTS_SH_TMU
        help
@@ -525,7 +494,7 @@ config SH_TIMER_TMU
 
 config EM_TIMER_STI
        bool "Renesas STI timer driver" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS && HAS_IOMEM
+       depends on HAS_IOMEM
        default SYS_SUPPORTS_EM_STI
        help
          This enables build of a clocksource and clockevent driver for
@@ -566,7 +535,6 @@ config CLKSRC_TANGO_XTAL
 
 config CLKSRC_PXA
        bool "Clocksource for PXA or SA-11x0 platform" if COMPILE_TEST
-       depends on GENERIC_CLOCKEVENTS
        depends on HAS_IOMEM
        select CLKSRC_MMIO
        help
@@ -575,20 +543,20 @@ config CLKSRC_PXA
 
 config H8300_TMR8
         bool "Clockevent timer for the H8300 platform" if COMPILE_TEST
-        depends on GENERIC_CLOCKEVENTS && HAS_IOMEM
+        depends on HAS_IOMEM
        help
          This enables the 8 bits timer for the H8300 platform.
 
 config H8300_TMR16
         bool "Clockevent timer for the H83069 platform" if COMPILE_TEST
-        depends on GENERIC_CLOCKEVENTS && HAS_IOMEM
+        depends on HAS_IOMEM
        help
          This enables the 16 bits timer for the H8300 platform with the
          H83069 cpu.
 
 config H8300_TPU
         bool "Clocksource for the H8300 platform" if COMPILE_TEST
-        depends on GENERIC_CLOCKEVENTS && HAS_IOMEM
+        depends on HAS_IOMEM
        help
          This enables the clocksource for the H8300 platform with the
          H8S2678 cpu.
@@ -600,7 +568,7 @@ config CLKSRC_IMX_GPT
 
 config CLKSRC_IMX_TPM
        bool "Clocksource using i.MX TPM" if COMPILE_TEST
-       depends on ARM && CLKDEV_LOOKUP && GENERIC_CLOCKEVENTS
+       depends on ARM && CLKDEV_LOOKUP
        select CLKSRC_MMIO
        help
          Enable this option to use IMX Timer/PWM Module (TPM) timer as
index fd4b7f684bd030151d388071e05a3c2cfcb5e2c4..0ecf5beb56ec91083b991f9d8bc208ee95c07d5f 100644 (file)
@@ -299,8 +299,7 @@ static u64 notrace arm64_858921_read_cntvct_el0(void)
 #endif
 
 #ifdef CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND
-DEFINE_PER_CPU(const struct arch_timer_erratum_workaround *,
-              timer_unstable_counter_workaround);
+DEFINE_PER_CPU(const struct arch_timer_erratum_workaround *, timer_unstable_counter_workaround);
 EXPORT_SYMBOL_GPL(timer_unstable_counter_workaround);
 
 DEFINE_STATIC_KEY_FALSE(arch_timer_read_ool_enabled);
@@ -1268,10 +1267,6 @@ arch_timer_mem_find_best_frame(struct arch_timer_mem *timer_mem)
 
        iounmap(cntctlbase);
 
-       if (!best_frame)
-               pr_err("Unable to find a suitable frame in timer @ %pa\n",
-                       &timer_mem->cntctlbase);
-
        return best_frame;
 }
 
@@ -1372,6 +1367,8 @@ static int __init arch_timer_mem_of_init(struct device_node *np)
 
        frame = arch_timer_mem_find_best_frame(timer_mem);
        if (!frame) {
+               pr_err("Unable to find a suitable frame in timer @ %pa\n",
+                       &timer_mem->cntctlbase);
                ret = -EINVAL;
                goto out;
        }
@@ -1420,7 +1417,7 @@ arch_timer_mem_verify_cntfrq(struct arch_timer_mem *timer_mem)
 static int __init arch_timer_mem_acpi_init(int platform_timer_count)
 {
        struct arch_timer_mem *timers, *timer;
-       struct arch_timer_mem_frame *frame;
+       struct arch_timer_mem_frame *frame, *best_frame = NULL;
        int timer_count, i, ret = 0;
 
        timers = kcalloc(platform_timer_count, sizeof(*timers),
@@ -1432,14 +1429,6 @@ static int __init arch_timer_mem_acpi_init(int platform_timer_count)
        if (ret || !timer_count)
                goto out;
 
-       for (i = 0; i < timer_count; i++) {
-               ret = arch_timer_mem_verify_cntfrq(&timers[i]);
-               if (ret) {
-                       pr_err("Disabling MMIO timers due to CNTFRQ mismatch\n");
-                       goto out;
-               }
-       }
-
        /*
         * While unlikely, it's theoretically possible that none of the frames
         * in a timer expose the combination of feature we want.
@@ -1448,12 +1437,26 @@ static int __init arch_timer_mem_acpi_init(int platform_timer_count)
                timer = &timers[i];
 
                frame = arch_timer_mem_find_best_frame(timer);
-               if (frame)
-                       break;
+               if (!best_frame)
+                       best_frame = frame;
+
+               ret = arch_timer_mem_verify_cntfrq(timer);
+               if (ret) {
+                       pr_err("Disabling MMIO timers due to CNTFRQ mismatch\n");
+                       goto out;
+               }
+
+               if (!best_frame) /* implies !frame */
+                       /*
+                        * Only complain about missing suitable frames if we
+                        * haven't already found one in a previous iteration.
+                        */
+                       pr_err("Unable to find a suitable frame in timer @ %pa\n",
+                               &timer->cntctlbase);
        }
 
-       if (frame)
-               ret = arch_timer_mem_frame_register(frame);
+       if (best_frame)
+               ret = arch_timer_mem_frame_register(best_frame);
 out:
        kfree(timers);
        return ret;
index ae3167c28b129b6c3d3cc0fbc5c4a0da1a9abacd..a04808a21d4ec9eef5d3c6d5e7ed140945d1001b 100644 (file)
@@ -39,16 +39,18 @@ static u64 notrace gic_read_count(void)
 
 static int gic_next_event(unsigned long delta, struct clock_event_device *evt)
 {
-       unsigned long flags;
+       int cpu = cpumask_first(evt->cpumask);
        u64 cnt;
        int res;
 
        cnt = gic_read_count();
        cnt += (u64)delta;
-       local_irq_save(flags);
-       write_gic_vl_other(mips_cm_vp_id(cpumask_first(evt->cpumask)));
-       write_gic_vo_compare(cnt);
-       local_irq_restore(flags);
+       if (cpu == raw_smp_processor_id()) {
+               write_gic_vl_compare(cnt);
+       } else {
+               write_gic_vl_other(mips_cm_vp_id(cpu));
+               write_gic_vo_compare(cnt);
+       }
        res = ((int)(gic_read_count() - cnt) >= 0) ? -ETIME : 0;
        return res;
 }
index d19c53c11094c20e31f08ffc125c3f8b83c0f780..c686305650797a8b75b2e7f5be4a2ec568d84c28 100644 (file)
@@ -125,7 +125,7 @@ static int __init owl_timer_init(struct device_node *node)
 
        owl_timer_base = of_io_request_and_map(node, 0, "owl-timer");
        if (IS_ERR(owl_timer_base)) {
-               pr_err("Can't map timer registers");
+               pr_err("Can't map timer registers\n");
                return PTR_ERR(owl_timer_base);
        }
 
@@ -134,7 +134,7 @@ static int __init owl_timer_init(struct device_node *node)
 
        timer1_irq = of_irq_get_byname(node, "timer1");
        if (timer1_irq <= 0) {
-               pr_err("Can't parse timer1 IRQ");
+               pr_err("Can't parse timer1 IRQ\n");
                return -EINVAL;
        }
 
index c27f4c850d83c6bbd82ba60da1140f3fee0e8ed0..33f370dbd0d62f533a0ce0fa2b1c1d674968f677 100644 (file)
@@ -274,7 +274,7 @@ static int __init rk_clksrc_init(struct device_node *np)
                TIMER_NAME, rk_clksrc->freq, 250, 32,
                clocksource_mmio_readl_down);
        if (ret) {
-               pr_err("Failed to register clocksource");
+               pr_err("Failed to register clocksource\n");
                goto out_clocksource;
        }
 
index e09e8bf0bb9bf53680ea50aebff431aa76f6078a..70b3cf8e23d01bd80caf92859171df39b3e171ff 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
@@ -39,16 +40,16 @@ struct sh_cmt_device;
  * SoC but also on the particular instance. The following table lists the main
  * characteristics of those flavours.
  *
- *                     16B     32B     32B-F   48B     48B-2
+ *                     16B     32B     32B-F   48B     R-Car Gen2
  * -----------------------------------------------------------------------------
  * Channels            2       1/4     1       6       2/8
  * Control Width       16      16      16      16      32
  * Counter Width       16      32      32      32/48   32/48
  * Shared Start/Stop   Y       Y       Y       Y       N
  *
- * The 48-bit gen2 version has a per-channel start/stop register located in the
- * channel registers block. All other versions have a shared start/stop register
- * located in the global space.
+ * The r8a73a4 / R-Car Gen2 version has a per-channel start/stop register
+ * located in the channel registers block. All other versions have a shared
+ * start/stop register located in the global space.
  *
  * Channels are indexed from 0 to N-1 in the documentation. The channel index
  * infers the start/stop bit position in the control register and the channel
@@ -66,14 +67,16 @@ struct sh_cmt_device;
 enum sh_cmt_model {
        SH_CMT_16BIT,
        SH_CMT_32BIT,
-       SH_CMT_32BIT_FAST,
        SH_CMT_48BIT,
-       SH_CMT_48BIT_GEN2,
+       SH_CMT0_RCAR_GEN2,
+       SH_CMT1_RCAR_GEN2,
 };
 
 struct sh_cmt_info {
        enum sh_cmt_model model;
 
+       unsigned int channels_mask;
+
        unsigned long width; /* 16 or 32 bit version of hardware block */
        unsigned long overflow_bit;
        unsigned long clear_bits;
@@ -200,18 +203,20 @@ static const struct sh_cmt_info sh_cmt_info[] = {
                .read_count = sh_cmt_read32,
                .write_count = sh_cmt_write32,
        },
-       [SH_CMT_32BIT_FAST] = {
-               .model = SH_CMT_32BIT_FAST,
+       [SH_CMT_48BIT] = {
+               .model = SH_CMT_48BIT,
+               .channels_mask = 0x3f,
                .width = 32,
                .overflow_bit = SH_CMT32_CMCSR_CMF,
                .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF),
-               .read_control = sh_cmt_read16,
-               .write_control = sh_cmt_write16,
+               .read_control = sh_cmt_read32,
+               .write_control = sh_cmt_write32,
                .read_count = sh_cmt_read32,
                .write_count = sh_cmt_write32,
        },
-       [SH_CMT_48BIT] = {
-               .model = SH_CMT_48BIT,
+       [SH_CMT0_RCAR_GEN2] = {
+               .model = SH_CMT0_RCAR_GEN2,
+               .channels_mask = 0x60,
                .width = 32,
                .overflow_bit = SH_CMT32_CMCSR_CMF,
                .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF),
@@ -220,8 +225,9 @@ static const struct sh_cmt_info sh_cmt_info[] = {
                .read_count = sh_cmt_read32,
                .write_count = sh_cmt_write32,
        },
-       [SH_CMT_48BIT_GEN2] = {
-               .model = SH_CMT_48BIT_GEN2,
+       [SH_CMT1_RCAR_GEN2] = {
+               .model = SH_CMT1_RCAR_GEN2,
+               .channels_mask = 0xff,
                .width = 32,
                .overflow_bit = SH_CMT32_CMCSR_CMF,
                .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF),
@@ -859,6 +865,7 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index,
        ch->cmt = cmt;
        ch->index = index;
        ch->hwidx = hwidx;
+       ch->timer_bit = hwidx;
 
        /*
         * Compute the address of the channel control register block. For the
@@ -873,16 +880,11 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index,
        case SH_CMT_48BIT:
                ch->ioctrl = cmt->mapbase + 0x10 + ch->hwidx * 0x10;
                break;
-       case SH_CMT_32BIT_FAST:
-               /*
-                * The 32-bit "fast" timer has a single channel at hwidx 5 but
-                * is located at offset 0x40 instead of 0x60 for some reason.
-                */
-               ch->ioctrl = cmt->mapbase + 0x40;
-               break;
-       case SH_CMT_48BIT_GEN2:
+       case SH_CMT0_RCAR_GEN2:
+       case SH_CMT1_RCAR_GEN2:
                ch->iostart = cmt->mapbase + ch->hwidx * 0x100;
                ch->ioctrl = ch->iostart + 0x10;
+               ch->timer_bit = 0;
                break;
        }
 
@@ -894,8 +896,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index,
        ch->match_value = ch->max_match_value;
        raw_spin_lock_init(&ch->lock);
 
-       ch->timer_bit = cmt->info->model == SH_CMT_48BIT_GEN2 ? 0 : ch->hwidx;
-
        ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev),
                              clockevent, clocksource);
        if (ret) {
@@ -935,22 +935,18 @@ static const struct platform_device_id sh_cmt_id_table[] = {
 MODULE_DEVICE_TABLE(platform, sh_cmt_id_table);
 
 static const struct of_device_id sh_cmt_of_table[] __maybe_unused = {
-       { .compatible = "renesas,cmt-32", .data = &sh_cmt_info[SH_CMT_32BIT] },
-       { .compatible = "renesas,cmt-32-fast", .data = &sh_cmt_info[SH_CMT_32BIT_FAST] },
        { .compatible = "renesas,cmt-48", .data = &sh_cmt_info[SH_CMT_48BIT] },
-       { .compatible = "renesas,cmt-48-gen2", .data = &sh_cmt_info[SH_CMT_48BIT_GEN2] },
+       {
+               /* deprecated, preserved for backward compatibility */
+               .compatible = "renesas,cmt-48-gen2",
+               .data = &sh_cmt_info[SH_CMT0_RCAR_GEN2]
+       },
+       { .compatible = "renesas,rcar-gen2-cmt0", .data = &sh_cmt_info[SH_CMT0_RCAR_GEN2] },
+       { .compatible = "renesas,rcar-gen2-cmt1", .data = &sh_cmt_info[SH_CMT1_RCAR_GEN2] },
        { }
 };
 MODULE_DEVICE_TABLE(of, sh_cmt_of_table);
 
-static int sh_cmt_parse_dt(struct sh_cmt_device *cmt)
-{
-       struct device_node *np = cmt->pdev->dev.of_node;
-
-       return of_property_read_u32(np, "renesas,channels-mask",
-                                   &cmt->hw_channels);
-}
-
 static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 {
        unsigned int mask;
@@ -961,14 +957,8 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
        raw_spin_lock_init(&cmt->lock);
 
        if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
-               const struct of_device_id *id;
-
-               id = of_match_node(sh_cmt_of_table, pdev->dev.of_node);
-               cmt->info = id->data;
-
-               ret = sh_cmt_parse_dt(cmt);
-               if (ret < 0)
-                       return ret;
+               cmt->info = of_device_get_match_data(&pdev->dev);
+               cmt->hw_channels = cmt->info->channels_mask;
        } else if (pdev->dev.platform_data) {
                struct sh_timer_config *cfg = pdev->dev.platform_data;
                const struct platform_device_id *id = pdev->id_entry;
index cdf23b62868820adf8463a2ac494d96fea6cd905..c020038ebfab2242ed844a143f3ce6706985685c 100644 (file)
@@ -264,14 +264,14 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
 
        fttmr010->base = of_iomap(np, 0);
        if (!fttmr010->base) {
-               pr_err("Can't remap registers");
+               pr_err("Can't remap registers\n");
                ret = -ENXIO;
                goto out_free;
        }
        /* IRQ for timer 1 */
        irq = irq_of_parse_and_map(np, 0);
        if (irq <= 0) {
-               pr_err("Can't parse IRQ");
+               pr_err("Can't parse IRQ\n");
                ret = -EINVAL;
                goto out_unmap;
        }
index c79122d8e10d0b9abd8f5428ceb00d049fa20d05..7c64a5c1bfc13bb536bdefc1f3dab53273e315fb 100644 (file)
@@ -176,3 +176,15 @@ out_fail:
                timer_base_exit(&to->of_base);
        return ret;
 }
+
+void timer_of_exit(struct timer_of *to)
+{
+       if (to->flags & TIMER_OF_IRQ)
+               timer_irq_exit(&to->of_irq);
+
+       if (to->flags & TIMER_OF_CLOCK)
+               timer_clk_exit(&to->of_clk);
+
+       if (to->flags & TIMER_OF_BASE)
+               timer_base_exit(&to->of_base);
+}
index c6d995ab93d59959fe4a54d0a753a07be58bc05c..43f5ba3f8979d9005c09247f5cb87583bef773bf 100644 (file)
@@ -67,4 +67,7 @@ static inline unsigned long timer_of_period(struct timer_of *to)
 
 extern int __init timer_of_init(struct device_node *np,
                                struct timer_of *to);
+
+extern void timer_of_exit(struct timer_of *to);
+
 #endif
index 3ff5160451b436ec48511a9428ab611b2291b1f9..b6d7c4c98d0ab67a3d141c0cc8360d722863d388 100644 (file)
@@ -90,6 +90,7 @@ struct global_pstate_info {
        int last_gpstate_idx;
        spinlock_t gpstate_lock;
        struct timer_list timer;
+       struct cpufreq_policy *policy;
 };
 
 static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1];
@@ -625,10 +626,10 @@ static inline void  queue_gpstate_timer(struct global_pstate_info *gpstates)
  * according quadratic equation. Queues a new timer if it is still not equal
  * to local pstate
  */
-void gpstate_timer_handler(unsigned long data)
+void gpstate_timer_handler(struct timer_list *t)
 {
-       struct cpufreq_policy *policy = (struct cpufreq_policy *)data;
-       struct global_pstate_info *gpstates = policy->driver_data;
+       struct global_pstate_info *gpstates = from_timer(gpstates, t, timer);
+       struct cpufreq_policy *policy = gpstates->policy;
        int gpstate_idx, lpstate_idx;
        unsigned long val;
        unsigned int time_diff = jiffies_to_msecs(jiffies)
@@ -800,9 +801,9 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
        policy->driver_data = gpstates;
 
        /* initialize timer */
-       init_timer_pinned_deferrable(&gpstates->timer);
-       gpstates->timer.data = (unsigned long)policy;
-       gpstates->timer.function = gpstate_timer_handler;
+       gpstates->policy = policy;
+       timer_setup(&gpstates->timer, gpstate_timer_handler,
+                   TIMER_PINNED | TIMER_DEFERRABLE);
        gpstates->timer.expires = jiffies +
                                msecs_to_jiffies(GPSTATE_TIMER_INTERVAL);
        spin_lock_init(&gpstates->gpstate_lock);
index 0f9754e077191e07f3ad985ad2897822f99a932c..456278440863b7b170bd7037e4a4eca9a122fdad 100644 (file)
@@ -2072,9 +2072,9 @@ static void artpec6_crypto_process_queue(struct artpec6_crypto *ac)
                del_timer(&ac->timer);
 }
 
-static void artpec6_crypto_timeout(unsigned long data)
+static void artpec6_crypto_timeout(struct timer_list *t)
 {
-       struct artpec6_crypto *ac = (struct artpec6_crypto *) data;
+       struct artpec6_crypto *ac = from_timer(ac, t, timer);
 
        dev_info_ratelimited(artpec6_crypto_dev, "timeout\n");
 
@@ -3063,7 +3063,7 @@ static int artpec6_crypto_probe(struct platform_device *pdev)
        spin_lock_init(&ac->queue_lock);
        INIT_LIST_HEAD(&ac->queue);
        INIT_LIST_HEAD(&ac->pending);
-       setup_timer(&ac->timer, artpec6_crypto_timeout, (unsigned long) ac);
+       timer_setup(&ac->timer, artpec6_crypto_timeout, 0);
 
        ac->base = base;
 
index bf25f415eea659862478283eef4cd190173a8a45..0eb2706f23c898932f01438d9bf8b5cb3c3585a6 100644 (file)
@@ -149,7 +149,7 @@ struct mv_req_hash_ctx {
        int count_add;
 };
 
-static void mv_completion_timer_callback(unsigned long unused)
+static void mv_completion_timer_callback(struct timer_list *unused)
 {
        int active = readl(cpg->reg + SEC_ACCEL_CMD) & SEC_CMD_EN_SEC_ACCL0;
 
@@ -167,7 +167,7 @@ static void mv_completion_timer_callback(unsigned long unused)
 
 static void mv_setup_timer(void)
 {
-       setup_timer(&cpg->completion_timer, &mv_completion_timer_callback, 0);
+       timer_setup(&cpg->completion_timer, mv_completion_timer_callback, 0);
        mod_timer(&cpg->completion_timer,
                        jiffies + msecs_to_jiffies(MV_CESA_EXPIRE));
 }
index b6f14844702e0c866037c0079539fdfc09be9753..5a6dc53b2b9db221e0e006391ee78e0f32a2e180 100644 (file)
@@ -1125,9 +1125,9 @@ static irqreturn_t spacc_spacc_irq(int irq, void *dev)
        return IRQ_HANDLED;
 }
 
-static void spacc_packet_timeout(unsigned long data)
+static void spacc_packet_timeout(struct timer_list *t)
 {
-       struct spacc_engine *engine = (struct spacc_engine *)data;
+       struct spacc_engine *engine = from_timer(engine, t, packet_timeout);
 
        spacc_process_done(engine);
 }
@@ -1714,8 +1714,7 @@ static int spacc_probe(struct platform_device *pdev)
        writel(SPA_IRQ_EN_STAT_EN | SPA_IRQ_EN_GLBL_EN,
               engine->regs + SPA_IRQ_EN_REG_OFFSET);
 
-       setup_timer(&engine->packet_timeout, spacc_packet_timeout,
-                   (unsigned long)engine);
+       timer_setup(&engine->packet_timeout, spacc_packet_timeout, 0);
 
        INIT_LIST_HEAD(&engine->pending);
        INIT_LIST_HEAD(&engine->completed);
index d6a09b9cd8ccae2c35cee866ac35b1d4ba066975..4372f9e4b0daeb97a45a08588b8064b73f2434e1 100644 (file)
@@ -137,9 +137,9 @@ int fw_cancel_transaction(struct fw_card *card,
 }
 EXPORT_SYMBOL(fw_cancel_transaction);
 
-static void split_transaction_timeout_callback(unsigned long data)
+static void split_transaction_timeout_callback(struct timer_list *timer)
 {
-       struct fw_transaction *t = (struct fw_transaction *)data;
+       struct fw_transaction *t = from_timer(t, timer, split_timeout_timer);
        struct fw_card *card = t->card;
        unsigned long flags;
 
@@ -373,8 +373,8 @@ void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode,
        t->tlabel = tlabel;
        t->card = card;
        t->is_split_transaction = false;
-       setup_timer(&t->split_timeout_timer,
-                   split_transaction_timeout_callback, (unsigned long)t);
+       timer_setup(&t->split_timeout_timer,
+                   split_transaction_timeout_callback, 0);
        t->callback = callback;
        t->callback_data = callback_data;
 
@@ -423,7 +423,7 @@ int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
        struct transaction_callback_data d;
        struct fw_transaction t;
 
-       init_timer_on_stack(&t.split_timeout_timer);
+       timer_setup_on_stack(&t.split_timeout_timer, NULL, 0);
        init_completion(&d.done);
        d.payload = payload;
        fw_send_request(card, &t, tcode, destination_id, generation, speed,
index fc9a6a83dfc7726d9213f5a22ed1cee7fed474b5..4b152e0d31a658970f6d7f5387f88d2a299fcbce 100644 (file)
@@ -975,9 +975,9 @@ static void hangcheck_timer_reset(struct etnaviv_gpu *gpu)
                  round_jiffies_up(jiffies + DRM_ETNAVIV_HANGCHECK_JIFFIES));
 }
 
-static void hangcheck_handler(unsigned long data)
+static void hangcheck_handler(struct timer_list *t)
 {
-       struct etnaviv_gpu *gpu = (struct etnaviv_gpu *)data;
+       struct etnaviv_gpu *gpu = from_timer(gpu, t, hangcheck_timer);
        u32 fence = gpu->completed_fence;
        bool progress = false;
 
@@ -1648,8 +1648,7 @@ static int etnaviv_gpu_bind(struct device *dev, struct device *master,
        INIT_WORK(&gpu->recover_work, recover_worker);
        init_waitqueue_head(&gpu->fence_event);
 
-       setup_deferrable_timer(&gpu->hangcheck_timer, hangcheck_handler,
-                              (unsigned long)gpu);
+       timer_setup(&gpu->hangcheck_timer, hangcheck_handler, TIMER_DEFERRABLE);
 
        priv->gpu[priv->num_gpus++] = gpu;
 
index 1d2ebb5e530f9bcafc805ac03190e56084f5f311..be6dda58fcae3d5e71a0e8e56d7884334240897f 100644 (file)
@@ -23,9 +23,9 @@
 #include "psb_intel_reg.h"
 #include <linux/spinlock.h>
 
-static void psb_lid_timer_func(unsigned long data)
+static void psb_lid_timer_func(struct timer_list *t)
 {
-       struct drm_psb_private * dev_priv = (struct drm_psb_private *)data;
+       struct drm_psb_private *dev_priv = from_timer(dev_priv, t, lid_timer);
        struct drm_device *dev = (struct drm_device *)dev_priv->dev;
        struct timer_list *lid_timer = &dev_priv->lid_timer;
        unsigned long irq_flags;
@@ -77,10 +77,8 @@ void psb_lid_timer_init(struct drm_psb_private *dev_priv)
        spin_lock_init(&dev_priv->lid_lock);
        spin_lock_irqsave(&dev_priv->lid_lock, irq_flags);
 
-       init_timer(lid_timer);
+       timer_setup(lid_timer, psb_lid_timer_func, 0);
 
-       lid_timer->data = (unsigned long)dev_priv;
-       lid_timer->function = psb_lid_timer_func;
        lid_timer->expires = jiffies + PSB_LID_DELAY;
 
        add_timer(lid_timer);
index 93d28c0ec8bf0ef867bc958592c58f60d3ce2913..9b167bc6eee48ca498a070ca46cc09836f02d8c1 100644 (file)
@@ -464,10 +464,10 @@ static void ssip_error(struct hsi_client *cl)
        hsi_async_read(cl, msg);
 }
 
-static void ssip_keep_alive(unsigned long data)
+static void ssip_keep_alive(struct timer_list *t)
 {
-       struct hsi_client *cl = (struct hsi_client *)data;
-       struct ssi_protocol *ssi = hsi_client_drvdata(cl);
+       struct ssi_protocol *ssi = from_timer(ssi, t, keep_alive);
+       struct hsi_client *cl = ssi->cl;
 
        dev_dbg(&cl->device, "Keep alive kick in: m(%d) r(%d) s(%d)\n",
                ssi->main_state, ssi->recv_state, ssi->send_state);
@@ -490,9 +490,19 @@ static void ssip_keep_alive(unsigned long data)
        spin_unlock(&ssi->lock);
 }
 
-static void ssip_wd(unsigned long data)
+static void ssip_rx_wd(struct timer_list *t)
+{
+       struct ssi_protocol *ssi = from_timer(ssi, t, rx_wd);
+       struct hsi_client *cl = ssi->cl;
+
+       dev_err(&cl->device, "Watchdog trigerred\n");
+       ssip_error(cl);
+}
+
+static void ssip_tx_wd(struct timer_list *t)
 {
-       struct hsi_client *cl = (struct hsi_client *)data;
+       struct ssi_protocol *ssi = from_timer(ssi, t, tx_wd);
+       struct hsi_client *cl = ssi->cl;
 
        dev_err(&cl->device, "Watchdog trigerred\n");
        ssip_error(cl);
@@ -1084,15 +1094,9 @@ static int ssi_protocol_probe(struct device *dev)
        }
 
        spin_lock_init(&ssi->lock);
-       init_timer_deferrable(&ssi->rx_wd);
-       init_timer_deferrable(&ssi->tx_wd);
-       init_timer(&ssi->keep_alive);
-       ssi->rx_wd.data = (unsigned long)cl;
-       ssi->rx_wd.function = ssip_wd;
-       ssi->tx_wd.data = (unsigned long)cl;
-       ssi->tx_wd.function = ssip_wd;
-       ssi->keep_alive.data = (unsigned long)cl;
-       ssi->keep_alive.function = ssip_keep_alive;
+       timer_setup(&ssi->rx_wd, ssip_rx_wd, TIMER_DEFERRABLE);
+       timer_setup(&ssi->tx_wd, ssip_tx_wd, TIMER_DEFERRABLE);
+       timer_setup(&ssi->keep_alive, ssip_keep_alive, 0);
        INIT_LIST_HEAD(&ssi->txqueue);
        INIT_LIST_HEAD(&ssi->cmdqueue);
        atomic_set(&ssi->tx_usecnt, 0);
index 3a234701d92c4ac3965cce3e48edc6ef856ca9a0..6f25da56a1690cfaaa3183a5b9b489474865dab5 100644 (file)
@@ -611,9 +611,9 @@ static int drive_is_ready(ide_drive_t *drive)
  *     logic that wants cleaning up.
  */
  
-void ide_timer_expiry (unsigned long data)
+void ide_timer_expiry (struct timer_list *t)
 {
-       ide_hwif_t      *hwif = (ide_hwif_t *)data;
+       ide_hwif_t      *hwif = from_timer(hwif, t, timer);
        ide_drive_t     *uninitialized_var(drive);
        ide_handler_t   *handler;
        unsigned long   flags;
index eaf39e5db08ba98ad2bfcc32e9892e2f2c8be972..17fd55af4d9247ee89c0b581c5de3ab3437860a2 100644 (file)
@@ -1184,7 +1184,7 @@ static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
 
        spin_lock_init(&hwif->lock);
 
-       setup_timer(&hwif->timer, &ide_timer_expiry, (unsigned long)hwif);
+       timer_setup(&hwif->timer, ide_timer_expiry, 0);
 
        init_completion(&hwif->gendev_rel_comp);
 
index 3b3db8c868e01f81878563a1ae8a74cda41cf372..d3265b6b58b8ebc06b69e8a40983d5303b938054 100644 (file)
@@ -145,7 +145,7 @@ static void touch_timer_fire(unsigned long data)
        }
 }
 
-static DEFINE_TIMER(touch_timer, touch_timer_fire, 0, 0);
+static DEFINE_TIMER(touch_timer, touch_timer_fire);
 
 /**
  * stylus_irq - touchscreen stylus event interrupt
index ea9bdc85a21dedc4a62d1fe3845d7366452c4d13..899ec1f4c83368919b76bcb0ed0b599015b706c8 100644 (file)
@@ -103,7 +103,7 @@ static DEFINE_MUTEX(smu_part_access);
 static int smu_irq_inited;
 static unsigned long smu_cmdbuf_abs;
 
-static void smu_i2c_retry(unsigned long data);
+static void smu_i2c_retry(struct timer_list *t);
 
 /*
  * SMU driver low level stuff
@@ -582,9 +582,7 @@ static int smu_late_init(void)
        if (!smu)
                return 0;
 
-       init_timer(&smu->i2c_timer);
-       smu->i2c_timer.function = smu_i2c_retry;
-       smu->i2c_timer.data = (unsigned long)smu;
+       timer_setup(&smu->i2c_timer, smu_i2c_retry, 0);
 
        if (smu->db_node) {
                smu->db_irq = irq_of_parse_and_map(smu->db_node, 0);
@@ -755,7 +753,7 @@ static void smu_i2c_complete_command(struct smu_i2c_cmd *cmd, int fail)
 }
 
 
-static void smu_i2c_retry(unsigned long data)
+static void smu_i2c_retry(struct timer_list *unused)
 {
        struct smu_i2c_cmd      *cmd = smu->cmd_i2c_cur;
 
@@ -795,7 +793,7 @@ static void smu_i2c_low_completion(struct smu_cmd *scmd, void *misc)
                BUG_ON(cmd != smu->cmd_i2c_cur);
                if (!smu_irq_inited) {
                        mdelay(5);
-                       smu_i2c_retry(0);
+                       smu_i2c_retry(NULL);
                        return;
                }
                mod_timer(&smu->i2c_timer, jiffies + msecs_to_jiffies(5));
index bb682c926b0a048ab1918ba13a89c140dff19d96..bcb29df9549eb80512a2c9b4c5d299e941a790c0 100644 (file)
@@ -57,6 +57,7 @@ struct altera_mbox {
 
        /* If the controller supports only RX polling mode */
        struct timer_list rxpoll_timer;
+       struct mbox_chan *chan;
 };
 
 static struct altera_mbox *mbox_chan_to_altera_mbox(struct mbox_chan *chan)
@@ -138,12 +139,11 @@ static void altera_mbox_rx_data(struct mbox_chan *chan)
        }
 }
 
-static void altera_mbox_poll_rx(unsigned long data)
+static void altera_mbox_poll_rx(struct timer_list *t)
 {
-       struct mbox_chan *chan = (struct mbox_chan *)data;
-       struct altera_mbox *mbox = mbox_chan_to_altera_mbox(chan);
+       struct altera_mbox *mbox = from_timer(mbox, t, rxpoll_timer);
 
-       altera_mbox_rx_data(chan);
+       altera_mbox_rx_data(mbox->chan);
 
        mod_timer(&mbox->rxpoll_timer,
                  jiffies + msecs_to_jiffies(MBOX_POLLING_MS));
@@ -206,8 +206,8 @@ static int altera_mbox_startup_receiver(struct mbox_chan *chan)
 
 polling:
        /* Setup polling timer */
-       setup_timer(&mbox->rxpoll_timer, altera_mbox_poll_rx,
-                   (unsigned long)chan);
+       mbox->chan = chan;
+       timer_setup(&mbox->rxpoll_timer, altera_mbox_poll_rx, 0);
        mod_timer(&mbox->rxpoll_timer,
                  jiffies + msecs_to_jiffies(MBOX_POLLING_MS));
 
index ad5b25b896990eab69616ad6e454bb2bd2d9601c..8289ee482f495b63c5a55bf57b03a5e82e8779fe 100644 (file)
@@ -330,10 +330,10 @@ static void pvr2_hdw_state_log_state(struct pvr2_hdw *);
 static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
 static int pvr2_hdw_commit_setup(struct pvr2_hdw *hdw);
 static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw);
-static void pvr2_hdw_quiescent_timeout(unsigned long);
-static void pvr2_hdw_decoder_stabilization_timeout(unsigned long);
-static void pvr2_hdw_encoder_wait_timeout(unsigned long);
-static void pvr2_hdw_encoder_run_timeout(unsigned long);
+static void pvr2_hdw_quiescent_timeout(struct timer_list *);
+static void pvr2_hdw_decoder_stabilization_timeout(struct timer_list *);
+static void pvr2_hdw_encoder_wait_timeout(struct timer_list *);
+static void pvr2_hdw_encoder_run_timeout(struct timer_list *);
 static int pvr2_issue_simple_cmd(struct pvr2_hdw *,u32);
 static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
                                unsigned int timeout,int probe_fl,
@@ -2373,18 +2373,15 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
        }
        if (!hdw) goto fail;
 
-       setup_timer(&hdw->quiescent_timer, pvr2_hdw_quiescent_timeout,
-                   (unsigned long)hdw);
+       timer_setup(&hdw->quiescent_timer, pvr2_hdw_quiescent_timeout, 0);
 
-       setup_timer(&hdw->decoder_stabilization_timer,
-                   pvr2_hdw_decoder_stabilization_timeout,
-                   (unsigned long)hdw);
+       timer_setup(&hdw->decoder_stabilization_timer,
+                   pvr2_hdw_decoder_stabilization_timeout, 0);
 
-       setup_timer(&hdw->encoder_wait_timer, pvr2_hdw_encoder_wait_timeout,
-                   (unsigned long)hdw);
+       timer_setup(&hdw->encoder_wait_timer, pvr2_hdw_encoder_wait_timeout,
+                   0);
 
-       setup_timer(&hdw->encoder_run_timer, pvr2_hdw_encoder_run_timeout,
-                   (unsigned long)hdw);
+       timer_setup(&hdw->encoder_run_timer, pvr2_hdw_encoder_run_timeout, 0);
 
        hdw->master_state = PVR2_STATE_DEAD;
 
@@ -3539,10 +3536,16 @@ static void pvr2_ctl_read_complete(struct urb *urb)
        complete(&hdw->ctl_done);
 }
 
+struct hdw_timer {
+       struct timer_list timer;
+       struct pvr2_hdw *hdw;
+};
 
-static void pvr2_ctl_timeout(unsigned long data)
+static void pvr2_ctl_timeout(struct timer_list *t)
 {
-       struct pvr2_hdw *hdw = (struct pvr2_hdw *)data;
+       struct hdw_timer *timer = from_timer(timer, t, timer);
+       struct pvr2_hdw *hdw = timer->hdw;
+
        if (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) {
                hdw->ctl_timeout_flag = !0;
                if (hdw->ctl_write_pend_flag)
@@ -3564,7 +3567,10 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
 {
        unsigned int idx;
        int status = 0;
-       struct timer_list timer;
+       struct hdw_timer timer = {
+               .hdw = hdw,
+       };
+
        if (!hdw->ctl_lock_held) {
                pvr2_trace(PVR2_TRACE_ERROR_LEGS,
                           "Attempted to execute control transfer without lock!!");
@@ -3621,8 +3627,8 @@ static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
        hdw->ctl_timeout_flag = 0;
        hdw->ctl_write_pend_flag = 0;
        hdw->ctl_read_pend_flag = 0;
-       setup_timer(&timer, pvr2_ctl_timeout, (unsigned long)hdw);
-       timer.expires = jiffies + timeout;
+       timer_setup_on_stack(&timer.timer, pvr2_ctl_timeout, 0);
+       timer.timer.expires = jiffies + timeout;
 
        if (write_len && write_data) {
                hdw->cmd_debug_state = 2;
@@ -3677,7 +3683,7 @@ status);
        }
 
        /* Start timer */
-       add_timer(&timer);
+       add_timer(&timer.timer);
 
        /* Now wait for all I/O to complete */
        hdw->cmd_debug_state = 4;
@@ -3687,7 +3693,7 @@ status);
        hdw->cmd_debug_state = 5;
 
        /* Stop timer */
-       del_timer_sync(&timer);
+       del_timer_sync(&timer.timer);
 
        hdw->cmd_debug_state = 6;
        status = 0;
@@ -3769,6 +3775,8 @@ status);
        if ((status < 0) && (!probe_fl)) {
                pvr2_hdw_render_useless(hdw);
        }
+       destroy_timer_on_stack(&timer.timer);
+
        return status;
 }
 
@@ -4366,9 +4374,9 @@ static int state_eval_encoder_run(struct pvr2_hdw *hdw)
 
 
 /* Timeout function for quiescent timer. */
-static void pvr2_hdw_quiescent_timeout(unsigned long data)
+static void pvr2_hdw_quiescent_timeout(struct timer_list *t)
 {
-       struct pvr2_hdw *hdw = (struct pvr2_hdw *)data;
+       struct pvr2_hdw *hdw = from_timer(hdw, t, quiescent_timer);
        hdw->state_decoder_quiescent = !0;
        trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent);
        hdw->state_stale = !0;
@@ -4377,9 +4385,9 @@ static void pvr2_hdw_quiescent_timeout(unsigned long data)
 
 
 /* Timeout function for decoder stabilization timer. */
-static void pvr2_hdw_decoder_stabilization_timeout(unsigned long data)
+static void pvr2_hdw_decoder_stabilization_timeout(struct timer_list *t)
 {
-       struct pvr2_hdw *hdw = (struct pvr2_hdw *)data;
+       struct pvr2_hdw *hdw = from_timer(hdw, t, decoder_stabilization_timer);
        hdw->state_decoder_ready = !0;
        trace_stbit("state_decoder_ready", hdw->state_decoder_ready);
        hdw->state_stale = !0;
@@ -4388,9 +4396,9 @@ static void pvr2_hdw_decoder_stabilization_timeout(unsigned long data)
 
 
 /* Timeout function for encoder wait timer. */
-static void pvr2_hdw_encoder_wait_timeout(unsigned long data)
+static void pvr2_hdw_encoder_wait_timeout(struct timer_list *t)
 {
-       struct pvr2_hdw *hdw = (struct pvr2_hdw *)data;
+       struct pvr2_hdw *hdw = from_timer(hdw, t, encoder_wait_timer);
        hdw->state_encoder_waitok = !0;
        trace_stbit("state_encoder_waitok",hdw->state_encoder_waitok);
        hdw->state_stale = !0;
@@ -4399,9 +4407,9 @@ static void pvr2_hdw_encoder_wait_timeout(unsigned long data)
 
 
 /* Timeout function for encoder run timer. */
-static void pvr2_hdw_encoder_run_timeout(unsigned long data)
+static void pvr2_hdw_encoder_run_timeout(struct timer_list *t)
 {
-       struct pvr2_hdw *hdw = (struct pvr2_hdw *)data;
+       struct pvr2_hdw *hdw = from_timer(hdw, t, encoder_run_timer);
        if (!hdw->state_encoder_runok) {
                hdw->state_encoder_runok = !0;
                trace_stbit("state_encoder_runok",hdw->state_encoder_runok);
index 48db922075e2adbcec880950edf7a9700827218b..bcdca9fbef51cc802d34b74a4fab19abd308b1bc 100644 (file)
@@ -59,6 +59,7 @@ struct jmb38x_ms_host {
        unsigned int            block_pos;
        unsigned long           timeout_jiffies;
        struct timer_list       timer;
+       struct memstick_host    *msh;
        struct memstick_request *req;
        unsigned char           cmd_flags;
        unsigned char           io_pos;
@@ -592,10 +593,10 @@ static irqreturn_t jmb38x_ms_isr(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-static void jmb38x_ms_abort(unsigned long data)
+static void jmb38x_ms_abort(struct timer_list *t)
 {
-       struct memstick_host *msh = (struct memstick_host *)data;
-       struct jmb38x_ms_host *host = memstick_priv(msh);
+       struct jmb38x_ms_host *host = from_timer(host, t, timer);
+       struct memstick_host *msh = host->msh;
        unsigned long flags;
 
        dev_dbg(&host->chip->pdev->dev, "abort\n");
@@ -878,6 +879,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
                return NULL;
 
        host = memstick_priv(msh);
+       host->msh = msh;
        host->chip = jm;
        host->addr = ioremap(pci_resource_start(jm->pdev, cnt),
                             pci_resource_len(jm->pdev, cnt));
@@ -897,7 +899,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
 
        msh->caps = MEMSTICK_CAP_PAR4 | MEMSTICK_CAP_PAR8;
 
-       setup_timer(&host->timer, jmb38x_ms_abort, (unsigned long)msh);
+       timer_setup(&host->timer, jmb38x_ms_abort, 0);
 
        if (!request_irq(host->irq, jmb38x_ms_isr, IRQF_SHARED, host->host_id,
                         msh))
index d5cfb503b9d693b1686bd1a13774ae0ac37bbf4c..627d6e62fe3133319f0da646a0b9f84fc12445d1 100644 (file)
@@ -616,9 +616,9 @@ static void r592_update_card_detect(struct r592_device *dev)
 }
 
 /* Timer routine that fires 1 second after last card detection event, */
-static void r592_detect_timer(long unsigned int data)
+static void r592_detect_timer(struct timer_list *t)
 {
-       struct r592_device *dev = (struct r592_device *)data;
+       struct r592_device *dev = from_timer(dev, t, detect_timer);
        r592_update_card_detect(dev);
        memstick_detect_change(dev->host);
 }
@@ -770,8 +770,7 @@ static int r592_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        spin_lock_init(&dev->io_thread_lock);
        init_completion(&dev->dma_done);
        INIT_KFIFO(dev->pio_fifo);
-       setup_timer(&dev->detect_timer,
-               r592_detect_timer, (long unsigned int)dev);
+       timer_setup(&dev->detect_timer, r592_detect_timer, 0);
 
        /* Host initialization */
        host->caps = MEMSTICK_CAP_PAR4;
index 7bafa72f8f5789ccec9cb9975e5f8aac293a0bcc..bed205849d027020e260dfa4b68ac3fba8aaa9ed 100644 (file)
@@ -538,9 +538,9 @@ static int tifm_ms_set_param(struct memstick_host *msh,
        return 0;
 }
 
-static void tifm_ms_abort(unsigned long data)
+static void tifm_ms_abort(struct timer_list *t)
 {
-       struct tifm_ms *host = (struct tifm_ms *)data;
+       struct tifm_ms *host = from_timer(host, t, timer);
 
        dev_dbg(&host->dev->dev, "status %x\n",
                readl(host->dev->addr + SOCK_MS_STATUS));
@@ -575,7 +575,7 @@ static int tifm_ms_probe(struct tifm_dev *sock)
        host->dev = sock;
        host->timeout_jiffies = msecs_to_jiffies(1000);
 
-       setup_timer(&host->timer, tifm_ms_abort, (unsigned long)host);
+       timer_setup(&host->timer, tifm_ms_abort, 0);
        tasklet_init(&host->notify, tifm_ms_req_tasklet, (unsigned long)msh);
 
        msh->request = tifm_ms_submit_req;
index 7f327121e6d7c43416a3ca6820cd39111796d683..0c775d6fcf590d1b1691926d144237ff02c960e1 100644 (file)
@@ -172,9 +172,9 @@ struct xpc_arch_operations xpc_arch_ops;
  * Timer function to enforce the timelimit on the partition disengage.
  */
 static void
-xpc_timeout_partition_disengage(unsigned long data)
+xpc_timeout_partition_disengage(struct timer_list *t)
 {
-       struct xpc_partition *part = (struct xpc_partition *)data;
+       struct xpc_partition *part = from_timer(part, t, disengage_timer);
 
        DBUG_ON(time_is_after_jiffies(part->disengage_timeout));
 
@@ -190,7 +190,7 @@ xpc_timeout_partition_disengage(unsigned long data)
  * specify when the next timeout should occur.
  */
 static void
-xpc_hb_beater(unsigned long dummy)
+xpc_hb_beater(struct timer_list *unused)
 {
        xpc_arch_ops.increment_heartbeat();
 
@@ -205,8 +205,7 @@ static void
 xpc_start_hb_beater(void)
 {
        xpc_arch_ops.heartbeat_init();
-       init_timer(&xpc_hb_timer);
-       xpc_hb_timer.function = xpc_hb_beater;
+       timer_setup(&xpc_hb_timer, xpc_hb_beater, 0);
        xpc_hb_beater(0);
 }
 
@@ -931,10 +930,8 @@ xpc_setup_partitions(void)
                part->act_state = XPC_P_AS_INACTIVE;
                XPC_SET_REASON(part, 0, 0);
 
-               init_timer(&part->disengage_timer);
-               part->disengage_timer.function =
-                   xpc_timeout_partition_disengage;
-               part->disengage_timer.data = (unsigned long)part;
+               timer_setup(&part->disengage_timer,
+                           xpc_timeout_partition_disengage, 0);
 
                part->setup_state = XPC_P_SS_UNSET;
                init_waitqueue_head(&part->teardown_wq);
index 7d71c04fc938873fa1798dfcc0e6a6b7a043346a..5a12d2a5404988718a19b7131dd125183e31912d 100644 (file)
@@ -323,16 +323,16 @@ xpc_handle_notify_IRQ_sn2(int irq, void *dev_id)
  * was received.
  */
 static void
-xpc_check_for_dropped_notify_IRQ_sn2(struct xpc_partition *part)
+xpc_check_for_dropped_notify_IRQ_sn2(struct timer_list *t)
 {
-       struct xpc_partition_sn2 *part_sn2 = &part->sn.sn2;
+       struct xpc_partition *part =
+               from_timer(part, t, sn.sn2.dropped_notify_IRQ_timer);
 
        if (xpc_part_ref(part)) {
                xpc_check_for_sent_chctl_flags_sn2(part);
 
-               part_sn2->dropped_notify_IRQ_timer.expires = jiffies +
-                   XPC_DROPPED_NOTIFY_IRQ_WAIT_INTERVAL;
-               add_timer(&part_sn2->dropped_notify_IRQ_timer);
+               t->expires = jiffies + XPC_DROPPED_NOTIFY_IRQ_WAIT_INTERVAL;
+               add_timer(t);
                xpc_part_deref(part);
        }
 }
@@ -1232,10 +1232,7 @@ xpc_setup_ch_structures_sn2(struct xpc_partition *part)
 
        /* Setup a timer to check for dropped notify IRQs */
        timer = &part_sn2->dropped_notify_IRQ_timer;
-       init_timer(timer);
-       timer->function =
-           (void (*)(unsigned long))xpc_check_for_dropped_notify_IRQ_sn2;
-       timer->data = (unsigned long)part;
+       timer_setup(timer, xpc_check_for_dropped_notify_IRQ_sn2, 0);
        timer->expires = jiffies + XPC_DROPPED_NOTIFY_IRQ_WAIT_INTERVAL;
        add_timer(timer);
 
index 1cbca8e5741ed420f1b7e7f76a7056f93a706e18..b6e2bfd7d2d6aae5f05794c71f818e14a844a6b4 100644 (file)
@@ -166,8 +166,8 @@ static unsigned int network_rec_config_shadow = 0;
 static unsigned int network_tr_ctrl_shadow = 0;
 
 /* Network speed indication. */
-static DEFINE_TIMER(speed_timer, NULL, 0, 0);
-static DEFINE_TIMER(clear_led_timer, NULL, 0, 0);
+static DEFINE_TIMER(speed_timer, NULL);
+static DEFINE_TIMER(clear_led_timer, NULL);
 static int current_speed; /* Speed read from transceiver */
 static int current_speed_selection; /* Speed selected by user */
 static unsigned long led_next_time;
@@ -175,7 +175,7 @@ static int led_active;
 static int rx_queue_len;
 
 /* Duplex */
-static DEFINE_TIMER(duplex_timer, NULL, 0, 0);
+static DEFINE_TIMER(duplex_timer, NULL);
 static int full_duplex;
 static enum duplex current_duplex;
 
index 9feec70094435e19ee039f18ea430291d9f7d1a0..29fea74bff2e6793a0305ef154a73886f1d2a82b 100644 (file)
@@ -4725,9 +4725,9 @@ static const struct net_device_ops qlge_netdev_ops = {
        .ndo_vlan_rx_kill_vid   = qlge_vlan_rx_kill_vid,
 };
 
-static void ql_timer(unsigned long data)
+static void ql_timer(struct timer_list *t)
 {
-       struct ql_adapter *qdev = (struct ql_adapter *)data;
+       struct ql_adapter *qdev = from_timer(qdev, t, timer);
        u32 var = 0;
 
        var = ql_read32(qdev, STS);
@@ -4806,11 +4806,8 @@ static int qlge_probe(struct pci_dev *pdev,
        /* Start up the timer to trigger EEH if
         * the bus goes dead
         */
-       init_timer_deferrable(&qdev->timer);
-       qdev->timer.data = (unsigned long)qdev;
-       qdev->timer.function = ql_timer;
-       qdev->timer.expires = jiffies + (5*HZ);
-       add_timer(&qdev->timer);
+       timer_setup(&qdev->timer, ql_timer, TIMER_DEFERRABLE);
+       mod_timer(&qdev->timer, jiffies + (5*HZ));
        ql_link_off(qdev);
        ql_display_dev_info(ndev);
        atomic_set(&qdev->lb_count, 0);
index 49ccee4b9aeccc3b6cd165b461d448f0aba7a6bd..56d06282fbde7343afa63f7df9b66fdd4fb10a5d 100644 (file)
@@ -608,9 +608,9 @@ static void tile_net_schedule_egress_timer(struct tile_net_cpu *info)
  * ISSUE: Maybe instead track number of expected completions, and free
  * only that many, resetting to zero if "pending" is ever false.
  */
-static void tile_net_handle_egress_timer(unsigned long arg)
+static void tile_net_handle_egress_timer(struct timer_list *t)
 {
-       struct tile_net_cpu *info = (struct tile_net_cpu *)arg;
+       struct tile_net_cpu *info = from_timer(info, t, egress_timer);
        struct net_device *dev = info->napi.dev;
 
        /* The timer is no longer scheduled. */
@@ -1004,9 +1004,8 @@ static void tile_net_register(void *dev_ptr)
                BUG();
 
        /* Initialize the egress timer. */
-       init_timer_pinned(&info->egress_timer);
-       info->egress_timer.data = (long)info;
-       info->egress_timer.function = tile_net_handle_egress_timer;
+       timer_setup(&info->egress_timer, tile_net_handle_egress_timer,
+                   TIMER_PINNED);
 
        u64_stats_init(&info->stats.syncp);
 
index b88c5cc00a6320ae3e241c8afcd569ec2d9e73e7..14c3632b8cde3cc95a25d98bc3ff826ed529205e 100644 (file)
@@ -157,7 +157,7 @@ static struct net_device *yam_devs[NR_PORTS];
 
 static struct yam_mcs *yam_data;
 
-static DEFINE_TIMER(yam_timer, NULL, 0, 0);
+static DEFINE_TIMER(yam_timer, NULL);
 
 /* --------------------------------------------------------------------- */
 
index d7c49cf1d5e91e2f962d499c4b88df87eec6dacd..3247d2feda07f8a671fe32aa45225cfbd34c50ff 100644 (file)
@@ -2325,9 +2325,9 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
 }
 
 /* Walk the forwarding table and purge stale entries */
-static void vxlan_cleanup(unsigned long arg)
+static void vxlan_cleanup(struct timer_list *t)
 {
-       struct vxlan_dev *vxlan = (struct vxlan_dev *) arg;
+       struct vxlan_dev *vxlan = from_timer(vxlan, t, age_timer);
        unsigned long next_timer = jiffies + FDB_AGE_INTERVAL;
        unsigned int h;
 
@@ -2647,9 +2647,7 @@ static void vxlan_setup(struct net_device *dev)
        INIT_LIST_HEAD(&vxlan->next);
        spin_lock_init(&vxlan->hash_lock);
 
-       init_timer_deferrable(&vxlan->age_timer);
-       vxlan->age_timer.function = vxlan_cleanup;
-       vxlan->age_timer.data = (unsigned long) vxlan;
+       timer_setup(&vxlan->age_timer, vxlan_cleanup, TIMER_DEFERRABLE);
 
        vxlan->dev = dev;
 
index 3a8d5e97dc8efecf4907f8d1a2fbc99e7be697f5..c09e40c9010ff0339f0f0e672151e0905133a7e8 100644 (file)
@@ -60,9 +60,9 @@ void ath6kl_recovery_hb_event(struct ath6kl *ar, u32 cookie)
                ar->fw_recovery.hb_pending = false;
 }
 
-static void ath6kl_recovery_hb_timer(unsigned long data)
+static void ath6kl_recovery_hb_timer(struct timer_list *t)
 {
-       struct ath6kl *ar = (struct ath6kl *) data;
+       struct ath6kl *ar = from_timer(ar, t, fw_recovery.hb_timer);
        int err;
 
        if (test_bit(RECOVERY_CLEANUP, &ar->flag) ||
@@ -104,9 +104,8 @@ void ath6kl_recovery_init(struct ath6kl *ar)
        recovery->seq_num = 0;
        recovery->hb_misscnt = 0;
        ar->fw_recovery.hb_pending = false;
-       ar->fw_recovery.hb_timer.function = ath6kl_recovery_hb_timer;
-       ar->fw_recovery.hb_timer.data = (unsigned long) ar;
-       init_timer_deferrable(&ar->fw_recovery.hb_timer);
+       timer_setup(&ar->fw_recovery.hb_timer, ath6kl_recovery_hb_timer,
+                   TIMER_DEFERRABLE);
 
        if (ar->fw_recovery.hb_poll)
                mod_timer(&ar->fw_recovery.hb_timer, jiffies +
index 94bf01f8b2a88872ecee00504f1266858539edca..ede89d4ffc8824cbf8e43dc0e78e227f02bb1539 100644 (file)
@@ -519,7 +519,7 @@ exit:
 /* LED trigger */
 static int tx_activity;
 static void at76_ledtrig_tx_timerfunc(unsigned long data);
-static DEFINE_TIMER(ledtrig_tx_timer, at76_ledtrig_tx_timerfunc, 0, 0);
+static DEFINE_TIMER(ledtrig_tx_timer, at76_ledtrig_tx_timerfunc);
 DEFINE_LED_TRIGGER(ledtrig_tx);
 
 static void at76_ledtrig_tx_timerfunc(unsigned long data)
index 74cc6dd982d2aaf5313c4647e02f305d4f0702fa..2d1a5c737c6ef53070ff9cacacc805e5d1903599 100644 (file)
@@ -44,10 +44,11 @@ static void parport_ieee1284_wakeup (struct parport *port)
        up (&port->physport->ieee1284.irq);
 }
 
-static struct parport *port_from_cookie[PARPORT_MAX];
-static void timeout_waiting_on_port (unsigned long cookie)
+static void timeout_waiting_on_port (struct timer_list *t)
 {
-       parport_ieee1284_wakeup (port_from_cookie[cookie % PARPORT_MAX]);
+       struct parport *port = from_timer(port, t, timer);
+
+       parport_ieee1284_wakeup (port);
 }
 
 /**
@@ -69,27 +70,19 @@ static void timeout_waiting_on_port (unsigned long cookie)
 int parport_wait_event (struct parport *port, signed long timeout)
 {
        int ret;
-       struct timer_list timer;
 
        if (!port->physport->cad->timeout)
                /* Zero timeout is special, and we can't down() the
                   semaphore. */
                return 1;
 
-       init_timer_on_stack(&timer);
-       timer.expires = jiffies + timeout;
-       timer.function = timeout_waiting_on_port;
-       port_from_cookie[port->number % PARPORT_MAX] = port;
-       timer.data = port->number;
-
-       add_timer (&timer);
+       timer_setup(&port->timer, timeout_waiting_on_port, 0);
+       mod_timer(&port->timer, jiffies + timeout);
        ret = down_interruptible (&port->physport->ieee1284.irq);
-       if (!del_timer_sync(&timer) && !ret)
+       if (!del_timer_sync(&port->timer) && !ret)
                /* Timed out. */
                ret = 1;
 
-       destroy_timer_on_stack(&timer);
-
        return ret;
 }
 
index 0802e0bc7d0c60dc4c0bfab927f3dd4fc8cfdb4b..16f573173471a89afac887d1df1a8ba118e95a46 100644 (file)
@@ -263,12 +263,12 @@ static int bcm63xx_pcmcia_get_status(struct pcmcia_socket *sock,
 /*
  * socket polling timer callback
  */
-static void bcm63xx_pcmcia_poll(unsigned long data)
+static void bcm63xx_pcmcia_poll(struct timer_list *t)
 {
        struct bcm63xx_pcmcia_socket *skt;
        unsigned int stat, events;
 
-       skt = (struct bcm63xx_pcmcia_socket *)data;
+       skt = from_timer(skt, t, timer);
 
        spin_lock_bh(&skt->lock);
 
@@ -392,7 +392,7 @@ static int bcm63xx_drv_pcmcia_probe(struct platform_device *pdev)
        sock->map_size = resource_size(skt->common_res);
 
        /* initialize polling timer */
-       setup_timer(&skt->timer, bcm63xx_pcmcia_poll, (unsigned long)skt);
+       timer_setup(&skt->timer, bcm63xx_pcmcia_poll, 0);
 
        /* initialize  pcmcia  control register,  drive  VS[12] to  0,
         * leave CB IDSEL to the old  value since it is set by the PCI
index 8b0923fd76c604322bd20fb482958a320e77ff36..00a296d431bab910be192d663660c99d221ce4e4 100644 (file)
@@ -86,9 +86,9 @@ static int bfin_cf_ss_init(struct pcmcia_socket *s)
 }
 
 /* the timer is primarily to kick this socket's pccardd */
-static void bfin_cf_timer(unsigned long _cf)
+static void bfin_cf_timer(struct timer_list *t)
 {
-       struct bfin_cf_socket *cf = (void *)_cf;
+       struct bfin_cf_socket *cf = from_timer(cf, t, timer);
        unsigned short present = bfin_cf_present(cf->cd_pfx);
 
        if (present != cf->present) {
@@ -227,7 +227,7 @@ static int bfin_cf_probe(struct platform_device *pdev)
 
        cf->cd_pfx = cd_pfx;
 
-       setup_timer(&cf->timer, bfin_cf_timer, (unsigned long)cf);
+       timer_setup(&cf->timer, bfin_cf_timer, 0);
 
        cf->pdev = pdev;
        platform_set_drvdata(pdev, cf);
index fb38cc01859f15ac3519e8310391bde330033156..891ccea2cccb0a7b455a9ab963df2b43c38ed93e 100644 (file)
@@ -875,7 +875,7 @@ static irqreturn_t pcic_interrupt(int irq, void *dev)
     return IRQ_RETVAL(handled);
 } /* pcic_interrupt */
 
-static void pcic_interrupt_wrapper(u_long data)
+static void pcic_interrupt_wrapper(struct timer_list *unused)
 {
     pcic_interrupt(0, NULL);
     poll_timer.expires = jiffies + poll_interval;
@@ -1289,9 +1289,7 @@ static int __init init_i82365(void)
 
     /* Finally, schedule a polling interrupt */
     if (poll_interval != 0) {
-       poll_timer.function = pcic_interrupt_wrapper;
-       poll_timer.data = 0;
-       init_timer(&poll_timer);
+       timer_setup(&poll_timer, pcic_interrupt_wrapper, 0);
        poll_timer.expires = jiffies + poll_interval;
        add_timer(&poll_timer);
     }
index 4e2f501e55486dbee297865f03148e5b46d09d91..c2a17a79f0b2ff86fa1fc5cd29a2ce49289bc669 100644 (file)
@@ -80,9 +80,9 @@ static int omap_cf_ss_init(struct pcmcia_socket *s)
 }
 
 /* the timer is primarily to kick this socket's pccardd */
-static void omap_cf_timer(unsigned long _cf)
+static void omap_cf_timer(struct timer_list *t)
 {
-       struct omap_cf_socket   *cf = (void *) _cf;
+       struct omap_cf_socket   *cf = from_timer(cf, t, timer);
        unsigned                present = omap_cf_present();
 
        if (present != cf->present) {
@@ -102,7 +102,9 @@ static void omap_cf_timer(unsigned long _cf)
  */
 static irqreturn_t omap_cf_irq(int irq, void *_cf)
 {
-       omap_cf_timer((unsigned long)_cf);
+       struct omap_cf_socket *cf = (struct omap_cf_socket *)_cf;
+
+       omap_cf_timer(&cf->timer);
        return IRQ_HANDLED;
 }
 
@@ -220,7 +222,7 @@ static int __init omap_cf_probe(struct platform_device *pdev)
        cf = kzalloc(sizeof *cf, GFP_KERNEL);
        if (!cf)
                return -ENOMEM;
-       setup_timer(&cf->timer, omap_cf_timer, (unsigned long)cf);
+       timer_setup(&cf->timer, omap_cf_timer, 0);
 
        cf->pdev = pdev;
        platform_set_drvdata(pdev, cf);
index 0f70b4d58f9e7c2d8bb2b9b6c0dc00d2dca3f308..959ae3e65ef8b2ae902141eb068865849e0deaad 100644 (file)
@@ -234,9 +234,9 @@ static irqreturn_t pd6729_interrupt(int irq, void *dev)
 
 /* socket functions */
 
-static void pd6729_interrupt_wrapper(unsigned long data)
+static void pd6729_interrupt_wrapper(struct timer_list *t)
 {
-       struct pd6729_socket *socket = (struct pd6729_socket *) data;
+       struct pd6729_socket *socket = from_timer(socket, t, poll_timer);
 
        pd6729_interrupt(0, (void *)socket);
        mod_timer(&socket->poll_timer, jiffies + HZ);
@@ -707,8 +707,7 @@ static int pd6729_pci_probe(struct pci_dev *dev,
                }
        } else {
                /* poll Card status change */
-               setup_timer(&socket->poll_timer, pd6729_interrupt_wrapper,
-                           (unsigned long)socket);
+               timer_setup(&socket->poll_timer, pd6729_interrupt_wrapper, 0);
                mod_timer(&socket->poll_timer, jiffies + HZ);
        }
 
index b6b316de055c7129648904cbdae92cafb593e8dd..764650eb8897995a55ccc7dc3aaf20c210b53199 100644 (file)
@@ -456,9 +456,9 @@ static void soc_common_check_status(struct soc_pcmcia_socket *skt)
 }
 
 /* Let's poll for events in addition to IRQs since IRQ only is unreliable... */
-static void soc_common_pcmcia_poll_event(unsigned long dummy)
+static void soc_common_pcmcia_poll_event(struct timer_list *t)
 {
-       struct soc_pcmcia_socket *skt = (struct soc_pcmcia_socket *)dummy;
+       struct soc_pcmcia_socket *skt = from_timer(skt, t, poll_timer);
        debug(skt, 4, "polling for events\n");
 
        mod_timer(&skt->poll_timer, jiffies + SOC_PCMCIA_POLL_PERIOD);
@@ -794,8 +794,7 @@ int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt)
 
        skt->cs_state = dead_socket;
 
-       setup_timer(&skt->poll_timer, soc_common_pcmcia_poll_event,
-                   (unsigned long)skt);
+       timer_setup(&skt->poll_timer, soc_common_pcmcia_poll_event, 0);
        skt->poll_timer.expires = jiffies + SOC_PCMCIA_POLL_PERIOD;
 
        ret = request_resource(&iomem_resource, &skt->res_skt);
index a1ac72d51d707d816a15130cccdb45549424e098..1a0e3f0987599d8a8b6415ac31dac40bc4bab8a1 100644 (file)
@@ -98,7 +98,7 @@ module_param(cycle_time, int, 0444);
 /*====================================================================*/
 
 static irqreturn_t tcic_interrupt(int irq, void *dev);
-static void tcic_timer(u_long data);
+static void tcic_timer(struct timer_list *unused);
 static struct pccard_operations tcic_operations;
 
 struct tcic_socket {
@@ -435,9 +435,7 @@ static int __init init_tcic(void)
     }
     
     /* Set up polling */
-    poll_timer.function = &tcic_timer;
-    poll_timer.data = 0;
-    init_timer(&poll_timer);
+    timer_setup(&poll_timer, &tcic_timer, 0);
 
     /* Build interrupt mask */
     printk(KERN_CONT ", %d sockets\n", sockets);
@@ -583,7 +581,7 @@ static irqreturn_t tcic_interrupt(int irq, void *dev)
     return IRQ_HANDLED;
 } /* tcic_interrupt */
 
-static void tcic_timer(u_long data)
+static void tcic_timer(struct timer_list *unused)
 {
     pr_debug("tcic_timer()\n");
     tcic_timer_pending = 0;
index 5d6d9b1549bc4fa345a613da000e6efc1ea01b91..ab3da2262f0fc89f7b65fe898d6efa5bd3113d8f 100644 (file)
@@ -534,9 +534,9 @@ static irqreturn_t yenta_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-static void yenta_interrupt_wrapper(unsigned long data)
+static void yenta_interrupt_wrapper(struct timer_list *t)
 {
-       struct yenta_socket *socket = (struct yenta_socket *) data;
+       struct yenta_socket *socket = from_timer(socket, t, poll_timer);
 
        yenta_interrupt(0, (void *)socket);
        socket->poll_timer.expires = jiffies + HZ;
@@ -1233,8 +1233,7 @@ static int yenta_probe(struct pci_dev *dev, const struct pci_device_id *id)
        if (!socket->cb_irq || request_irq(socket->cb_irq, yenta_interrupt, IRQF_SHARED, "yenta", socket)) {
                /* No IRQ or request_irq failed. Poll */
                socket->cb_irq = 0; /* But zero is a valid IRQ number. */
-               setup_timer(&socket->poll_timer, yenta_interrupt_wrapper,
-                           (unsigned long)socket);
+               timer_setup(&socket->poll_timer, yenta_interrupt_wrapper, 0);
                mod_timer(&socket->poll_timer, jiffies + HZ);
                dev_info(&dev->dev,
                         "no PCI IRQ, CardBus support disabled for this socket.\n");
index adbf1a9e089eec7f8292f27047137e39f777063b..ca44e6977cf2f7d7c58563e457cdcf3cb4b507ba 100644 (file)
@@ -169,11 +169,9 @@ static void cec_mod_timer(struct timer_list *t, unsigned long interval)
        mod_timer(t, round_jiffies(iv));
 }
 
-static void cec_timer_fn(unsigned long data)
+static void cec_timer_fn(struct timer_list *unused)
 {
-       struct ce_array *ca = (struct ce_array *)data;
-
-       do_spring_cleaning(ca);
+       do_spring_cleaning(&ce_arr);
 
        cec_mod_timer(&cec_timer, timer_interval);
 }
@@ -510,7 +508,7 @@ void __init cec_init(void)
        if (create_debugfs_nodes())
                return;
 
-       setup_timer(&cec_timer, cec_timer_fn, (unsigned long)&ce_arr);
+       timer_setup(&cec_timer, cec_timer_fn, 0);
        cec_mod_timer(&cec_timer, CEC_TIMER_DEFAULT_INTERVAL);
 
        pr_info("Correctable Errors collector initialized.\n");
index 2ed970d61da140c23a266e43a8b3b6b0eae8914d..722d683e0b0f5fd3f024d1da7b65ac61e42320b0 100644 (file)
@@ -161,6 +161,9 @@ static struct rtc_device *rtc_allocate_device(void)
 
        device_initialize(&rtc->dev);
 
+       /* Drivers can revise this default after allocating the device. */
+       rtc->set_offset_nsec =  NSEC_PER_SEC / 2;
+
        rtc->irq_freq = 1;
        rtc->max_user_freq = 64;
        rtc->dev.class = rtc_class;
index b4a68ffcd06bb876231f2893de69f30a8fe854d9..0c177647ea6c71c00d5df725beea9b83c7e4e79e 100644 (file)
@@ -10,6 +10,7 @@
 /**
  * rtc_set_ntp_time - Save NTP synchronized time to the RTC
  * @now: Current time of day
+ * @target_nsec: pointer for desired now->tv_nsec value
  *
  * Replacement for the NTP platform function update_persistent_clock64
  * that stores time for later retrieval by rtc_hctosys.
  * possible at all, and various other -errno for specific temporary failure
  * cases.
  *
+ * -EPROTO is returned if now.tv_nsec is not close enough to *target_nsec.
+ (
  * If temporary failure is indicated the caller should try again 'soon'
  */
-int rtc_set_ntp_time(struct timespec64 now)
+int rtc_set_ntp_time(struct timespec64 now, unsigned long *target_nsec)
 {
        struct rtc_device *rtc;
        struct rtc_time tm;
+       struct timespec64 to_set;
        int err = -ENODEV;
-
-       if (now.tv_nsec < (NSEC_PER_SEC >> 1))
-               rtc_time64_to_tm(now.tv_sec, &tm);
-       else
-               rtc_time64_to_tm(now.tv_sec + 1, &tm);
+       bool ok;
 
        rtc = rtc_class_open(CONFIG_RTC_SYSTOHC_DEVICE);
-       if (rtc) {
-               /* rtc_hctosys exclusively uses UTC, so we call set_time here,
-                * not set_mmss. */
-               if (rtc->ops &&
-                   (rtc->ops->set_time ||
-                    rtc->ops->set_mmss64 ||
-                    rtc->ops->set_mmss))
-                       err = rtc_set_time(rtc, &tm);
-               rtc_class_close(rtc);
+       if (!rtc)
+               goto out_err;
+
+       if (!rtc->ops || (!rtc->ops->set_time && !rtc->ops->set_mmss64 &&
+                         !rtc->ops->set_mmss))
+               goto out_close;
+
+       /* Compute the value of tv_nsec we require the caller to supply in
+        * now.tv_nsec.  This is the value such that (now +
+        * set_offset_nsec).tv_nsec == 0.
+        */
+       set_normalized_timespec64(&to_set, 0, -rtc->set_offset_nsec);
+       *target_nsec = to_set.tv_nsec;
+
+       /* The ntp code must call this with the correct value in tv_nsec, if
+        * it does not we update target_nsec and return EPROTO to make the ntp
+        * code try again later.
+        */
+       ok = rtc_tv_nsec_ok(rtc->set_offset_nsec, &to_set, &now);
+       if (!ok) {
+               err = -EPROTO;
+               goto out_close;
        }
 
+       rtc_time64_to_tm(to_set.tv_sec, &tm);
+
+       /* rtc_hctosys exclusively uses UTC, so we call set_time here, not
+        * set_mmss.
+        */
+       err = rtc_set_time(rtc, &tm);
+
+out_close:
+       rtc_class_close(rtc);
+out_err:
        return err;
 }
index 997b25f6e4cc0a8cc6c935deeb58816589056fbe..8bec5f9ea92c900d9d26f1f4df0783daf5420c6d 100644 (file)
@@ -129,6 +129,7 @@ struct tape_request {
        int options;                    /* options for execution. */
        int retries;                    /* retry counter for error recovery. */
        int rescnt;                     /* residual count from devstat. */
+       struct timer_list timer;        /* timer for std_assign_timeout(). */
 
        /* Callback for delivering final status. */
        void (*callback)(struct tape_request *, void *);
index 7caba0cc8b2af14b962877e352f04c391ab3bfae..1f5fab617b67901d73527e02e51c3c819f5af8dc 100644 (file)
  * tape_std_assign
  */
 static void
-tape_std_assign_timeout(unsigned long data)
+tape_std_assign_timeout(struct timer_list *t)
 {
-       struct tape_request *   request;
-       struct tape_device *    device;
+       struct tape_request *   request = from_timer(request, t, timer);
+       struct tape_device *    device = request->device;
        int rc;
 
-       request = (struct tape_request *) data;
-       device = request->device;
        BUG_ON(!device);
 
        DBF_EVENT(3, "%08x: Assignment timeout. Device busy.\n",
@@ -71,16 +69,12 @@ tape_std_assign(struct tape_device *device)
         * to another host (actually this shouldn't happen but it does).
         * So we set up a timeout for this call.
         */
-       init_timer_on_stack(&timeout);
-       timeout.function = tape_std_assign_timeout;
-       timeout.data     = (unsigned long) request;
-       timeout.expires  = jiffies + 2 * HZ;
-       add_timer(&timeout);
+       timer_setup(&request->timer, tape_std_assign_timeout, 0);
+       mod_timer(&timeout, jiffies + 2 * HZ);
 
        rc = tape_do_io_interruptible(device, request);
 
-       del_timer_sync(&timeout);
-       destroy_timer_on_stack(&timeout);
+       del_timer_sync(&request->timer);
 
        if (rc != 0) {
                DBF_EVENT(3, "%08x: assign failed - device might be busy\n",
index d01b5c2a77600e4d21ce7f74bc00baf5fde29184..b855c6f08e96bd3e2dfa5b0eadfb720a9ad74399 100644 (file)
@@ -834,13 +834,13 @@ lcs_notify_lancmd_waiters(struct lcs_card *card, struct lcs_cmd *cmd)
  * Emit buffer of a lan command.
  */
 static void
-lcs_lancmd_timeout(unsigned long data)
+lcs_lancmd_timeout(struct timer_list *t)
 {
-       struct lcs_reply *reply, *list_reply, *r;
+       struct lcs_reply *reply = from_timer(reply, t, timer);
+       struct lcs_reply *list_reply, *r;
        unsigned long flags;
 
        LCS_DBF_TEXT(4, trace, "timeout");
-       reply = (struct lcs_reply *) data;
        spin_lock_irqsave(&reply->card->lock, flags);
        list_for_each_entry_safe(list_reply, r,
                                 &reply->card->lancmd_waiters,list) {
@@ -864,7 +864,6 @@ lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer,
 {
        struct lcs_reply *reply;
        struct lcs_cmd *cmd;
-       struct timer_list timer;
        unsigned long flags;
        int rc;
 
@@ -885,14 +884,10 @@ lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer,
        rc = lcs_ready_buffer(&card->write, buffer);
        if (rc)
                return rc;
-       init_timer_on_stack(&timer);
-       timer.function = lcs_lancmd_timeout;
-       timer.data = (unsigned long) reply;
-       timer.expires = jiffies + HZ*card->lancmd_timeout;
-       add_timer(&timer);
+       timer_setup(&reply->timer, lcs_lancmd_timeout, 0);
+       mod_timer(&reply->timer, jiffies + HZ * card->lancmd_timeout);
        wait_event(reply->wait_q, reply->received);
-       del_timer_sync(&timer);
-       destroy_timer_on_stack(&timer);
+       del_timer_sync(&reply->timer);
        LCS_DBF_TEXT_(4, trace, "rc:%d",reply->rc);
        rc = reply->rc;
        lcs_put_reply(reply);
index f94d8f6dd7a8e417de743234639db2c465e2812d..fbc8b90b1f85a098b8761602454e1d1d0506f916 100644 (file)
@@ -276,6 +276,7 @@ struct lcs_reply {
        void (*callback)(struct lcs_card *, struct lcs_cmd *);
        wait_queue_head_t wait_q;
        struct lcs_card *card;
+       struct timer_list timer;
        int received;
        int rc;
 };
index d47b527b25dd0423fe23630fdab6007ce0a7bd33..31f2bb9d71461900bec98a3049ed7495b4ba53d9 100644 (file)
@@ -1046,8 +1046,6 @@ typedef enum {
 
 typedef uint8_t ahd_mode_state;
 
-typedef void ahd_callback_t (void *);
-
 struct ahd_completion
 {
        uint16_t        tag;
@@ -1122,8 +1120,7 @@ struct ahd_softc {
        /*
         * Timer handles for timer driven callbacks.
         */
-       ahd_timer_t               reset_timer;
-       ahd_timer_t               stat_timer;
+       struct timer_list       stat_timer;
 
        /*
         * Statistics.
index 95d8f25cbccab7056dc4c7967814cd5932fd3507..b560f396ee99c6665013283059ef8137be1e927e 100644 (file)
@@ -207,7 +207,7 @@ static void         ahd_add_scb_to_free_list(struct ahd_softc *ahd,
 static u_int           ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
                                     u_int prev, u_int next, u_int tid);
 static void            ahd_reset_current_bus(struct ahd_softc *ahd);
-static ahd_callback_t  ahd_stat_timer;
+static void            ahd_stat_timer(struct timer_list *t);
 #ifdef AHD_DUMP_SEQ
 static void            ahd_dumpseq(struct ahd_softc *ahd);
 #endif
@@ -6104,8 +6104,7 @@ ahd_alloc(void *platform_arg, char *name)
        ahd->bugs = AHD_BUGNONE;
        ahd->flags = AHD_SPCHK_ENB_A|AHD_RESET_BUS_A|AHD_TERM_ENB_A
                   | AHD_EXTENDED_TRANS_A|AHD_STPWLEVEL_A;
-       ahd_timer_init(&ahd->reset_timer);
-       ahd_timer_init(&ahd->stat_timer);
+       timer_setup(&ahd->stat_timer, ahd_stat_timer, 0);
        ahd->int_coalescing_timer = AHD_INT_COALESCING_TIMER_DEFAULT;
        ahd->int_coalescing_maxcmds = AHD_INT_COALESCING_MAXCMDS_DEFAULT;
        ahd->int_coalescing_mincmds = AHD_INT_COALESCING_MINCMDS_DEFAULT;
@@ -6235,8 +6234,7 @@ ahd_shutdown(void *arg)
        /*
         * Stop periodic timer callbacks.
         */
-       ahd_timer_stop(&ahd->reset_timer);
-       ahd_timer_stop(&ahd->stat_timer);
+       del_timer_sync(&ahd->stat_timer);
 
        /* This will reset most registers to 0, but not all */
        ahd_reset(ahd, /*reinit*/FALSE);
@@ -7039,20 +7037,11 @@ static const char *termstat_strings[] = {
 };
 
 /***************************** Timer Facilities *******************************/
-#define ahd_timer_init init_timer
-#define ahd_timer_stop del_timer_sync
-typedef void ahd_linux_callback_t (u_long);
-
 static void
-ahd_timer_reset(ahd_timer_t *timer, int usec, ahd_callback_t *func, void *arg)
+ahd_timer_reset(struct timer_list *timer, int usec)
 {
-       struct ahd_softc *ahd;
-
-       ahd = (struct ahd_softc *)arg;
        del_timer(timer);
-       timer->data = (u_long)arg;
        timer->expires = jiffies + (usec * HZ)/1000000;
-       timer->function = (ahd_linux_callback_t*)func;
        add_timer(timer);
 }
 
@@ -7279,8 +7268,7 @@ ahd_init(struct ahd_softc *ahd)
        }
 init_done:
        ahd_restart(ahd);
-       ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US,
-                       ahd_stat_timer, ahd);
+       ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US);
        return (0);
 }
 
@@ -8878,9 +8866,9 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
 
 /**************************** Statistics Processing ***************************/
 static void
-ahd_stat_timer(void *arg)
+ahd_stat_timer(struct timer_list *t)
 {
-       struct  ahd_softc *ahd = arg;
+       struct  ahd_softc *ahd = from_timer(ahd, t, stat_timer);
        u_long  s;
        int     enint_coal;
        
@@ -8907,8 +8895,7 @@ ahd_stat_timer(void *arg)
        ahd->cmdcmplt_bucket = (ahd->cmdcmplt_bucket+1) & (AHD_STAT_BUCKETS-1);
        ahd->cmdcmplt_total -= ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket];
        ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket] = 0;
-       ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US,
-                       ahd_stat_timer, ahd);
+       ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US);
        ahd_unlock(ahd, &s);
 }
 
index 728193a42e6e7a9e7cffab30332b5944e8c183cb..8a8b7ae7aed3ec74338a3d80ef8d8db2f3edfe2e 100644 (file)
@@ -203,9 +203,6 @@ int ahd_dmamap_unload(struct ahd_softc *, bus_dma_tag_t, bus_dmamap_t);
  */
 #define ahd_dmamap_sync(ahd, dma_tag, dmamap, offset, len, op)
 
-/************************** Timer DataStructures ******************************/
-typedef struct timer_list ahd_timer_t;
-
 /********************************** Includes **********************************/
 #ifdef CONFIG_AIC79XX_REG_PRETTY_PRINT
 #define AIC_DEBUG_REGISTERS 1
@@ -214,10 +211,6 @@ typedef struct timer_list ahd_timer_t;
 #endif
 #include "aic79xx.h"
 
-/***************************** Timer Facilities *******************************/
-#define ahd_timer_init init_timer
-#define ahd_timer_stop del_timer_sync
-
 /***************************** SMP support ************************************/
 #include <linux/spinlock.h>
 
index f2671a8fa7e3358f304c539e7431d73733b95258..7cbc7213b2b23a8a3b751e846396e427762666fd 100644 (file)
@@ -1178,8 +1178,7 @@ static void asd_start_scb_timers(struct list_head *list)
        struct asd_ascb *ascb;
        list_for_each_entry(ascb, list, list) {
                if (!ascb->uldd_timer) {
-                       ascb->timer.data = (unsigned long) ascb;
-                       ascb->timer.function = asd_ascb_timedout;
+                       ascb->timer.function = (TIMER_FUNC_TYPE)asd_ascb_timedout;
                        ascb->timer.expires = jiffies + AIC94XX_SCB_TIMEOUT;
                        add_timer(&ascb->timer);
                }
index 8c1c28239e9307bfd5f30aadad0f2ba852d961c8..8f147e720cfdfe54234eb36a0a8633620276086b 100644 (file)
@@ -291,8 +291,7 @@ static inline void asd_init_ascb(struct asd_ha_struct *asd_ha,
        INIT_LIST_HEAD(&ascb->list);
        ascb->scb = ascb->dma_scb.vaddr;
        ascb->ha = asd_ha;
-       ascb->timer.function = NULL;
-       init_timer(&ascb->timer);
+       timer_setup(&ascb->timer, NULL, 0);
        ascb->tc_index = -1;
 }
 
@@ -392,7 +391,7 @@ void asd_control_led(struct asd_ha_struct *asd_ha, int phy_id, int op);
 void asd_turn_led(struct asd_ha_struct *asd_ha, int phy_id, int op);
 int  asd_enable_phys(struct asd_ha_struct *asd_ha, const u8 phy_mask);
 
-void asd_ascb_timedout(unsigned long data);
+void asd_ascb_timedout(struct timer_list *t);
 int  asd_chip_hardrst(struct asd_ha_struct *asd_ha);
 
 #endif
index fdac7c2fef379bdddd6570d1229bada750c6643b..22873ce8bbfaaf3b97c8d169e251eff8fdc50203 100644 (file)
@@ -866,12 +866,12 @@ void asd_build_initiate_link_adm_task(struct asd_ascb *ascb, int phy_id,
  * Upper layers can implement their own timeout function, say to free
  * resources they have with this SCB, and then call this one at the
  * end of their timeout function.  To do this, one should initialize
- * the ascb->timer.{function, data, expires} prior to calling the post
+ * the ascb->timer.{function, expires} prior to calling the post
  * function. The timer is started by the post function.
  */
-void asd_ascb_timedout(unsigned long data)
+void asd_ascb_timedout(struct timer_list *t)
 {
-       struct asd_ascb *ascb = (void *) data;
+       struct asd_ascb *ascb = from_timer(ascb, t, timer);
        struct asd_seq_data *seq = &ascb->ha->seq;
        unsigned long flags;
 
index d4c35df3d4ae600f9e5d0d7a02ed547f4c8ff905..4637119c09d8aad052c566cf6e9fb2d16c7e87f3 100644 (file)
 static int asd_enqueue_internal(struct asd_ascb *ascb,
                void (*tasklet_complete)(struct asd_ascb *,
                                         struct done_list_struct *),
-                               void (*timed_out)(unsigned long))
+                               void (*timed_out)(struct timer_list *t))
 {
        int res;
 
        ascb->tasklet_complete = tasklet_complete;
        ascb->uldd_timer = 1;
 
-       ascb->timer.data = (unsigned long) ascb;
-       ascb->timer.function = timed_out;
+       ascb->timer.function = (TIMER_FUNC_TYPE)timed_out;
        ascb->timer.expires = jiffies + AIC94XX_SCB_TIMEOUT;
 
        add_timer(&ascb->timer);
@@ -87,9 +86,9 @@ static void asd_clear_nexus_tasklet_complete(struct asd_ascb *ascb,
        asd_ascb_free(ascb);
 }
 
-static void asd_clear_nexus_timedout(unsigned long data)
+static void asd_clear_nexus_timedout(struct timer_list *t)
 {
-       struct asd_ascb *ascb = (void *)data;
+       struct asd_ascb *ascb = from_timer(ascb, t, timer);
        struct tasklet_completion_status *tcs = ascb->uldd_task;
 
        ASD_DPRINTK("%s: here\n", __func__);
@@ -261,9 +260,9 @@ static int asd_clear_nexus_index(struct sas_task *task)
 
 /* ---------- TMFs ---------- */
 
-static void asd_tmf_timedout(unsigned long data)
+static void asd_tmf_timedout(struct timer_list *t)
 {
-       struct asd_ascb *ascb = (void *) data;
+       struct asd_ascb *ascb = from_timer(ascb, t, timer);
        struct tasklet_completion_status *tcs = ascb->uldd_task;
 
        ASD_DPRINTK("tmf timed out\n");
index b4542e7e2ad5b77cb910f25554ba98d3663fb1cb..d8bd6f2c9c830a837e76b2dabddb3f915afc4943 100644 (file)
@@ -5230,12 +5230,11 @@ static void beiscsi_eqd_update_work(struct work_struct *work)
                              msecs_to_jiffies(BEISCSI_EQD_UPDATE_INTERVAL));
 }
 
-static void beiscsi_hw_tpe_check(unsigned long ptr)
+static void beiscsi_hw_tpe_check(struct timer_list *t)
 {
-       struct beiscsi_hba *phba;
+       struct beiscsi_hba *phba = from_timer(phba, t, hw_check);
        u32 wait;
 
-       phba = (struct beiscsi_hba *)ptr;
        /* if not TPE, do nothing */
        if (!beiscsi_detect_tpe(phba))
                return;
@@ -5248,11 +5247,10 @@ static void beiscsi_hw_tpe_check(unsigned long ptr)
                           msecs_to_jiffies(wait));
 }
 
-static void beiscsi_hw_health_check(unsigned long ptr)
+static void beiscsi_hw_health_check(struct timer_list *t)
 {
-       struct beiscsi_hba *phba;
+       struct beiscsi_hba *phba = from_timer(phba, t, hw_check);
 
-       phba = (struct beiscsi_hba *)ptr;
        beiscsi_detect_ue(phba);
        if (beiscsi_detect_ue(phba)) {
                __beiscsi_log(phba, KERN_ERR,
@@ -5264,7 +5262,7 @@ static void beiscsi_hw_health_check(unsigned long ptr)
                if (!test_bit(BEISCSI_HBA_UER_SUPP, &phba->state))
                        return;
                /* modify this timer to check TPE */
-               phba->hw_check.function = beiscsi_hw_tpe_check;
+               phba->hw_check.function = (TIMER_FUNC_TYPE)beiscsi_hw_tpe_check;
        }
 
        mod_timer(&phba->hw_check,
@@ -5351,7 +5349,7 @@ static int beiscsi_enable_port(struct beiscsi_hba *phba)
         * Timer function gets modified for TPE detection.
         * Always reinit to do health check first.
         */
-       phba->hw_check.function = beiscsi_hw_health_check;
+       phba->hw_check.function = (TIMER_FUNC_TYPE)beiscsi_hw_health_check;
        mod_timer(&phba->hw_check,
                  jiffies + msecs_to_jiffies(BEISCSI_UE_DETECT_INTERVAL));
        return 0;
@@ -5708,9 +5706,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
         * Start UE detection here. UE before this will cause stall in probe
         * and eventually fail the probe.
         */
-       init_timer(&phba->hw_check);
-       phba->hw_check.function = beiscsi_hw_health_check;
-       phba->hw_check.data = (unsigned long)phba;
+       timer_setup(&phba->hw_check, beiscsi_hw_health_check, 0);
        mod_timer(&phba->hw_check,
                  jiffies + msecs_to_jiffies(BEISCSI_UE_DETECT_INTERVAL));
        beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
index 6844ba36161638d995f3d5d5135c160fc54bc9ed..e6b9de7d41ac08719835dc06ba6bcbd0b00df8fc 100644 (file)
@@ -823,7 +823,7 @@ static int bnx2fc_net_config(struct fc_lport *lport, struct net_device *netdev)
 
        skb_queue_head_init(&port->fcoe_pending_queue);
        port->fcoe_pending_queue_active = 0;
-       setup_timer(&port->timer, fcoe_queue_timer, (unsigned long) lport);
+       timer_setup(&port->timer, fcoe_queue_timer, 0);
 
        fcoe_link_speed_update(lport);
 
@@ -845,9 +845,9 @@ static int bnx2fc_net_config(struct fc_lport *lport, struct net_device *netdev)
        return 0;
 }
 
-static void bnx2fc_destroy_timer(unsigned long data)
+static void bnx2fc_destroy_timer(struct timer_list *t)
 {
-       struct bnx2fc_hba *hba = (struct bnx2fc_hba *)data;
+       struct bnx2fc_hba *hba = from_timer(hba, t, destroy_timer);
 
        printk(KERN_ERR PFX "ERROR:bnx2fc_destroy_timer - "
               "Destroy compl not received!!\n");
@@ -1946,11 +1946,10 @@ static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba)
 {
        if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) {
                if (bnx2fc_send_fw_fcoe_destroy_msg(hba) == 0) {
-                       init_timer(&hba->destroy_timer);
+                       timer_setup(&hba->destroy_timer, bnx2fc_destroy_timer,
+                                   0);
                        hba->destroy_timer.expires = BNX2FC_FW_TIMEOUT +
                                                                jiffies;
-                       hba->destroy_timer.function = bnx2fc_destroy_timer;
-                       hba->destroy_timer.data = (unsigned long)hba;
                        add_timer(&hba->destroy_timer);
                        wait_event_interruptible(hba->destroy_wait,
                                        test_bit(BNX2FC_FLAG_DESTROY_CMPL,
index 89ef1a1678d192d291dd5de4efb14fd537ac7aa3..663a63d4dae4dca425f39639d38308eb90e37f77 100644 (file)
@@ -858,7 +858,7 @@ extern int bnx2i_alloc_qp_resc(struct bnx2i_hba *hba,
                               struct bnx2i_endpoint *ep);
 extern void bnx2i_free_qp_resc(struct bnx2i_hba *hba,
                               struct bnx2i_endpoint *ep);
-extern void bnx2i_ep_ofld_timer(unsigned long data);
+extern void bnx2i_ep_ofld_timer(struct timer_list *t);
 extern struct bnx2i_endpoint *bnx2i_find_ep_in_ofld_list(
                struct bnx2i_hba *hba, u32 iscsi_cid);
 extern struct bnx2i_endpoint *bnx2i_find_ep_in_destroy_list(
index 42921dbba9272f793a2a4a483e727dfa78809e4b..61a93994d5ed210b8fca4905871b95a6c98b4329 100644 (file)
@@ -698,9 +698,9 @@ void bnx2i_update_iscsi_conn(struct iscsi_conn *conn)
  *
  * routine to handle connection offload/destroy request timeout
  */
-void bnx2i_ep_ofld_timer(unsigned long data)
+void bnx2i_ep_ofld_timer(struct timer_list *t)
 {
-       struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) data;
+       struct bnx2i_endpoint *ep = from_timer(ep, t, ofld_timer);
 
        if (ep->state == EP_STATE_OFLD_START) {
                printk(KERN_ALERT "ofld_timer: CONN_OFLD timeout\n");
index 03c104b47f31c98670d9a80d64e0b986d707d9f0..de0a507577ef56bc90330c8c0b532086823f1e85 100644 (file)
@@ -1611,9 +1611,8 @@ static int bnx2i_conn_start(struct iscsi_cls_conn *cls_conn)
         * this should normally not sleep for a long time so it should
         * not disrupt the caller.
         */
+       timer_setup(&bnx2i_conn->ep->ofld_timer, bnx2i_ep_ofld_timer, 0);
        bnx2i_conn->ep->ofld_timer.expires = 1 * HZ + jiffies;
-       bnx2i_conn->ep->ofld_timer.function = bnx2i_ep_ofld_timer;
-       bnx2i_conn->ep->ofld_timer.data = (unsigned long) bnx2i_conn->ep;
        add_timer(&bnx2i_conn->ep->ofld_timer);
        /* update iSCSI context for this conn, wait for CNIC to complete */
        wait_event_interruptible(bnx2i_conn->ep->ofld_wait,
@@ -1729,10 +1728,8 @@ static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
        }
 
        ep->state = EP_STATE_CLEANUP_START;
-       init_timer(&ep->ofld_timer);
+       timer_setup(&ep->ofld_timer, bnx2i_ep_ofld_timer, 0);
        ep->ofld_timer.expires = hba->conn_ctx_destroy_tmo + jiffies;
-       ep->ofld_timer.function = bnx2i_ep_ofld_timer;
-       ep->ofld_timer.data = (unsigned long) ep;
        add_timer(&ep->ofld_timer);
 
        bnx2i_ep_destroy_list_add(hba, ep);
@@ -1835,10 +1832,8 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
        bnx2i_ep->state = EP_STATE_OFLD_START;
        bnx2i_ep_ofld_list_add(hba, bnx2i_ep);
 
-       init_timer(&bnx2i_ep->ofld_timer);
+       timer_setup(&bnx2i_ep->ofld_timer, bnx2i_ep_ofld_timer, 0);
        bnx2i_ep->ofld_timer.expires = 2 * HZ + jiffies;
-       bnx2i_ep->ofld_timer.function = bnx2i_ep_ofld_timer;
-       bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep;
        add_timer(&bnx2i_ep->ofld_timer);
 
        if (bnx2i_send_conn_ofld_req(hba, bnx2i_ep)) {
@@ -2054,10 +2049,8 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
                session = conn->session;
        }
 
-       init_timer(&bnx2i_ep->ofld_timer);
+       timer_setup(&bnx2i_ep->ofld_timer, bnx2i_ep_ofld_timer, 0);
        bnx2i_ep->ofld_timer.expires = hba->conn_teardown_tmo + jiffies;
-       bnx2i_ep->ofld_timer.function = bnx2i_ep_ofld_timer;
-       bnx2i_ep->ofld_timer.data = (unsigned long) bnx2i_ep;
        add_timer(&bnx2i_ep->ofld_timer);
 
        if (!test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic))
index 5be0086142cac6991598cd9099522212709a216c..0bd1131b6cc940fd731f754eb31f1b7672ba544e 100644 (file)
@@ -3347,9 +3347,10 @@ csio_mberr_worker(void *data)
  *
  **/
 static void
-csio_hw_mb_timer(uintptr_t data)
+csio_hw_mb_timer(struct timer_list *t)
 {
-       struct csio_hw *hw = (struct csio_hw *)data;
+       struct csio_mbm *mbm = from_timer(mbm, t, timer);
+       struct csio_hw *hw = mbm->hw;
        struct csio_mb *mbp = NULL;
 
        spin_lock_irq(&hw->lock);
@@ -3715,9 +3716,9 @@ csio_mgmt_req_lookup(struct csio_mgmtm *mgmtm, struct csio_ioreq *io_req)
  * Return - none.
  */
 static void
-csio_mgmt_tmo_handler(uintptr_t data)
+csio_mgmt_tmo_handler(struct timer_list *t)
 {
-       struct csio_mgmtm *mgmtm = (struct csio_mgmtm *) data;
+       struct csio_mgmtm *mgmtm = from_timer(mgmtm, t, mgmt_timer);
        struct list_head *tmp;
        struct csio_ioreq *io_req;
 
@@ -3797,11 +3798,7 @@ csio_mgmtm_cleanup(struct csio_mgmtm *mgmtm)
 static int
 csio_mgmtm_init(struct csio_mgmtm *mgmtm, struct csio_hw *hw)
 {
-       struct timer_list *timer = &mgmtm->mgmt_timer;
-
-       init_timer(timer);
-       timer->function = csio_mgmt_tmo_handler;
-       timer->data = (unsigned long)mgmtm;
+       timer_setup(&mgmtm->mgmt_timer, csio_mgmt_tmo_handler, 0);
 
        INIT_LIST_HEAD(&mgmtm->active_q);
        INIT_LIST_HEAD(&mgmtm->cbfn_q);
index 9451787ca7f299715a97e34692315d69e7968910..abcedfbcecda26ddec8d0feb87f1af633c6011d3 100644 (file)
@@ -1644,13 +1644,10 @@ csio_mb_cancel_all(struct csio_hw *hw, struct list_head *cbfn_q)
  */
 int
 csio_mbm_init(struct csio_mbm *mbm, struct csio_hw *hw,
-             void (*timer_fn)(uintptr_t))
+             void (*timer_fn)(struct timer_list *))
 {
-       struct timer_list *timer = &mbm->timer;
-
-       init_timer(timer);
-       timer->function = timer_fn;
-       timer->data = (unsigned long)hw;
+       mbm->hw = hw;
+       timer_setup(&mbm->timer, timer_fn, 0);
 
        INIT_LIST_HEAD(&mbm->req_q);
        INIT_LIST_HEAD(&mbm->cbfn_q);
index 1bc82d0bc260259a84f16a03e2049a19844a85f2..a6823df730154a10e74a5fb1084ec869eb048518 100644 (file)
@@ -137,6 +137,7 @@ struct csio_mbm {
        uint32_t                a_mbox;                 /* Async mbox num */
        uint32_t                intr_idx;               /* Interrupt index */
        struct timer_list       timer;                  /* Mbox timer */
+       struct csio_hw          *hw;                    /* Hardware pointer */
        struct list_head        req_q;                  /* Mbox request queue */
        struct list_head        cbfn_q;                 /* Mbox completion q */
        struct csio_mb          *mcurrent;              /* Current mailbox */
@@ -252,7 +253,7 @@ void csio_mb_process_portparams_rsp(struct csio_hw *hw, struct csio_mb *mbp,
 
 /* MB module functions */
 int csio_mbm_init(struct csio_mbm *, struct csio_hw *,
-                           void (*)(uintptr_t));
+                           void (*)(struct timer_list *));
 void csio_mbm_exit(struct csio_mbm *);
 void csio_mb_intr_enable(struct csio_hw *);
 void csio_mb_intr_disable(struct csio_hw *);
index 7b09e7ddf35e7b99c2c87a64e42b369ebd7dbed1..babd79361a461097f93dedba4fb400d8caecf390 100644 (file)
@@ -545,10 +545,10 @@ static int act_open_rpl_status_to_errno(int status)
        }
 }
 
-static void act_open_retry_timer(unsigned long data)
+static void act_open_retry_timer(struct timer_list *t)
 {
+       struct cxgbi_sock *csk = from_timer(csk, t, retry_timer);
        struct sk_buff *skb;
-       struct cxgbi_sock *csk = (struct cxgbi_sock *)data;
 
        log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK,
                "csk 0x%p,%u,0x%lx,%u.\n",
@@ -586,8 +586,8 @@ static int do_act_open_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
        cxgbi_sock_get(csk);
        spin_lock_bh(&csk->lock);
        if (rpl->status == CPL_ERR_CONN_EXIST &&
-           csk->retry_timer.function != act_open_retry_timer) {
-               csk->retry_timer.function = act_open_retry_timer;
+           csk->retry_timer.function != (TIMER_FUNC_TYPE)act_open_retry_timer) {
+               csk->retry_timer.function = (TIMER_FUNC_TYPE)act_open_retry_timer;
                mod_timer(&csk->retry_timer, jiffies + HZ / 2);
        } else
                cxgbi_sock_fail_act_open(csk,
index 1d02cf9fe06c5e941e5d1a76254f86ce658fc04b..1bef2724eb783d7441b98e224eea3668f0792f28 100644 (file)
@@ -872,10 +872,10 @@ static int act_open_rpl_status_to_errno(int status)
        }
 }
 
-static void csk_act_open_retry_timer(unsigned long data)
+static void csk_act_open_retry_timer(struct timer_list *t)
 {
        struct sk_buff *skb = NULL;
-       struct cxgbi_sock *csk = (struct cxgbi_sock *)data;
+       struct cxgbi_sock *csk = from_timer(csk, t, retry_timer);
        struct cxgb4_lld_info *lldi = cxgbi_cdev_priv(csk->cdev);
        void (*send_act_open_func)(struct cxgbi_sock *, struct sk_buff *,
                                   struct l2t_entry *);
@@ -963,8 +963,8 @@ static void do_act_open_rpl(struct cxgbi_device *cdev, struct sk_buff *skb)
        spin_lock_bh(&csk->lock);
 
        if (status == CPL_ERR_CONN_EXIST &&
-           csk->retry_timer.function != csk_act_open_retry_timer) {
-               csk->retry_timer.function = csk_act_open_retry_timer;
+           csk->retry_timer.function != (TIMER_FUNC_TYPE)csk_act_open_retry_timer) {
+               csk->retry_timer.function = (TIMER_FUNC_TYPE)csk_act_open_retry_timer;
                mod_timer(&csk->retry_timer, jiffies + HZ / 2);
        } else
                cxgbi_sock_fail_act_open(csk,
index 512c8f1ea5b06efd4d42c2eed805be9e6a23d533..a61a152136a3c3dd9716157131d057245a62f887 100644 (file)
@@ -572,7 +572,7 @@ static struct cxgbi_sock *cxgbi_sock_create(struct cxgbi_device *cdev)
        kref_init(&csk->refcnt);
        skb_queue_head_init(&csk->receive_queue);
        skb_queue_head_init(&csk->write_queue);
-       setup_timer(&csk->retry_timer, NULL, (unsigned long)csk);
+       timer_setup(&csk->retry_timer, NULL, 0);
        rwlock_init(&csk->callback_lock);
        csk->cdev = cdev;
        csk->flags = 0;
index 5ee7f44cf869b906397447a0572b1b227e8951a1..60ef8df42b95c95f671cba4a0d9223161813b20c 100644 (file)
@@ -395,7 +395,7 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
                struct ScsiReqBlk *srb);
 static void set_xfer_rate(struct AdapterCtlBlk *acb,
                struct DeviceCtlBlk *dcb);
-static void waiting_timeout(unsigned long ptr);
+static void waiting_timeout(struct timer_list *t);
 
 
 /*---------------------------------------------------------------------------
@@ -857,9 +857,6 @@ static void waiting_set_timer(struct AdapterCtlBlk *acb, unsigned long to)
 {
        if (timer_pending(&acb->waiting_timer))
                return;
-       init_timer(&acb->waiting_timer);
-       acb->waiting_timer.function = waiting_timeout;
-       acb->waiting_timer.data = (unsigned long) acb;
        if (time_before(jiffies + to, acb->last_reset - HZ / 2))
                acb->waiting_timer.expires =
                    acb->last_reset - HZ / 2 + 1;
@@ -936,10 +933,10 @@ static void waiting_process_next(struct AdapterCtlBlk *acb)
 
 
 /* Wake up waiting queue */
-static void waiting_timeout(unsigned long ptr)
+static void waiting_timeout(struct timer_list *t)
 {
        unsigned long flags;
-       struct AdapterCtlBlk *acb = (struct AdapterCtlBlk *)ptr;
+       struct AdapterCtlBlk *acb = from_timer(acb, t, waiting_timer);
        dprintkdbg(DBG_1,
                "waiting_timeout: Queue woken up by timer. acb=%p\n", acb);
        DC395x_LOCK_IO(acb->scsi_host, flags);
@@ -4366,8 +4363,8 @@ static void adapter_init_params(struct AdapterCtlBlk *acb)
        INIT_LIST_HEAD(&acb->srb_free_list);
        /*  temp SRB for Q tag used or abort command used  */
        acb->tmp_srb = &acb->srb;
-       init_timer(&acb->waiting_timer);
-       init_timer(&acb->selto_timer);
+       timer_setup(&acb->waiting_timer, waiting_timeout, 0);
+       timer_setup(&acb->selto_timer, NULL, 0);
 
        acb->srb_count = DC395x_MAX_SRB_CNT;
 
index 85f9a3eba387c47b37e7555d3a183aafa556a742..5cc09dce4d25080d44c442821034dd5297cdff80 100644 (file)
@@ -754,7 +754,7 @@ static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev)
 
        skb_queue_head_init(&port->fcoe_pending_queue);
        port->fcoe_pending_queue_active = 0;
-       setup_timer(&port->timer, fcoe_queue_timer, (unsigned long)lport);
+       timer_setup(&port->timer, fcoe_queue_timer, 0);
 
        fcoe_link_speed_update(lport);
 
index 375c536cbc688f0e5b9467ca65e9885b96ea130d..1ba5f51713a3216353991e1d7aa54217f66ab851 100644 (file)
@@ -455,9 +455,11 @@ EXPORT_SYMBOL_GPL(fcoe_check_wait_queue);
  *
  * Calls fcoe_check_wait_queue on timeout
  */
-void fcoe_queue_timer(ulong lport)
+void fcoe_queue_timer(struct timer_list *t)
 {
-       fcoe_check_wait_queue((struct fc_lport *)lport, NULL);
+       struct fcoe_port *port = from_timer(port, t, timer);
+
+       fcoe_check_wait_queue(port->lport, NULL);
 }
 EXPORT_SYMBOL_GPL(fcoe_queue_timer);
 
index a4473356a9dc2a4fcfd1f4d34d3096ba50797b5f..c35f05c4c6bbbbb5e029201dc36564f322bb451a 100644 (file)
@@ -3705,7 +3705,7 @@ static void gdth_log_event(gdth_evt_data *dvr, char *buffer)
 #ifdef GDTH_STATISTICS
 static u8      gdth_timer_running;
 
-static void gdth_timeout(unsigned long data)
+static void gdth_timeout(struct timer_list *unused)
 {
     u32 i;
     Scsi_Cmnd *nscp;
@@ -3743,8 +3743,6 @@ static void gdth_timer_init(void)
        gdth_timer_running = 1;
        TRACE2(("gdth_detect(): Initializing timer !\n"));
        gdth_timer.expires = jiffies + HZ;
-       gdth_timer.data = 0L;
-       gdth_timer.function = gdth_timeout;
        add_timer(&gdth_timer);
 }
 #else
@@ -5165,7 +5163,7 @@ static int __init gdth_init(void)
        /* initializations */
        gdth_polling = TRUE;
        gdth_clear_events();
-       init_timer(&gdth_timer);
+       timer_setup(&gdth_timer, gdth_timeout, 0);
 
        /* As default we do not probe for EISA or ISA controllers */
        if (probe_eisa_isa) {
index 07f4a4cfbec1b3275280eb0193009fbf3e72b264..15692ea05cedd401917b6521fd8805e94897c2e4 100644 (file)
@@ -103,7 +103,6 @@ struct hisi_sas_phy {
        struct hisi_sas_port    *port;
        struct asd_sas_phy      sas_phy;
        struct sas_identify     identify;
-       struct timer_list       timer;
        struct work_struct      phyup_ws;
        u64             port_id; /* from hw */
        u64             dev_sas_addr;
index 16664f2e15fbadd77d30439d723f1d972d0efbbf..37c838be47577e26cb8c88fc6b402c142cc5c1e7 100644 (file)
@@ -627,7 +627,6 @@ static void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int phy_no)
 
        phy->hisi_hba = hisi_hba;
        phy->port = NULL;
-       init_timer(&phy->timer);
        sas_phy->enabled = (phy_no < hisi_hba->n_phy) ? 1 : 0;
        sas_phy->class = SAS;
        sas_phy->iproto = SAS_PROTOCOL_ALL;
@@ -792,9 +791,10 @@ static void hisi_sas_task_done(struct sas_task *task)
        complete(&task->slow_task->completion);
 }
 
-static void hisi_sas_tmf_timedout(unsigned long data)
+static void hisi_sas_tmf_timedout(struct timer_list *t)
 {
-       struct sas_task *task = (struct sas_task *)data;
+       struct sas_task_slow *slow = from_timer(slow, t, timer);
+       struct sas_task *task = slow->task;
        unsigned long flags;
 
        spin_lock_irqsave(&task->task_state_lock, flags);
@@ -833,8 +833,7 @@ static int hisi_sas_exec_internal_tmf_task(struct domain_device *device,
                }
                task->task_done = hisi_sas_task_done;
 
-               task->slow_task->timer.data = (unsigned long) task;
-               task->slow_task->timer.function = hisi_sas_tmf_timedout;
+               task->slow_task->timer.function = (TIMER_FUNC_TYPE)hisi_sas_tmf_timedout;
                task->slow_task->timer.expires = jiffies + TASK_TIMEOUT*HZ;
                add_timer(&task->slow_task->timer);
 
@@ -1447,8 +1446,7 @@ hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba,
        task->dev = device;
        task->task_proto = device->tproto;
        task->task_done = hisi_sas_task_done;
-       task->slow_task->timer.data = (unsigned long)task;
-       task->slow_task->timer.function = hisi_sas_tmf_timedout;
+       task->slow_task->timer.function = (TIMER_FUNC_TYPE)hisi_sas_tmf_timedout;
        task->slow_task->timer.expires = jiffies + msecs_to_jiffies(110);
        add_timer(&task->slow_task->timer);
 
@@ -1877,7 +1875,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
        hisi_hba->shost = shost;
        SHOST_TO_SAS_HA(shost) = &hisi_hba->sha;
 
-       init_timer(&hisi_hba->timer);
+       timer_setup(&hisi_hba->timer, NULL, 0);
 
        if (hisi_sas_get_fw_info(hisi_hba) < 0)
                goto err_out;
index 08eca20b0b81812a8ef32ac23d47a5ccbbb4f5ab..9385554e43a6095537f2852f02960fa0b8dbad92 100644 (file)
@@ -807,9 +807,9 @@ static void phy_hard_reset_v1_hw(struct hisi_hba *hisi_hba, int phy_no)
        start_phy_v1_hw(hisi_hba, phy_no);
 }
 
-static void start_phys_v1_hw(unsigned long data)
+static void start_phys_v1_hw(struct timer_list *t)
 {
-       struct hisi_hba *hisi_hba = (struct hisi_hba *)data;
+       struct hisi_hba *hisi_hba = from_timer(hisi_hba, t, timer);
        int i;
 
        for (i = 0; i < hisi_hba->n_phy; i++) {
@@ -828,7 +828,7 @@ static void phys_init_v1_hw(struct hisi_hba *hisi_hba)
                hisi_sas_phy_read32(hisi_hba, i, CHL_INT2_MSK);
        }
 
-       setup_timer(timer, start_phys_v1_hw, (unsigned long)hisi_hba);
+       timer_setup(timer, start_phys_v1_hw, 0);
        mod_timer(timer, jiffies + HZ);
 }
 
index 779af979b6db93380386210c4a19f6231ecf8fc1..b1f097dabd0187f55b8990b0939dda6614fcba8f 100644 (file)
@@ -728,7 +728,7 @@ enum {
 #define ERR_ON_RX_PHASE(err_phase) (err_phase == 0x10 || \
                err_phase == 0x20 || err_phase == 0x40)
 
-static void link_timeout_disable_link(unsigned long data);
+static void link_timeout_disable_link(struct timer_list *t);
 
 static u32 hisi_sas_read32(struct hisi_hba *hisi_hba, u32 off)
 {
@@ -1270,9 +1270,9 @@ static void init_reg_v2_hw(struct hisi_hba *hisi_hba)
                         upper_32_bits(hisi_hba->initial_fis_dma));
 }
 
-static void link_timeout_enable_link(unsigned long data)
+static void link_timeout_enable_link(struct timer_list *t)
 {
-       struct hisi_hba *hisi_hba = (struct hisi_hba *)data;
+       struct hisi_hba *hisi_hba = from_timer(hisi_hba, t, timer);
        int i, reg_val;
 
        for (i = 0; i < hisi_hba->n_phy; i++) {
@@ -1287,13 +1287,13 @@ static void link_timeout_enable_link(unsigned long data)
                }
        }
 
-       hisi_hba->timer.function = link_timeout_disable_link;
+       hisi_hba->timer.function = (TIMER_FUNC_TYPE)link_timeout_disable_link;
        mod_timer(&hisi_hba->timer, jiffies + msecs_to_jiffies(900));
 }
 
-static void link_timeout_disable_link(unsigned long data)
+static void link_timeout_disable_link(struct timer_list *t)
 {
-       struct hisi_hba *hisi_hba = (struct hisi_hba *)data;
+       struct hisi_hba *hisi_hba = from_timer(hisi_hba, t, timer);
        int i, reg_val;
 
        reg_val = hisi_sas_read32(hisi_hba, PHY_STATE);
@@ -1308,14 +1308,13 @@ static void link_timeout_disable_link(unsigned long data)
                }
        }
 
-       hisi_hba->timer.function = link_timeout_enable_link;
+       hisi_hba->timer.function = (TIMER_FUNC_TYPE)link_timeout_enable_link;
        mod_timer(&hisi_hba->timer, jiffies + msecs_to_jiffies(100));
 }
 
 static void set_link_timer_quirk(struct hisi_hba *hisi_hba)
 {
-       hisi_hba->timer.data = (unsigned long)hisi_hba;
-       hisi_hba->timer.function = link_timeout_disable_link;
+       hisi_hba->timer.function = (TIMER_FUNC_TYPE)link_timeout_disable_link;
        hisi_hba->timer.expires = jiffies + msecs_to_jiffies(1000);
        add_timer(&hisi_hba->timer);
 }
@@ -2574,9 +2573,9 @@ static int prep_ata_v2_hw(struct hisi_hba *hisi_hba,
        return 0;
 }
 
-static void hisi_sas_internal_abort_quirk_timeout(unsigned long data)
+static void hisi_sas_internal_abort_quirk_timeout(struct timer_list *t)
 {
-       struct hisi_sas_slot *slot = (struct hisi_sas_slot *)data;
+       struct hisi_sas_slot *slot = from_timer(slot, t, internal_abort_timer);
        struct hisi_sas_port *port = slot->port;
        struct asd_sas_port *asd_sas_port;
        struct asd_sas_phy *sas_phy;
@@ -2619,8 +2618,7 @@ static int prep_abort_v2_hw(struct hisi_hba *hisi_hba,
        struct timer_list *timer = &slot->internal_abort_timer;
 
        /* setup the quirk timer */
-       setup_timer(timer, hisi_sas_internal_abort_quirk_timeout,
-                   (unsigned long)slot);
+       timer_setup(timer, hisi_sas_internal_abort_quirk_timeout, 0);
        /* Set the timeout to 10ms less than internal abort timeout */
        mod_timer(timer, jiffies + msecs_to_jiffies(100));
 
index 2e5fa9717be89acdcc3b1565c0b1c85a5ab089c1..3f2f0baf2a5edf234749fcab089648c7b14cae17 100644 (file)
@@ -1823,7 +1823,7 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev)
        hisi_hba->shost = shost;
        SHOST_TO_SAS_HA(shost) = &hisi_hba->sha;
 
-       init_timer(&hisi_hba->timer);
+       timer_setup(&hisi_hba->timer, NULL, 0);
 
        if (hisi_sas_get_fw_info(hisi_hba) < 0)
                goto err_out;
index b491af31a5f8e0289c1a3dea2f1a588ff4a3796e..0d2f7eb3acb6933b8b38c353c9f1b283c01350e4 100644 (file)
@@ -1393,8 +1393,9 @@ static int ibmvfc_map_sg_data(struct scsi_cmnd *scmd,
  *
  * Called when an internally generated command times out
  **/
-static void ibmvfc_timeout(struct ibmvfc_event *evt)
+static void ibmvfc_timeout(struct timer_list *t)
 {
+       struct ibmvfc_event *evt = from_timer(evt, t, timer);
        struct ibmvfc_host *vhost = evt->vhost;
        dev_err(vhost->dev, "Command timed out (%p). Resetting connection\n", evt);
        ibmvfc_reset_host(vhost);
@@ -1424,12 +1425,10 @@ static int ibmvfc_send_event(struct ibmvfc_event *evt,
                BUG();
 
        list_add_tail(&evt->queue, &vhost->sent);
-       init_timer(&evt->timer);
+       timer_setup(&evt->timer, ibmvfc_timeout, 0);
 
        if (timeout) {
-               evt->timer.data = (unsigned long) evt;
                evt->timer.expires = jiffies + (timeout * HZ);
-               evt->timer.function = (void (*)(unsigned long))ibmvfc_timeout;
                add_timer(&evt->timer);
        }
 
@@ -3692,8 +3691,9 @@ static void ibmvfc_tgt_adisc_cancel_done(struct ibmvfc_event *evt)
  * out, reset the CRQ. When the ADISC comes back as cancelled,
  * log back into the target.
  **/
-static void ibmvfc_adisc_timeout(struct ibmvfc_target *tgt)
+static void ibmvfc_adisc_timeout(struct timer_list *t)
 {
+       struct ibmvfc_target *tgt = from_timer(tgt, t, timer);
        struct ibmvfc_host *vhost = tgt->vhost;
        struct ibmvfc_event *evt;
        struct ibmvfc_tmf *tmf;
@@ -3778,9 +3778,7 @@ static void ibmvfc_tgt_adisc(struct ibmvfc_target *tgt)
        if (timer_pending(&tgt->timer))
                mod_timer(&tgt->timer, jiffies + (IBMVFC_ADISC_TIMEOUT * HZ));
        else {
-               tgt->timer.data = (unsigned long) tgt;
                tgt->timer.expires = jiffies + (IBMVFC_ADISC_TIMEOUT * HZ);
-               tgt->timer.function = (void (*)(unsigned long))ibmvfc_adisc_timeout;
                add_timer(&tgt->timer);
        }
 
@@ -3912,7 +3910,7 @@ static int ibmvfc_alloc_target(struct ibmvfc_host *vhost, u64 scsi_id)
        tgt->vhost = vhost;
        tgt->need_login = 1;
        tgt->cancel_key = vhost->task_set++;
-       init_timer(&tgt->timer);
+       timer_setup(&tgt->timer, ibmvfc_adisc_timeout, 0);
        kref_init(&tgt->kref);
        ibmvfc_init_tgt(tgt, ibmvfc_tgt_implicit_logout);
        spin_lock_irqsave(vhost->host->host_lock, flags);
index 7d156b161482988367ac323f8182d177421d1163..17df76f0be3c5212798f106539ccea6883fbe495 100644 (file)
@@ -837,8 +837,9 @@ static void ibmvscsi_reset_host(struct ibmvscsi_host_data *hostdata)
  *
  * Called when an internally generated command times out
 */
-static void ibmvscsi_timeout(struct srp_event_struct *evt_struct)
+static void ibmvscsi_timeout(struct timer_list *t)
 {
+       struct srp_event_struct *evt_struct = from_timer(evt_struct, t, timer);
        struct ibmvscsi_host_data *hostdata = evt_struct->hostdata;
 
        dev_err(hostdata->dev, "Command timed out (%x). Resetting connection\n",
@@ -927,11 +928,9 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
         */
        list_add_tail(&evt_struct->list, &hostdata->sent);
 
-       init_timer(&evt_struct->timer);
+       timer_setup(&evt_struct->timer, ibmvscsi_timeout, 0);
        if (timeout) {
-               evt_struct->timer.data = (unsigned long) evt_struct;
                evt_struct->timer.expires = jiffies + (timeout * HZ);
-               evt_struct->timer.function = (void (*)(unsigned long))ibmvscsi_timeout;
                add_timer(&evt_struct->timer);
        }
 
index f838bd73befa8f3b2fe915b8bbbe1990c563de1f..d53429371127a4eb3ea76ce52dc2408ec05b9a11 100644 (file)
@@ -694,7 +694,7 @@ static void ipr_init_ipr_cmnd(struct ipr_cmnd *ipr_cmd,
        ipr_cmd->sibling = NULL;
        ipr_cmd->eh_comp = NULL;
        ipr_cmd->fast_done = fast_done;
-       init_timer(&ipr_cmd->timer);
+       timer_setup(&ipr_cmd->timer, NULL, 0);
 }
 
 /**
@@ -990,15 +990,14 @@ static void ipr_send_command(struct ipr_cmnd *ipr_cmd)
  **/
 static void ipr_do_req(struct ipr_cmnd *ipr_cmd,
                       void (*done) (struct ipr_cmnd *),
-                      void (*timeout_func) (struct ipr_cmnd *), u32 timeout)
+                      void (*timeout_func) (struct timer_list *), u32 timeout)
 {
        list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_pending_q);
 
        ipr_cmd->done = done;
 
-       ipr_cmd->timer.data = (unsigned long) ipr_cmd;
        ipr_cmd->timer.expires = jiffies + timeout;
-       ipr_cmd->timer.function = (void (*)(unsigned long))timeout_func;
+       ipr_cmd->timer.function = (TIMER_FUNC_TYPE)timeout_func;
 
        add_timer(&ipr_cmd->timer);
 
@@ -1080,7 +1079,7 @@ static void ipr_init_ioadl(struct ipr_cmnd *ipr_cmd, dma_addr_t dma_addr,
  *     none
  **/
 static void ipr_send_blocking_cmd(struct ipr_cmnd *ipr_cmd,
-                                 void (*timeout_func) (struct ipr_cmnd *ipr_cmd),
+                                 void (*timeout_func) (struct timer_list *),
                                  u32 timeout)
 {
        struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
@@ -2664,8 +2663,9 @@ static void ipr_process_error(struct ipr_cmnd *ipr_cmd)
  * Return value:
  *     none
  **/
-static void ipr_timeout(struct ipr_cmnd *ipr_cmd)
+static void ipr_timeout(struct timer_list *t)
 {
+       struct ipr_cmnd *ipr_cmd = from_timer(ipr_cmd, t, timer);
        unsigned long lock_flags = 0;
        struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
 
@@ -2696,8 +2696,9 @@ static void ipr_timeout(struct ipr_cmnd *ipr_cmd)
  * Return value:
  *     none
  **/
-static void ipr_oper_timeout(struct ipr_cmnd *ipr_cmd)
+static void ipr_oper_timeout(struct timer_list *t)
 {
+       struct ipr_cmnd *ipr_cmd = from_timer(ipr_cmd, t, timer);
        unsigned long lock_flags = 0;
        struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
 
@@ -5449,8 +5450,9 @@ static void ipr_bus_reset_done(struct ipr_cmnd *ipr_cmd)
  * Return value:
  *     none
  **/
-static void ipr_abort_timeout(struct ipr_cmnd *ipr_cmd)
+static void ipr_abort_timeout(struct timer_list *t)
 {
+       struct ipr_cmnd *ipr_cmd = from_timer(ipr_cmd, t, timer);
        struct ipr_cmnd *reset_cmd;
        struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
        struct ipr_cmd_pkt *cmd_pkt;
@@ -8271,8 +8273,9 @@ static int ipr_ioafp_identify_hrrq(struct ipr_cmnd *ipr_cmd)
  * Return value:
  *     none
  **/
-static void ipr_reset_timer_done(struct ipr_cmnd *ipr_cmd)
+static void ipr_reset_timer_done(struct timer_list *t)
 {
+       struct ipr_cmnd *ipr_cmd = from_timer(ipr_cmd, t, timer);
        struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
        unsigned long lock_flags = 0;
 
@@ -8308,9 +8311,8 @@ static void ipr_reset_start_timer(struct ipr_cmnd *ipr_cmd,
        list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_pending_q);
        ipr_cmd->done = ipr_reset_ioa_job;
 
-       ipr_cmd->timer.data = (unsigned long) ipr_cmd;
        ipr_cmd->timer.expires = jiffies + timeout;
-       ipr_cmd->timer.function = (void (*)(unsigned long))ipr_reset_timer_done;
+       ipr_cmd->timer.function = (TIMER_FUNC_TYPE)ipr_reset_timer_done;
        add_timer(&ipr_cmd->timer);
 }
 
@@ -8394,9 +8396,8 @@ static int ipr_reset_next_stage(struct ipr_cmnd *ipr_cmd)
                }
        }
 
-       ipr_cmd->timer.data = (unsigned long) ipr_cmd;
        ipr_cmd->timer.expires = jiffies + stage_time * HZ;
-       ipr_cmd->timer.function = (void (*)(unsigned long))ipr_oper_timeout;
+       ipr_cmd->timer.function = (TIMER_FUNC_TYPE)ipr_oper_timeout;
        ipr_cmd->done = ipr_reset_ioa_job;
        add_timer(&ipr_cmd->timer);
 
@@ -8466,9 +8467,8 @@ static int ipr_reset_enable_ioa(struct ipr_cmnd *ipr_cmd)
                return IPR_RC_JOB_CONTINUE;
        }
 
-       ipr_cmd->timer.data = (unsigned long) ipr_cmd;
        ipr_cmd->timer.expires = jiffies + (ioa_cfg->transop_timeout * HZ);
-       ipr_cmd->timer.function = (void (*)(unsigned long))ipr_oper_timeout;
+       ipr_cmd->timer.function = (TIMER_FUNC_TYPE)ipr_oper_timeout;
        ipr_cmd->done = ipr_reset_ioa_job;
        add_timer(&ipr_cmd->timer);
        list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_pending_q);
index 609dafd661d1437a0287c7511d8e31f7c1e1c199..13b37cdffa8edbf02ce56a09e40a80ff1c7cc5f7 100644 (file)
@@ -958,9 +958,9 @@ static enum sci_status sci_controller_start_next_phy(struct isci_host *ihost)
        return status;
 }
 
-static void phy_startup_timeout(unsigned long data)
+static void phy_startup_timeout(struct timer_list *t)
 {
-       struct sci_timer *tmr = (struct sci_timer *)data;
+       struct sci_timer *tmr = from_timer(tmr, t, timer);
        struct isci_host *ihost = container_of(tmr, typeof(*ihost), phy_timer);
        unsigned long flags;
        enum sci_status status;
@@ -1592,9 +1592,9 @@ static const struct sci_base_state sci_controller_state_table[] = {
        [SCIC_FAILED] = {}
 };
 
-static void controller_timeout(unsigned long data)
+static void controller_timeout(struct timer_list *t)
 {
-       struct sci_timer *tmr = (struct sci_timer *)data;
+       struct sci_timer *tmr = from_timer(tmr, t, timer);
        struct isci_host *ihost = container_of(tmr, typeof(*ihost), timer);
        struct sci_base_state_machine *sm = &ihost->sm;
        unsigned long flags;
@@ -1737,9 +1737,9 @@ static u8 max_spin_up(struct isci_host *ihost)
                             MAX_CONCURRENT_DEVICE_SPIN_UP_COUNT);
 }
 
-static void power_control_timeout(unsigned long data)
+static void power_control_timeout(struct timer_list *t)
 {
-       struct sci_timer *tmr = (struct sci_timer *)data;
+       struct sci_timer *tmr = from_timer(tmr, t, timer);
        struct isci_host *ihost = container_of(tmr, typeof(*ihost), power_control.timer);
        struct isci_phy *iphy;
        unsigned long flags;
index 234ab46fce3346948300d9ae95364e33103792ee..680e3094767160b74398ee41ad98939bc856f177 100644 (file)
@@ -498,12 +498,10 @@ struct sci_timer {
 };
 
 static inline
-void sci_init_timer(struct sci_timer *tmr, void (*fn)(unsigned long))
+void sci_init_timer(struct sci_timer *tmr, void (*fn)(struct timer_list *t))
 {
-       tmr->timer.function = fn;
-       tmr->timer.data = (unsigned long) tmr;
        tmr->cancel = 0;
-       init_timer(&tmr->timer);
+       timer_setup(&tmr->timer, fn, 0);
 }
 
 static inline void sci_mod_timer(struct sci_timer *tmr, unsigned long msec)
index cb87b2ef7c92ab2ab5b25cbedbb594e85956eb05..1deca8c5a94f5645f6f14d60c303c65ac1258d2b 100644 (file)
@@ -315,9 +315,9 @@ sci_phy_link_layer_initialization(struct isci_phy *iphy,
        return SCI_SUCCESS;
 }
 
-static void phy_sata_timeout(unsigned long data)
+static void phy_sata_timeout(struct timer_list *t)
 {
-       struct sci_timer *tmr = (struct sci_timer *)data;
+       struct sci_timer *tmr = from_timer(tmr, t, timer);
        struct isci_phy *iphy = container_of(tmr, typeof(*iphy), sata_timer);
        struct isci_host *ihost = iphy->owning_port->owning_controller;
        unsigned long flags;
index a4dd5c91508cc379b2a52ea0414e6508f720ce02..1df45f028ea7570841d1b4ae7303cd8cafeb2d20 100644 (file)
@@ -769,9 +769,9 @@ bool sci_port_link_detected(struct isci_port *iport, struct isci_phy *iphy)
        return true;
 }
 
-static void port_timeout(unsigned long data)
+static void port_timeout(struct timer_list *t)
 {
-       struct sci_timer *tmr = (struct sci_timer *)data;
+       struct sci_timer *tmr = from_timer(tmr, t, timer);
        struct isci_port *iport = container_of(tmr, typeof(*iport), timer);
        struct isci_host *ihost = iport->owning_controller;
        unsigned long flags;
index ac879745ef8007ab2a4973aff26e3c950e8f1dba..edb7be786c6501602195b25285dda78ceb9ea537 100644 (file)
@@ -319,10 +319,10 @@ sci_mpc_agent_validate_phy_configuration(struct isci_host *ihost,
        return sci_port_configuration_agent_validate_ports(ihost, port_agent);
 }
 
-static void mpc_agent_timeout(unsigned long data)
+static void mpc_agent_timeout(struct timer_list *t)
 {
        u8 index;
-       struct sci_timer *tmr = (struct sci_timer *)data;
+       struct sci_timer *tmr = from_timer(tmr, t, timer);
        struct sci_port_configuration_agent *port_agent;
        struct isci_host *ihost;
        unsigned long flags;
@@ -654,10 +654,10 @@ static void sci_apc_agent_link_down(
 }
 
 /* configure the phys into ports when the timer fires */
-static void apc_agent_timeout(unsigned long data)
+static void apc_agent_timeout(struct timer_list *t)
 {
        u32 index;
-       struct sci_timer *tmr = (struct sci_timer *)data;
+       struct sci_timer *tmr = from_timer(tmr, t, timer);
        struct sci_port_configuration_agent *port_agent;
        struct isci_host *ihost;
        unsigned long flags;
index 772c35a5c49ef7899ce0ef65417f566390fea712..1a4e701a844966e4a7db873a3c2dfe3a58768fc2 100644 (file)
@@ -97,7 +97,7 @@ static void fc_fcp_complete_locked(struct fc_fcp_pkt *);
 static void fc_tm_done(struct fc_seq *, struct fc_frame *, void *);
 static void fc_fcp_error(struct fc_fcp_pkt *, struct fc_frame *);
 static void fc_fcp_recovery(struct fc_fcp_pkt *, u8 code);
-static void fc_fcp_timeout(unsigned long);
+static void fc_fcp_timeout(struct timer_list *);
 static void fc_fcp_rec(struct fc_fcp_pkt *);
 static void fc_fcp_rec_error(struct fc_fcp_pkt *, struct fc_frame *);
 static void fc_fcp_rec_resp(struct fc_seq *, struct fc_frame *, void *);
@@ -155,8 +155,7 @@ static struct fc_fcp_pkt *fc_fcp_pkt_alloc(struct fc_lport *lport, gfp_t gfp)
                fsp->lp = lport;
                fsp->xfer_ddp = FC_XID_UNKNOWN;
                refcount_set(&fsp->ref_cnt, 1);
-               init_timer(&fsp->timer);
-               fsp->timer.data = (unsigned long)fsp;
+               timer_setup(&fsp->timer, NULL, 0);
                INIT_LIST_HEAD(&fsp->list);
                spin_lock_init(&fsp->scsi_pkt_lock);
        } else {
@@ -1215,7 +1214,7 @@ static int fc_fcp_cmd_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp,
        fsp->seq_ptr = seq;
        fc_fcp_pkt_hold(fsp);   /* hold for fc_fcp_pkt_destroy */
 
-       setup_timer(&fsp->timer, fc_fcp_timeout, (unsigned long)fsp);
+       fsp->timer.function = (TIMER_FUNC_TYPE)fc_fcp_timeout;
        if (rpriv->flags & FC_RP_FLAGS_REC_SUPPORTED)
                fc_fcp_timer_set(fsp, get_fsp_rec_tov(fsp));
 
@@ -1298,9 +1297,9 @@ static int fc_fcp_pkt_abort(struct fc_fcp_pkt *fsp)
  * fc_lun_reset_send() - Send LUN reset command
  * @data: The FCP packet that identifies the LUN to be reset
  */
-static void fc_lun_reset_send(unsigned long data)
+static void fc_lun_reset_send(struct timer_list *t)
 {
-       struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)data;
+       struct fc_fcp_pkt *fsp = from_timer(fsp, t, timer);
        struct fc_lport *lport = fsp->lp;
 
        if (lport->tt.fcp_cmd_send(lport, fsp, fc_tm_done)) {
@@ -1308,7 +1307,7 @@ static void fc_lun_reset_send(unsigned long data)
                        return;
                if (fc_fcp_lock_pkt(fsp))
                        return;
-               setup_timer(&fsp->timer, fc_lun_reset_send, (unsigned long)fsp);
+               fsp->timer.function = (TIMER_FUNC_TYPE)fc_lun_reset_send;
                fc_fcp_timer_set(fsp, get_fsp_rec_tov(fsp));
                fc_fcp_unlock_pkt(fsp);
        }
@@ -1334,7 +1333,7 @@ static int fc_lun_reset(struct fc_lport *lport, struct fc_fcp_pkt *fsp,
        fsp->wait_for_comp = 1;
        init_completion(&fsp->tm_done);
 
-       fc_lun_reset_send((unsigned long)fsp);
+       fc_lun_reset_send(&fsp->timer);
 
        /*
         * wait for completion of reset
@@ -1431,9 +1430,9 @@ static void fc_fcp_cleanup(struct fc_lport *lport)
  * received we see if data was received recently. If it has been then we
  * continue waiting, otherwise, we abort the command.
  */
-static void fc_fcp_timeout(unsigned long data)
+static void fc_fcp_timeout(struct timer_list *t)
 {
-       struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)data;
+       struct fc_fcp_pkt *fsp = from_timer(fsp, t, timer);
        struct fc_rport *rport = fsp->rport;
        struct fc_rport_libfc_priv *rpriv = rport->dd_data;
 
@@ -1446,7 +1445,7 @@ static void fc_fcp_timeout(unsigned long data)
        if (fsp->lp->qfull) {
                FC_FCP_DBG(fsp, "fcp timeout, resetting timer delay %d\n",
                           fsp->timer_delay);
-               setup_timer(&fsp->timer, fc_fcp_timeout, (unsigned long)fsp);
+               fsp->timer.function = (TIMER_FUNC_TYPE)fc_fcp_timeout;
                fc_fcp_timer_set(fsp, fsp->timer_delay);
                goto unlock;
        }
index f8dc1601efd5f1eb51b4d776087d6ea20534d09e..9c50d2d9f27c2dc88de46f2fd743922002c1b841 100644 (file)
@@ -1805,9 +1805,9 @@ int iscsi_target_alloc(struct scsi_target *starget)
 }
 EXPORT_SYMBOL_GPL(iscsi_target_alloc);
 
-static void iscsi_tmf_timedout(unsigned long data)
+static void iscsi_tmf_timedout(struct timer_list *t)
 {
-       struct iscsi_conn *conn = (struct iscsi_conn *)data;
+       struct iscsi_conn *conn = from_timer(conn, t, tmf_timer);
        struct iscsi_session *session = conn->session;
 
        spin_lock(&session->frwd_lock);
@@ -1838,8 +1838,6 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
        }
        conn->tmfcmd_pdus_cnt++;
        conn->tmf_timer.expires = timeout * HZ + jiffies;
-       conn->tmf_timer.function = iscsi_tmf_timedout;
-       conn->tmf_timer.data = (unsigned long)conn;
        add_timer(&conn->tmf_timer);
        ISCSI_DBG_EH(session, "tmf set timeout\n");
 
@@ -2089,9 +2087,9 @@ done:
 }
 EXPORT_SYMBOL_GPL(iscsi_eh_cmd_timed_out);
 
-static void iscsi_check_transport_timeouts(unsigned long data)
+static void iscsi_check_transport_timeouts(struct timer_list *t)
 {
-       struct iscsi_conn *conn = (struct iscsi_conn *)data;
+       struct iscsi_conn *conn = from_timer(conn, t, transport_timer);
        struct iscsi_session *session = conn->session;
        unsigned long recv_timeout, next_timeout = 0, last_recv;
 
@@ -2913,9 +2911,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
        conn->exp_statsn = 0;
        conn->tmf_state = TMF_INITIAL;
 
-       init_timer(&conn->transport_timer);
-       conn->transport_timer.data = (unsigned long)conn;
-       conn->transport_timer.function = iscsi_check_transport_timeouts;
+       timer_setup(&conn->transport_timer, iscsi_check_transport_timeouts, 0);
 
        INIT_LIST_HEAD(&conn->mgmtqueue);
        INIT_LIST_HEAD(&conn->cmdqueue);
@@ -2939,7 +2935,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
                goto login_task_data_alloc_fail;
        conn->login_task->data = conn->data = data;
 
-       init_timer(&conn->tmf_timer);
+       timer_setup(&conn->tmf_timer, iscsi_tmf_timedout, 0);
        init_waitqueue_head(&conn->ehwait);
 
        return cls_conn;
index 6b4fd2375178588b5d6b899ae32da25766e0f3dd..174e5eff615579d3c2822692de37e59a0b219b03 100644 (file)
@@ -41,9 +41,10 @@ static int sas_disable_routing(struct domain_device *dev,  u8 *sas_addr);
 
 /* ---------- SMP task management ---------- */
 
-static void smp_task_timedout(unsigned long _task)
+static void smp_task_timedout(struct timer_list *t)
 {
-       struct sas_task *task = (void *) _task;
+       struct sas_task_slow *slow = from_timer(slow, t, timer);
+       struct sas_task *task = slow->task;
        unsigned long flags;
 
        spin_lock_irqsave(&task->task_state_lock, flags);
@@ -91,8 +92,7 @@ static int smp_execute_task_sg(struct domain_device *dev,
 
                task->task_done = smp_task_done;
 
-               task->slow_task->timer.data = (unsigned long) task;
-               task->slow_task->timer.function = smp_task_timedout;
+               task->slow_task->timer.function = (TIMER_FUNC_TYPE)smp_task_timedout;
                task->slow_task->timer.expires = jiffies + SMP_TIMEOUT*HZ;
                add_timer(&task->slow_task->timer);
 
index 64e9cdda1c3ca01d47d60fcbf535dea44507fdb3..681fcb837354ec497fdc5facbe1040418f279a72 100644 (file)
@@ -66,7 +66,8 @@ struct sas_task *sas_alloc_slow_task(gfp_t flags)
        }
 
        task->slow_task = slow;
-       init_timer(&slow->timer);
+       slow->task = task;
+       timer_setup(&slow->timer, NULL, 0);
        init_completion(&slow->completion);
 
        return task;
index ea8ad06ff582eef292a0b11d42248502aaef8b33..91795eb56206603bb0a52baa62237e9787dd2bcf 100644 (file)
@@ -919,7 +919,7 @@ void sas_task_abort(struct sas_task *task)
                        return;
                if (!del_timer(&slow->timer))
                        return;
-               slow->timer.function(slow->timer.data);
+               slow->timer.function((TIMER_DATA_TYPE)&slow->timer);
                return;
        }
 
index 7e300734b345443bace5dd76de1441ca7d254077..4e858b38529afc9ce46d47915785a17085ca2f26 100644 (file)
@@ -113,7 +113,7 @@ void lpfc_disc_list_loopmap(struct lpfc_vport *);
 void lpfc_disc_start(struct lpfc_vport *);
 void lpfc_cleanup_discovery_resources(struct lpfc_vport *);
 void lpfc_cleanup(struct lpfc_vport *);
-void lpfc_disc_timeout(unsigned long);
+void lpfc_disc_timeout(struct timer_list *);
 
 int lpfc_unregister_fcf_prep(struct lpfc_hba *);
 struct lpfc_nodelist *__lpfc_findnode_rpi(struct lpfc_vport *, uint16_t);
@@ -154,7 +154,7 @@ int lpfc_els_rsp_adisc_acc(struct lpfc_vport *, struct lpfc_iocbq *,
 int lpfc_els_rsp_prli_acc(struct lpfc_vport *, struct lpfc_iocbq *,
                          struct lpfc_nodelist *);
 void lpfc_cancel_retry_delay_tmo(struct lpfc_vport *, struct lpfc_nodelist *);
-void lpfc_els_retry_delay(unsigned long);
+void lpfc_els_retry_delay(struct timer_list *);
 void lpfc_els_retry_delay_handler(struct lpfc_nodelist *);
 void lpfc_els_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,
                          struct lpfc_iocbq *);
@@ -165,7 +165,7 @@ void lpfc_els_flush_all_cmd(struct lpfc_hba *);
 void lpfc_els_flush_cmd(struct lpfc_vport *);
 int lpfc_els_disc_adisc(struct lpfc_vport *);
 int lpfc_els_disc_plogi(struct lpfc_vport *);
-void lpfc_els_timeout(unsigned long);
+void lpfc_els_timeout(struct timer_list *);
 void lpfc_els_timeout_handler(struct lpfc_vport *);
 struct lpfc_iocbq *lpfc_prep_els_iocb(struct lpfc_vport *, uint8_t, uint16_t,
                                      uint8_t, struct lpfc_nodelist *,
@@ -180,7 +180,7 @@ int lpfc_get_gidft_type(struct lpfc_vport *vport, struct lpfc_iocbq *iocbq);
 int lpfc_ns_cmd(struct lpfc_vport *, int, uint8_t, uint32_t);
 int lpfc_fdmi_cmd(struct lpfc_vport *, struct lpfc_nodelist *, int, uint32_t);
 void lpfc_fdmi_num_disc_check(struct lpfc_vport *);
-void lpfc_delayed_disc_tmo(unsigned long);
+void lpfc_delayed_disc_tmo(struct timer_list *);
 void lpfc_delayed_disc_timeout_handler(struct lpfc_vport *);
 
 int lpfc_config_port_prep(struct lpfc_hba *);
@@ -279,9 +279,9 @@ void lpfc_mem_free(struct lpfc_hba *);
 void lpfc_mem_free_all(struct lpfc_hba *);
 void lpfc_stop_vport_timers(struct lpfc_vport *);
 
-void lpfc_poll_timeout(unsigned long ptr);
+void lpfc_poll_timeout(struct timer_list *t);
 void lpfc_poll_start_timer(struct lpfc_hba *);
-void lpfc_poll_eratt(unsigned long);
+void lpfc_poll_eratt(struct timer_list *);
 int
 lpfc_sli_handle_fast_ring_event(struct lpfc_hba *,
                        struct lpfc_sli_ring *, uint32_t);
@@ -351,7 +351,7 @@ int
 lpfc_sli_abort_taskmgmt(struct lpfc_vport *, struct lpfc_sli_ring *,
                        uint16_t, uint64_t, lpfc_ctx_cmd);
 
-void lpfc_mbox_timeout(unsigned long);
+void lpfc_mbox_timeout(struct timer_list *t);
 void lpfc_mbox_timeout_handler(struct lpfc_hba *);
 
 struct lpfc_nodelist *lpfc_findnode_did(struct lpfc_vport *, uint32_t);
@@ -445,7 +445,7 @@ extern unsigned int lpfc_fcp_look_ahead;
 /* Interface exported by fabric iocb scheduler */
 void lpfc_fabric_abort_nport(struct lpfc_nodelist *);
 void lpfc_fabric_abort_hba(struct lpfc_hba *);
-void lpfc_fabric_block_timeout(unsigned long);
+void lpfc_fabric_block_timeout(struct timer_list *);
 void lpfc_unblock_fabric_iocbs(struct lpfc_hba *);
 void lpfc_rampdown_queue_depth(struct lpfc_hba *);
 void lpfc_ramp_down_queue_handler(struct lpfc_hba *);
index 33417681f5d40784ffc15517f1ed137f2c6f23e3..f77673ab4a8445b8a3ec34816c21727c1b0804f1 100644 (file)
@@ -2884,9 +2884,9 @@ fdmi_cmd_exit:
  * the worker thread.
  **/
 void
-lpfc_delayed_disc_tmo(unsigned long ptr)
+lpfc_delayed_disc_tmo(struct timer_list *t)
 {
-       struct lpfc_vport *vport = (struct lpfc_vport *)ptr;
+       struct lpfc_vport *vport = from_timer(vport, t, delayed_disc_tmo);
        struct lpfc_hba   *phba = vport->phba;
        uint32_t tmo_posted;
        unsigned long iflag;
index 468a66371de9d0c30f6e522641e42677156701cd..0dd6c21433fe531de8110c8e040ea3f10c4abcda 100644 (file)
@@ -3131,9 +3131,9 @@ lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp)
  * to the event associated with the ndlp.
  **/
 void
-lpfc_els_retry_delay(unsigned long ptr)
+lpfc_els_retry_delay(struct timer_list *t)
 {
-       struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) ptr;
+       struct lpfc_nodelist *ndlp = from_timer(ndlp, t, nlp_delayfunc);
        struct lpfc_vport *vport = ndlp->vport;
        struct lpfc_hba   *phba = vport->phba;
        unsigned long flags;
@@ -7385,9 +7385,9 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
  * lpfc_els_timeout_handler() to work on the posted event WORKER_ELS_TMO.
  **/
 void
-lpfc_els_timeout(unsigned long ptr)
+lpfc_els_timeout(struct timer_list *t)
 {
-       struct lpfc_vport *vport = (struct lpfc_vport *) ptr;
+       struct lpfc_vport *vport = from_timer(vport, t, els_tmofunc);
        struct lpfc_hba   *phba = vport->phba;
        uint32_t tmo_posted;
        unsigned long iflag;
@@ -9017,9 +9017,9 @@ lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
  * posted event WORKER_FABRIC_BLOCK_TMO.
  **/
 void
-lpfc_fabric_block_timeout(unsigned long ptr)
+lpfc_fabric_block_timeout(struct timer_list *t)
 {
-       struct lpfc_hba  *phba = (struct lpfc_hba *) ptr;
+       struct lpfc_hba  *phba = from_timer(phba, t, fabric_block_timer);
        unsigned long iflags;
        uint32_t tmo_posted;
 
index 20808349a80e9908d6d535b5107aa50882c0f553..8d491084eb5d0aa85fe380d42b8be5b90643fb3f 100644 (file)
@@ -4370,8 +4370,7 @@ lpfc_initialize_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 {
        INIT_LIST_HEAD(&ndlp->els_retry_evt.evt_listp);
        INIT_LIST_HEAD(&ndlp->dev_loss_evt.evt_listp);
-       setup_timer(&ndlp->nlp_delayfunc, lpfc_els_retry_delay,
-                       (unsigned long)ndlp);
+       timer_setup(&ndlp->nlp_delayfunc, lpfc_els_retry_delay, 0);
        ndlp->nlp_DID = did;
        ndlp->vport = vport;
        ndlp->phba = vport->phba;
@@ -5508,9 +5507,9 @@ lpfc_cleanup_discovery_resources(struct lpfc_vport *vport)
  */
 /*****************************************************************************/
 void
-lpfc_disc_timeout(unsigned long ptr)
+lpfc_disc_timeout(struct timer_list *t)
 {
-       struct lpfc_vport *vport = (struct lpfc_vport *) ptr;
+       struct lpfc_vport *vport = from_timer(vport, t, fc_disctmo);
        struct lpfc_hba   *phba = vport->phba;
        uint32_t tmo_posted;
        unsigned long flags = 0;
index 100bc4c8798d76852adb9224edc763f70f0741ff..6a1e28ba92585a9219030d11a491facc7e7a0049 100644 (file)
@@ -1138,13 +1138,13 @@ lpfc_hba_down_post(struct lpfc_hba *phba)
  * be cleared by the worker thread after it has taken the event bitmap out.
  **/
 static void
-lpfc_hb_timeout(unsigned long ptr)
+lpfc_hb_timeout(struct timer_list *t)
 {
        struct lpfc_hba *phba;
        uint32_t tmo_posted;
        unsigned long iflag;
 
-       phba = (struct lpfc_hba *)ptr;
+       phba = from_timer(phba, t, hb_tmofunc);
 
        /* Check for heart beat timeout conditions */
        spin_lock_irqsave(&phba->pport->work_port_lock, iflag);
@@ -1172,12 +1172,12 @@ lpfc_hb_timeout(unsigned long ptr)
  * be cleared by the worker thread after it has taken the event bitmap out.
  **/
 static void
-lpfc_rrq_timeout(unsigned long ptr)
+lpfc_rrq_timeout(struct timer_list *t)
 {
        struct lpfc_hba *phba;
        unsigned long iflag;
 
-       phba = (struct lpfc_hba *)ptr;
+       phba = from_timer(phba, t, rrq_tmr);
        spin_lock_irqsave(&phba->pport->work_port_lock, iflag);
        if (!(phba->pport->load_flag & FC_UNLOADING))
                phba->hba_flag |= HBA_RRQ_ACTIVE;
@@ -3937,14 +3937,11 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
        INIT_LIST_HEAD(&vport->rcv_buffer_list);
        spin_lock_init(&vport->work_port_lock);
 
-       setup_timer(&vport->fc_disctmo, lpfc_disc_timeout,
-                       (unsigned long)vport);
+       timer_setup(&vport->fc_disctmo, lpfc_disc_timeout, 0);
 
-       setup_timer(&vport->els_tmofunc, lpfc_els_timeout,
-                       (unsigned long)vport);
+       timer_setup(&vport->els_tmofunc, lpfc_els_timeout, 0);
 
-       setup_timer(&vport->delayed_disc_tmo, lpfc_delayed_disc_tmo,
-                       (unsigned long)vport);
+       timer_setup(&vport->delayed_disc_tmo, lpfc_delayed_disc_tmo, 0);
 
        error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev);
        if (error)
@@ -4210,9 +4207,9 @@ lpfc_fcf_redisc_wait_start_timer(struct lpfc_hba *phba)
  * worker thread context.
  **/
 static void
-lpfc_sli4_fcf_redisc_wait_tmo(unsigned long ptr)
+lpfc_sli4_fcf_redisc_wait_tmo(struct timer_list *t)
 {
-       struct lpfc_hba *phba = (struct lpfc_hba *)ptr;
+       struct lpfc_hba *phba = from_timer(phba, t, fcf.redisc_wait);
 
        /* Don't send FCF rediscovery event if timer cancelled */
        spin_lock_irq(&phba->hbalock);
@@ -5624,15 +5621,13 @@ lpfc_setup_driver_resource_phase1(struct lpfc_hba *phba)
        INIT_LIST_HEAD(&phba->luns);
 
        /* MBOX heartbeat timer */
-       setup_timer(&psli->mbox_tmo, lpfc_mbox_timeout, (unsigned long)phba);
+       timer_setup(&psli->mbox_tmo, lpfc_mbox_timeout, 0);
        /* Fabric block timer */
-       setup_timer(&phba->fabric_block_timer, lpfc_fabric_block_timeout,
-                       (unsigned long)phba);
+       timer_setup(&phba->fabric_block_timer, lpfc_fabric_block_timeout, 0);
        /* EA polling mode timer */
-       setup_timer(&phba->eratt_poll, lpfc_poll_eratt,
-                       (unsigned long)phba);
+       timer_setup(&phba->eratt_poll, lpfc_poll_eratt, 0);
        /* Heartbeat timer */
-       setup_timer(&phba->hb_tmofunc, lpfc_hb_timeout, (unsigned long)phba);
+       timer_setup(&phba->hb_tmofunc, lpfc_hb_timeout, 0);
 
        return 0;
 }
@@ -5658,8 +5653,7 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba)
         */
 
        /* FCP polling mode timer */
-       setup_timer(&phba->fcp_poll_timer, lpfc_poll_timeout,
-                       (unsigned long)phba);
+       timer_setup(&phba->fcp_poll_timer, lpfc_poll_timeout, 0);
 
        /* Host attention work mask setup */
        phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT);
@@ -5829,11 +5823,10 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
         * Initialize timers used by driver
         */
 
-       setup_timer(&phba->rrq_tmr, lpfc_rrq_timeout, (unsigned long)phba);
+       timer_setup(&phba->rrq_tmr, lpfc_rrq_timeout, 0);
 
        /* FCF rediscover timer */
-       setup_timer(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo,
-                       (unsigned long)phba);
+       timer_setup(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 0);
 
        /*
         * Control structure for handling external multi-buffer mailbox
index 1a6f122bb25db6697f7a5e705fdba992cf2bd9fd..c0cdaef4db24f1f124709d9ff3b0e9fcbcfbf361 100644 (file)
@@ -4501,9 +4501,9 @@ void lpfc_poll_start_timer(struct lpfc_hba * phba)
  * and FCP Ring interrupt is disable.
  **/
 
-void lpfc_poll_timeout(unsigned long ptr)
+void lpfc_poll_timeout(struct timer_list *t)
 {
-       struct lpfc_hba *phba = (struct lpfc_hba *) ptr;
+       struct lpfc_hba *phba = from_timer(phba, t, fcp_poll_timer);
 
        if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
                lpfc_sli_handle_fast_ring_event(phba,
index 8b119f87b51d67382b89aa60500d9ffe6f18ab19..4edb81073409df585e147cf5646e6ae51f7e99c5 100644 (file)
@@ -3004,13 +3004,13 @@ lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
  * and wake up worker thread to process it. Otherwise, it will set up the
  * Error Attention polling timer for the next poll.
  **/
-void lpfc_poll_eratt(unsigned long ptr)
+void lpfc_poll_eratt(struct timer_list *t)
 {
        struct lpfc_hba *phba;
        uint32_t eratt = 0;
        uint64_t sli_intr, cnt;
 
-       phba = (struct lpfc_hba *)ptr;
+       phba = from_timer(phba, t, eratt_poll);
 
        /* Here we will also keep track of interrupts per sec of the hba */
        sli_intr = phba->sli.slistat.sli_intr;
@@ -7167,9 +7167,9 @@ out_free_mbox:
  * done by the worker thread function lpfc_mbox_timeout_handler.
  **/
 void
-lpfc_mbox_timeout(unsigned long ptr)
+lpfc_mbox_timeout(struct timer_list *t)
 {
-       struct lpfc_hba  *phba = (struct lpfc_hba *) ptr;
+       struct lpfc_hba  *phba = from_timer(phba, t, sli.mbox_tmo);
        unsigned long iflag;
        uint32_t tmo_posted;
 
index 05f6e4ec345396931c5edfd374ef146c1eb340d4..eedcbde46459999ac42a602534191d3611711ff9 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/types.h>
 #include <linux/semaphore.h>
+#include <linux/timer.h>
 
 #include "mbox_defs.h"
 
@@ -153,6 +154,11 @@ typedef struct uioc {
 
 } __attribute__ ((aligned(1024),packed)) uioc_t;
 
+/* For on-stack uioc timers. */
+struct uioc_timeout {
+       struct timer_list timer;
+       uioc_t            *uioc;
+};
 
 /**
  * struct mraid_hba_info - information about the controller
index ec3c4385497865399c7d4cab92b0c6cd8558a7aa..530358cdcb3912e2c5c751b076905a348e32408e 100644 (file)
@@ -3904,19 +3904,19 @@ megaraid_sysfs_get_ldmap_done(uioc_t *uioc)
        wake_up(&raid_dev->sysfs_wait_q);
 }
 
-
 /**
  * megaraid_sysfs_get_ldmap_timeout - timeout handling for get ldmap
- * @data       : timed out packet
+ * @t  : timed out timer
  *
  * Timeout routine to recover and return to application, in case the adapter
  * has stopped responding. A timeout of 60 seconds for this command seems like
  * a good value.
  */
 static void
-megaraid_sysfs_get_ldmap_timeout(unsigned long data)
+megaraid_sysfs_get_ldmap_timeout(struct timer_list *t)
 {
-       uioc_t          *uioc = (uioc_t *)data;
+       struct uioc_timeout *timeout = from_timer(timeout, t, timer);
+       uioc_t          *uioc = timeout->uioc;
        adapter_t       *adapter = (adapter_t *)uioc->buf_vaddr;
        mraid_device_t  *raid_dev = ADAP2RAIDDEV(adapter);
 
@@ -3951,8 +3951,7 @@ megaraid_sysfs_get_ldmap(adapter_t *adapter)
        mbox64_t                *mbox64;
        mbox_t                  *mbox;
        char                    *raw_mbox;
-       struct timer_list       sysfs_timer;
-       struct timer_list       *timerp;
+       struct uioc_timeout     timeout;
        caddr_t                 ldmap;
        int                     rval = 0;
 
@@ -3988,14 +3987,12 @@ megaraid_sysfs_get_ldmap(adapter_t *adapter)
        /*
         * Setup a timer to recover from a non-responding controller
         */
-       timerp  = &sysfs_timer;
-       init_timer(timerp);
-
-       timerp->function        = megaraid_sysfs_get_ldmap_timeout;
-       timerp->data            = (unsigned long)uioc;
-       timerp->expires         = jiffies + 60 * HZ;
+       timeout.uioc = uioc;
+       timer_setup_on_stack(&timeout.timer,
+                            megaraid_sysfs_get_ldmap_timeout, 0);
 
-       add_timer(timerp);
+       timeout.timer.expires           = jiffies + 60 * HZ;
+       add_timer(&timeout.timer);
 
        /*
         * Send the command to the firmware
@@ -4033,7 +4030,8 @@ megaraid_sysfs_get_ldmap(adapter_t *adapter)
        }
 
 
-       del_timer_sync(timerp);
+       del_timer_sync(&timeout.timer);
+       destroy_timer_on_stack(&timeout.timer);
 
        mutex_unlock(&raid_dev->sysfs_mtx);
 
index 65b6f6ace3a5334fc3c81b9480871abe3fe2ad04..bb802b0c12b8663570dbc57bf6f032d575360e7a 100644 (file)
@@ -35,7 +35,7 @@ static int kioc_to_mimd(uioc_t *, mimd_t __user *);
 static int handle_drvrcmd(void __user *, uint8_t, int *);
 static int lld_ioctl(mraid_mmadp_t *, uioc_t *);
 static void ioctl_done(uioc_t *);
-static void lld_timedout(unsigned long);
+static void lld_timedout(struct timer_list *);
 static void hinfo_to_cinfo(mraid_hba_info_t *, mcontroller_t *);
 static mraid_mmadp_t *mraid_mm_get_adapter(mimd_t __user *, int *);
 static uioc_t *mraid_mm_alloc_kioc(mraid_mmadp_t *);
@@ -686,8 +686,7 @@ static int
 lld_ioctl(mraid_mmadp_t *adp, uioc_t *kioc)
 {
        int                     rval;
-       struct timer_list       timer;
-       struct timer_list       *tp = NULL;
+       struct uioc_timeout     timeout = { };
 
        kioc->status    = -ENODATA;
        rval            = adp->issue_uioc(adp->drvr_data, kioc, IOCTL_ISSUE);
@@ -698,14 +697,12 @@ lld_ioctl(mraid_mmadp_t *adp, uioc_t *kioc)
         * Start the timer
         */
        if (adp->timeout > 0) {
-               tp              = &timer;
-               init_timer(tp);
+               timeout.uioc = kioc;
+               timer_setup_on_stack(&timeout.timer, lld_timedout, 0);
 
-               tp->function    = lld_timedout;
-               tp->data        = (unsigned long)kioc;
-               tp->expires     = jiffies + adp->timeout * HZ;
+               timeout.timer.expires   = jiffies + adp->timeout * HZ;
 
-               add_timer(tp);
+               add_timer(&timeout.timer);
        }
 
        /*
@@ -713,8 +710,9 @@ lld_ioctl(mraid_mmadp_t *adp, uioc_t *kioc)
         * call, the ioctl either completed successfully or timedout.
         */
        wait_event(wait_q, (kioc->status != -ENODATA));
-       if (tp) {
-               del_timer_sync(tp);
+       if (timeout.timer.function) {
+               del_timer_sync(&timeout.timer);
+               destroy_timer_on_stack(&timeout.timer);
        }
 
        /*
@@ -783,12 +781,13 @@ ioctl_done(uioc_t *kioc)
 
 /**
  * lld_timedout        - callback from the expired timer
- * @ptr                : ioctl packet that timed out
+ * @t          : timer that timed out
  */
 static void
-lld_timedout(unsigned long ptr)
+lld_timedout(struct timer_list *t)
 {
-       uioc_t *kioc    = (uioc_t *)ptr;
+       struct uioc_timeout *timeout = from_timer(timeout, t, timer);
+       uioc_t *kioc    = timeout->uioc;
 
        kioc->status    = -ETIME;
        kioc->timedout  = 1;
index e518dadc81615fd4e981b9127e840b9c7adc2d2b..a36e18156e49302ba91fb0eb4f73a3afada8f7b4 100644 (file)
@@ -2114,22 +2114,19 @@ static void megasas_complete_cmd_dpc(unsigned long instance_addr)
        megasas_check_and_restore_queue_depth(instance);
 }
 
+static void megasas_sriov_heartbeat_handler(struct timer_list *t);
+
 /**
- * megasas_start_timer - Initializes a timer object
+ * megasas_start_timer - Initializes sriov heartbeat timer object
  * @instance:          Adapter soft state
- * @timer:             timer object to be initialized
- * @fn:                        timer function
- * @interval:          time interval between timer function call
  *
  */
-void megasas_start_timer(struct megasas_instance *instance,
-                       struct timer_list *timer,
-                       void *fn, unsigned long interval)
-{
-       init_timer(timer);
-       timer->expires = jiffies + interval;
-       timer->data = (unsigned long)instance;
-       timer->function = fn;
+void megasas_start_timer(struct megasas_instance *instance)
+{
+       struct timer_list *timer = &instance->sriov_heartbeat_timer;
+
+       timer_setup(timer, megasas_sriov_heartbeat_handler, 0);
+       timer->expires = jiffies + MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF;
        add_timer(timer);
 }
 
@@ -2515,10 +2512,10 @@ out:
 }
 
 /* Handler for SR-IOV heartbeat */
-void megasas_sriov_heartbeat_handler(unsigned long instance_addr)
+static void megasas_sriov_heartbeat_handler(struct timer_list *t)
 {
        struct megasas_instance *instance =
-               (struct megasas_instance *)instance_addr;
+               from_timer(instance, t, sriov_heartbeat_timer);
 
        if (instance->hb_host_mem->HB.fwCounter !=
            instance->hb_host_mem->HB.driverCounter) {
@@ -5493,10 +5490,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
        /* Launch SR-IOV heartbeat timer */
        if (instance->requestorId) {
                if (!megasas_sriov_start_heartbeat(instance, 1))
-                       megasas_start_timer(instance,
-                                           &instance->sriov_heartbeat_timer,
-                                           megasas_sriov_heartbeat_handler,
-                                           MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF);
+                       megasas_start_timer(instance);
                else
                        instance->skip_heartbeat_timer_del = 1;
        }
@@ -6507,10 +6501,7 @@ megasas_resume(struct pci_dev *pdev)
        /* Re-launch SR-IOV heartbeat timer */
        if (instance->requestorId) {
                if (!megasas_sriov_start_heartbeat(instance, 0))
-                       megasas_start_timer(instance,
-                                           &instance->sriov_heartbeat_timer,
-                                           megasas_sriov_heartbeat_handler,
-                                           MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF);
+                       megasas_start_timer(instance);
                else {
                        instance->skip_heartbeat_timer_del = 1;
                        goto fail_init_mfi;
index 11bd2e698b84c6b9a637fea7d4aba8928d04e3fd..3c399e7b3fe1ca1dc74c5881e6acaa1aa7fd39f3 100644 (file)
@@ -85,12 +85,9 @@ int megasas_transition_to_ready(struct megasas_instance *instance, int ocr);
 void megaraid_sas_kill_hba(struct megasas_instance *instance);
 
 extern u32 megasas_dbg_lvl;
-void megasas_sriov_heartbeat_handler(unsigned long instance_addr);
 int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
                                  int initial);
-void megasas_start_timer(struct megasas_instance *instance,
-                       struct timer_list *timer,
-                        void *fn, unsigned long interval);
+void megasas_start_timer(struct megasas_instance *instance);
 extern struct megasas_mgmt_info megasas_mgmt_info;
 extern unsigned int resetwaittime;
 extern unsigned int dual_qdepth_disable;
@@ -4369,10 +4366,7 @@ transition_to_ready:
                        /* Restart SR-IOV heartbeat */
                        if (instance->requestorId) {
                                if (!megasas_sriov_start_heartbeat(instance, 0))
-                                       megasas_start_timer(instance,
-                                                           &instance->sriov_heartbeat_timer,
-                                                           megasas_sriov_heartbeat_handler,
-                                                           MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF);
+                                       megasas_start_timer(instance);
                                else
                                        instance->skip_heartbeat_timer_del = 1;
                        }
@@ -4404,10 +4398,7 @@ fail_kill_adapter:
        } else {
                /* For VF: Restart HB timer if we didn't OCR */
                if (instance->requestorId) {
-                       megasas_start_timer(instance,
-                                           &instance->sriov_heartbeat_timer,
-                                           megasas_sriov_heartbeat_handler,
-                                           MEGASAS_SRIOV_HEARTBEAT_INTERVAL_VF);
+                       megasas_start_timer(instance);
                }
                clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags);
                instance->instancet->enable_intr(instance);
index 718c88de328bff527c37ce1edd33f03208b8e711..8c91637cd598d971afd11b2ae5e4aceb024a7b22 100644 (file)
@@ -95,7 +95,7 @@ static void mvs_phy_init(struct mvs_info *mvi, int phy_id)
 
        phy->mvi = mvi;
        phy->port = NULL;
-       init_timer(&phy->timer);
+       timer_setup(&phy->timer, NULL, 0);
        sas_phy->enabled = (phy_id < mvi->chip->n_phy) ? 1 : 0;
        sas_phy->class = SAS;
        sas_phy->iproto = SAS_PROTOCOL_ALL;
@@ -248,7 +248,6 @@ static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost)
                mvi->devices[i].dev_type = SAS_PHY_UNUSED;
                mvi->devices[i].device_id = i;
                mvi->devices[i].dev_status = MVS_DEV_NORMAL;
-               init_timer(&mvi->devices[i].timer);
        }
 
        /*
index ee81d10252e043fa1ed505d429ed7a7dbcebde3d..cff1c37b8d2e46374ffda812b97877851b1cea2c 100644 (file)
@@ -1283,9 +1283,10 @@ static void mvs_task_done(struct sas_task *task)
        complete(&task->slow_task->completion);
 }
 
-static void mvs_tmf_timedout(unsigned long data)
+static void mvs_tmf_timedout(struct timer_list *t)
 {
-       struct sas_task *task = (struct sas_task *)data;
+       struct sas_task_slow *slow = from_timer(slow, t, timer);
+       struct sas_task *task = slow->task;
 
        task->task_state_flags |= SAS_TASK_STATE_ABORTED;
        complete(&task->slow_task->completion);
@@ -1309,8 +1310,7 @@ static int mvs_exec_internal_tmf_task(struct domain_device *dev,
                memcpy(&task->ssp_task, parameter, para_len);
                task->task_done = mvs_task_done;
 
-               task->slow_task->timer.data = (unsigned long) task;
-               task->slow_task->timer.function = mvs_tmf_timedout;
+               task->slow_task->timer.function = (TIMER_FUNC_TYPE)mvs_tmf_timedout;
                task->slow_task->timer.expires = jiffies + MVS_TASK_TIMEOUT*HZ;
                add_timer(&task->slow_task->timer);
 
@@ -1954,9 +1954,9 @@ static int mvs_handle_event(struct mvs_info *mvi, void *data, int handler)
        return ret;
 }
 
-static void mvs_sig_time_out(unsigned long tphy)
+static void mvs_sig_time_out(struct timer_list *t)
 {
-       struct mvs_phy *phy = (struct mvs_phy *)tphy;
+       struct mvs_phy *phy = from_timer(phy, t, timer);
        struct mvs_info *mvi = phy->mvi;
        u8 phy_no;
 
@@ -2020,8 +2020,7 @@ void mvs_int_port(struct mvs_info *mvi, int phy_no, u32 events)
                MVS_CHIP_DISP->write_port_irq_mask(mvi, phy_no,
                                        tmp | PHYEV_SIG_FIS);
                if (phy->timer.function == NULL) {
-                       phy->timer.data = (unsigned long)phy;
-                       phy->timer.function = mvs_sig_time_out;
+                       phy->timer.function = (TIMER_FUNC_TYPE)mvs_sig_time_out;
                        phy->timer.expires = jiffies + 5*HZ;
                        add_timer(&phy->timer);
                }
index f9afd4cdd4c4e9784e2bf83736ca5c48ed675f7e..080676c1c9e5a1322829dcea71edd62e993b33c5 100644 (file)
@@ -247,7 +247,6 @@ struct mvs_device {
        enum sas_device_type dev_type;
        struct mvs_info *mvi_info;
        struct domain_device *sas_device;
-       struct timer_list timer;
        u32 attached_phy;
        u32 device_id;
        u32 running_req;
index ce584c31d36e505a005b2e09aab8ccbaa6e4025c..7b2f92ae986602e2ffba558ff069f05c3685c8e4 100644 (file)
@@ -656,9 +656,10 @@ void pm8001_task_done(struct sas_task *task)
        complete(&task->slow_task->completion);
 }
 
-static void pm8001_tmf_timedout(unsigned long data)
+static void pm8001_tmf_timedout(struct timer_list *t)
 {
-       struct sas_task *task = (struct sas_task *)data;
+       struct sas_task_slow *slow = from_timer(slow, t, timer);
+       struct sas_task *task = slow->task;
 
        task->task_state_flags |= SAS_TASK_STATE_ABORTED;
        complete(&task->slow_task->completion);
@@ -694,8 +695,7 @@ static int pm8001_exec_internal_tmf_task(struct domain_device *dev,
                task->task_proto = dev->tproto;
                memcpy(&task->ssp_task, parameter, para_len);
                task->task_done = pm8001_task_done;
-               task->slow_task->timer.data = (unsigned long)task;
-               task->slow_task->timer.function = pm8001_tmf_timedout;
+               task->slow_task->timer.function = (TIMER_FUNC_TYPE)pm8001_tmf_timedout;
                task->slow_task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ;
                add_timer(&task->slow_task->timer);
 
@@ -781,8 +781,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
                task->dev = dev;
                task->task_proto = dev->tproto;
                task->task_done = pm8001_task_done;
-               task->slow_task->timer.data = (unsigned long)task;
-               task->slow_task->timer.function = pm8001_tmf_timedout;
+               task->slow_task->timer.function = (TIMER_FUNC_TYPE)pm8001_tmf_timedout;
                task->slow_task->timer.expires = jiffies + PM8001_TASK_TIMEOUT * HZ;
                add_timer(&task->slow_task->timer);
 
index b4d6cd8cd1ad5bc1ad0590ecefb31e6809a5c3f3..4f9f115fb6a0c8c9a3d3e5753d5d236c52897e60 100644 (file)
@@ -348,7 +348,7 @@ static void pmcraid_init_cmdblk(struct pmcraid_cmd *cmd, int index)
        cmd->sense_buffer = NULL;
        cmd->sense_buffer_dma = 0;
        cmd->dma_handle = 0;
-       init_timer(&cmd->timer);
+       timer_setup(&cmd->timer, NULL, 0);
 }
 
 /**
@@ -557,8 +557,9 @@ static void pmcraid_reset_type(struct pmcraid_instance *pinstance)
 
 static void pmcraid_ioa_reset(struct pmcraid_cmd *);
 
-static void pmcraid_bist_done(struct pmcraid_cmd *cmd)
+static void pmcraid_bist_done(struct timer_list *t)
 {
+       struct pmcraid_cmd *cmd = from_timer(cmd, t, timer);
        struct pmcraid_instance *pinstance = cmd->drv_inst;
        unsigned long lock_flags;
        int rc;
@@ -572,9 +573,6 @@ static void pmcraid_bist_done(struct pmcraid_cmd *cmd)
                pmcraid_info("BIST not complete, waiting another 2 secs\n");
                cmd->timer.expires = jiffies + cmd->time_left;
                cmd->time_left = 0;
-               cmd->timer.data = (unsigned long)cmd;
-               cmd->timer.function =
-                       (void (*)(unsigned long))pmcraid_bist_done;
                add_timer(&cmd->timer);
        } else {
                cmd->time_left = 0;
@@ -605,9 +603,8 @@ static void pmcraid_start_bist(struct pmcraid_cmd *cmd)
                      doorbells, intrs);
 
        cmd->time_left = msecs_to_jiffies(PMCRAID_BIST_TIMEOUT);
-       cmd->timer.data = (unsigned long)cmd;
        cmd->timer.expires = jiffies + msecs_to_jiffies(PMCRAID_BIST_TIMEOUT);
-       cmd->timer.function = (void (*)(unsigned long))pmcraid_bist_done;
+       cmd->timer.function = (TIMER_FUNC_TYPE)pmcraid_bist_done;
        add_timer(&cmd->timer);
 }
 
@@ -617,8 +614,9 @@ static void pmcraid_start_bist(struct pmcraid_cmd *cmd)
  * Return value
  *  None
  */
-static void pmcraid_reset_alert_done(struct pmcraid_cmd *cmd)
+static void pmcraid_reset_alert_done(struct timer_list *t)
 {
+       struct pmcraid_cmd *cmd = from_timer(cmd, t, timer);
        struct pmcraid_instance *pinstance = cmd->drv_inst;
        u32 status = ioread32(pinstance->ioa_status);
        unsigned long lock_flags;
@@ -637,10 +635,8 @@ static void pmcraid_reset_alert_done(struct pmcraid_cmd *cmd)
                pmcraid_info("critical op is not yet reset waiting again\n");
                /* restart timer if some more time is available to wait */
                cmd->time_left -= PMCRAID_CHECK_FOR_RESET_TIMEOUT;
-               cmd->timer.data = (unsigned long)cmd;
                cmd->timer.expires = jiffies + PMCRAID_CHECK_FOR_RESET_TIMEOUT;
-               cmd->timer.function =
-                       (void (*)(unsigned long))pmcraid_reset_alert_done;
+               cmd->timer.function = (TIMER_FUNC_TYPE)pmcraid_reset_alert_done;
                add_timer(&cmd->timer);
        }
 }
@@ -676,10 +672,8 @@ static void pmcraid_reset_alert(struct pmcraid_cmd *cmd)
                 * bit to be reset.
                 */
                cmd->time_left = PMCRAID_RESET_TIMEOUT;
-               cmd->timer.data = (unsigned long)cmd;
                cmd->timer.expires = jiffies + PMCRAID_CHECK_FOR_RESET_TIMEOUT;
-               cmd->timer.function =
-                       (void (*)(unsigned long))pmcraid_reset_alert_done;
+               cmd->timer.function = (TIMER_FUNC_TYPE)pmcraid_reset_alert_done;
                add_timer(&cmd->timer);
 
                iowrite32(DOORBELL_IOA_RESET_ALERT,
@@ -704,8 +698,9 @@ static void pmcraid_reset_alert(struct pmcraid_cmd *cmd)
  * Return value:
  *   None
  */
-static void pmcraid_timeout_handler(struct pmcraid_cmd *cmd)
+static void pmcraid_timeout_handler(struct timer_list *t)
 {
+       struct pmcraid_cmd *cmd = from_timer(cmd, t, timer);
        struct pmcraid_instance *pinstance = cmd->drv_inst;
        unsigned long lock_flags;
 
@@ -919,7 +914,7 @@ static void pmcraid_send_cmd(
        struct pmcraid_cmd *cmd,
        void (*cmd_done) (struct pmcraid_cmd *),
        unsigned long timeout,
-       void (*timeout_func) (struct pmcraid_cmd *)
+       void (*timeout_func) (struct timer_list *)
 )
 {
        /* initialize done function */
@@ -927,9 +922,8 @@ static void pmcraid_send_cmd(
 
        if (timeout_func) {
                /* setup timeout handler */
-               cmd->timer.data = (unsigned long)cmd;
                cmd->timer.expires = jiffies + timeout;
-               cmd->timer.function = (void (*)(unsigned long))timeout_func;
+               cmd->timer.function = (TIMER_FUNC_TYPE)timeout_func;
                add_timer(&cmd->timer);
        }
 
@@ -1955,10 +1949,9 @@ static void pmcraid_soft_reset(struct pmcraid_cmd *cmd)
         * would re-initiate a reset
         */
        cmd->cmd_done = pmcraid_ioa_reset;
-       cmd->timer.data = (unsigned long)cmd;
        cmd->timer.expires = jiffies +
                             msecs_to_jiffies(PMCRAID_TRANSOP_TIMEOUT);
-       cmd->timer.function = (void (*)(unsigned long))pmcraid_timeout_handler;
+       cmd->timer.function = (TIMER_FUNC_TYPE)pmcraid_timeout_handler;
 
        if (!timer_pending(&cmd->timer))
                add_timer(&cmd->timer);
index 8a29fb09db141365832f3b62436d083357a6156b..390775d5c91888361ebaad09a5425a02217baaed 100644 (file)
@@ -758,9 +758,9 @@ enum action {
 };
 
 
-static void qla1280_mailbox_timeout(unsigned long __data)
+static void qla1280_mailbox_timeout(struct timer_list *t)
 {
-       struct scsi_qla_host *ha = (struct scsi_qla_host *)__data;
+       struct scsi_qla_host *ha = from_timer(ha, t, mailbox_timer);
        struct device_reg __iomem *reg;
        reg = ha->iobase;
 
@@ -2465,7 +2465,6 @@ qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb)
        uint16_t __iomem *mptr;
        uint16_t data;
        DECLARE_COMPLETION_ONSTACK(wait);
-       struct timer_list timer;
 
        ENTER("qla1280_mailbox_command");
 
@@ -2494,18 +2493,15 @@ qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb)
        /* Issue set host interrupt command. */
 
        /* set up a timer just in case we're really jammed */
-       init_timer_on_stack(&timer);
-       timer.expires = jiffies + 20*HZ;
-       timer.data = (unsigned long)ha;
-       timer.function = qla1280_mailbox_timeout;
-       add_timer(&timer);
+       timer_setup(&ha->mailbox_timer, qla1280_mailbox_timeout, 0);
+       mod_timer(&ha->mailbox_timer, jiffies + 20 * HZ);
 
        spin_unlock_irq(ha->host->host_lock);
        WRT_REG_WORD(&reg->host_cmd, HC_SET_HOST_INT);
        data = qla1280_debounce_register(&reg->istatus);
 
        wait_for_completion(&wait);
-       del_timer_sync(&timer);
+       del_timer_sync(&ha->mailbox_timer);
 
        spin_lock_irq(ha->host->host_lock);
 
index 834884b9eed5b579e62a622ce4725c80ad897a7b..1522aca2c8c83c603f61c06265b959da6ec254f2 100644 (file)
@@ -1055,6 +1055,7 @@ struct scsi_qla_host {
        struct list_head done_q;        /* Done queue */
 
        struct completion *mailbox_wait;
+       struct timer_list mailbox_timer;
 
        volatile struct {
                uint32_t online:1;                      /* 0 */
index f852ca60c49fd182192efaeb6853bf5c379f015c..3ad375f85b59e325c7e35ac1d7b0264963999e1d 100644 (file)
@@ -206,8 +206,8 @@ int qla24xx_async_abort_cmd(srb_t *);
  */
 extern struct scsi_host_template qla2xxx_driver_template;
 extern struct scsi_transport_template *qla2xxx_transport_vport_template;
-extern void qla2x00_timer(scsi_qla_host_t *);
-extern void qla2x00_start_timer(scsi_qla_host_t *, void *, unsigned long);
+extern void qla2x00_timer(struct timer_list *);
+extern void qla2x00_start_timer(scsi_qla_host_t *, unsigned long);
 extern void qla24xx_deallocate_vp_id(scsi_qla_host_t *);
 extern int qla24xx_disable_vp (scsi_qla_host_t *);
 extern int qla24xx_enable_vp (scsi_qla_host_t *);
@@ -753,7 +753,7 @@ extern int qla82xx_restart_isp(scsi_qla_host_t *);
 /* IOCB related functions */
 extern int qla82xx_start_scsi(srb_t *);
 extern void qla2x00_sp_free(void *);
-extern void qla2x00_sp_timeout(unsigned long);
+extern void qla2x00_sp_timeout(struct timer_list *);
 extern void qla2x00_bsg_job_done(void *, int);
 extern void qla2x00_bsg_sp_free(void *);
 extern void qla2x00_start_iocbs(struct scsi_qla_host *, struct req_que *);
index b5b48ddca9621d82bb9b7b674b8eb9f79f083fbe..44cf875a484adb4ac5e7afb98a5f5a87cc0f12f1 100644 (file)
@@ -45,9 +45,9 @@ static void qla24xx_handle_prli_done_event(struct scsi_qla_host *,
 /* SRB Extensions ---------------------------------------------------------- */
 
 void
-qla2x00_sp_timeout(unsigned long __data)
+qla2x00_sp_timeout(struct timer_list *t)
 {
-       srb_t *sp = (srb_t *)__data;
+       srb_t *sp = from_timer(sp, t, u.iocb_cmd.timer);
        struct srb_iocb *iocb;
        scsi_qla_host_t *vha = sp->vha;
        struct req_que *req;
index 9a2c86eacf44add92137dc94d5bf2846987e89e0..17d2c20f1f75a1084fd3328f558fa7f1d6eb234f 100644 (file)
@@ -269,10 +269,8 @@ qla2x00_rel_sp(srb_t *sp)
 static inline void
 qla2x00_init_timer(srb_t *sp, unsigned long tmo)
 {
-       init_timer(&sp->u.iocb_cmd.timer);
+       timer_setup(&sp->u.iocb_cmd.timer, qla2x00_sp_timeout, 0);
        sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ;
-       sp->u.iocb_cmd.timer.data = (unsigned long)sp;
-       sp->u.iocb_cmd.timer.function = qla2x00_sp_timeout;
        add_timer(&sp->u.iocb_cmd.timer);
        sp->free = qla2x00_sp_free;
        if (IS_QLAFX00(sp->vha->hw) && (sp->type == SRB_FXIOCB_DCMD))
index c0f8f6c17b793384cd9f9c70ef34f8ec945642e7..cbf544dbf883d791c3a841b7ddc829cd0a0dff36 100644 (file)
@@ -487,7 +487,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
        atomic_set(&vha->loop_state, LOOP_DOWN);
        atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
 
-       qla2x00_start_timer(vha, qla2x00_timer, WATCH_INTERVAL);
+       qla2x00_start_timer(vha, WATCH_INTERVAL);
 
        vha->req = base_vha->req;
        host->can_queue = base_vha->req->length + 128;
index dce42a416876573087e497c9cf7242e267b04b4d..50286cf02eca046b830b973ca4868c0f02944ec0 100644 (file)
@@ -330,12 +330,10 @@ struct scsi_transport_template *qla2xxx_transport_vport_template = NULL;
  */
 
 __inline__ void
-qla2x00_start_timer(scsi_qla_host_t *vha, void *func, unsigned long interval)
+qla2x00_start_timer(scsi_qla_host_t *vha, unsigned long interval)
 {
-       init_timer(&vha->timer);
+       timer_setup(&vha->timer, qla2x00_timer, 0);
        vha->timer.expires = jiffies + interval * HZ;
-       vha->timer.data = (unsigned long)vha;
-       vha->timer.function = (void (*)(unsigned long))func;
        add_timer(&vha->timer);
        vha->timer_active = 1;
 }
@@ -3247,7 +3245,7 @@ skip_dpc:
        base_vha->host->irq = ha->pdev->irq;
 
        /* Initialized the timer */
-       qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL);
+       qla2x00_start_timer(base_vha, WATCH_INTERVAL);
        ql_dbg(ql_dbg_init, base_vha, 0x00ef,
            "Started qla2x00_timer with "
            "interval=%d.\n", WATCH_INTERVAL);
@@ -5996,8 +5994,9 @@ qla2x00_rst_aen(scsi_qla_host_t *vha)
 * Context: Interrupt
 ***************************************************************************/
 void
-qla2x00_timer(scsi_qla_host_t *vha)
+qla2x00_timer(struct timer_list *t)
 {
+       scsi_qla_host_t *vha = from_timer(vha, t, timer);
        unsigned long   cpu_flags = 0;
        int             start_dpc = 0;
        int             index;
index 64c6fa563fdb7562f6e33d83357879d8e572940e..2b8a8ce2a4313e3c44fdca937b8e1bd7a0838c82 100644 (file)
@@ -3955,16 +3955,15 @@ exit_session_conn_param:
 /*
  * Timer routines
  */
+static void qla4xxx_timer(struct timer_list *t);
 
-static void qla4xxx_start_timer(struct scsi_qla_host *ha, void *func,
+static void qla4xxx_start_timer(struct scsi_qla_host *ha,
                                unsigned long interval)
 {
        DEBUG(printk("scsi: %s: Starting timer thread for adapter %d\n",
                     __func__, ha->host->host_no));
-       init_timer(&ha->timer);
+       timer_setup(&ha->timer, qla4xxx_timer, 0);
        ha->timer.expires = jiffies + interval * HZ;
-       ha->timer.data = (unsigned long)ha;
-       ha->timer.function = (void (*)(unsigned long))func;
        add_timer(&ha->timer);
        ha->timer_active = 1;
 }
@@ -4508,8 +4507,9 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
  * qla4xxx_timer - checks every second for work to do.
  * @ha: Pointer to host adapter structure.
  **/
-static void qla4xxx_timer(struct scsi_qla_host *ha)
+static void qla4xxx_timer(struct timer_list *t)
 {
+       struct scsi_qla_host *ha = from_timer(ha, t, timer);
        int start_dpc = 0;
        uint16_t w;
 
@@ -8805,7 +8805,7 @@ skip_retry_init:
        ha->isp_ops->enable_intrs(ha);
 
        /* Start timer thread. */
-       qla4xxx_start_timer(ha, qla4xxx_timer, 1);
+       qla4xxx_start_timer(ha, 1);
 
        set_bit(AF_INIT_DONE, &ha->flags);
 
index 83bdbd84eb01f427e9d74d56526b2e1f1ceb9e33..90f6effc32b43834d06f7b6346791795bac5f9cf 100644 (file)
@@ -2860,11 +2860,12 @@ out:
 
 #define PQI_HEARTBEAT_TIMER_INTERVAL   (10 * HZ)
 
-static void pqi_heartbeat_timer_handler(unsigned long data)
+static void pqi_heartbeat_timer_handler(struct timer_list *t)
 {
        int num_interrupts;
        u32 heartbeat_count;
-       struct pqi_ctrl_info *ctrl_info = (struct pqi_ctrl_info *)data;
+       struct pqi_ctrl_info *ctrl_info = from_timer(ctrl_info, t,
+                                                    heartbeat_timer);
 
        pqi_check_ctrl_health(ctrl_info);
        if (pqi_ctrl_offline(ctrl_info))
@@ -2902,8 +2903,6 @@ static void pqi_start_heartbeat_timer(struct pqi_ctrl_info *ctrl_info)
 
        ctrl_info->heartbeat_timer.expires =
                jiffies + PQI_HEARTBEAT_TIMER_INTERVAL;
-       ctrl_info->heartbeat_timer.data = (unsigned long)ctrl_info;
-       ctrl_info->heartbeat_timer.function = pqi_heartbeat_timer_handler;
        add_timer(&ctrl_info->heartbeat_timer);
 }
 
@@ -6465,7 +6464,7 @@ static struct pqi_ctrl_info *pqi_alloc_ctrl_info(int numa_node)
        INIT_DELAYED_WORK(&ctrl_info->rescan_work, pqi_rescan_worker);
        INIT_DELAYED_WORK(&ctrl_info->update_time_work, pqi_update_time_worker);
 
-       init_timer(&ctrl_info->heartbeat_timer);
+       timer_setup(&ctrl_info->heartbeat_timer, pqi_heartbeat_timer_handler, 0);
        INIT_WORK(&ctrl_info->ctrl_offline_work, pqi_ctrl_offline_worker);
 
        sema_init(&ctrl_info->sync_request_sem,
index 56f7be6af1f695a873c9acfe6619d3ec8dafd496..585925bb49a4ec614ec6e3be0b97d9f2d1a257f5 100644 (file)
@@ -1165,7 +1165,7 @@ static const int NUM_CTL_LABELS = (MSG_CTL_END - MSG_CTL_START + 1);
 
 static void read_all_doc(struct vc_data *vc);
 static void cursor_done(u_long data);
-static DEFINE_TIMER(cursor_timer, cursor_done, 0, 0);
+static DEFINE_TIMER(cursor_timer, cursor_done);
 
 static void do_handle_shift(struct vc_data *vc, u_char value, char up_flag)
 {
index a1ca68c765792cd73034bb41e0ca18725db50d04..6ddd3fc3f08d15d5aff35e296ee13868eb1ecd74 100644 (file)
@@ -158,7 +158,7 @@ static void thread_wake_up(u_long data)
        wake_up_interruptible_all(&speakup_event);
 }
 
-static DEFINE_TIMER(thread_timer, thread_wake_up, 0, 0);
+static DEFINE_TIMER(thread_timer, thread_wake_up);
 
 void synth_start(void)
 {
index af12925a9d2b58f0c92b8b68a5b01fc41eee63ea..de6ff59e3e6573fa630c7f80a8cfb2452143dbeb 100644 (file)
@@ -267,7 +267,7 @@ static void update_scan_time(void)
                last_scanned_shadow[i].time_scan = jiffies;
 }
 
-static void remove_network_from_shadow(unsigned long arg)
+static void remove_network_from_shadow(unsigned long unused)
 {
        unsigned long now = jiffies;
        int i, j;
@@ -288,7 +288,6 @@ static void remove_network_from_shadow(unsigned long arg)
        }
 
        if (last_scanned_cnt != 0) {
-               hAgingTimer.data = arg;
                mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
        }
 }
@@ -305,7 +304,6 @@ static int is_network_in_shadow(struct network_info *pstrNetworkInfo,
        int i;
 
        if (last_scanned_cnt == 0) {
-               hAgingTimer.data = (unsigned long)user_void;
                mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME));
                state = -1;
        } else {
index 5001261f5d69d759dd25161401510551d35c3da7..9e67c7678c86d2af0aa4617a40686103efa55fd2 100644 (file)
@@ -372,6 +372,8 @@ struct iscsi_np *iscsit_add_np(
        init_completion(&np->np_restart_comp);
        INIT_LIST_HEAD(&np->np_list);
 
+       timer_setup(&np->np_login_timer, iscsi_handle_login_thread_timeout, 0);
+
        ret = iscsi_target_setup_login_socket(np, sockaddr);
        if (ret != 0) {
                kfree(np);
index 7fe2aa73cff69e04f8df8d79e3af1c634fb5ca04..718fe9a1b709f8918a58b562c72a9aaba8e07c8e 100644 (file)
@@ -749,9 +749,9 @@ int iscsit_check_post_dataout(
        }
 }
 
-static void iscsit_handle_time2retain_timeout(unsigned long data)
+void iscsit_handle_time2retain_timeout(struct timer_list *t)
 {
-       struct iscsi_session *sess = (struct iscsi_session *) data;
+       struct iscsi_session *sess = from_timer(sess, t, time2retain_timer);
        struct iscsi_portal_group *tpg = sess->tpg;
        struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
 
@@ -809,14 +809,10 @@ void iscsit_start_time2retain_handler(struct iscsi_session *sess)
        pr_debug("Starting Time2Retain timer for %u seconds on"
                " SID: %u\n", sess->sess_ops->DefaultTime2Retain, sess->sid);
 
-       init_timer(&sess->time2retain_timer);
-       sess->time2retain_timer.expires =
-               (get_jiffies_64() + sess->sess_ops->DefaultTime2Retain * HZ);
-       sess->time2retain_timer.data = (unsigned long)sess;
-       sess->time2retain_timer.function = iscsit_handle_time2retain_timeout;
        sess->time2retain_timer_flags &= ~ISCSI_TF_STOP;
        sess->time2retain_timer_flags |= ISCSI_TF_RUNNING;
-       add_timer(&sess->time2retain_timer);
+       mod_timer(&sess->time2retain_timer,
+                 jiffies + sess->sess_ops->DefaultTime2Retain * HZ);
 }
 
 /*
index 3393407bc4e43dddb522bd87e9eba86ef2cced99..883ebf6d36cf07695119841301e7b3306cd8c498 100644 (file)
@@ -12,6 +12,7 @@ extern void iscsit_set_dataout_sequence_values(struct iscsi_cmd *);
 extern int iscsit_check_pre_dataout(struct iscsi_cmd *, unsigned char *);
 extern int iscsit_check_post_dataout(struct iscsi_cmd *, unsigned char *, u8);
 extern void iscsit_start_time2retain_handler(struct iscsi_session *);
+extern void iscsit_handle_time2retain_timeout(struct timer_list *t);
 extern int iscsit_stop_time2retain_timer(struct iscsi_session *);
 extern void iscsit_connection_reinstatement_rcfr(struct iscsi_conn *);
 extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int);
index fe9b7f1e44aca5c8bcda8677310351f03e507095..76184094a0cf944efc26c0aa32626b71e56b07b8 100644 (file)
@@ -1148,11 +1148,11 @@ static int iscsit_set_dataout_timeout_values(
 /*
  *     NOTE: Called from interrupt (timer) context.
  */
-static void iscsit_handle_dataout_timeout(unsigned long data)
+void iscsit_handle_dataout_timeout(struct timer_list *t)
 {
        u32 pdu_length = 0, pdu_offset = 0;
        u32 r2t_length = 0, r2t_offset = 0;
-       struct iscsi_cmd *cmd = (struct iscsi_cmd *) data;
+       struct iscsi_cmd *cmd = from_timer(cmd, t, dataout_timer);
        struct iscsi_conn *conn = cmd->conn;
        struct iscsi_session *sess = NULL;
        struct iscsi_node_attrib *na;
@@ -1264,13 +1264,9 @@ void iscsit_start_dataout_timer(
        pr_debug("Starting DataOUT timer for ITT: 0x%08x on"
                " CID: %hu.\n", cmd->init_task_tag, conn->cid);
 
-       init_timer(&cmd->dataout_timer);
-       cmd->dataout_timer.expires = (get_jiffies_64() + na->dataout_timeout * HZ);
-       cmd->dataout_timer.data = (unsigned long)cmd;
-       cmd->dataout_timer.function = iscsit_handle_dataout_timeout;
        cmd->dataout_timer_flags &= ~ISCSI_TF_STOP;
        cmd->dataout_timer_flags |= ISCSI_TF_RUNNING;
-       add_timer(&cmd->dataout_timer);
+       mod_timer(&cmd->dataout_timer, jiffies + na->dataout_timeout * HZ);
 }
 
 void iscsit_stop_dataout_timer(struct iscsi_cmd *cmd)
index 5f66b265b25bf2d8b2baa44c0f05c9c5e791ff1a..1f6973f87fea06f4b7df9bda74ca1b1c57fe015e 100644 (file)
@@ -30,6 +30,7 @@ extern int iscsit_execute_ooo_cmdsns(struct iscsi_session *);
 extern int iscsit_execute_cmd(struct iscsi_cmd *, int);
 extern int iscsit_handle_ooo_cmdsn(struct iscsi_session *, struct iscsi_cmd *, u32);
 extern void iscsit_remove_ooo_cmdsn(struct iscsi_session *, struct iscsi_ooo_cmdsn *);
+extern void iscsit_handle_dataout_timeout(struct timer_list *t);
 extern void iscsit_mod_dataout_timer(struct iscsi_cmd *);
 extern void iscsit_start_dataout_timer(struct iscsi_cmd *, struct iscsi_conn *);
 extern void iscsit_stop_dataout_timer(struct iscsi_cmd *);
index dc13afbd4c88dec2390ca8e65b3332d2f78acd73..64c5a57b92e4923a1b8298cdc71637bd03314276 100644 (file)
@@ -333,6 +333,9 @@ static int iscsi_login_zero_tsih_s1(
        spin_lock_init(&sess->session_usage_lock);
        spin_lock_init(&sess->ttt_lock);
 
+       timer_setup(&sess->time2retain_timer,
+                   iscsit_handle_time2retain_timeout, 0);
+
        idr_preload(GFP_KERNEL);
        spin_lock_bh(&sess_idr_lock);
        ret = idr_alloc(&sess_idr, NULL, 0, 0, GFP_NOWAIT);
@@ -839,9 +842,9 @@ void iscsi_post_login_handler(
        iscsit_dec_conn_usage_count(conn);
 }
 
-static void iscsi_handle_login_thread_timeout(unsigned long data)
+void iscsi_handle_login_thread_timeout(struct timer_list *t)
 {
-       struct iscsi_np *np = (struct iscsi_np *) data;
+       struct iscsi_np *np = from_timer(np, t, np_login_timer);
 
        spin_lock_bh(&np->np_thread_lock);
        pr_err("iSCSI Login timeout on Network Portal %pISpc\n",
@@ -866,13 +869,9 @@ static void iscsi_start_login_thread_timer(struct iscsi_np *np)
         * point we do not have access to ISCSI_TPG_ATTRIB(tpg)->login_timeout
         */
        spin_lock_bh(&np->np_thread_lock);
-       init_timer(&np->np_login_timer);
-       np->np_login_timer.expires = (get_jiffies_64() + TA_LOGIN_TIMEOUT * HZ);
-       np->np_login_timer.data = (unsigned long)np;
-       np->np_login_timer.function = iscsi_handle_login_thread_timeout;
        np->np_login_timer_flags &= ~ISCSI_TF_STOP;
        np->np_login_timer_flags |= ISCSI_TF_RUNNING;
-       add_timer(&np->np_login_timer);
+       mod_timer(&np->np_login_timer, jiffies + TA_LOGIN_TIMEOUT * HZ);
 
        pr_debug("Added timeout timer to iSCSI login request for"
                        " %u seconds.\n", TA_LOGIN_TIMEOUT);
@@ -1266,6 +1265,10 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
        pr_debug("Moving to TARG_CONN_STATE_FREE.\n");
        conn->conn_state = TARG_CONN_STATE_FREE;
 
+       timer_setup(&conn->nopin_response_timer,
+                   iscsit_handle_nopin_response_timeout, 0);
+       timer_setup(&conn->nopin_timer, iscsit_handle_nopin_timeout, 0);
+
        if (iscsit_conn_set_transport(conn, np->np_transport) < 0) {
                kfree(conn);
                return 1;
index c2495e03625c5b6ecd68fc0caea25eb42b3eb3e4..74ac3abc44a02564ba1231e96c1338b1ecd87bd7 100644 (file)
@@ -25,5 +25,6 @@ extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8)
 extern void iscsi_target_login_sess_out(struct iscsi_conn *, struct iscsi_np *,
                                bool, bool);
 extern int iscsi_target_login_thread(void *);
+extern void iscsi_handle_login_thread_timeout(struct timer_list *t);
 
 #endif   /*** ISCSI_TARGET_LOGIN_H ***/
index 7a6751fecd323cf948a77e4508430487b3cc4717..b686e2ce9c0e5df3e6142f5cf4ab144ef6d5ef85 100644 (file)
@@ -559,9 +559,15 @@ static void iscsi_target_login_drop(struct iscsi_conn *conn, struct iscsi_login
        iscsi_target_login_sess_out(conn, np, zero_tsih, true);
 }
 
-static void iscsi_target_login_timeout(unsigned long data)
+struct conn_timeout {
+       struct timer_list timer;
+       struct iscsi_conn *conn;
+};
+
+static void iscsi_target_login_timeout(struct timer_list *t)
 {
-       struct iscsi_conn *conn = (struct iscsi_conn *)data;
+       struct conn_timeout *timeout = from_timer(timeout, t, timer);
+       struct iscsi_conn *conn = timeout->conn;
 
        pr_debug("Entering iscsi_target_login_timeout >>>>>>>>>>>>>>>>>>>\n");
 
@@ -580,7 +586,7 @@ static void iscsi_target_do_login_rx(struct work_struct *work)
        struct iscsi_np *np = login->np;
        struct iscsi_portal_group *tpg = conn->tpg;
        struct iscsi_tpg_np *tpg_np = conn->tpg_np;
-       struct timer_list login_timer;
+       struct conn_timeout timeout;
        int rc, zero_tsih = login->zero_tsih;
        bool state;
 
@@ -618,15 +624,14 @@ static void iscsi_target_do_login_rx(struct work_struct *work)
        conn->login_kworker = current;
        allow_signal(SIGINT);
 
-       init_timer(&login_timer);
-       login_timer.expires = (get_jiffies_64() + TA_LOGIN_TIMEOUT * HZ);
-       login_timer.data = (unsigned long)conn;
-       login_timer.function = iscsi_target_login_timeout;
-       add_timer(&login_timer);
-       pr_debug("Starting login_timer for %s/%d\n", current->comm, current->pid);
+       timeout.conn = conn;
+       timer_setup_on_stack(&timeout.timer, iscsi_target_login_timeout, 0);
+       mod_timer(&timeout.timer, jiffies + TA_LOGIN_TIMEOUT * HZ);
+       pr_debug("Starting login timer for %s/%d\n", current->comm, current->pid);
 
        rc = conn->conn_transport->iscsit_get_login_rx(conn, login);
-       del_timer_sync(&login_timer);
+       del_timer_sync(&timeout.timer);
+       destroy_timer_on_stack(&timeout.timer);
        flush_signals(current);
        conn->login_kworker = NULL;
 
index 1e36f83b596164ec8932d5fb3f703229f052bedf..54f20f184dd6b5c8422f8e72f81e173c70d5efd0 100644 (file)
@@ -176,6 +176,7 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state)
        spin_lock_init(&cmd->istate_lock);
        spin_lock_init(&cmd->error_lock);
        spin_lock_init(&cmd->r2t_lock);
+       timer_setup(&cmd->dataout_timer, iscsit_handle_dataout_timeout, 0);
 
        return cmd;
 }
@@ -880,9 +881,9 @@ static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response)
        return 0;
 }
 
-static void iscsit_handle_nopin_response_timeout(unsigned long data)
+void iscsit_handle_nopin_response_timeout(struct timer_list *t)
 {
-       struct iscsi_conn *conn = (struct iscsi_conn *) data;
+       struct iscsi_conn *conn = from_timer(conn, t, nopin_response_timer);
 
        iscsit_inc_conn_usage_count(conn);
 
@@ -949,14 +950,10 @@ void iscsit_start_nopin_response_timer(struct iscsi_conn *conn)
                return;
        }
 
-       init_timer(&conn->nopin_response_timer);
-       conn->nopin_response_timer.expires =
-               (get_jiffies_64() + na->nopin_response_timeout * HZ);
-       conn->nopin_response_timer.data = (unsigned long)conn;
-       conn->nopin_response_timer.function = iscsit_handle_nopin_response_timeout;
        conn->nopin_response_timer_flags &= ~ISCSI_TF_STOP;
        conn->nopin_response_timer_flags |= ISCSI_TF_RUNNING;
-       add_timer(&conn->nopin_response_timer);
+       mod_timer(&conn->nopin_response_timer,
+                 jiffies + na->nopin_response_timeout * HZ);
 
        pr_debug("Started NOPIN Response Timer on CID: %d to %u"
                " seconds\n", conn->cid, na->nopin_response_timeout);
@@ -980,9 +977,9 @@ void iscsit_stop_nopin_response_timer(struct iscsi_conn *conn)
        spin_unlock_bh(&conn->nopin_timer_lock);
 }
 
-static void iscsit_handle_nopin_timeout(unsigned long data)
+void iscsit_handle_nopin_timeout(struct timer_list *t)
 {
-       struct iscsi_conn *conn = (struct iscsi_conn *) data;
+       struct iscsi_conn *conn = from_timer(conn, t, nopin_timer);
 
        iscsit_inc_conn_usage_count(conn);
 
@@ -1015,13 +1012,9 @@ void __iscsit_start_nopin_timer(struct iscsi_conn *conn)
        if (conn->nopin_timer_flags & ISCSI_TF_RUNNING)
                return;
 
-       init_timer(&conn->nopin_timer);
-       conn->nopin_timer.expires = (get_jiffies_64() + na->nopin_timeout * HZ);
-       conn->nopin_timer.data = (unsigned long)conn;
-       conn->nopin_timer.function = iscsit_handle_nopin_timeout;
        conn->nopin_timer_flags &= ~ISCSI_TF_STOP;
        conn->nopin_timer_flags |= ISCSI_TF_RUNNING;
-       add_timer(&conn->nopin_timer);
+       mod_timer(&conn->nopin_timer, jiffies + na->nopin_timeout * HZ);
 
        pr_debug("Started NOPIN Timer on CID: %d at %u second"
                " interval\n", conn->cid, na->nopin_timeout);
@@ -1043,13 +1036,9 @@ void iscsit_start_nopin_timer(struct iscsi_conn *conn)
                return;
        }
 
-       init_timer(&conn->nopin_timer);
-       conn->nopin_timer.expires = (get_jiffies_64() + na->nopin_timeout * HZ);
-       conn->nopin_timer.data = (unsigned long)conn;
-       conn->nopin_timer.function = iscsit_handle_nopin_timeout;
        conn->nopin_timer_flags &= ~ISCSI_TF_STOP;
        conn->nopin_timer_flags |= ISCSI_TF_RUNNING;
-       add_timer(&conn->nopin_timer);
+       mod_timer(&conn->nopin_timer, jiffies + na->nopin_timeout * HZ);
 
        pr_debug("Started NOPIN Timer on CID: %d at %u second"
                        " interval\n", conn->cid, na->nopin_timeout);
index 5e053d61c0c52f1ccd04358ca44d6f54edb649bc..d66dfc2126247c814ee554c8632f2fa7f126bfd3 100644 (file)
@@ -48,9 +48,11 @@ extern struct iscsi_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *,
 extern void iscsit_check_conn_usage_count(struct iscsi_conn *);
 extern void iscsit_dec_conn_usage_count(struct iscsi_conn *);
 extern void iscsit_inc_conn_usage_count(struct iscsi_conn *);
+extern void iscsit_handle_nopin_response_timeout(struct timer_list *t);
 extern void iscsit_mod_nopin_response_timer(struct iscsi_conn *);
 extern void iscsit_start_nopin_response_timer(struct iscsi_conn *);
 extern void iscsit_stop_nopin_response_timer(struct iscsi_conn *);
+extern void iscsit_handle_nopin_timeout(struct timer_list *t);
 extern void __iscsit_start_nopin_timer(struct iscsi_conn *);
 extern void iscsit_start_nopin_timer(struct iscsi_conn *);
 extern void iscsit_stop_nopin_timer(struct iscsi_conn *);
index d272bc4e7fb5699aafabea9483cf6252d7d4fd40..dac8a1a8e4acdffd9fde5d68fd55dbe06506d82a 100644 (file)
@@ -283,7 +283,7 @@ static void cyz_poll(unsigned long);
 /* The Cyclades-Z polling cycle is defined by this variable */
 static long cyz_polling_cycle = CZ_DEF_POLL;
 
-static DEFINE_TIMER(cyz_timerlist, cyz_poll, 0, 0);
+static DEFINE_TIMER(cyz_timerlist, cyz_poll);
 
 #else                          /* CONFIG_CYZ_INTR */
 static void cyz_rx_restart(unsigned long);
index 61ecdd6b2fc24479bdbfcd3a24f810604908d29b..40af32108ff5e7d753a3eef3a3115bb3c6ea6dd7 100644 (file)
@@ -177,7 +177,7 @@ static struct tty_driver *isicom_normal;
 static void isicom_tx(unsigned long _data);
 static void isicom_start(struct tty_struct *tty);
 
-static DEFINE_TIMER(tx, isicom_tx, 0, 0);
+static DEFINE_TIMER(tx, isicom_tx);
 
 /*   baud index mappings from linux defns to isi */
 
index 7f3d4cb0341be03fdb3e67f06097a495cd2971b5..93d37655d928ec94ed3dd8e9ec7e92de32692aff 100644 (file)
@@ -428,7 +428,7 @@ static const struct tty_port_operations moxa_port_ops = {
 };
 
 static struct tty_driver *moxaDriver;
-static DEFINE_TIMER(moxaTimer, moxa_poll, 0, 0);
+static DEFINE_TIMER(moxaTimer, moxa_poll);
 
 /*
  * HW init
index 20d79a6007d50bcb9457890df30c1d341899485d..aa695fda1084e557bec716cbcd9c4c4947911025 100644 (file)
@@ -111,7 +111,7 @@ static struct r_port *rp_table[MAX_RP_PORTS];              /*  The main repository of
 static unsigned int xmit_flags[NUM_BOARDS];           /*  Bit significant, indicates port had data to transmit. */
                                                       /*  eg.  Bit 0 indicates port 0 has xmit data, ...        */
 static atomic_t rp_num_ports_open;                    /*  Number of serial ports open                           */
-static DEFINE_TIMER(rocket_timer, rp_do_poll, 0, 0);
+static DEFINE_TIMER(rocket_timer, rp_do_poll);
 
 static unsigned long board1;                          /* ISA addresses, retrieved from rocketport.conf          */
 static unsigned long board2;
index f4166263bb3aaf383b0b64c28b929e749e6607da..f974d6340d0449bce837d9b6e90677fcb064f22d 100644 (file)
@@ -250,7 +250,7 @@ static void kd_nosound(unsigned long ignored)
        input_handler_for_each_handle(&kbd_handler, &zero, kd_sound_helper);
 }
 
-static DEFINE_TIMER(kd_mksound_timer, kd_nosound, 0, 0);
+static DEFINE_TIMER(kd_mksound_timer, kd_nosound);
 
 void kd_mksound(unsigned int hz, unsigned int ticks)
 {
index 2ebaba16f7858ec2ac0b0395af2c16d5d98a8273..602d716309521ca744b90e91e0a45c820581c88f 100644 (file)
@@ -228,7 +228,7 @@ static int scrollback_delta;
  */
 int (*console_blank_hook)(int);
 
-static DEFINE_TIMER(console_timer, blank_screen_t, 0, 0);
+static DEFINE_TIMER(console_timer, blank_screen_t);
 static int blank_state;
 static int blank_timer_expired;
 enum {
index b3fc602b2e247ea150a49c13323ae66cde2b6b4b..5ad74750e8a4b858d77b98c9962f91dcccca78f8 100644 (file)
@@ -576,11 +576,16 @@ alloc_sglist(int nents, int max, int vary, struct usbtest_dev *dev, int pipe)
        return sg;
 }
 
-static void sg_timeout(unsigned long _req)
+struct sg_timeout {
+       struct timer_list timer;
+       struct usb_sg_request *req;
+};
+
+static void sg_timeout(struct timer_list *t)
 {
-       struct usb_sg_request   *req = (struct usb_sg_request *) _req;
+       struct sg_timeout *timeout = from_timer(timeout, t, timer);
 
-       usb_sg_cancel(req);
+       usb_sg_cancel(timeout->req);
 }
 
 static int perform_sglist(
@@ -594,9 +599,11 @@ static int perform_sglist(
 {
        struct usb_device       *udev = testdev_to_usbdev(tdev);
        int                     retval = 0;
-       struct timer_list       sg_timer;
+       struct sg_timeout       timeout = {
+               .req = req,
+       };
 
-       setup_timer_on_stack(&sg_timer, sg_timeout, (unsigned long) req);
+       timer_setup_on_stack(&timeout.timer, sg_timeout, 0);
 
        while (retval == 0 && iterations-- > 0) {
                retval = usb_sg_init(req, udev, pipe,
@@ -607,13 +614,14 @@ static int perform_sglist(
 
                if (retval)
                        break;
-               mod_timer(&sg_timer, jiffies +
+               mod_timer(&timeout.timer, jiffies +
                                msecs_to_jiffies(SIMPLE_IO_TIMEOUT));
                usb_sg_wait(req);
-               if (!del_timer_sync(&sg_timer))
+               if (!del_timer_sync(&timeout.timer))
                        retval = -ETIMEDOUT;
                else
                        retval = req->status;
+               destroy_timer_on_stack(&timeout.timer);
 
                /* FIXME check resulting data pattern */
 
index 665e0e7dfe1e2e2e03eb371bc377f58b6f9f5236..18e896eeca62352f3c5e2c73479aab506c064958 100644 (file)
@@ -71,7 +71,7 @@ MODULE_PARM_DESC(use_gpio,
                "Use the gpio watchdog (required by old cobalt boards).");
 
 static void wdt_timer_ping(unsigned long);
-static DEFINE_TIMER(timer, wdt_timer_ping, 0, 1);
+static DEFINE_TIMER(timer, wdt_timer_ping);
 static unsigned long next_heartbeat;
 static unsigned long wdt_is_open;
 static char wdt_expect_close;
@@ -87,7 +87,7 @@ MODULE_PARM_DESC(nowayout,
  *     Whack the dog
  */
 
-static void wdt_timer_ping(unsigned long data)
+static void wdt_timer_ping(unsigned long unused)
 {
        /* If we got a heartbeat pulse within the WDT_US_INTERVAL
         * we agree to ping the WDT
index 3d43775548e59cda1966146897daa4b6d396b471..aee0b25cf10d9afd48604b943fa17d97a6fe6927 100644 (file)
@@ -230,9 +230,9 @@ static void cpwd_resetbrokentimer(struct cpwd *p, int index)
  * interrupts within the PLD so me must continually
  * reset the timers ad infinitum.
  */
-static void cpwd_brokentimer(unsigned long data)
+static void cpwd_brokentimer(struct timer_list *unused)
 {
-       struct cpwd *p = (struct cpwd *) data;
+       struct cpwd *p = cpwd_device;
        int id, tripped = 0;
 
        /* kill a running timer instance, in case we
@@ -275,7 +275,7 @@ static void cpwd_stoptimer(struct cpwd *p, int index)
 
                if (p->broken) {
                        p->devs[index].runstatus |= WD_STAT_BSTOP;
-                       cpwd_brokentimer((unsigned long) p);
+                       cpwd_brokentimer(NULL);
                }
        }
 }
@@ -608,7 +608,7 @@ static int cpwd_probe(struct platform_device *op)
        }
 
        if (p->broken) {
-               setup_timer(&cpwd_timer, cpwd_brokentimer, (unsigned long)p);
+               timer_setup(&cpwd_timer, cpwd_brokentimer, 0);
                cpwd_timer.expires      = WD_BTIMEOUT;
 
                pr_info("PLD defect workaround enabled for model %s\n",
index 3b8bb59adf027bddf5fde1013c3621f4b480e9a3..b4221f43cd947f625d8124062cb05ccbed875ef8 100644 (file)
@@ -78,10 +78,10 @@ static int lpc18xx_wdt_feed(struct watchdog_device *wdt_dev)
        return 0;
 }
 
-static void lpc18xx_wdt_timer_feed(unsigned long data)
+static void lpc18xx_wdt_timer_feed(struct timer_list *t)
 {
-       struct watchdog_device *wdt_dev = (struct watchdog_device *)data;
-       struct lpc18xx_wdt_dev *lpc18xx_wdt = watchdog_get_drvdata(wdt_dev);
+       struct lpc18xx_wdt_dev *lpc18xx_wdt = from_timer(lpc18xx_wdt, t, timer);
+       struct watchdog_device *wdt_dev = &lpc18xx_wdt->wdt_dev;
 
        lpc18xx_wdt_feed(wdt_dev);
 
@@ -96,7 +96,9 @@ static void lpc18xx_wdt_timer_feed(unsigned long data)
  */
 static int lpc18xx_wdt_stop(struct watchdog_device *wdt_dev)
 {
-       lpc18xx_wdt_timer_feed((unsigned long)wdt_dev);
+       struct lpc18xx_wdt_dev *lpc18xx_wdt = watchdog_get_drvdata(wdt_dev);
+
+       lpc18xx_wdt_timer_feed(&lpc18xx_wdt->timer);
 
        return 0;
 }
@@ -267,8 +269,7 @@ static int lpc18xx_wdt_probe(struct platform_device *pdev)
 
        __lpc18xx_wdt_set_timeout(lpc18xx_wdt);
 
-       setup_timer(&lpc18xx_wdt->timer, lpc18xx_wdt_timer_feed,
-                   (unsigned long)&lpc18xx_wdt->wdt_dev);
+       timer_setup(&lpc18xx_wdt->timer, lpc18xx_wdt_timer_feed, 0);
 
        watchdog_set_nowayout(&lpc18xx_wdt->wdt_dev, nowayout);
        watchdog_set_restart_priority(&lpc18xx_wdt->wdt_dev, 128);
index 9826b59ef73471c1e450e564176c2e49c4fcb283..8a616a57bb90441cc946c2d4d25c71dd5ae8f544 100644 (file)
@@ -127,7 +127,7 @@ static int zf_action = GEN_RESET;
 static unsigned long zf_is_open;
 static char zf_expect_close;
 static DEFINE_SPINLOCK(zf_port_lock);
-static DEFINE_TIMER(zf_timer, zf_ping, 0, 0);
+static DEFINE_TIMER(zf_timer, zf_ping);
 static unsigned long next_heartbeat;
 
 
index be86ea359eee1c1ffefd1cbae6f6e12f0059f273..c9e38096ea91fff0bcfed82f8d8058ff0bb7be17 100644 (file)
@@ -105,7 +105,7 @@ static unsigned long mixcomwd_opened; /* long req'd for setbit --RR */
 
 static int watchdog_port;
 static int mixcomwd_timer_alive;
-static DEFINE_TIMER(mixcomwd_timer, mixcomwd_timerfun, 0, 0);
+static DEFINE_TIMER(mixcomwd_timer, mixcomwd_timerfun);
 static char expect_close;
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
index 2eef58a0cf059837c5055d386bede89e21247c7f..8d589939bc8447b7cb116ba8b3ff70bdb8f207b6 100644 (file)
@@ -113,7 +113,7 @@ MODULE_PARM_DESC(nowayout,
                                __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
 static void wdt_timer_ping(unsigned long);
-static DEFINE_TIMER(timer, wdt_timer_ping, 0, 0);
+static DEFINE_TIMER(timer, wdt_timer_ping);
 static unsigned long next_heartbeat;
 static unsigned long wdt_is_open;
 static char wdt_expect_close;
index 1cfd3f6a13d5f428adebe5a7b3e030b155f06a44..3e9bbaa37bf46ac872b51da65fc4ed31ee1b9f2e 100644 (file)
@@ -124,7 +124,7 @@ MODULE_PARM_DESC(nowayout,
 static __u16 __iomem *wdtmrctl;
 
 static void wdt_timer_ping(unsigned long);
-static DEFINE_TIMER(timer, wdt_timer_ping, 0, 0);
+static DEFINE_TIMER(timer, wdt_timer_ping);
 static unsigned long next_heartbeat;
 static unsigned long wdt_is_open;
 static char wdt_expect_close;
index 5f9cbc37520d2e4fd029ba02e594e9ac024c7e6f..ad3c3be13b40981d5a4ddecbccfbbfb262071e71 100644 (file)
@@ -68,7 +68,7 @@ static struct resource wdt_res;
 static void __iomem *wdt_mem;
 static unsigned int mmio;
 static void wdt_timer_tick(unsigned long data);
-static DEFINE_TIMER(timer, wdt_timer_tick, 0, 0);
+static DEFINE_TIMER(timer, wdt_timer_tick);
                                        /* The timer that pings the watchdog */
 static unsigned long next_heartbeat;   /* the next_heartbeat for the timer */
 
index f0483c75ed324b63cf3d63f33a2367325b1c7869..ba6b680af1000ebe795c0522691675494b28795a 100644 (file)
@@ -98,7 +98,7 @@ MODULE_PARM_DESC(nowayout,
                                __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
 static void wdt_timer_ping(unsigned long);
-static DEFINE_TIMER(timer, wdt_timer_ping, 0, 0);
+static DEFINE_TIMER(timer, wdt_timer_ping);
 static unsigned long next_heartbeat;
 static unsigned long wdt_is_open;
 static char wdt_expect_close;
index 2c6a9114d332c74a85e2d679b9c2672a7447e188..a8721d71818635a771eeb25d438c6da51943ee3b 100644 (file)
@@ -305,7 +305,7 @@ struct deferred_entry {
 };
 static LIST_HEAD(deferred_list);
 static void gnttab_handle_deferred(unsigned long);
-static DEFINE_TIMER(deferred_timer, gnttab_handle_deferred, 0, 0);
+static DEFINE_TIMER(deferred_timer, gnttab_handle_deferred);
 
 static void gnttab_handle_deferred(unsigned long unused)
 {
index 6d0f14c8609971378ee75104380873a6da67a4be..129f1937fa2c11527633c98a8840c2aae011fa0e 100644 (file)
@@ -618,7 +618,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
        server->tx.creq         = NULL;
        server->rcv.creq        = NULL;
 
-       init_timer(&server->timeout_tm);
+       timer_setup(&server->timeout_tm, ncpdgram_timeout_call, 0);
 #undef NCP_PACKET_SIZE
 #define NCP_PACKET_SIZE 131072
        error = -ENOMEM;
@@ -650,8 +650,6 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
        } else {
                INIT_WORK(&server->rcv.tq, ncpdgram_rcv_proc);
                INIT_WORK(&server->timeout_tq, ncpdgram_timeout_proc);
-               server->timeout_tm.data = (unsigned long)server;
-               server->timeout_tm.function = ncpdgram_timeout_call;
        }
        release_sock(sock->sk);
 
index 89031d7e3ae1966625a8970a9890cfe26dfc481d..f06cde4adf7167a35c30b2c37fad0066b55910e3 100644 (file)
@@ -150,7 +150,7 @@ extern void ncp_tcp_rcv_proc(struct work_struct *work);
 extern void ncp_tcp_tx_proc(struct work_struct *work);
 extern void ncpdgram_rcv_proc(struct work_struct *work);
 extern void ncpdgram_timeout_proc(struct work_struct *work);
-extern void ncpdgram_timeout_call(unsigned long server);
+extern void ncpdgram_timeout_call(struct timer_list *t);
 extern void ncp_tcp_data_ready(struct sock* sk);
 extern void ncp_tcp_write_space(struct sock* sk);
 extern void ncp_tcp_error_report(struct sock* sk);
index 7dd7170d6cdf2904086792650ca258736cfd1db8..efb176b1751a551bd636c58b277370b51cbfa0ca 100644 (file)
@@ -117,10 +117,10 @@ void ncp_tcp_write_space(struct sock *sk)
                schedule_work(&server->tx.tq);
 }
 
-void ncpdgram_timeout_call(unsigned long v)
+void ncpdgram_timeout_call(struct timer_list *t)
 {
-       struct ncp_server *server = (void*)v;
-       
+       struct ncp_server *server = from_timer(server, t, timeout_tm);
+
        schedule_work(&server->timeout_tq);
 }
 
index 2b21d180157c16a823f2f21d41e31d820bf77232..086e491faf04b655e4fdf2903b105a984e788f04 100644 (file)
@@ -62,7 +62,7 @@ MODULE_PARM_DESC(update_ms, "milliseconds before pstore updates its content "
 static int pstore_new_entry;
 
 static void pstore_timefunc(unsigned long);
-static DEFINE_TIMER(pstore_timer, pstore_timefunc, 0, 0);
+static DEFINE_TIMER(pstore_timer, pstore_timefunc);
 
 static void pstore_dowork(struct work_struct *);
 static DECLARE_WORK(pstore_work, pstore_dowork);
@@ -482,10 +482,7 @@ void pstore_record_init(struct pstore_record *record,
        record->psi = psinfo;
 
        /* Report zeroed timestamp if called before timekeeping has resumed. */
-       if (__getnstimeofday(&record->time)) {
-               record->time.tv_sec = 0;
-               record->time.tv_nsec = 0;
-       }
+       record->time = ns_to_timespec(ktime_get_real_fast_ns());
 }
 
 /*
index 70db3af045417d7077fa2aa2fce15990f7b08547..771989d25ef882fd91cec3744e605eea1e96cbd5 100644 (file)
@@ -1212,7 +1212,7 @@ extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout);
 
 extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout);
 
-extern void ide_timer_expiry(unsigned long);
+extern void ide_timer_expiry(struct timer_list *t);
 extern irqreturn_t ide_intr(int irq, void *dev_id);
 extern void do_ide_request(struct request_queue *);
 extern void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq);
index 4e26609c77d4136cd0ecb096ac3616cebf4e0a6e..86d53a3cb497ff0d587952f4b9073da2f71e98a2 100644 (file)
@@ -76,7 +76,7 @@ extern int tsk_fork_get_node(struct task_struct *tsk);
  */
 struct kthread_work;
 typedef void (*kthread_work_func_t)(struct kthread_work *work);
-void kthread_delayed_work_timer_fn(unsigned long __data);
+void kthread_delayed_work_timer_fn(struct timer_list *t);
 
 enum {
        KTW_FREEZABLE           = 1 << 0,       /* freeze during suspend */
@@ -117,8 +117,8 @@ struct kthread_delayed_work {
 
 #define KTHREAD_DELAYED_WORK_INIT(dwork, fn) {                         \
        .work = KTHREAD_WORK_INIT((dwork).work, (fn)),                  \
-       .timer = __TIMER_INITIALIZER(kthread_delayed_work_timer_fn,     \
-                                    0, (unsigned long)&(dwork),        \
+       .timer = __TIMER_INITIALIZER((TIMER_FUNC_TYPE)kthread_delayed_work_timer_fn,\
+                                    (TIMER_DATA_TYPE)&(dwork.timer),   \
                                     TIMER_IRQSAFE),                    \
        }
 
@@ -165,8 +165,8 @@ extern void __kthread_init_worker(struct kthread_worker *worker,
        do {                                                            \
                kthread_init_work(&(dwork)->work, (fn));                \
                __setup_timer(&(dwork)->timer,                          \
-                             kthread_delayed_work_timer_fn,            \
-                             (unsigned long)(dwork),                   \
+                             (TIMER_FUNC_TYPE)kthread_delayed_work_timer_fn,\
+                             (TIMER_DATA_TYPE)&(dwork)->timer,         \
                              TIMER_IRQSAFE);                           \
        } while (0)
 
index 0c8bd45c820615eeaa3d50370f598c7f567ce51d..5b9fddbaac4166b11121f75a3f3b4db7af1aac4c 100644 (file)
@@ -270,5 +270,6 @@ static inline ktime_t ms_to_ktime(u64 ms)
 }
 
 # include <linux/timekeeping.h>
+# include <linux/timekeeping32.h>
 
 #endif
index 58e3c64c6b4926b5f8734db2f2589780e66d3bc4..397607a0c0ebef2969a3c4ea81893be860c8aacc 100644 (file)
@@ -225,6 +225,7 @@ struct parport {
        struct pardevice *waittail;
 
        struct list_head list;
+       struct timer_list timer;
        unsigned int flags;
 
        void *sysctl_table;
index f6d7ee98d93c3afb7c8b205a75361bd101a56600..41319a2e409b459d553cc6add16218eea75c1cca 100644 (file)
@@ -136,6 +136,14 @@ struct rtc_device {
        /* Some hardware can't support UIE mode */
        int uie_unsupported;
 
+       /* Number of nsec it takes to set the RTC clock. This influences when
+        * the set ops are called. An offset:
+        *   - of 0.5 s will call RTC set for wall clock time 10.0 s at 9.5 s
+        *   - of 1.5 s will call RTC set for wall clock time 10.0 s at 8.5 s
+        *   - of -0.5 s will call RTC set for wall clock time 10.0 s at 10.5 s
+        */
+       long set_offset_nsec;
+
        bool registered;
 
        struct nvmem_config *nvmem_config;
@@ -173,7 +181,7 @@ extern void devm_rtc_device_unregister(struct device *dev,
 
 extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm);
 extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm);
-extern int rtc_set_ntp_time(struct timespec64 now);
+extern int rtc_set_ntp_time(struct timespec64 now, unsigned long *target_nsec);
 int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm);
 extern int rtc_read_alarm(struct rtc_device *rtc,
                        struct rtc_wkalrm *alrm);
@@ -222,6 +230,39 @@ static inline bool is_leap_year(unsigned int year)
        return (!(year % 4) && (year % 100)) || !(year % 400);
 }
 
+/* Determine if we can call to driver to set the time. Drivers can only be
+ * called to set a second aligned time value, and the field set_offset_nsec
+ * specifies how far away from the second aligned time to call the driver.
+ *
+ * This also computes 'to_set' which is the time we are trying to set, and has
+ * a zero in tv_nsecs, such that:
+ *    to_set - set_delay_nsec == now +/- FUZZ
+ *
+ */
+static inline bool rtc_tv_nsec_ok(s64 set_offset_nsec,
+                                 struct timespec64 *to_set,
+                                 const struct timespec64 *now)
+{
+       /* Allowed error in tv_nsec, arbitarily set to 5 jiffies in ns. */
+       const unsigned long TIME_SET_NSEC_FUZZ = TICK_NSEC * 5;
+       struct timespec64 delay = {.tv_sec = 0,
+                                  .tv_nsec = set_offset_nsec};
+
+       *to_set = timespec64_add(*now, delay);
+
+       if (to_set->tv_nsec < TIME_SET_NSEC_FUZZ) {
+               to_set->tv_nsec = 0;
+               return true;
+       }
+
+       if (to_set->tv_nsec > NSEC_PER_SEC - TIME_SET_NSEC_FUZZ) {
+               to_set->tv_sec++;
+               to_set->tv_nsec = 0;
+               return true;
+       }
+       return false;
+}
+
 #define rtc_register_device(device) \
        __rtc_register_device(THIS_MODULE, device)
 
index 87c36cf1cec2cada829e3b04c3531b84aff3a423..4b62a2c0a66129c7615fd60e36852be02a642a14 100644 (file)
@@ -18,149 +18,10 @@ int get_itimerspec64(struct itimerspec64 *it,
 int put_itimerspec64(const struct itimerspec64 *it,
                        struct itimerspec __user *uit);
 
-#define TIME_T_MAX     (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)
-
-static inline int timespec_equal(const struct timespec *a,
-                                 const struct timespec *b)
-{
-       return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
-}
-
-/*
- * lhs < rhs:  return <0
- * lhs == rhs: return 0
- * lhs > rhs:  return >0
- */
-static inline int timespec_compare(const struct timespec *lhs, const struct timespec *rhs)
-{
-       if (lhs->tv_sec < rhs->tv_sec)
-               return -1;
-       if (lhs->tv_sec > rhs->tv_sec)
-               return 1;
-       return lhs->tv_nsec - rhs->tv_nsec;
-}
-
-static inline int timeval_compare(const struct timeval *lhs, const struct timeval *rhs)
-{
-       if (lhs->tv_sec < rhs->tv_sec)
-               return -1;
-       if (lhs->tv_sec > rhs->tv_sec)
-               return 1;
-       return lhs->tv_usec - rhs->tv_usec;
-}
-
 extern time64_t mktime64(const unsigned int year, const unsigned int mon,
                        const unsigned int day, const unsigned int hour,
                        const unsigned int min, const unsigned int sec);
 
-/**
- * Deprecated. Use mktime64().
- */
-static inline unsigned long mktime(const unsigned int year,
-                       const unsigned int mon, const unsigned int day,
-                       const unsigned int hour, const unsigned int min,
-                       const unsigned int sec)
-{
-       return mktime64(year, mon, day, hour, min, sec);
-}
-
-extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec);
-
-/*
- * timespec_add_safe assumes both values are positive and checks
- * for overflow. It will return TIME_T_MAX if the reutrn would be
- * smaller then either of the arguments.
- */
-extern struct timespec timespec_add_safe(const struct timespec lhs,
-                                        const struct timespec rhs);
-
-
-static inline struct timespec timespec_add(struct timespec lhs,
-                                               struct timespec rhs)
-{
-       struct timespec ts_delta;
-       set_normalized_timespec(&ts_delta, lhs.tv_sec + rhs.tv_sec,
-                               lhs.tv_nsec + rhs.tv_nsec);
-       return ts_delta;
-}
-
-/*
- * sub = lhs - rhs, in normalized form
- */
-static inline struct timespec timespec_sub(struct timespec lhs,
-                                               struct timespec rhs)
-{
-       struct timespec ts_delta;
-       set_normalized_timespec(&ts_delta, lhs.tv_sec - rhs.tv_sec,
-                               lhs.tv_nsec - rhs.tv_nsec);
-       return ts_delta;
-}
-
-/*
- * Returns true if the timespec is norm, false if denorm:
- */
-static inline bool timespec_valid(const struct timespec *ts)
-{
-       /* Dates before 1970 are bogus */
-       if (ts->tv_sec < 0)
-               return false;
-       /* Can't have more nanoseconds then a second */
-       if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC)
-               return false;
-       return true;
-}
-
-static inline bool timespec_valid_strict(const struct timespec *ts)
-{
-       if (!timespec_valid(ts))
-               return false;
-       /* Disallow values that could overflow ktime_t */
-       if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX)
-               return false;
-       return true;
-}
-
-static inline bool timeval_valid(const struct timeval *tv)
-{
-       /* Dates before 1970 are bogus */
-       if (tv->tv_sec < 0)
-               return false;
-
-       /* Can't have more microseconds then a second */
-       if (tv->tv_usec < 0 || tv->tv_usec >= USEC_PER_SEC)
-               return false;
-
-       return true;
-}
-
-extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
-
-/*
- * Validates if a timespec/timeval used to inject a time offset is valid.
- * Offsets can be postive or negative. The value of the timeval/timespec
- * is the sum of its fields, but *NOTE*: the field tv_usec/tv_nsec must
- * always be non-negative.
- */
-static inline bool timeval_inject_offset_valid(const struct timeval *tv)
-{
-       /* We don't check the tv_sec as it can be positive or negative */
-
-       /* Can't have more microseconds then a second */
-       if (tv->tv_usec < 0 || tv->tv_usec >= USEC_PER_SEC)
-               return false;
-       return true;
-}
-
-static inline bool timespec_inject_offset_valid(const struct timespec *ts)
-{
-       /* We don't check the tv_sec as it can be positive or negative */
-
-       /* Can't have more nanoseconds then a second */
-       if (ts->tv_nsec < 0 || ts->tv_nsec >= NSEC_PER_SEC)
-               return false;
-       return true;
-}
-
 /* Some architectures do not supply their own clocksource.
  * This is mainly the case in architectures that get their
  * inter-tick times by reading the counter on their interval
@@ -209,73 +70,7 @@ struct tm {
 
 void time64_to_tm(time64_t totalsecs, int offset, struct tm *result);
 
-/**
- * time_to_tm - converts the calendar time to local broken-down time
- *
- * @totalsecs  the number of seconds elapsed since 00:00:00 on January 1, 1970,
- *             Coordinated Universal Time (UTC).
- * @offset     offset seconds adding to totalsecs.
- * @result     pointer to struct tm variable to receive broken-down time
- */
-static inline void time_to_tm(time_t totalsecs, int offset, struct tm *result)
-{
-       time64_to_tm(totalsecs, offset, result);
-}
-
-/**
- * timespec_to_ns - Convert timespec to nanoseconds
- * @ts:                pointer to the timespec variable to be converted
- *
- * Returns the scalar nanosecond representation of the timespec
- * parameter.
- */
-static inline s64 timespec_to_ns(const struct timespec *ts)
-{
-       return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec;
-}
-
-/**
- * timeval_to_ns - Convert timeval to nanoseconds
- * @ts:                pointer to the timeval variable to be converted
- *
- * Returns the scalar nanosecond representation of the timeval
- * parameter.
- */
-static inline s64 timeval_to_ns(const struct timeval *tv)
-{
-       return ((s64) tv->tv_sec * NSEC_PER_SEC) +
-               tv->tv_usec * NSEC_PER_USEC;
-}
-
-/**
- * ns_to_timespec - Convert nanoseconds to timespec
- * @nsec:      the nanoseconds value to be converted
- *
- * Returns the timespec representation of the nsec parameter.
- */
-extern struct timespec ns_to_timespec(const s64 nsec);
-
-/**
- * ns_to_timeval - Convert nanoseconds to timeval
- * @nsec:      the nanoseconds value to be converted
- *
- * Returns the timeval representation of the nsec parameter.
- */
-extern struct timeval ns_to_timeval(const s64 nsec);
-
-/**
- * timespec_add_ns - Adds nanoseconds to a timespec
- * @a:         pointer to timespec to be incremented
- * @ns:                unsigned nanoseconds value to be added
- *
- * This must always be inlined because its used from the x86-64 vdso,
- * which cannot call other kernel functions.
- */
-static __always_inline void timespec_add_ns(struct timespec *a, u64 ns)
-{
-       a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
-       a->tv_nsec = ns;
-}
+# include <linux/time32.h>
 
 static inline bool itimerspec64_valid(const struct itimerspec64 *its)
 {
diff --git a/include/linux/time32.h b/include/linux/time32.h
new file mode 100644 (file)
index 0000000..65b1de2
--- /dev/null
@@ -0,0 +1,221 @@
+#ifndef _LINUX_TIME32_H
+#define _LINUX_TIME32_H
+/*
+ * These are all interfaces based on the old time_t definition
+ * that overflows in 2038 on 32-bit architectures. New code
+ * should use the replacements based on time64_t and timespec64.
+ *
+ * Any interfaces in here that become unused as we migrate
+ * code to time64_t should get removed.
+ */
+
+#include <linux/time64.h>
+
+#define TIME_T_MAX     (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)
+
+#if __BITS_PER_LONG == 64
+
+/* timespec64 is defined as timespec here */
+static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64)
+{
+       return ts64;
+}
+
+static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
+{
+       return ts;
+}
+
+# define timespec_equal                        timespec64_equal
+# define timespec_compare              timespec64_compare
+# define set_normalized_timespec       set_normalized_timespec64
+# define timespec_add                  timespec64_add
+# define timespec_sub                  timespec64_sub
+# define timespec_valid                        timespec64_valid
+# define timespec_valid_strict         timespec64_valid_strict
+# define timespec_to_ns                        timespec64_to_ns
+# define ns_to_timespec                        ns_to_timespec64
+# define timespec_add_ns               timespec64_add_ns
+
+#else
+static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64)
+{
+       struct timespec ret;
+
+       ret.tv_sec = (time_t)ts64.tv_sec;
+       ret.tv_nsec = ts64.tv_nsec;
+       return ret;
+}
+
+static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
+{
+       struct timespec64 ret;
+
+       ret.tv_sec = ts.tv_sec;
+       ret.tv_nsec = ts.tv_nsec;
+       return ret;
+}
+
+static inline int timespec_equal(const struct timespec *a,
+                                const struct timespec *b)
+{
+       return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
+}
+
+/*
+ * lhs < rhs:  return <0
+ * lhs == rhs: return 0
+ * lhs > rhs:  return >0
+ */
+static inline int timespec_compare(const struct timespec *lhs, const struct timespec *rhs)
+{
+       if (lhs->tv_sec < rhs->tv_sec)
+               return -1;
+       if (lhs->tv_sec > rhs->tv_sec)
+               return 1;
+       return lhs->tv_nsec - rhs->tv_nsec;
+}
+
+extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec);
+
+static inline struct timespec timespec_add(struct timespec lhs,
+                                               struct timespec rhs)
+{
+       struct timespec ts_delta;
+
+       set_normalized_timespec(&ts_delta, lhs.tv_sec + rhs.tv_sec,
+                               lhs.tv_nsec + rhs.tv_nsec);
+       return ts_delta;
+}
+
+/*
+ * sub = lhs - rhs, in normalized form
+ */
+static inline struct timespec timespec_sub(struct timespec lhs,
+                                               struct timespec rhs)
+{
+       struct timespec ts_delta;
+
+       set_normalized_timespec(&ts_delta, lhs.tv_sec - rhs.tv_sec,
+                               lhs.tv_nsec - rhs.tv_nsec);
+       return ts_delta;
+}
+
+/*
+ * Returns true if the timespec is norm, false if denorm:
+ */
+static inline bool timespec_valid(const struct timespec *ts)
+{
+       /* Dates before 1970 are bogus */
+       if (ts->tv_sec < 0)
+               return false;
+       /* Can't have more nanoseconds then a second */
+       if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC)
+               return false;
+       return true;
+}
+
+static inline bool timespec_valid_strict(const struct timespec *ts)
+{
+       if (!timespec_valid(ts))
+               return false;
+       /* Disallow values that could overflow ktime_t */
+       if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX)
+               return false;
+       return true;
+}
+
+/**
+ * timespec_to_ns - Convert timespec to nanoseconds
+ * @ts:                pointer to the timespec variable to be converted
+ *
+ * Returns the scalar nanosecond representation of the timespec
+ * parameter.
+ */
+static inline s64 timespec_to_ns(const struct timespec *ts)
+{
+       return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec;
+}
+
+/**
+ * ns_to_timespec - Convert nanoseconds to timespec
+ * @nsec:      the nanoseconds value to be converted
+ *
+ * Returns the timespec representation of the nsec parameter.
+ */
+extern struct timespec ns_to_timespec(const s64 nsec);
+
+/**
+ * timespec_add_ns - Adds nanoseconds to a timespec
+ * @a:         pointer to timespec to be incremented
+ * @ns:                unsigned nanoseconds value to be added
+ *
+ * This must always be inlined because its used from the x86-64 vdso,
+ * which cannot call other kernel functions.
+ */
+static __always_inline void timespec_add_ns(struct timespec *a, u64 ns)
+{
+       a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
+       a->tv_nsec = ns;
+}
+
+#endif
+
+/**
+ * time_to_tm - converts the calendar time to local broken-down time
+ *
+ * @totalsecs  the number of seconds elapsed since 00:00:00 on January 1, 1970,
+ *             Coordinated Universal Time (UTC).
+ * @offset     offset seconds adding to totalsecs.
+ * @result     pointer to struct tm variable to receive broken-down time
+ */
+static inline void time_to_tm(time_t totalsecs, int offset, struct tm *result)
+{
+       time64_to_tm(totalsecs, offset, result);
+}
+
+static inline unsigned long mktime(const unsigned int year,
+                       const unsigned int mon, const unsigned int day,
+                       const unsigned int hour, const unsigned int min,
+                       const unsigned int sec)
+{
+       return mktime64(year, mon, day, hour, min, sec);
+}
+
+static inline bool timeval_valid(const struct timeval *tv)
+{
+       /* Dates before 1970 are bogus */
+       if (tv->tv_sec < 0)
+               return false;
+
+       /* Can't have more microseconds then a second */
+       if (tv->tv_usec < 0 || tv->tv_usec >= USEC_PER_SEC)
+               return false;
+
+       return true;
+}
+
+extern struct timespec timespec_trunc(struct timespec t, unsigned int gran);
+
+/**
+ * timeval_to_ns - Convert timeval to nanoseconds
+ * @ts:                pointer to the timeval variable to be converted
+ *
+ * Returns the scalar nanosecond representation of the timeval
+ * parameter.
+ */
+static inline s64 timeval_to_ns(const struct timeval *tv)
+{
+       return ((s64) tv->tv_sec * NSEC_PER_SEC) +
+               tv->tv_usec * NSEC_PER_USEC;
+}
+
+/**
+ * ns_to_timeval - Convert nanoseconds to timeval
+ * @nsec:      the nanoseconds value to be converted
+ *
+ * Returns the timeval representation of the nsec parameter.
+ */
+extern struct timeval ns_to_timeval(const s64 nsec);
+
+#endif
index ad33260618f766e8c2814530dc177961c8be485e..93d39499838e06d168dbcefb970d23b047a288ad 100644 (file)
@@ -8,11 +8,8 @@
 typedef __s64 time64_t;
 typedef __u64 timeu64_t;
 
-/*
- * This wants to go into uapi/linux/time.h once we agreed about the
- * userspace interfaces.
- */
 #if __BITS_PER_LONG == 64
+/* this trick allows us to optimize out timespec64_to_timespec */
 # define timespec64 timespec
 #define itimerspec64 itimerspec
 #else
@@ -42,77 +39,6 @@ struct itimerspec64 {
 #define KTIME_MAX                      ((s64)~((u64)1 << 63))
 #define KTIME_SEC_MAX                  (KTIME_MAX / NSEC_PER_SEC)
 
-#if __BITS_PER_LONG == 64
-
-static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64)
-{
-       return ts64;
-}
-
-static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
-{
-       return ts;
-}
-
-static inline struct itimerspec itimerspec64_to_itimerspec(struct itimerspec64 *its64)
-{
-       return *its64;
-}
-
-static inline struct itimerspec64 itimerspec_to_itimerspec64(struct itimerspec *its)
-{
-       return *its;
-}
-
-# define timespec64_equal              timespec_equal
-# define timespec64_compare            timespec_compare
-# define set_normalized_timespec64     set_normalized_timespec
-# define timespec64_add                        timespec_add
-# define timespec64_sub                        timespec_sub
-# define timespec64_valid              timespec_valid
-# define timespec64_valid_strict       timespec_valid_strict
-# define timespec64_to_ns              timespec_to_ns
-# define ns_to_timespec64              ns_to_timespec
-# define timespec64_add_ns             timespec_add_ns
-
-#else
-
-static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64)
-{
-       struct timespec ret;
-
-       ret.tv_sec = (time_t)ts64.tv_sec;
-       ret.tv_nsec = ts64.tv_nsec;
-       return ret;
-}
-
-static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
-{
-       struct timespec64 ret;
-
-       ret.tv_sec = ts.tv_sec;
-       ret.tv_nsec = ts.tv_nsec;
-       return ret;
-}
-
-static inline struct itimerspec itimerspec64_to_itimerspec(struct itimerspec64 *its64)
-{
-       struct itimerspec ret;
-
-       ret.it_interval = timespec64_to_timespec(its64->it_interval);
-       ret.it_value = timespec64_to_timespec(its64->it_value);
-       return ret;
-}
-
-static inline struct itimerspec64 itimerspec_to_itimerspec64(struct itimerspec *its)
-{
-       struct itimerspec64 ret;
-
-       ret.it_interval = timespec_to_timespec64(its->it_interval);
-       ret.it_value = timespec_to_timespec64(its->it_value);
-       return ret;
-}
-
 static inline int timespec64_equal(const struct timespec64 *a,
                                   const struct timespec64 *b)
 {
@@ -214,8 +140,6 @@ static __always_inline void timespec64_add_ns(struct timespec64 *a, u64 ns)
        a->tv_nsec = ns;
 }
 
-#endif
-
 /*
  * timespec64_add_safe assumes both values are positive and checks for
  * overflow. It will return TIME64_MAX in case of overflow.
index 97154c61e5d2b3dc9e59f37abb187652f10bb8f7..7e9011101cb08f674a5c2ba698be5f67367a464c 100644 (file)
 /**
  * struct tk_read_base - base structure for timekeeping readout
  * @clock:     Current clocksource used for timekeeping.
- * @read:      Read function of @clock
  * @mask:      Bitmask for two's complement subtraction of non 64bit clocks
  * @cycle_last: @clock cycle value at last update
  * @mult:      (NTP adjusted) multiplier for scaled math conversion
  * @shift:     Shift value for scaled math conversion
  * @xtime_nsec: Shifted (fractional) nano seconds offset for readout
  * @base:      ktime_t (nanoseconds) base time for readout
+ * @base_real: Nanoseconds base value for clock REALTIME readout
  *
  * This struct has size 56 byte on 64 bit. Together with a seqcount it
  * occupies a single 64byte cache line.
  *
  * The struct is separate from struct timekeeper as it is also used
  * for a fast NMI safe accessors.
+ *
+ * @base_real is for the fast NMI safe accessor to allow reading clock
+ * realtime from any context.
  */
 struct tk_read_base {
        struct clocksource      *clock;
@@ -36,6 +39,7 @@ struct tk_read_base {
        u32                     shift;
        u64                     xtime_nsec;
        ktime_t                 base;
+       u64                     base_real;
 };
 
 /**
index 0021575fe871133da5d67e2a5f09c85d0196fccd..c198ab40c04fb37174e7dbd683abe82715dcfb16 100644 (file)
@@ -16,27 +16,16 @@ extern void xtime_update(unsigned long ticks);
 /*
  * Get and set timeofday
  */
-extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday64(const struct timespec64 *ts);
 extern int do_sys_settimeofday64(const struct timespec64 *tv,
                                 const struct timezone *tz);
 /*
  * Kernel time accessors
  */
-unsigned long get_seconds(void);
 struct timespec64 current_kernel_time64(void);
-/* does not take xtime_lock */
-struct timespec __current_kernel_time(void);
-
-static inline struct timespec current_kernel_time(void)
-{
-       struct timespec64 now = current_kernel_time64();
-
-       return timespec64_to_timespec(now);
-}
 
 /*
- * timespec based interfaces
+ * timespec64 based interfaces
  */
 struct timespec64 get_monotonic_coarse64(void);
 extern void getrawmonotonic64(struct timespec64 *ts);
@@ -48,116 +37,6 @@ extern int __getnstimeofday64(struct timespec64 *tv);
 extern void getnstimeofday64(struct timespec64 *tv);
 extern void getboottime64(struct timespec64 *ts);
 
-#if BITS_PER_LONG == 64
-/**
- * Deprecated. Use do_settimeofday64().
- */
-static inline int do_settimeofday(const struct timespec *ts)
-{
-       return do_settimeofday64(ts);
-}
-
-static inline int __getnstimeofday(struct timespec *ts)
-{
-       return __getnstimeofday64(ts);
-}
-
-static inline void getnstimeofday(struct timespec *ts)
-{
-       getnstimeofday64(ts);
-}
-
-static inline void ktime_get_ts(struct timespec *ts)
-{
-       ktime_get_ts64(ts);
-}
-
-static inline void ktime_get_real_ts(struct timespec *ts)
-{
-       getnstimeofday64(ts);
-}
-
-static inline void getrawmonotonic(struct timespec *ts)
-{
-       getrawmonotonic64(ts);
-}
-
-static inline struct timespec get_monotonic_coarse(void)
-{
-       return get_monotonic_coarse64();
-}
-
-static inline void getboottime(struct timespec *ts)
-{
-       return getboottime64(ts);
-}
-#else
-/**
- * Deprecated. Use do_settimeofday64().
- */
-static inline int do_settimeofday(const struct timespec *ts)
-{
-       struct timespec64 ts64;
-
-       ts64 = timespec_to_timespec64(*ts);
-       return do_settimeofday64(&ts64);
-}
-
-static inline int __getnstimeofday(struct timespec *ts)
-{
-       struct timespec64 ts64;
-       int ret = __getnstimeofday64(&ts64);
-
-       *ts = timespec64_to_timespec(ts64);
-       return ret;
-}
-
-static inline void getnstimeofday(struct timespec *ts)
-{
-       struct timespec64 ts64;
-
-       getnstimeofday64(&ts64);
-       *ts = timespec64_to_timespec(ts64);
-}
-
-static inline void ktime_get_ts(struct timespec *ts)
-{
-       struct timespec64 ts64;
-
-       ktime_get_ts64(&ts64);
-       *ts = timespec64_to_timespec(ts64);
-}
-
-static inline void ktime_get_real_ts(struct timespec *ts)
-{
-       struct timespec64 ts64;
-
-       getnstimeofday64(&ts64);
-       *ts = timespec64_to_timespec(ts64);
-}
-
-static inline void getrawmonotonic(struct timespec *ts)
-{
-       struct timespec64 ts64;
-
-       getrawmonotonic64(&ts64);
-       *ts = timespec64_to_timespec(ts64);
-}
-
-static inline struct timespec get_monotonic_coarse(void)
-{
-       return timespec64_to_timespec(get_monotonic_coarse64());
-}
-
-static inline void getboottime(struct timespec *ts)
-{
-       struct timespec64 ts64;
-
-       getboottime64(&ts64);
-       *ts = timespec64_to_timespec(ts64);
-}
-#endif
-
 #define ktime_get_real_ts64(ts)        getnstimeofday64(ts)
 
 /*
@@ -240,25 +119,16 @@ static inline u64 ktime_get_raw_ns(void)
 extern u64 ktime_get_mono_fast_ns(void);
 extern u64 ktime_get_raw_fast_ns(void);
 extern u64 ktime_get_boot_fast_ns(void);
+extern u64 ktime_get_real_fast_ns(void);
 
 /*
- * Timespec interfaces utilizing the ktime based ones
+ * timespec64 interfaces utilizing the ktime based ones
  */
-static inline void get_monotonic_boottime(struct timespec *ts)
-{
-       *ts = ktime_to_timespec(ktime_get_boottime());
-}
-
 static inline void get_monotonic_boottime64(struct timespec64 *ts)
 {
        *ts = ktime_to_timespec64(ktime_get_boottime());
 }
 
-static inline void timekeeping_clocktai(struct timespec *ts)
-{
-       *ts = ktime_to_timespec(ktime_get_clocktai());
-}
-
 static inline void timekeeping_clocktai64(struct timespec64 *ts)
 {
        *ts = ktime_to_timespec64(ktime_get_clocktai());
@@ -341,10 +211,8 @@ extern void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot);
  */
 extern int persistent_clock_is_local;
 
-extern void read_persistent_clock(struct timespec *ts);
 extern void read_persistent_clock64(struct timespec64 *ts);
 extern void read_boot_clock64(struct timespec64 *ts);
-extern int update_persistent_clock(struct timespec now);
 extern int update_persistent_clock64(struct timespec64 now);
 
 
diff --git a/include/linux/timekeeping32.h b/include/linux/timekeeping32.h
new file mode 100644 (file)
index 0000000..af4114d
--- /dev/null
@@ -0,0 +1,151 @@
+#ifndef _LINUX_TIMEKEEPING32_H
+#define _LINUX_TIMEKEEPING32_H
+/*
+ * These interfaces are all based on the old timespec type
+ * and should get replaced with the timespec64 based versions
+ * over time so we can remove the file here.
+ */
+
+extern void do_gettimeofday(struct timeval *tv);
+unsigned long get_seconds(void);
+
+/* does not take xtime_lock */
+struct timespec __current_kernel_time(void);
+
+static inline struct timespec current_kernel_time(void)
+{
+       struct timespec64 now = current_kernel_time64();
+
+       return timespec64_to_timespec(now);
+}
+
+#if BITS_PER_LONG == 64
+/**
+ * Deprecated. Use do_settimeofday64().
+ */
+static inline int do_settimeofday(const struct timespec *ts)
+{
+       return do_settimeofday64(ts);
+}
+
+static inline int __getnstimeofday(struct timespec *ts)
+{
+       return __getnstimeofday64(ts);
+}
+
+static inline void getnstimeofday(struct timespec *ts)
+{
+       getnstimeofday64(ts);
+}
+
+static inline void ktime_get_ts(struct timespec *ts)
+{
+       ktime_get_ts64(ts);
+}
+
+static inline void ktime_get_real_ts(struct timespec *ts)
+{
+       getnstimeofday64(ts);
+}
+
+static inline void getrawmonotonic(struct timespec *ts)
+{
+       getrawmonotonic64(ts);
+}
+
+static inline struct timespec get_monotonic_coarse(void)
+{
+       return get_monotonic_coarse64();
+}
+
+static inline void getboottime(struct timespec *ts)
+{
+       return getboottime64(ts);
+}
+#else
+/**
+ * Deprecated. Use do_settimeofday64().
+ */
+static inline int do_settimeofday(const struct timespec *ts)
+{
+       struct timespec64 ts64;
+
+       ts64 = timespec_to_timespec64(*ts);
+       return do_settimeofday64(&ts64);
+}
+
+static inline int __getnstimeofday(struct timespec *ts)
+{
+       struct timespec64 ts64;
+       int ret = __getnstimeofday64(&ts64);
+
+       *ts = timespec64_to_timespec(ts64);
+       return ret;
+}
+
+static inline void getnstimeofday(struct timespec *ts)
+{
+       struct timespec64 ts64;
+
+       getnstimeofday64(&ts64);
+       *ts = timespec64_to_timespec(ts64);
+}
+
+static inline void ktime_get_ts(struct timespec *ts)
+{
+       struct timespec64 ts64;
+
+       ktime_get_ts64(&ts64);
+       *ts = timespec64_to_timespec(ts64);
+}
+
+static inline void ktime_get_real_ts(struct timespec *ts)
+{
+       struct timespec64 ts64;
+
+       getnstimeofday64(&ts64);
+       *ts = timespec64_to_timespec(ts64);
+}
+
+static inline void getrawmonotonic(struct timespec *ts)
+{
+       struct timespec64 ts64;
+
+       getrawmonotonic64(&ts64);
+       *ts = timespec64_to_timespec(ts64);
+}
+
+static inline struct timespec get_monotonic_coarse(void)
+{
+       return timespec64_to_timespec(get_monotonic_coarse64());
+}
+
+static inline void getboottime(struct timespec *ts)
+{
+       struct timespec64 ts64;
+
+       getboottime64(&ts64);
+       *ts = timespec64_to_timespec(ts64);
+}
+#endif
+
+/*
+ * Timespec interfaces utilizing the ktime based ones
+ */
+static inline void get_monotonic_boottime(struct timespec *ts)
+{
+       *ts = ktime_to_timespec(ktime_get_boottime());
+}
+
+static inline void timekeeping_clocktai(struct timespec *ts)
+{
+       *ts = ktime_to_timespec(ktime_get_clocktai());
+}
+
+/*
+ * Persistent clock related interfaces
+ */
+extern void read_persistent_clock(struct timespec *ts);
+extern int update_persistent_clock(struct timespec now);
+
+#endif
index ac66f29c69169a24d010df022750b488878a85e0..bf781acfc6d820f555eefed29dbcdc7c8c4f7033 100644 (file)
@@ -64,31 +64,21 @@ struct timer_list {
 
 #define TIMER_TRACE_FLAGMASK   (TIMER_MIGRATING | TIMER_DEFERRABLE | TIMER_PINNED | TIMER_IRQSAFE)
 
-#define __TIMER_INITIALIZER(_function, _expires, _data, _flags) { \
+#define TIMER_DATA_TYPE                unsigned long
+#define TIMER_FUNC_TYPE                void (*)(TIMER_DATA_TYPE)
+
+#define __TIMER_INITIALIZER(_function, _data, _flags) {                \
                .entry = { .next = TIMER_ENTRY_STATIC },        \
                .function = (_function),                        \
-               .expires = (_expires),                          \
                .data = (_data),                                \
                .flags = (_flags),                              \
                __TIMER_LOCKDEP_MAP_INITIALIZER(                \
                        __FILE__ ":" __stringify(__LINE__))     \
        }
 
-#define TIMER_INITIALIZER(_function, _expires, _data)          \
-       __TIMER_INITIALIZER((_function), (_expires), (_data), 0)
-
-#define TIMER_PINNED_INITIALIZER(_function, _expires, _data)   \
-       __TIMER_INITIALIZER((_function), (_expires), (_data), TIMER_PINNED)
-
-#define TIMER_DEFERRED_INITIALIZER(_function, _expires, _data) \
-       __TIMER_INITIALIZER((_function), (_expires), (_data), TIMER_DEFERRABLE)
-
-#define TIMER_PINNED_DEFERRED_INITIALIZER(_function, _expires, _data)  \
-       __TIMER_INITIALIZER((_function), (_expires), (_data), TIMER_DEFERRABLE | TIMER_PINNED)
-
-#define DEFINE_TIMER(_name, _function, _expires, _data)                \
+#define DEFINE_TIMER(_name, _function)                         \
        struct timer_list _name =                               \
-               TIMER_INITIALIZER(_function, _expires, _data)
+               __TIMER_INITIALIZER((TIMER_FUNC_TYPE)_function, 0, 0)
 
 void init_timer_key(struct timer_list *timer, unsigned int flags,
                    const char *name, struct lock_class_key *key);
@@ -129,14 +119,6 @@ static inline void init_timer_on_stack_key(struct timer_list *timer,
 
 #define init_timer(timer)                                              \
        __init_timer((timer), 0)
-#define init_timer_pinned(timer)                                       \
-       __init_timer((timer), TIMER_PINNED)
-#define init_timer_deferrable(timer)                                   \
-       __init_timer((timer), TIMER_DEFERRABLE)
-#define init_timer_pinned_deferrable(timer)                            \
-       __init_timer((timer), TIMER_DEFERRABLE | TIMER_PINNED)
-#define init_timer_on_stack(timer)                                     \
-       __init_timer_on_stack((timer), 0)
 
 #define __setup_timer(_timer, _fn, _data, _flags)                      \
        do {                                                            \
@@ -169,9 +151,7 @@ static inline void init_timer_on_stack_key(struct timer_list *timer,
 #define setup_pinned_deferrable_timer_on_stack(timer, fn, data)                \
        __setup_timer_on_stack((timer), (fn), (data), TIMER_DEFERRABLE | TIMER_PINNED)
 
-#define TIMER_DATA_TYPE                unsigned long
-#define TIMER_FUNC_TYPE                void (*)(TIMER_DATA_TYPE)
-
+#ifndef CONFIG_LOCKDEP
 static inline void timer_setup(struct timer_list *timer,
                               void (*callback)(struct timer_list *),
                               unsigned int flags)
@@ -180,6 +160,28 @@ static inline void timer_setup(struct timer_list *timer,
                      (TIMER_DATA_TYPE)timer, flags);
 }
 
+static inline void timer_setup_on_stack(struct timer_list *timer,
+                              void (*callback)(struct timer_list *),
+                              unsigned int flags)
+{
+       __setup_timer_on_stack(timer, (TIMER_FUNC_TYPE)callback,
+                              (TIMER_DATA_TYPE)timer, flags);
+}
+#else
+/*
+ * Under LOCKDEP, the timer lock_class_key (set up in __init_timer) needs
+ * to be tied to the caller's context, so an inline (above) won't work. We
+ * do want to keep the inline for argument type checking, though.
+ */
+# define timer_setup(timer, callback, flags)                           \
+               __setup_timer((timer), (TIMER_FUNC_TYPE)(callback),     \
+                             (TIMER_DATA_TYPE)(timer), (flags))
+# define timer_setup_on_stack(timer, callback, flags)                  \
+               __setup_timer_on_stack((timer),                         \
+                                      (TIMER_FUNC_TYPE)(callback),     \
+                                      (TIMER_DATA_TYPE)(timer), (flags))
+#endif
+
 #define from_timer(var, callback_timer, timer_fieldname) \
        container_of(callback_timer, typeof(*var), timer_fieldname)
 
@@ -202,6 +204,7 @@ extern void add_timer_on(struct timer_list *timer, int cpu);
 extern int del_timer(struct timer_list * timer);
 extern int mod_timer(struct timer_list *timer, unsigned long expires);
 extern int mod_timer_pending(struct timer_list *timer, unsigned long expires);
+extern int timer_reduce(struct timer_list *timer, unsigned long expires);
 
 /*
  * The jiffies value which is added to now, when there is no timer
index 0eae11fc7a23fee792e13b4b16e0bf110d491cd5..31fef0db46d4512ce985bba9986b95653cab1424 100644 (file)
@@ -18,7 +18,7 @@ struct workqueue_struct;
 
 struct work_struct;
 typedef void (*work_func_t)(struct work_struct *work);
-void delayed_work_timer_fn(unsigned long __data);
+void delayed_work_timer_fn(struct timer_list *t);
 
 /*
  * The first word is the work queue pointer and the flags rolled into
@@ -176,8 +176,8 @@ struct execute_work {
 
 #define __DELAYED_WORK_INITIALIZER(n, f, tflags) {                     \
        .work = __WORK_INITIALIZER((n).work, (f)),                      \
-       .timer = __TIMER_INITIALIZER(delayed_work_timer_fn,             \
-                                    0, (unsigned long)&(n),            \
+       .timer = __TIMER_INITIALIZER((TIMER_FUNC_TYPE)delayed_work_timer_fn,\
+                                    (TIMER_DATA_TYPE)&(n.timer),       \
                                     (tflags) | TIMER_IRQSAFE),         \
        }
 
@@ -242,8 +242,9 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
 #define __INIT_DELAYED_WORK(_work, _func, _tflags)                     \
        do {                                                            \
                INIT_WORK(&(_work)->work, (_func));                     \
-               __setup_timer(&(_work)->timer, delayed_work_timer_fn,   \
-                             (unsigned long)(_work),                   \
+               __setup_timer(&(_work)->timer,                          \
+                             (TIMER_FUNC_TYPE)delayed_work_timer_fn,   \
+                             (TIMER_DATA_TYPE)&(_work)->timer,         \
                              (_tflags) | TIMER_IRQSAFE);               \
        } while (0)
 
@@ -251,8 +252,8 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
        do {                                                            \
                INIT_WORK_ONSTACK(&(_work)->work, (_func));             \
                __setup_timer_on_stack(&(_work)->timer,                 \
-                                      delayed_work_timer_fn,           \
-                                      (unsigned long)(_work),          \
+                                      (TIMER_FUNC_TYPE)delayed_work_timer_fn,\
+                                      (TIMER_DATA_TYPE)&(_work)->timer,\
                                       (_tflags) | TIMER_IRQSAFE);      \
        } while (0)
 
index 722d3264d3bf92b42077eafc25aeff6477df12a5..cb8a273732cf667d47a7f43e5770ada588ce9ab7 100644 (file)
@@ -382,7 +382,7 @@ static inline struct net_device *fcoe_get_netdev(const struct fc_lport *lport)
 
 void fcoe_clean_pending_queue(struct fc_lport *);
 void fcoe_check_wait_queue(struct fc_lport *lport, struct sk_buff *skb);
-void fcoe_queue_timer(ulong lport);
+void fcoe_queue_timer(struct timer_list *t);
 int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen,
                           struct fcoe_percpu_s *fps);
 
index 6c0dc6155ee757b5e066b075316dc899f6dddddc..388aaf72b48023506e5037f52fcfea915ff03de9 100644 (file)
@@ -629,6 +629,7 @@ struct sas_task_slow {
         */
        struct timer_list     timer;
        struct completion     completion;
+       struct sas_task       *task;
 };
 
 #define SAS_TASK_STATE_PENDING      1
index 987d7bca4864ffda66e6fa64d3213aed2082383e..1215229d1c1281b2363092b86d9246336ee636e0 100644 (file)
@@ -21,7 +21,7 @@ static int irqfixup __read_mostly;
 
 #define POLL_SPURIOUS_IRQ_INTERVAL (HZ/10)
 static void poll_spurious_irqs(unsigned long dummy);
-static DEFINE_TIMER(poll_spurious_irq_timer, poll_spurious_irqs, 0, 0);
+static DEFINE_TIMER(poll_spurious_irq_timer, poll_spurious_irqs);
 static int irq_poll_cpu;
 static atomic_t irq_poll_active;
 
index 1c19edf824272db47a48730478af5f3b582bbf67..ba3992c8c3753bcc0785ecf998e457d21c013873 100644 (file)
@@ -798,15 +798,14 @@ EXPORT_SYMBOL_GPL(kthread_queue_work);
 /**
  * kthread_delayed_work_timer_fn - callback that queues the associated kthread
  *     delayed work when the timer expires.
- * @__data: pointer to the data associated with the timer
+ * @t: pointer to the expired timer
  *
  * The format of the function is defined by struct timer_list.
  * It should have been called from irqsafe timer with irq already off.
  */
-void kthread_delayed_work_timer_fn(unsigned long __data)
+void kthread_delayed_work_timer_fn(struct timer_list *t)
 {
-       struct kthread_delayed_work *dwork =
-               (struct kthread_delayed_work *)__data;
+       struct kthread_delayed_work *dwork = from_timer(dwork, t, timer);
        struct kthread_work *work = &dwork->work;
        struct kthread_worker *worker = work->worker;
 
@@ -837,8 +836,7 @@ void __kthread_queue_delayed_work(struct kthread_worker *worker,
        struct timer_list *timer = &dwork->timer;
        struct kthread_work *work = &dwork->work;
 
-       WARN_ON_ONCE(timer->function != kthread_delayed_work_timer_fn ||
-                    timer->data != (unsigned long)dwork);
+       WARN_ON_ONCE(timer->function != (TIMER_FUNC_TYPE)kthread_delayed_work_timer_fn);
 
        /*
         * If @delay is 0, queue @dwork->work immediately.  This is for
index 45f2ffbc1e78ed587d26d6764cb8d1aba0f6f2d8..96a3cdaeed9155df0c9dff341ca090acd9dfdf6c 100644 (file)
@@ -1076,7 +1076,7 @@ static void rcu_torture_timer_cb(struct rcu_head *rhp)
  * counter in the element should never be greater than 1, otherwise, the
  * RCU implementation is broken.
  */
-static void rcu_torture_timer(unsigned long unused)
+static void rcu_torture_timer(struct timer_list *unused)
 {
        int idx;
        unsigned long started;
@@ -1163,7 +1163,7 @@ rcu_torture_reader(void *arg)
        VERBOSE_TOROUT_STRING("rcu_torture_reader task started");
        set_user_nice(current, MAX_NICE);
        if (irqreader && cur_ops->irq_capable)
-               setup_timer_on_stack(&t, rcu_torture_timer, 0);
+               timer_setup_on_stack(&t, rcu_torture_timer, 0);
 
        do {
                if (irqreader && cur_ops->irq_capable) {
index e012b9be777e3ba00ccf2fe4d05df78b78abd8f5..e85946d9843b7feee47c5d2dcb89ef9da2499b1c 100644 (file)
@@ -2261,9 +2261,11 @@ static void do_nocb_deferred_wakeup_common(struct rcu_data *rdp)
 }
 
 /* Do a deferred wakeup of rcu_nocb_kthread() from a timer handler. */
-static void do_nocb_deferred_wakeup_timer(unsigned long x)
+static void do_nocb_deferred_wakeup_timer(struct timer_list *t)
 {
-       do_nocb_deferred_wakeup_common((struct rcu_data *)x);
+       struct rcu_data *rdp = from_timer(rdp, t, nocb_timer);
+
+       do_nocb_deferred_wakeup_common(rdp);
 }
 
 /*
@@ -2327,8 +2329,7 @@ static void __init rcu_boot_init_nocb_percpu_data(struct rcu_data *rdp)
        init_swait_queue_head(&rdp->nocb_wq);
        rdp->nocb_follower_tail = &rdp->nocb_follower_head;
        raw_spin_lock_init(&rdp->nocb_lock);
-       setup_timer(&rdp->nocb_timer, do_nocb_deferred_wakeup_timer,
-                   (unsigned long)rdp);
+       timer_setup(&rdp->nocb_timer, do_nocb_deferred_wakeup_timer, 0);
 }
 
 /*
index ac09bc29eb08216a8588710d08515705a749fb19..d689a9557e170b9d89ddb7cb42e518a82d5851cb 100644 (file)
@@ -56,7 +56,7 @@ menu "Timers subsystem"
 
 # Core internal switch. Selected by NO_HZ_COMMON / HIGH_RES_TIMERS. This is
 # only related to the tick functionality. Oneshot clockevent devices
-# are supported independ of this.
+# are supported independent of this.
 config TICK_ONESHOT
        bool
 
index 4237e0744e26bd276de92ca083a44676c9ede240..16c027e9cc730a38d1bb97da89dd9f30c4557145 100644 (file)
@@ -280,17 +280,22 @@ static int clockevents_program_min_delta(struct clock_event_device *dev)
 static int clockevents_program_min_delta(struct clock_event_device *dev)
 {
        unsigned long long clc;
-       int64_t delta;
+       int64_t delta = 0;
+       int i;
 
-       delta = dev->min_delta_ns;
-       dev->next_event = ktime_add_ns(ktime_get(), delta);
+       for (i = 0; i < 10; i++) {
+               delta += dev->min_delta_ns;
+               dev->next_event = ktime_add_ns(ktime_get(), delta);
 
-       if (clockevent_state_shutdown(dev))
-               return 0;
+               if (clockevent_state_shutdown(dev))
+                       return 0;
 
-       dev->retries++;
-       clc = ((unsigned long long) delta * dev->mult) >> dev->shift;
-       return dev->set_next_event((unsigned long) clc, dev);
+               dev->retries++;
+               clc = ((unsigned long long) delta * dev->mult) >> dev->shift;
+               if (dev->set_next_event((unsigned long) clc, dev) == 0)
+                       return 0;
+       }
+       return -ETIME;
 }
 
 #endif /* CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST */
index 99e03bec68e4cbaa3ba103f3097eeb1e5d38e3ee..8d70da1b9a0d21bb8057eacd47362f45314c254a 100644 (file)
@@ -493,6 +493,67 @@ out:
        return leap;
 }
 
+static void sync_hw_clock(struct work_struct *work);
+static DECLARE_DELAYED_WORK(sync_work, sync_hw_clock);
+
+static void sched_sync_hw_clock(struct timespec64 now,
+                               unsigned long target_nsec, bool fail)
+
+{
+       struct timespec64 next;
+
+       getnstimeofday64(&next);
+       if (!fail)
+               next.tv_sec = 659;
+       else {
+               /*
+                * Try again as soon as possible. Delaying long periods
+                * decreases the accuracy of the work queue timer. Due to this
+                * the algorithm is very likely to require a short-sleep retry
+                * after the above long sleep to synchronize ts_nsec.
+                */
+               next.tv_sec = 0;
+       }
+
+       /* Compute the needed delay that will get to tv_nsec == target_nsec */
+       next.tv_nsec = target_nsec - next.tv_nsec;
+       if (next.tv_nsec <= 0)
+               next.tv_nsec += NSEC_PER_SEC;
+       if (next.tv_nsec >= NSEC_PER_SEC) {
+               next.tv_sec++;
+               next.tv_nsec -= NSEC_PER_SEC;
+       }
+
+       queue_delayed_work(system_power_efficient_wq, &sync_work,
+                          timespec64_to_jiffies(&next));
+}
+
+static void sync_rtc_clock(void)
+{
+       unsigned long target_nsec;
+       struct timespec64 adjust, now;
+       int rc;
+
+       if (!IS_ENABLED(CONFIG_RTC_SYSTOHC))
+               return;
+
+       getnstimeofday64(&now);
+
+       adjust = now;
+       if (persistent_clock_is_local)
+               adjust.tv_sec -= (sys_tz.tz_minuteswest * 60);
+
+       /*
+        * The current RTC in use will provide the target_nsec it wants to be
+        * called at, and does rtc_tv_nsec_ok internally.
+        */
+       rc = rtc_set_ntp_time(adjust, &target_nsec);
+       if (rc == -ENODEV)
+               return;
+
+       sched_sync_hw_clock(now, target_nsec, rc);
+}
+
 #ifdef CONFIG_GENERIC_CMOS_UPDATE
 int __weak update_persistent_clock(struct timespec now)
 {
@@ -508,76 +569,75 @@ int __weak update_persistent_clock64(struct timespec64 now64)
 }
 #endif
 
-#if defined(CONFIG_GENERIC_CMOS_UPDATE) || defined(CONFIG_RTC_SYSTOHC)
-static void sync_cmos_clock(struct work_struct *work);
-
-static DECLARE_DELAYED_WORK(sync_cmos_work, sync_cmos_clock);
-
-static void sync_cmos_clock(struct work_struct *work)
+static bool sync_cmos_clock(void)
 {
+       static bool no_cmos;
        struct timespec64 now;
-       struct timespec64 next;
-       int fail = 1;
+       struct timespec64 adjust;
+       int rc = -EPROTO;
+       long target_nsec = NSEC_PER_SEC / 2;
+
+       if (!IS_ENABLED(CONFIG_GENERIC_CMOS_UPDATE))
+               return false;
+
+       if (no_cmos)
+               return false;
 
        /*
-        * If we have an externally synchronized Linux clock, then update
-        * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-        * called as close as possible to 500 ms before the new second starts.
-        * This code is run on a timer.  If the clock is set, that timer
-        * may not expire at the correct time.  Thus, we adjust...
-        * We want the clock to be within a couple of ticks from the target.
+        * Historically update_persistent_clock64() has followed x86
+        * semantics, which match the MC146818A/etc RTC. This RTC will store
+        * 'adjust' and then in .5s it will advance once second.
+        *
+        * Architectures are strongly encouraged to use rtclib and not
+        * implement this legacy API.
         */
-       if (!ntp_synced()) {
-               /*
-                * Not synced, exit, do not restart a timer (if one is
-                * running, let it run out).
-                */
-               return;
-       }
-
        getnstimeofday64(&now);
-       if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec * 5) {
-               struct timespec64 adjust = now;
-
-               fail = -ENODEV;
+       if (rtc_tv_nsec_ok(-1 * target_nsec, &adjust, &now)) {
                if (persistent_clock_is_local)
                        adjust.tv_sec -= (sys_tz.tz_minuteswest * 60);
-#ifdef CONFIG_GENERIC_CMOS_UPDATE
-               fail = update_persistent_clock64(adjust);
-#endif
-
-#ifdef CONFIG_RTC_SYSTOHC
-               if (fail == -ENODEV)
-                       fail = rtc_set_ntp_time(adjust);
-#endif
+               rc = update_persistent_clock64(adjust);
+               /*
+                * The machine does not support update_persistent_clock64 even
+                * though it defines CONFIG_GENERIC_CMOS_UPDATE.
+                */
+               if (rc == -ENODEV) {
+                       no_cmos = true;
+                       return false;
+               }
        }
 
-       next.tv_nsec = (NSEC_PER_SEC / 2) - now.tv_nsec - (TICK_NSEC / 2);
-       if (next.tv_nsec <= 0)
-               next.tv_nsec += NSEC_PER_SEC;
+       sched_sync_hw_clock(now, target_nsec, rc);
+       return true;
+}
 
-       if (!fail || fail == -ENODEV)
-               next.tv_sec = 659;
-       else
-               next.tv_sec = 0;
+/*
+ * If we have an externally synchronized Linux clock, then update RTC clock
+ * accordingly every ~11 minutes. Generally RTCs can only store second
+ * precision, but many RTCs will adjust the phase of their second tick to
+ * match the moment of update. This infrastructure arranges to call to the RTC
+ * set at the correct moment to phase synchronize the RTC second tick over
+ * with the kernel clock.
+ */
+static void sync_hw_clock(struct work_struct *work)
+{
+       if (!ntp_synced())
+               return;
 
-       if (next.tv_nsec >= NSEC_PER_SEC) {
-               next.tv_sec++;
-               next.tv_nsec -= NSEC_PER_SEC;
-       }
-       queue_delayed_work(system_power_efficient_wq,
-                          &sync_cmos_work, timespec64_to_jiffies(&next));
+       if (sync_cmos_clock())
+               return;
+
+       sync_rtc_clock();
 }
 
 void ntp_notify_cmos_timer(void)
 {
-       queue_delayed_work(system_power_efficient_wq, &sync_cmos_work, 0);
-}
-
-#else
-void ntp_notify_cmos_timer(void) { }
-#endif
+       if (!ntp_synced())
+               return;
 
+       if (IS_ENABLED(CONFIG_GENERIC_CMOS_UPDATE) ||
+           IS_ENABLED(CONFIG_RTC_SYSTOHC))
+               queue_delayed_work(system_power_efficient_wq, &sync_work, 0);
+}
 
 /*
  * Propagate a new txc->status value into the NTP state:
@@ -654,67 +714,6 @@ static inline void process_adjtimex_modes(struct timex *txc,
 }
 
 
-
-/**
- * ntp_validate_timex - Ensures the timex is ok for use in do_adjtimex
- */
-int ntp_validate_timex(struct timex *txc)
-{
-       if (txc->modes & ADJ_ADJTIME) {
-               /* singleshot must not be used with any other mode bits */
-               if (!(txc->modes & ADJ_OFFSET_SINGLESHOT))
-                       return -EINVAL;
-               if (!(txc->modes & ADJ_OFFSET_READONLY) &&
-                   !capable(CAP_SYS_TIME))
-                       return -EPERM;
-       } else {
-               /* In order to modify anything, you gotta be super-user! */
-                if (txc->modes && !capable(CAP_SYS_TIME))
-                       return -EPERM;
-               /*
-                * if the quartz is off by more than 10% then
-                * something is VERY wrong!
-                */
-               if (txc->modes & ADJ_TICK &&
-                   (txc->tick <  900000/USER_HZ ||
-                    txc->tick > 1100000/USER_HZ))
-                       return -EINVAL;
-       }
-
-       if (txc->modes & ADJ_SETOFFSET) {
-               /* In order to inject time, you gotta be super-user! */
-               if (!capable(CAP_SYS_TIME))
-                       return -EPERM;
-
-               if (txc->modes & ADJ_NANO) {
-                       struct timespec ts;
-
-                       ts.tv_sec = txc->time.tv_sec;
-                       ts.tv_nsec = txc->time.tv_usec;
-                       if (!timespec_inject_offset_valid(&ts))
-                               return -EINVAL;
-
-               } else {
-                       if (!timeval_inject_offset_valid(&txc->time))
-                               return -EINVAL;
-               }
-       }
-
-       /*
-        * Check for potential multiplication overflows that can
-        * only happen on 64-bit systems:
-        */
-       if ((txc->modes & ADJ_FREQUENCY) && (BITS_PER_LONG == 64)) {
-               if (LLONG_MIN / PPM_SCALE > txc->freq)
-                       return -EINVAL;
-               if (LLONG_MAX / PPM_SCALE < txc->freq)
-                       return -EINVAL;
-       }
-
-       return 0;
-}
-
-
 /*
  * adjtimex mainly allows reading (and writing, if superuser) of
  * kernel time-keeping variables. used by xntpd.
index 0a53e6ea47b19ac52994222f376b51409f1b3bbb..909bd1f1bfb14dba87f6dc82fc85009108cabcdc 100644 (file)
@@ -8,7 +8,6 @@ extern void ntp_clear(void);
 extern u64 ntp_tick_length(void);
 extern ktime_t ntp_get_next_leap(void);
 extern int second_overflow(time64_t secs);
-extern int ntp_validate_timex(struct timex *);
 extern int __do_adjtimex(struct timex *, struct timespec64 *, s32 *);
 extern void __hardpps(const struct timespec64 *, const struct timespec64 *);
 #endif /* _LINUX_NTP_INTERNAL_H */
index 06f34feb635ed4ddb4b736f6e9ece10f2686d4f6..b258bee13b021bcf72879a84a9d336cacf48e4ff 100644 (file)
@@ -117,8 +117,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
                const struct timespec __user *, rqtp,
                struct timespec __user *, rmtp)
 {
-       struct timespec64 t64;
-       struct timespec t;
+       struct timespec64 t;
 
        switch (which_clock) {
        case CLOCK_REALTIME:
@@ -129,16 +128,15 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
                return -EINVAL;
        }
 
-       if (copy_from_user(&t, rqtp, sizeof (struct timespec)))
+       if (get_timespec64(&t, rqtp))
                return -EFAULT;
-       t64 = timespec_to_timespec64(t);
-       if (!timespec64_valid(&t64))
+       if (!timespec64_valid(&t))
                return -EINVAL;
        if (flags & TIMER_ABSTIME)
                rmtp = NULL;
        current->restart_block.nanosleep.type = rmtp ? TT_NATIVE : TT_NONE;
        current->restart_block.nanosleep.rmtp = rmtp;
-       return hrtimer_nanosleep(&t64, flags & TIMER_ABSTIME ?
+       return hrtimer_nanosleep(&t, flags & TIMER_ABSTIME ?
                                 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
                                 which_clock);
 }
@@ -203,8 +201,7 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
                       struct compat_timespec __user *, rqtp,
                       struct compat_timespec __user *, rmtp)
 {
-       struct timespec64 t64;
-       struct timespec t;
+       struct timespec64 t;
 
        switch (which_clock) {
        case CLOCK_REALTIME:
@@ -215,16 +212,15 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
                return -EINVAL;
        }
 
-       if (compat_get_timespec(&t, rqtp))
+       if (compat_get_timespec64(&t, rqtp))
                return -EFAULT;
-       t64 = timespec_to_timespec64(t);
-       if (!timespec64_valid(&t64))
+       if (!timespec64_valid(&t))
                return -EINVAL;
        if (flags & TIMER_ABSTIME)
                rmtp = NULL;
        current->restart_block.nanosleep.type = rmtp ? TT_COMPAT : TT_NONE;
        current->restart_block.nanosleep.compat_rmtp = rmtp;
-       return hrtimer_nanosleep(&t64, flags & TIMER_ABSTIME ?
+       return hrtimer_nanosleep(&t, flags & TIMER_ABSTIME ?
                                 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
                                 which_clock);
 }
index 6b009c2076718f284b455ea2b6c084b208a57e53..c1f518e7aa808a281b5dab69f3961a02b2c14315 100644 (file)
@@ -33,6 +33,7 @@ int tick_program_event(ktime_t expires, int force)
                 * We don't need the clock event device any more, stop it.
                 */
                clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED);
+               dev->next_event = KTIME_MAX;
                return 0;
        }
 
index 44a8c1402133be79d00fd6e66eb5825404277185..bd4e6c7dd6899d8320259856c8b99e5b98388fd1 100644 (file)
@@ -82,7 +82,7 @@ SYSCALL_DEFINE1(time, time_t __user *, tloc)
 
 SYSCALL_DEFINE1(stime, time_t __user *, tptr)
 {
-       struct timespec tv;
+       struct timespec64 tv;
        int err;
 
        if (get_user(tv.tv_sec, tptr))
@@ -90,11 +90,11 @@ SYSCALL_DEFINE1(stime, time_t __user *, tptr)
 
        tv.tv_nsec = 0;
 
-       err = security_settime(&tv, NULL);
+       err = security_settime64(&tv, NULL);
        if (err)
                return err;
 
-       do_settimeofday(&tv);
+       do_settimeofday64(&tv);
        return 0;
 }
 
@@ -122,7 +122,7 @@ COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc)
 
 COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr)
 {
-       struct timespec tv;
+       struct timespec64 tv;
        int err;
 
        if (get_user(tv.tv_sec, tptr))
@@ -130,11 +130,11 @@ COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr)
 
        tv.tv_nsec = 0;
 
-       err = security_settime(&tv, NULL);
+       err = security_settime64(&tv, NULL);
        if (err)
                return err;
 
-       do_settimeofday(&tv);
+       do_settimeofday64(&tv);
        return 0;
 }
 
@@ -157,40 +157,6 @@ SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv,
        return 0;
 }
 
-/*
- * Indicates if there is an offset between the system clock and the hardware
- * clock/persistent clock/rtc.
- */
-int persistent_clock_is_local;
-
-/*
- * Adjust the time obtained from the CMOS to be UTC time instead of
- * local time.
- *
- * This is ugly, but preferable to the alternatives.  Otherwise we
- * would either need to write a program to do it in /etc/rc (and risk
- * confusion if the program gets run more than once; it would also be
- * hard to make the program warp the clock precisely n hours)  or
- * compile in the timezone information into the kernel.  Bad, bad....
- *
- *                                             - TYT, 1992-01-01
- *
- * The best thing to do is to keep the CMOS clock in universal time (UTC)
- * as real UNIX machines always do it. This avoids all headaches about
- * daylight saving times and warping kernel clocks.
- */
-static inline void warp_clock(void)
-{
-       if (sys_tz.tz_minuteswest != 0) {
-               struct timespec adjust;
-
-               persistent_clock_is_local = 1;
-               adjust.tv_sec = sys_tz.tz_minuteswest * 60;
-               adjust.tv_nsec = 0;
-               timekeeping_inject_offset(&adjust);
-       }
-}
-
 /*
  * In case for some reason the CMOS clock has not already been running
  * in UTC, but in some local time: The first time we set the timezone,
@@ -224,7 +190,7 @@ int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz
                if (firsttime) {
                        firsttime = 0;
                        if (!tv)
-                               warp_clock();
+                               timekeeping_warp_clock();
                }
        }
        if (tv)
@@ -441,6 +407,7 @@ time64_t mktime64(const unsigned int year0, const unsigned int mon0,
 }
 EXPORT_SYMBOL(mktime64);
 
+#if __BITS_PER_LONG == 32
 /**
  * set_normalized_timespec - set timespec sec and nsec parts and normalize
  *
@@ -501,6 +468,7 @@ struct timespec ns_to_timespec(const s64 nsec)
        return ts;
 }
 EXPORT_SYMBOL(ns_to_timespec);
+#endif
 
 /**
  * ns_to_timeval - Convert nanoseconds to timeval
@@ -520,7 +488,6 @@ struct timeval ns_to_timeval(const s64 nsec)
 }
 EXPORT_SYMBOL(ns_to_timeval);
 
-#if BITS_PER_LONG == 32
 /**
  * set_normalized_timespec - set timespec sec and nsec parts and normalize
  *
@@ -581,7 +548,7 @@ struct timespec64 ns_to_timespec64(const s64 nsec)
        return ts;
 }
 EXPORT_SYMBOL(ns_to_timespec64);
-#endif
+
 /**
  * msecs_to_jiffies: - convert milliseconds to jiffies
  * @m: time in milliseconds
@@ -852,24 +819,6 @@ unsigned long nsecs_to_jiffies(u64 n)
 }
 EXPORT_SYMBOL_GPL(nsecs_to_jiffies);
 
-/*
- * Add two timespec values and do a safety check for overflow.
- * It's assumed that both values are valid (>= 0)
- */
-struct timespec timespec_add_safe(const struct timespec lhs,
-                                 const struct timespec rhs)
-{
-       struct timespec res;
-
-       set_normalized_timespec(&res, lhs.tv_sec + rhs.tv_sec,
-                               lhs.tv_nsec + rhs.tv_nsec);
-
-       if (res.tv_sec < lhs.tv_sec || res.tv_sec < rhs.tv_sec)
-               res.tv_sec = TIME_T_MAX;
-
-       return res;
-}
-
 /*
  * Add two timespec64 values and do a safety check for overflow.
  * It's assumed that both values are valid (>= 0).
index 2cafb49aa65e13b5b1d29223e8943d53386a795d..198afa78bf69e425b8cc1b0dfed538467df12bf7 100644 (file)
@@ -60,8 +60,27 @@ struct tk_fast {
        struct tk_read_base     base[2];
 };
 
-static struct tk_fast tk_fast_mono ____cacheline_aligned;
-static struct tk_fast tk_fast_raw  ____cacheline_aligned;
+/* Suspend-time cycles value for halted fast timekeeper. */
+static u64 cycles_at_suspend;
+
+static u64 dummy_clock_read(struct clocksource *cs)
+{
+       return cycles_at_suspend;
+}
+
+static struct clocksource dummy_clock = {
+       .read = dummy_clock_read,
+};
+
+static struct tk_fast tk_fast_mono ____cacheline_aligned = {
+       .base[0] = { .clock = &dummy_clock, },
+       .base[1] = { .clock = &dummy_clock, },
+};
+
+static struct tk_fast tk_fast_raw  ____cacheline_aligned = {
+       .base[0] = { .clock = &dummy_clock, },
+       .base[1] = { .clock = &dummy_clock, },
+};
 
 /* flag for if timekeeping is suspended */
 int __read_mostly timekeeping_suspended;
@@ -477,17 +496,39 @@ u64 notrace ktime_get_boot_fast_ns(void)
 }
 EXPORT_SYMBOL_GPL(ktime_get_boot_fast_ns);
 
-/* Suspend-time cycles value for halted fast timekeeper. */
-static u64 cycles_at_suspend;
 
-static u64 dummy_clock_read(struct clocksource *cs)
+/*
+ * See comment for __ktime_get_fast_ns() vs. timestamp ordering
+ */
+static __always_inline u64 __ktime_get_real_fast_ns(struct tk_fast *tkf)
 {
-       return cycles_at_suspend;
+       struct tk_read_base *tkr;
+       unsigned int seq;
+       u64 now;
+
+       do {
+               seq = raw_read_seqcount_latch(&tkf->seq);
+               tkr = tkf->base + (seq & 0x01);
+               now = ktime_to_ns(tkr->base_real);
+
+               now += timekeeping_delta_to_ns(tkr,
+                               clocksource_delta(
+                                       tk_clock_read(tkr),
+                                       tkr->cycle_last,
+                                       tkr->mask));
+       } while (read_seqcount_retry(&tkf->seq, seq));
+
+       return now;
 }
 
-static struct clocksource dummy_clock = {
-       .read = dummy_clock_read,
-};
+/**
+ * ktime_get_real_fast_ns: - NMI safe and fast access to clock realtime.
+ */
+u64 ktime_get_real_fast_ns(void)
+{
+       return __ktime_get_real_fast_ns(&tk_fast_mono);
+}
+EXPORT_SYMBOL_GPL(ktime_get_real_fast_ns);
 
 /**
  * halt_fast_timekeeper - Prevent fast timekeeper from accessing clocksource.
@@ -507,6 +548,7 @@ static void halt_fast_timekeeper(struct timekeeper *tk)
        memcpy(&tkr_dummy, tkr, sizeof(tkr_dummy));
        cycles_at_suspend = tk_clock_read(tkr);
        tkr_dummy.clock = &dummy_clock;
+       tkr_dummy.base_real = tkr->base + tk->offs_real;
        update_fast_timekeeper(&tkr_dummy, &tk_fast_mono);
 
        tkr = &tk->tkr_raw;
@@ -654,6 +696,7 @@ static void timekeeping_update(struct timekeeper *tk, unsigned int action)
        update_vsyscall(tk);
        update_pvclock_gtod(tk, action & TK_CLOCK_WAS_SET);
 
+       tk->tkr_mono.base_real = tk->tkr_mono.base + tk->offs_real;
        update_fast_timekeeper(&tk->tkr_mono, &tk_fast_mono);
        update_fast_timekeeper(&tk->tkr_raw,  &tk_fast_raw);
 
@@ -1264,33 +1307,31 @@ EXPORT_SYMBOL(do_settimeofday64);
  *
  * Adds or subtracts an offset value from the current time.
  */
-int timekeeping_inject_offset(struct timespec *ts)
+static int timekeeping_inject_offset(struct timespec64 *ts)
 {
        struct timekeeper *tk = &tk_core.timekeeper;
        unsigned long flags;
-       struct timespec64 ts64, tmp;
+       struct timespec64 tmp;
        int ret = 0;
 
-       if (!timespec_inject_offset_valid(ts))
+       if (ts->tv_nsec < 0 || ts->tv_nsec >= NSEC_PER_SEC)
                return -EINVAL;
 
-       ts64 = timespec_to_timespec64(*ts);
-
        raw_spin_lock_irqsave(&timekeeper_lock, flags);
        write_seqcount_begin(&tk_core.seq);
 
        timekeeping_forward_now(tk);
 
        /* Make sure the proposed value is valid */
-       tmp = timespec64_add(tk_xtime(tk),  ts64);
-       if (timespec64_compare(&tk->wall_to_monotonic, &ts64) > 0 ||
+       tmp = timespec64_add(tk_xtime(tk), *ts);
+       if (timespec64_compare(&tk->wall_to_monotonic, ts) > 0 ||
            !timespec64_valid_strict(&tmp)) {
                ret = -EINVAL;
                goto error;
        }
 
-       tk_xtime_add(tk, &ts64);
-       tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, ts64));
+       tk_xtime_add(tk, ts);
+       tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, *ts));
 
 error: /* even if we error out, we forwarded the time, so call update */
        timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET);
@@ -1303,7 +1344,40 @@ error: /* even if we error out, we forwarded the time, so call update */
 
        return ret;
 }
-EXPORT_SYMBOL(timekeeping_inject_offset);
+
+/*
+ * Indicates if there is an offset between the system clock and the hardware
+ * clock/persistent clock/rtc.
+ */
+int persistent_clock_is_local;
+
+/*
+ * Adjust the time obtained from the CMOS to be UTC time instead of
+ * local time.
+ *
+ * This is ugly, but preferable to the alternatives.  Otherwise we
+ * would either need to write a program to do it in /etc/rc (and risk
+ * confusion if the program gets run more than once; it would also be
+ * hard to make the program warp the clock precisely n hours)  or
+ * compile in the timezone information into the kernel.  Bad, bad....
+ *
+ *                                             - TYT, 1992-01-01
+ *
+ * The best thing to do is to keep the CMOS clock in universal time (UTC)
+ * as real UNIX machines always do it. This avoids all headaches about
+ * daylight saving times and warping kernel clocks.
+ */
+void timekeeping_warp_clock(void)
+{
+       if (sys_tz.tz_minuteswest != 0) {
+               struct timespec64 adjust;
+
+               persistent_clock_is_local = 1;
+               adjust.tv_sec = sys_tz.tz_minuteswest * 60;
+               adjust.tv_nsec = 0;
+               timekeeping_inject_offset(&adjust);
+       }
+}
 
 /**
  * __timekeeping_set_tai_offset - Sets the TAI offset from UTC and monotonic
@@ -2247,6 +2321,72 @@ ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq, ktime_t *offs_real,
        return base;
 }
 
+/**
+ * timekeeping_validate_timex - Ensures the timex is ok for use in do_adjtimex
+ */
+static int timekeeping_validate_timex(struct timex *txc)
+{
+       if (txc->modes & ADJ_ADJTIME) {
+               /* singleshot must not be used with any other mode bits */
+               if (!(txc->modes & ADJ_OFFSET_SINGLESHOT))
+                       return -EINVAL;
+               if (!(txc->modes & ADJ_OFFSET_READONLY) &&
+                   !capable(CAP_SYS_TIME))
+                       return -EPERM;
+       } else {
+               /* In order to modify anything, you gotta be super-user! */
+               if (txc->modes && !capable(CAP_SYS_TIME))
+                       return -EPERM;
+               /*
+                * if the quartz is off by more than 10% then
+                * something is VERY wrong!
+                */
+               if (txc->modes & ADJ_TICK &&
+                   (txc->tick <  900000/USER_HZ ||
+                    txc->tick > 1100000/USER_HZ))
+                       return -EINVAL;
+       }
+
+       if (txc->modes & ADJ_SETOFFSET) {
+               /* In order to inject time, you gotta be super-user! */
+               if (!capable(CAP_SYS_TIME))
+                       return -EPERM;
+
+               /*
+                * Validate if a timespec/timeval used to inject a time
+                * offset is valid.  Offsets can be postive or negative, so
+                * we don't check tv_sec. The value of the timeval/timespec
+                * is the sum of its fields,but *NOTE*:
+                * The field tv_usec/tv_nsec must always be non-negative and
+                * we can't have more nanoseconds/microseconds than a second.
+                */
+               if (txc->time.tv_usec < 0)
+                       return -EINVAL;
+
+               if (txc->modes & ADJ_NANO) {
+                       if (txc->time.tv_usec >= NSEC_PER_SEC)
+                               return -EINVAL;
+               } else {
+                       if (txc->time.tv_usec >= USEC_PER_SEC)
+                               return -EINVAL;
+               }
+       }
+
+       /*
+        * Check for potential multiplication overflows that can
+        * only happen on 64-bit systems:
+        */
+       if ((txc->modes & ADJ_FREQUENCY) && (BITS_PER_LONG == 64)) {
+               if (LLONG_MIN / PPM_SCALE > txc->freq)
+                       return -EINVAL;
+               if (LLONG_MAX / PPM_SCALE < txc->freq)
+                       return -EINVAL;
+       }
+
+       return 0;
+}
+
+
 /**
  * do_adjtimex() - Accessor function to NTP __do_adjtimex function
  */
@@ -2259,12 +2399,12 @@ int do_adjtimex(struct timex *txc)
        int ret;
 
        /* Validate the data before disabling interrupts */
-       ret = ntp_validate_timex(txc);
+       ret = timekeeping_validate_timex(txc);
        if (ret)
                return ret;
 
        if (txc->modes & ADJ_SETOFFSET) {
-               struct timespec delta;
+               struct timespec64 delta;
                delta.tv_sec  = txc->time.tv_sec;
                delta.tv_nsec = txc->time.tv_usec;
                if (!(txc->modes & ADJ_NANO))
index c9f9af33991498e29fbd49d677882f3ad9137cc7..7a9b4eb7a1d5bde85e7a7b1c7747602cdd605975 100644 (file)
@@ -11,7 +11,7 @@ extern ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq,
 
 extern int timekeeping_valid_for_hres(void);
 extern u64 timekeeping_max_deferment(void);
-extern int timekeeping_inject_offset(struct timespec *ts);
+extern void timekeeping_warp_clock(void);
 extern int timekeeping_suspend(void);
 extern void timekeeping_resume(void);
 
index f2674a056c268a58e0525194ea225fcd0bd9e1d5..af0b8bae45027042ff153172522b659fb605cf1d 100644 (file)
@@ -610,7 +610,7 @@ static bool timer_fixup_init(void *addr, enum debug_obj_state state)
 }
 
 /* Stub timer callback for improperly used timers. */
-static void stub_timer(unsigned long data)
+static void stub_timer(struct timer_list *unused)
 {
        WARN_ON(1);
 }
@@ -626,7 +626,7 @@ static bool timer_fixup_activate(void *addr, enum debug_obj_state state)
 
        switch (state) {
        case ODEBUG_STATE_NOTAVAILABLE:
-               setup_timer(timer, stub_timer, 0);
+               timer_setup(timer, stub_timer, 0);
                return true;
 
        case ODEBUG_STATE_ACTIVE:
@@ -665,7 +665,7 @@ static bool timer_fixup_assert_init(void *addr, enum debug_obj_state state)
 
        switch (state) {
        case ODEBUG_STATE_NOTAVAILABLE:
-               setup_timer(timer, stub_timer, 0);
+               timer_setup(timer, stub_timer, 0);
                return true;
        default:
                return false;
@@ -929,8 +929,11 @@ static struct timer_base *lock_timer_base(struct timer_list *timer,
        }
 }
 
+#define MOD_TIMER_PENDING_ONLY         0x01
+#define MOD_TIMER_REDUCE               0x02
+
 static inline int
-__mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
+__mod_timer(struct timer_list *timer, unsigned long expires, unsigned int options)
 {
        struct timer_base *base, *new_base;
        unsigned int idx = UINT_MAX;
@@ -950,7 +953,11 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
                 * larger granularity than you would get from adding a new
                 * timer with this expiry.
                 */
-               if (timer->expires == expires)
+               long diff = timer->expires - expires;
+
+               if (!diff)
+                       return 1;
+               if (options & MOD_TIMER_REDUCE && diff <= 0)
                        return 1;
 
                /*
@@ -962,6 +969,12 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
                base = lock_timer_base(timer, &flags);
                forward_timer_base(base);
 
+               if (timer_pending(timer) && (options & MOD_TIMER_REDUCE) &&
+                   time_before_eq(timer->expires, expires)) {
+                       ret = 1;
+                       goto out_unlock;
+               }
+
                clk = base->clk;
                idx = calc_wheel_index(expires, clk);
 
@@ -971,7 +984,10 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
                 * subsequent call will exit in the expires check above.
                 */
                if (idx == timer_get_idx(timer)) {
-                       timer->expires = expires;
+                       if (!(options & MOD_TIMER_REDUCE))
+                               timer->expires = expires;
+                       else if (time_after(timer->expires, expires))
+                               timer->expires = expires;
                        ret = 1;
                        goto out_unlock;
                }
@@ -981,7 +997,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
        }
 
        ret = detach_if_pending(timer, base, false);
-       if (!ret && pending_only)
+       if (!ret && (options & MOD_TIMER_PENDING_ONLY))
                goto out_unlock;
 
        debug_activate(timer, expires);
@@ -1042,7 +1058,7 @@ out_unlock:
  */
 int mod_timer_pending(struct timer_list *timer, unsigned long expires)
 {
-       return __mod_timer(timer, expires, true);
+       return __mod_timer(timer, expires, MOD_TIMER_PENDING_ONLY);
 }
 EXPORT_SYMBOL(mod_timer_pending);
 
@@ -1068,10 +1084,25 @@ EXPORT_SYMBOL(mod_timer_pending);
  */
 int mod_timer(struct timer_list *timer, unsigned long expires)
 {
-       return __mod_timer(timer, expires, false);
+       return __mod_timer(timer, expires, 0);
 }
 EXPORT_SYMBOL(mod_timer);
 
+/**
+ * timer_reduce - Modify a timer's timeout if it would reduce the timeout
+ * @timer:     The timer to be modified
+ * @expires:   New timeout in jiffies
+ *
+ * timer_reduce() is very similar to mod_timer(), except that it will only
+ * modify a running timer if that would reduce the expiration time (it will
+ * start a timer that isn't running).
+ */
+int timer_reduce(struct timer_list *timer, unsigned long expires)
+{
+       return __mod_timer(timer, expires, MOD_TIMER_REDUCE);
+}
+EXPORT_SYMBOL(timer_reduce);
+
 /**
  * add_timer - start a timer
  * @timer: the timer to be added
@@ -1560,8 +1591,11 @@ static int collect_expired_timers(struct timer_base *base,
                 * jiffies, otherwise forward to the next expiry time:
                 */
                if (time_after(next, jiffies)) {
-                       /* The call site will increment clock! */
-                       base->clk = jiffies - 1;
+                       /*
+                        * The call site will increment base->clk and then
+                        * terminate the expiry loop immediately.
+                        */
+                       base->clk = jiffies;
                        return 0;
                }
                base->clk = next;
@@ -1668,9 +1702,20 @@ void run_local_timers(void)
        raise_softirq(TIMER_SOFTIRQ);
 }
 
-static void process_timeout(unsigned long __data)
+/*
+ * Since schedule_timeout()'s timer is defined on the stack, it must store
+ * the target task on the stack as well.
+ */
+struct process_timer {
+       struct timer_list timer;
+       struct task_struct *task;
+};
+
+static void process_timeout(struct timer_list *t)
 {
-       wake_up_process((struct task_struct *)__data);
+       struct process_timer *timeout = from_timer(timeout, t, timer);
+
+       wake_up_process(timeout->task);
 }
 
 /**
@@ -1704,7 +1749,7 @@ static void process_timeout(unsigned long __data)
  */
 signed long __sched schedule_timeout(signed long timeout)
 {
-       struct timer_list timer;
+       struct process_timer timer;
        unsigned long expire;
 
        switch (timeout)
@@ -1738,13 +1783,14 @@ signed long __sched schedule_timeout(signed long timeout)
 
        expire = timeout + jiffies;
 
-       setup_timer_on_stack(&timer, process_timeout, (unsigned long)current);
-       __mod_timer(&timer, expire, false);
+       timer.task = current;
+       timer_setup_on_stack(&timer.timer, process_timeout, 0);
+       __mod_timer(&timer.timer, expire, 0);
        schedule();
-       del_singleshot_timer_sync(&timer);
+       del_singleshot_timer_sync(&timer.timer);
 
        /* Remove the timer from the object tracker */
-       destroy_timer_on_stack(&timer);
+       destroy_timer_on_stack(&timer.timer);
 
        timeout = expire - jiffies;
 
index a2dccfe1acec34bbda97a292344b997055e56d9a..3b67c0a0df1623b8f36d8e21397ceca36d456bed 100644 (file)
@@ -1493,9 +1493,9 @@ bool queue_work_on(int cpu, struct workqueue_struct *wq,
 }
 EXPORT_SYMBOL(queue_work_on);
 
-void delayed_work_timer_fn(unsigned long __data)
+void delayed_work_timer_fn(struct timer_list *t)
 {
-       struct delayed_work *dwork = (struct delayed_work *)__data;
+       struct delayed_work *dwork = from_timer(dwork, t, timer);
 
        /* should have been called from irqsafe timer with irq already off */
        __queue_work(dwork->cpu, dwork->wq, &dwork->work);
@@ -1509,8 +1509,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,
        struct work_struct *work = &dwork->work;
 
        WARN_ON_ONCE(!wq);
-       WARN_ON_ONCE(timer->function != delayed_work_timer_fn ||
-                    timer->data != (unsigned long)dwork);
+       WARN_ON_ONCE(timer->function != (TIMER_FUNC_TYPE)delayed_work_timer_fn);
        WARN_ON_ONCE(timer_pending(timer));
        WARN_ON_ONCE(!list_empty(&work->entry));
 
@@ -1833,9 +1832,9 @@ static void destroy_worker(struct worker *worker)
        wake_up_process(worker->task);
 }
 
-static void idle_worker_timeout(unsigned long __pool)
+static void idle_worker_timeout(struct timer_list *t)
 {
-       struct worker_pool *pool = (void *)__pool;
+       struct worker_pool *pool = from_timer(pool, t, idle_timer);
 
        spin_lock_irq(&pool->lock);
 
@@ -1881,9 +1880,9 @@ static void send_mayday(struct work_struct *work)
        }
 }
 
-static void pool_mayday_timeout(unsigned long __pool)
+static void pool_mayday_timeout(struct timer_list *t)
 {
-       struct worker_pool *pool = (void *)__pool;
+       struct worker_pool *pool = from_timer(pool, t, mayday_timer);
        struct work_struct *work;
 
        spin_lock_irq(&pool->lock);
@@ -3236,11 +3235,9 @@ static int init_worker_pool(struct worker_pool *pool)
        INIT_LIST_HEAD(&pool->idle_list);
        hash_init(pool->busy_hash);
 
-       setup_deferrable_timer(&pool->idle_timer, idle_worker_timeout,
-                              (unsigned long)pool);
+       timer_setup(&pool->idle_timer, idle_worker_timeout, TIMER_DEFERRABLE);
 
-       setup_timer(&pool->mayday_timer, pool_mayday_timeout,
-                   (unsigned long)pool);
+       timer_setup(&pool->mayday_timer, pool_mayday_timeout, 0);
 
        mutex_init(&pool->attach_mutex);
        INIT_LIST_HEAD(&pool->workers);
@@ -5383,11 +5380,8 @@ static void workqueue_sysfs_unregister(struct workqueue_struct *wq)      { }
  */
 #ifdef CONFIG_WQ_WATCHDOG
 
-static void wq_watchdog_timer_fn(unsigned long data);
-
 static unsigned long wq_watchdog_thresh = 30;
-static struct timer_list wq_watchdog_timer =
-       TIMER_DEFERRED_INITIALIZER(wq_watchdog_timer_fn, 0, 0);
+static struct timer_list wq_watchdog_timer;
 
 static unsigned long wq_watchdog_touched = INITIAL_JIFFIES;
 static DEFINE_PER_CPU(unsigned long, wq_watchdog_touched_cpu) = INITIAL_JIFFIES;
@@ -5401,7 +5395,7 @@ static void wq_watchdog_reset_touched(void)
                per_cpu(wq_watchdog_touched_cpu, cpu) = jiffies;
 }
 
-static void wq_watchdog_timer_fn(unsigned long data)
+static void wq_watchdog_timer_fn(struct timer_list *unused)
 {
        unsigned long thresh = READ_ONCE(wq_watchdog_thresh) * HZ;
        bool lockup_detected = false;
@@ -5503,6 +5497,7 @@ module_param_cb(watchdog_thresh, &wq_watchdog_thresh_ops, &wq_watchdog_thresh,
 
 static void wq_watchdog_init(void)
 {
+       timer_setup(&wq_watchdog_timer, wq_watchdog_timer_fn, TIMER_DEFERRABLE);
        wq_watchdog_set_thresh(wq_watchdog_thresh);
 }
 
index 0a90cb0e0fb65f8480c398a7d2e0b42d1c6ef885..65cc018fef40d714272fb2e7948084e4082fe499 100644 (file)
@@ -215,7 +215,7 @@ core_initcall(prandom_init);
 
 static void __prandom_timer(unsigned long dontcare);
 
-static DEFINE_TIMER(seed_timer, __prandom_timer, 0, 0);
+static DEFINE_TIMER(seed_timer, __prandom_timer);
 
 static void __prandom_timer(unsigned long dontcare)
 {
index 883d25778fa47dcadf64b90f451c918ca8bc45fe..e882d8b5db05e889be00fe26a0595458ead470a4 100644 (file)
@@ -121,7 +121,7 @@ static struct notifier_block mpoa_notifier = {
 
 struct mpoa_client *mpcs = NULL; /* FIXME */
 static struct atm_mpoa_qos *qos_head = NULL;
-static DEFINE_TIMER(mpc_timer, NULL, 0, 0);
+static DEFINE_TIMER(mpc_timer, NULL);
 
 
 static struct mpoa_client *find_mpc_by_itfnum(int itf)
index bff5ab88cdbb4e0496223271fcd2798c3edc8395..b36dceab0dc12000a73e6fec63e28ffa98691f59 100644 (file)
@@ -131,7 +131,7 @@ static struct dn_rt_hash_bucket *dn_rt_hash_table;
 static unsigned int dn_rt_hash_mask;
 
 static struct timer_list dn_route_timer;
-static DEFINE_TIMER(dn_rt_flush_timer, dn_run_flush, 0, 0);
+static DEFINE_TIMER(dn_rt_flush_timer, dn_run_flush);
 int decnet_dst_gc_interval = 2;
 
 static struct dst_ops dn_dst_ops = {
index 15535ee327c5780e80feb050c2ab4e0d1cc3e99c..9f2e73c71768d917ff3ca0cb0e22aed28f710ce5 100644 (file)
@@ -47,7 +47,7 @@ static atomic_t fl_size = ATOMIC_INIT(0);
 static struct ip6_flowlabel __rcu *fl_ht[FL_HASH_MASK+1];
 
 static void ip6_fl_gc(unsigned long dummy);
-static DEFINE_TIMER(ip6_fl_gc_timer, ip6_fl_gc, 0, 0);
+static DEFINE_TIMER(ip6_fl_gc_timer, ip6_fl_gc);
 
 /* FL hash table lock: it protects only of GC */
 
index f73561ca982d01750a88b8b82dc4c732de835d92..3e053cb300709cfb09b93364b33da69c5f9dff2a 100644 (file)
@@ -104,7 +104,7 @@ static inline void ct_write_unlock_bh(unsigned int key)
        spin_unlock_bh(&__ip_vs_conntbl_lock_array[key&CT_LOCKARRAY_MASK].l);
 }
 
-static void ip_vs_conn_expire(unsigned long data);
+static void ip_vs_conn_expire(struct timer_list *t);
 
 /*
  *     Returns hash value for IPVS connection entry
@@ -457,7 +457,7 @@ EXPORT_SYMBOL_GPL(ip_vs_conn_out_get_proto);
 static void __ip_vs_conn_put_notimer(struct ip_vs_conn *cp)
 {
        __ip_vs_conn_put(cp);
-       ip_vs_conn_expire((unsigned long)cp);
+       ip_vs_conn_expire(&cp->timer);
 }
 
 /*
@@ -817,9 +817,9 @@ static void ip_vs_conn_rcu_free(struct rcu_head *head)
        kmem_cache_free(ip_vs_conn_cachep, cp);
 }
 
-static void ip_vs_conn_expire(unsigned long data)
+static void ip_vs_conn_expire(struct timer_list *t)
 {
-       struct ip_vs_conn *cp = (struct ip_vs_conn *)data;
+       struct ip_vs_conn *cp = from_timer(cp, t, timer);
        struct netns_ipvs *ipvs = cp->ipvs;
 
        /*
@@ -909,7 +909,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p, int dest_af,
        }
 
        INIT_HLIST_NODE(&cp->c_list);
-       setup_timer(&cp->timer, ip_vs_conn_expire, (unsigned long)cp);
+       timer_setup(&cp->timer, ip_vs_conn_expire, 0);
        cp->ipvs           = ipvs;
        cp->af             = p->af;
        cp->daf            = dest_af;
index fac8c802b4eaf0605403c1ebf48ac82ef41775c6..fff213eacf2aeda24f15d07eac1b1d4f64df1e34 100644 (file)
@@ -1146,9 +1146,9 @@ ip_vs_del_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest)
        return 0;
 }
 
-static void ip_vs_dest_trash_expire(unsigned long data)
+static void ip_vs_dest_trash_expire(struct timer_list *t)
 {
-       struct netns_ipvs *ipvs = (struct netns_ipvs *)data;
+       struct netns_ipvs *ipvs = from_timer(ipvs, t, dest_trash_timer);
        struct ip_vs_dest *dest, *next;
        unsigned long now = jiffies;
 
@@ -4023,8 +4023,7 @@ int __net_init ip_vs_control_net_init(struct netns_ipvs *ipvs)
 
        INIT_LIST_HEAD(&ipvs->dest_trash);
        spin_lock_init(&ipvs->dest_trash_lock);
-       setup_timer(&ipvs->dest_trash_timer, ip_vs_dest_trash_expire,
-                   (unsigned long) ipvs);
+       timer_setup(&ipvs->dest_trash_timer, ip_vs_dest_trash_expire, 0);
        atomic_set(&ipvs->ftpsvc_counter, 0);
        atomic_set(&ipvs->nullsvc_counter, 0);
        atomic_set(&ipvs->conn_out_counter, 0);
index 457c6c193e1332ab803b6f381f1329f85f1ebdf6..489055091a9b3ba5ce9ba8b1d868dd9f79575f85 100644 (file)
@@ -97,12 +97,12 @@ static void ip_vs_read_cpu_stats(struct ip_vs_kstats *sum,
 }
 
 
-static void estimation_timer(unsigned long arg)
+static void estimation_timer(struct timer_list *t)
 {
        struct ip_vs_estimator *e;
        struct ip_vs_stats *s;
        u64 rate;
-       struct netns_ipvs *ipvs = (struct netns_ipvs *)arg;
+       struct netns_ipvs *ipvs = from_timer(ipvs, t, est_timer);
 
        spin_lock(&ipvs->est_lock);
        list_for_each_entry(e, &ipvs->est_list, list) {
@@ -192,7 +192,7 @@ int __net_init ip_vs_estimator_net_init(struct netns_ipvs *ipvs)
 {
        INIT_LIST_HEAD(&ipvs->est_list);
        spin_lock_init(&ipvs->est_lock);
-       setup_timer(&ipvs->est_timer, estimation_timer, (unsigned long)ipvs);
+       timer_setup(&ipvs->est_timer, estimation_timer, 0);
        mod_timer(&ipvs->est_timer, jiffies + 2 * HZ);
        return 0;
 }
index b6aa4a970c6e97678e8c88e8fe0e0e0b4e4d476d..d625179de485b0324d862f78cf6db7764609404e 100644 (file)
@@ -106,6 +106,7 @@ struct ip_vs_lblc_table {
        struct rcu_head         rcu_head;
        struct hlist_head       bucket[IP_VS_LBLC_TAB_SIZE];  /* hash bucket */
        struct timer_list       periodic_timer; /* collect stale entries */
+       struct ip_vs_service    *svc;           /* pointer back to service */
        atomic_t                entries;        /* number of entries */
        int                     max_size;       /* maximum size of entries */
        int                     rover;          /* rover for expire check */
@@ -294,10 +295,10 @@ static inline void ip_vs_lblc_full_check(struct ip_vs_service *svc)
  *             of the table.
  *      The full expiration check is for this purpose now.
  */
-static void ip_vs_lblc_check_expire(unsigned long data)
+static void ip_vs_lblc_check_expire(struct timer_list *t)
 {
-       struct ip_vs_service *svc = (struct ip_vs_service *) data;
-       struct ip_vs_lblc_table *tbl = svc->sched_data;
+       struct ip_vs_lblc_table *tbl = from_timer(tbl, t, periodic_timer);
+       struct ip_vs_service *svc = tbl->svc;
        unsigned long now = jiffies;
        int goal;
        int i, j;
@@ -369,12 +370,12 @@ static int ip_vs_lblc_init_svc(struct ip_vs_service *svc)
        tbl->rover = 0;
        tbl->counter = 1;
        tbl->dead = 0;
+       tbl->svc = svc;
 
        /*
         *    Hook periodic timer for garbage collection
         */
-       setup_timer(&tbl->periodic_timer, ip_vs_lblc_check_expire,
-                       (unsigned long)svc);
+       timer_setup(&tbl->periodic_timer, ip_vs_lblc_check_expire, 0);
        mod_timer(&tbl->periodic_timer, jiffies + CHECK_EXPIRE_INTERVAL);
 
        return 0;
index c13ff575f9f73ab9fb53837ff1b01cd279156c9f..84c57b62a5887b433b672d0d71c681bbf9b11a59 100644 (file)
@@ -278,6 +278,7 @@ struct ip_vs_lblcr_table {
        atomic_t                entries;        /* number of entries */
        int                     max_size;       /* maximum size of entries */
        struct timer_list       periodic_timer; /* collect stale entries */
+       struct ip_vs_service    *svc;           /* pointer back to service */
        int                     rover;          /* rover for expire check */
        int                     counter;        /* counter for no expire */
        bool                    dead;
@@ -458,10 +459,10 @@ static inline void ip_vs_lblcr_full_check(struct ip_vs_service *svc)
  *             of the table.
  *      The full expiration check is for this purpose now.
  */
-static void ip_vs_lblcr_check_expire(unsigned long data)
+static void ip_vs_lblcr_check_expire(struct timer_list *t)
 {
-       struct ip_vs_service *svc = (struct ip_vs_service *) data;
-       struct ip_vs_lblcr_table *tbl = svc->sched_data;
+       struct ip_vs_lblcr_table *tbl = from_timer(tbl, t, periodic_timer);
+       struct ip_vs_service *svc = tbl->svc;
        unsigned long now = jiffies;
        int goal;
        int i, j;
@@ -532,12 +533,12 @@ static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc)
        tbl->rover = 0;
        tbl->counter = 1;
        tbl->dead = 0;
+       tbl->svc = svc;
 
        /*
         *    Hook periodic timer for garbage collection
         */
-       setup_timer(&tbl->periodic_timer, ip_vs_lblcr_check_expire,
-                       (unsigned long)svc);
+       timer_setup(&tbl->periodic_timer, ip_vs_lblcr_check_expire, 0);
        mod_timer(&tbl->periodic_timer, jiffies + CHECK_EXPIRE_INTERVAL);
 
        return 0;
index 94d4e922af53c0fb5e1c34508dbad6a76f46d96f..989ae647825ef4568c0bd5717c8721e85cde46c6 100644 (file)
@@ -18,7 +18,7 @@
 static void nr_loopback_timer(unsigned long);
 
 static struct sk_buff_head loopback_queue;
-static DEFINE_TIMER(loopback_timer, nr_loopback_timer, 0, 0);
+static DEFINE_TIMER(loopback_timer, nr_loopback_timer);
 
 void __init nr_loopback_init(void)
 {
index f01d48cb3de1aac09266b59bcfa732597c6534b4..afb3a9175d7686e2997f253d1ecad486fcd2badb 100644 (file)
@@ -30,7 +30,7 @@ DECLARE_WORK(key_gc_work, key_garbage_collector);
  * Reaper for links from keyrings to dead keys.
  */
 static void key_gc_timer_func(unsigned long);
-static DEFINE_TIMER(key_gc_timer, key_gc_timer_func, 0, 0);
+static DEFINE_TIMER(key_gc_timer, key_gc_timer_func);
 
 static time_t key_gc_next_run = LONG_MAX;
 static struct key_type *key_gc_dead_keytype;
index 701c7625c9713aafa310e742cf5e87dfa4dc3247..1277df815d5bf26641c682fc408dab60c26c1b4e 100644 (file)
@@ -52,7 +52,7 @@ static struct midi_parms parms[MAX_MIDI_DEV];
 static void midi_poll(unsigned long dummy);
 
 
-static DEFINE_TIMER(poll_timer, midi_poll, 0, 0);
+static DEFINE_TIMER(poll_timer, midi_poll);
 
 static volatile int open_devs;
 static DEFINE_SPINLOCK(lock);
index b70c7c8f9c5d366dc41fce47e47c78339b8b1fd1..4391062e5cfdb813a0d2439b89067394f8c3fb3a 100644 (file)
@@ -662,7 +662,7 @@ static void do_sequencer_timer(unsigned long dummy)
 }
 
 
-static DEFINE_TIMER(seq_timer, do_sequencer_timer, 0, 0);
+static DEFINE_TIMER(seq_timer, do_sequencer_timer);
 
 void request_sound_timer(int count)
 {
index d17019d25b994526251a7fc8d9b088b0fecc109c..8a4b5625dba6d347711cd929664647f9fadaac01 100644 (file)
@@ -28,7 +28,7 @@ static unsigned long prev_event_time;
 
 static void     poll_def_tmr(unsigned long dummy);
 static DEFINE_SPINLOCK(lock);
-static DEFINE_TIMER(def_tmr, poll_def_tmr, 0, 0);
+static DEFINE_TIMER(def_tmr, poll_def_tmr);
 
 static unsigned long
 tmr2ticks(int tmr_value)
index eda32d7eddbdc89a9181e5e319cb1d65cf1d4b81..a9d3f756852505ebd26370f013c3f865393610d2 100644 (file)
@@ -78,7 +78,7 @@ static void (*midi_input_intr) (int dev, unsigned char data);
 static void poll_uart6850(unsigned long dummy);
 
 
-static DEFINE_TIMER(uart6850_timer, poll_uart6850, 0, 0);
+static DEFINE_TIMER(uart6850_timer, poll_uart6850);
 
 static void uart6850_input_loop(void)
 {