timer: Introduce mod_timer_msec()
Subsystems (36)
PATCH 1/1 timer: Introduce mod_timer_msec()
Quoted 1 line
From
247f568d09e22fb5041f49b23bf2d5414c1299dbMon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Sat, 2 Jan 2010 10:37:57 -0800
Subject: [PATCH] timer: Introduce mod_timer_msec()
It is a common paradigm in drivers to want to set/change a timer for a relative amount of milliseconds.
This patch adds a mod_timer_msec() API function to make this easier and to remove the awareness of both "jiffies" and the HZ value from various drivers that don't care about such implementation detail.
Conversion of various users of the API are done in separate patches that will go via the various maintainers separately.
--- include/linux/timer.h | 1 + kernel/timer.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-)
include/linux/timer.h +1 -0
@@ -162,6 +162,7 @@ static inline int timer_pending(const struct timer_list * timer)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_msec (struct timer_list *timer,unsigned long delay_ms);extern int mod_timer_pending (struct timer_list *timer,unsigned long expires);extern int mod_timer_pinned (struct timer_list *timer,unsigned long expires);
kernel/timer.c +20 -0
@@ -749,6 +749,26 @@ int mod_timer(struct timer_list *timer, unsigned long expires)EXPORT_SYMBOL (mod_timer);/** +* mod_timer_msec - modify a timer's timeout, using relative milliseconds +* @timer: the timer to be modified +* @delay_ms: the desired minimum delay in milliseconds +* +* Changes the timeout of a timer similar to mod_timer(). +* +* mod_timer_msec() takes relative milliseconds rather than absolute +* jiffies as argument. +* +* The function returns whether it has modified a pending timer or not. +* (ie. mod_timer_msec() of an inactive timer returns 0, mod_timer_msec() of +* an active timer returns 1.) +*/ +int mod_timer_msec (struct timer_list *timer,unsigned long delay_ms) +{ +return mod_timer (timer,msecs_to_jiffies (delay_ms)); +} +EXPORT_SYMBOL (mod_timer_msec); + +/** * mod_timer_pinned - modify a timer's timeout * @timer: the timer to be modified * @expires: new timeout in jiffies
Signature · 8 lines
1.6.2.5 -- Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org
users of mod_timer_msec()
just for illustration at this point:
example users of the mod_timer_msec() API... after the review/merge of the primary patch this will be sent to the various maintainers...
drivers/ata/ahci.c +2 -2
@@ -1367,7 +1367,7 @@ static void ahci_sw_activity(struct ata_link *link) emp->activity++;if (!timer_pending (&emp->timer)) -mod_timer (&emp->timer, jiffies +msecs_to_jiffies (10 )); +mod_timer_msec (&emp->timer,10 ); }static void ahci_sw_activity_blink (unsigned long arg)
@@ -1403,7 +1403,7 @@ static void ahci_sw_activity_blink(unsigned long arg)/* toggle state */ led_message |= (activity_led_state <<16 ); -mod_timer (&emp->timer, jiffies +msecs_to_jiffies (100 )); +mod_timer_msec (&emp->timer,100 ); }else {/* switch to idle */ led_message &= ~EM_MSG_LED_VALUE_ACTIVITY ;
drivers/atm/iphase.c +1 -1
@@ -2428,7 +2428,7 @@ static void ia_led_timer(unsigned long arg) { } } } -mod_timer (&ia_timer, jiffies +HZ /4 ); +mod_timer_msec (&ia_timer,250 );return ; }
drivers/bluetooth/bluecard_cs.c +2 -2
@@ -188,13 +188,13 @@ static void bluecard_enable_activity_led(bluecard_info_t *info)outb (0x10 |0x40 , iobase +0x30 );/* Stop the LED after HZ/4 */ -mod_timer (&(info->timer), jiffies +HZ /4 ); +mod_timer_msec (&(info->timer),250 ); }else {/* Enable power LED */ outb (0x08 |0x20 , iobase +0x30 );/* Stop the LED after HZ/2 */ -mod_timer (&(info->timer), jiffies +HZ /2 ); +mod_timer_msec (&(info->timer),500 ); } }
drivers/bluetooth/hci_bcsp.c +1 -1
@@ -312,7 +312,7 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)struct sk_buff *nskb =bcsp_prepare_pkt (bcsp, skb->data, skb->len,bt_cb (skb)->pkt_type);if (nskb) {__skb_queue_tail (&bcsp->unack, skb); -mod_timer (&bcsp->tbcsp, jiffies +HZ /4 ); +mod_timer_msec (&bcsp->tbcsp,250 );spin_unlock_irqrestore (&bcsp->unack.lock, flags);return nskb; }else {
drivers/char/isicom.c +1 -1
@@ -506,7 +506,7 @@ unlock:spin_unlock_irqrestore (&isi_card[card].card_lock, flags);/* schedule another tx for hopefully in about 10ms */ sched_again: -mod_timer (&tx, jiffies +msecs_to_jiffies (10 )); +mod_timer_msec (&tx,10 ); }/*
drivers/char/moxa.c +2 -2
@@ -882,7 +882,7 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)spin_lock_bh (&moxa_lock); brd->ready =1 ;if (!timer_pending (&moxaTimer)) -mod_timer (&moxaTimer, jiffies +HZ /50 ); +mod_timer_msec (&moxaTimer,20 );spin_unlock_bh (&moxa_lock);return 0 ;
@@ -1464,7 +1464,7 @@ static void moxa_poll(unsigned long ignored) moxaLowWaterChk =0 ;if (served) -mod_timer (&moxaTimer, jiffies +HZ /50 ); +mod_timer_msec (&moxaTimer,20 );spin_unlock (&moxa_lock); }
drivers/char/synclink.c +2 -3
@@ -4024,7 +4024,7 @@ static bool load_next_tx_holding_buffer(struct mgsl_struct *info) info->get_tx_holding_index=0 ;/* restart transmit timer */ -mod_timer (&info->tx_timer, jiffies +msecs_to_jiffies (5000 )); +mod_timer_msec (&info->tx_timer,5000 ); ret = true; }
@@ -5653,8 +5653,7 @@ static void usc_start_transmitter( struct mgsl_struct *info )usc_TCmd ( info, TCmd_SendFrame ); -mod_timer (&info->tx_timer, jiffies + -msecs_to_jiffies (5000 )); +mod_timer_msec (&info->tx_timer,5000 ); } info->tx_active = true; }
drivers/char/synclink_gt.c +1 -1
@@ -803,7 +803,7 @@ static void update_tx_timer(struct slgt_info *info)*/ if (info->params.mode ==MGSL_MODE_HDLC ) {int timeout = (tbuf_bytes (info) *7 ) +1000 ; -mod_timer (&info->tx_timer, jiffies +msecs_to_jiffies (timeout)); +mod_timer_msec (&info->tx_timer, timeout); } }
drivers/char/synclinkmp.c +3 -4
@@ -2685,7 +2685,7 @@ static int startup(SLMP_INFO * info)change_params (info); -mod_timer (&info->status_timer, jiffies +msecs_to_jiffies (10 )); +mod_timer_msec (&info->status_timer,10 );if (info->port.tty)clear_bit (TTY_IO_ERROR , &info->port.tty->flags);
@@ -4252,8 +4252,7 @@ static void tx_start(SLMP_INFO *info)write_reg (info,TXDMA +DIR ,0x40 );/* enable Tx DMA interrupts (EOM) */ write_reg (info,TXDMA +DSR ,0xf2 );/* clear Tx DMA IRQs, enable Tx DMA */ -mod_timer (&info->tx_timer, jiffies + -msecs_to_jiffies (5000 )); +mod_timer_msec (&info->tx_timer,5000 ); }else {tx_load_fifo (info);
@@ -5534,7 +5533,7 @@ static void status_timeout(unsigned long context)if (status)isr_io_pin (info,status); -mod_timer (&info->status_timer, jiffies +msecs_to_jiffies (10 )); +mod_timer_msec (&info->status_timer,10 ); }
drivers/input/gameport/gameport.c +2 -2
@@ -147,7 +147,7 @@ void gameport_start_polling(struct gameport *gameport)if (!gameport->poll_cnt++) {BUG_ON (!gameport->poll_handler);BUG_ON (!gameport->poll_interval); -mod_timer (&gameport->poll_timer, jiffies +msecs_to_jiffies (gameport->poll_interval)); +mod_timer_msec (&gameport->poll_timer, gameport->poll_interval); }spin_unlock (&gameport->timer_lock);
@@ -171,7 +171,7 @@ static void gameport_run_poll_handler(unsigned long d) gameport->poll_handler (gameport);if (gameport->poll_cnt) -mod_timer (&gameport->poll_timer, jiffies +msecs_to_jiffies (gameport->poll_interval)); +mod_timer_msec (&gameport->poll_timer, gameport->poll_interval); }/*
drivers/input/keyboard/corgikbd.c +3 -3
@@ -179,7 +179,7 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data)/* if any keys are pressed, enable the timer */ if (num_pressed) -mod_timer (&corgikbd_data->timer, jiffies +msecs_to_jiffies (SCAN_INTERVAL )); +mod_timer_msec (&corgikbd_data->timer,SCAN_INTERVAL );spin_unlock_irqrestore (&corgikbd_data->lock, flags); }
@@ -249,7 +249,7 @@ static void corgikbd_hinge_timer(unsigned long data)spin_unlock_irqrestore (&corgikbd_data->lock, flags); } } -mod_timer (&corgikbd_data->htimer, jiffies +msecs_to_jiffies (HINGE_SCAN_INTERVAL )); +mod_timer_msec (&corgikbd_data->htimer,HINGE_SCAN_INTERVAL ); }#ifdef CONFIG_PM
@@ -341,7 +341,7 @@ static int __devinit corgikbd_probe(struct platform_device *pdev)if (err) goto fail; -mod_timer (&corgikbd->htimer, jiffies +msecs_to_jiffies (HINGE_SCAN_INTERVAL )); +mod_timer_msec (&corgikbd->htimer,HINGE_SCAN_INTERVAL );/* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ for (i =0 ; i <CORGI_KEY_SENSE_NUM ; i++) {
drivers/input/keyboard/spitzkbd.c +4 -4
@@ -228,7 +228,7 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data)/* if any keys are pressed, enable the timer */ if (num_pressed) -mod_timer (&spitzkbd_data->timer, jiffies +msecs_to_jiffies (SCAN_INTERVAL )); +mod_timer_msec (&spitzkbd_data->timer,SCAN_INTERVAL );spin_unlock_irqrestore (&spitzkbd_data->lock, flags); }
@@ -269,7 +269,7 @@ static irqreturn_t spitzkbd_hinge_isr(int irq, void *dev_id)struct spitzkbd *spitzkbd_data = dev_id;if (!timer_pending (&spitzkbd_data->htimer)) -mod_timer (&spitzkbd_data->htimer, jiffies +msecs_to_jiffies (HINGE_SCAN_INTERVAL )); +mod_timer_msec (&spitzkbd_data->htimer,HINGE_SCAN_INTERVAL );return IRQ_HANDLED ; }
@@ -303,7 +303,7 @@ static void spitzkbd_hinge_timer(unsigned long data)spin_unlock_irqrestore (&spitzkbd_data->lock, flags); }else { -mod_timer (&spitzkbd_data->htimer, jiffies +msecs_to_jiffies (HINGE_SCAN_INTERVAL )); +mod_timer_msec (&spitzkbd_data->htimer,HINGE_SCAN_INTERVAL ); } }
@@ -399,7 +399,7 @@ static int __devinit spitzkbd_probe(struct platform_device *dev)if (err) goto fail; -mod_timer (&spitzkbd->htimer, jiffies +msecs_to_jiffies (HINGE_SCAN_INTERVAL )); +mod_timer_msec (&spitzkbd->htimer,HINGE_SCAN_INTERVAL );/* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ for (i =0 ; i <SPITZ_KEY_SENSE_NUM ; i++) {
drivers/input/serio/hil_mlc.c +1 -1
@@ -790,7 +790,7 @@ static void hil_mlcs_timer(unsigned long data)tasklet_schedule (&hil_mlcs_tasklet);/* Re-insert the periodic task. */ if (!timer_pending (&hil_mlcs_kicker)) -mod_timer (&hil_mlcs_kicker, jiffies +HZ ); +mod_timer_msec (&hil_mlcs_kicker,1000 ); }/******************** user/kernel context functions **********************/
drivers/input/serio/hp_sdc.c +1 -1
@@ -799,7 +799,7 @@ void hp_sdc_kicker (unsigned long data) {tasklet_schedule (&hp_sdc.task);/* Re-insert the periodic task. */ -mod_timer (&hp_sdc.kicker, jiffies +HZ ); +mod_timer_msec (&hp_sdc.kicker,1000 ); }/************************** Module Initialization ***************************/
drivers/input/touchscreen/corgi_ts.c +2 -2
@@ -199,10 +199,10 @@ static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer) corgi_ts->pendown =1 ;new_data (corgi_ts); } -mod_timer (&corgi_ts->timer, jiffies +HZ /100 ); +mod_timer_msec (&corgi_ts->timer,10 ); }else {if (corgi_ts->pendown ==1 || corgi_ts->pendown ==2 ) { -mod_timer (&corgi_ts->timer, jiffies +HZ /100 ); +mod_timer_msec (&corgi_ts->timer,10 ); corgi_ts->pendown++;return ; }
drivers/input/touchscreen/w90p910_ts.c +1 -1
@@ -133,7 +133,7 @@ static irqreturn_t w90p910_ts_interrupt(int irq, void *dev_id)case TS_WAIT_Y_COORD :w90p910_report_event (w90p910_ts, true);w90p910_prepare_next_packet (w90p910_ts); -mod_timer (&w90p910_ts->timer, jiffies +msecs_to_jiffies (100 )); +mod_timer_msec (&w90p910_ts->timer,100 );break ;case TS_IDLE :
drivers/isdn/gigaset/common.c +1 -1
@@ -178,7 +178,7 @@ static void timer_tick(unsigned long data) timeout =1 ;if (cs->running) { -mod_timer (&cs->timer, jiffies +msecs_to_jiffies (GIG_TICK )); +mod_timer_msec (&cs->timer,GIG_TICK );if (timeout) {gig_dbg (DEBUG_CMD ,"scheduling timeout" );tasklet_schedule (&cs->event_tasklet);
drivers/leds/ledtrig-ide-disk.c +2 -2
@@ -29,7 +29,7 @@ void ledtrig_ide_activity(void) { ide_activity++;if (!timer_pending (&ledtrig_ide_timer)) -mod_timer (&ledtrig_ide_timer, jiffies +msecs_to_jiffies (10 )); +mod_timer_msec (&ledtrig_ide_timer,10 ); }EXPORT_SYMBOL (ledtrig_ide_activity);
@@ -39,7 +39,7 @@ static void ledtrig_ide_timerfunc(unsigned long data) ide_lastactivity = ide_activity;/* INT_MAX will set each LED to its maximum brightness */ led_trigger_event (ledtrig_ide,INT_MAX ); -mod_timer (&ledtrig_ide_timer, jiffies +msecs_to_jiffies (10 )); +mod_timer_msec (&ledtrig_ide_timer,10 ); }else {led_trigger_event (ledtrig_ide,LED_OFF ); }
drivers/leds/ledtrig-timer.c +1 -1
@@ -61,7 +61,7 @@ static void led_timer_function(unsigned long data)led_set_brightness (led_cdev, brightness); -mod_timer (&timer_data->timer, jiffies +msecs_to_jiffies (delay)); +mod_timer_msec (&timer_data->timer, delay); } static ssize_t led_delay_on_show(struct device *dev,
drivers/media/dvb/ttpci/budget-ci.c +1 -1
@@ -182,7 +182,7 @@ static void msp430_ir_interrupt(unsigned long data) budget_ci->ir.last_raw = raw; } -mod_timer (&budget_ci->ir.timer_keyup, jiffies +msecs_to_jiffies (IR_KEYPRESS_TIMEOUT )); +mod_timer_msec (&budget_ci->ir.timer_keyup,IR_KEYPRESS_TIMEOUT ); }static int msp430_ir_init (struct budget_ci *budget_ci)
drivers/media/video/bt8xx/bttv-input.c +1 -1
@@ -141,7 +141,7 @@ static void bttv_input_timer(unsigned long data)ir_enltv_handle_key (btv); elseir_handle_key (btv ); -mod_timer (&ir->timer, jiffies +msecs_to_jiffies (ir->polling)); +mod_timer_msec (&ir->timer, ir->polling); }/* ---------------------------------------------------------------*/
drivers/media/video/cx231xx/cx231xx-input.c +1 -1
@@ -146,7 +146,7 @@ static void cx231xx_ir_work(struct work_struct *work) struct cx231xx_IR *ir = container_of(work, struct cx231xx_IR, work);cx231xx_ir_handle_key (ir); -mod_timer (&ir->timer, jiffies +msecs_to_jiffies (ir->polling)); +mod_timer_msec (&ir->timer, ir->polling); }void cx231xx_ir_start (struct cx231xx_IR *ir)
drivers/media/video/saa7134/saa7134-input.c +2 -2
@@ -413,7 +413,7 @@ static void saa7134_input_timer(unsigned long data)struct card_ir *ir = dev->remote;build_key (dev); -mod_timer (&ir->timer, jiffies +msecs_to_jiffies (ir->polling)); +mod_timer_msec (&ir->timer, ir->polling); }void saa7134_ir_start (struct saa7134_dev *dev,struct card_ir *ir)
@@ -1007,7 +1007,7 @@ static void nec_task(unsigned long data)dprintk ("Repeat last key\n" );/* Keep repeating the last key */ -mod_timer (&ir->timer_keyup, jiffies +msecs_to_jiffies (150 )); +mod_timer_msec (&ir->timer_keyup,150 );saa_setl (SAA7134_IRQ2 ,SAA7134_IRQ2_INTE_GPIO18 ); }
drivers/media/video/tvaudio.c +2 -2
@@ -329,7 +329,7 @@ static int chip_thread(void *data) desc->setmode (chip,V4L2_TUNER_MODE_MONO );/* schedule next check */ -mod_timer (&chip->wt, jiffies+msecs_to_jiffies (2000 )); +mod_timer_msec (&chip->wt,2000 ); }v4l2_dbg (1 , debug, sd,"thread exiting\n" );
@@ -1893,7 +1893,7 @@ static int tvaudio_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *fr desc->setmode (chip,V4L2_TUNER_MODE_MONO );if (chip->prevmode !=V4L2_TUNER_MODE_MONO ) chip->prevmode =-1 ;/* reset previous mode */ -mod_timer (&chip->wt, jiffies+msecs_to_jiffies (2000 )); +mod_timer_msec (&chip->wt,2000 ); }return 0 ; }
drivers/mmc/host/atmel-mci.c +1 -1
@@ -1534,7 +1534,7 @@ static irqreturn_t atmci_detect_interrupt(int irq, void *dev_id)* middle of the timer routine when this interrupt triggers. */ disable_irq_nosync (irq); -mod_timer (&slot->detect_timer, jiffies +msecs_to_jiffies (20 )); +mod_timer_msec (&slot->detect_timer,20 );return IRQ_HANDLED ; }
drivers/mmc/host/wbsd.c +1 -1
@@ -906,7 +906,7 @@ static void wbsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)* We cannot resume card detection immediatly * because of capacitance and delays in the chip. */ -mod_timer (&host->ignore_timer, jiffies +HZ /100 ); +mod_timer_msec (&host->ignore_timer,10 ); } }wbsd_write_index (host,WBSD_IDX_SETUP , setup);
drivers/net/s2io.c +2 -2
@@ -4309,7 +4309,7 @@ s2io_alarm_handle(unsigned long data)struct net_device *dev = sp->dev;s2io_handle_errors (dev); -mod_timer (&sp->alarm_timer, jiffies +HZ /2 ); +mod_timer_msec (&sp->alarm_timer,500 ); }static irqreturn_t s2io_msix_ring_handle (int irq,void *dev_id)
@@ -5483,7 +5483,7 @@ static void s2io_phy_id(unsigned long data)writeq (val64, &bar0->adapter_control); } -mod_timer (&sp->id_timer, jiffies +HZ /2 ); +mod_timer_msec (&sp->id_timer,500 ); }/**
drivers/net/wireless/at76c50x-usb.c +2 -2
@@ -545,7 +545,7 @@ static void at76_ledtrig_tx_timerfunc(unsigned long data)if (tx_lastactivity != tx_activity) { tx_lastactivity = tx_activity;led_trigger_event (ledtrig_tx,LED_FULL ); -mod_timer (&ledtrig_tx_timer, jiffies +HZ /4 ); +mod_timer_msec (&ledtrig_tx_timer,250 ); }else led_trigger_event (ledtrig_tx,LED_OFF ); }
@@ -554,7 +554,7 @@ static void at76_ledtrig_tx_activity(void) { tx_activity++;if (!timer_pending (&ledtrig_tx_timer)) -mod_timer (&ledtrig_tx_timer, jiffies +HZ /4 ); +mod_timer_msec (&ledtrig_tx_timer,250 ); }static int at76_remap (struct usb_device *udev)
drivers/net/wireless/ath/ath9k/main.c +3 -5
@@ -449,7 +449,7 @@ set_timer:if (!common->ani.caldone) cal_interval =min (cal_interval, (u32 )short_cal_interval); -mod_timer (&common->ani.timer, jiffies +msecs_to_jiffies (cal_interval)); +mod_timer_msec (&common->ani.timer, cal_interval); }static void ath_start_ani (struct ath_common *common)
@@ -460,8 +460,7 @@ static void ath_start_ani(struct ath_common *common) common->ani.shortcal_timer = timestamp; common->ani.checkani_timer = timestamp; -mod_timer (&common->ani.timer, - jiffies +msecs_to_jiffies (ATH_ANI_POLLINTERVAL )); +mod_timer_msec (&common->ani.timer,ATH_ANI_POLLINTERVAL ); }/*
@@ -1493,8 +1492,7 @@ static void ath_btcoex_period_timer(unsigned long data) btcoex->hw_timer_enabled = true; } -mod_timer (&btcoex->period_timer, jiffies + -msecs_to_jiffies (ATH_BTCOEX_DEF_BT_PERIOD )); +mod_timer_msec (&btcoex->period_timer,ATH_BTCOEX_DEF_BT_PERIOD ); }/*
drivers/pci/intel-iommu.c +1 -1
@@ -2706,7 +2706,7 @@ static void add_unmap(struct dmar_domain *dom, struct iova *iova) deferred_flush[iommu_id].next++;if (!timer_on) { -mod_timer (&unmap_timer, jiffies +msecs_to_jiffies (10 )); +mod_timer_msec (&unmap_timer,10 ); timer_on =1 ; } list_size++;
drivers/scsi/bfa/bfad.c +2 -2
@@ -558,7 +558,7 @@ bfad_bfa_tmo(unsigned long data)spin_unlock_irqrestore (&bfad->bfad_lock, flags); } -mod_timer (&bfad->hal_tmo, jiffies +msecs_to_jiffies (BFA_TIMER_FREQ )); +mod_timer_msec (&bfad->hal_tmo,BFA_TIMER_FREQ ); }void
@@ -568,7 +568,7 @@ bfad_init_timer(struct bfad_s *bfad) bfad->hal_tmo.function = bfad_bfa_tmo; bfad->hal_tmo.data = (unsigned long )bfad; -mod_timer (&bfad->hal_tmo, jiffies +msecs_to_jiffies (BFA_TIMER_FREQ )); +mod_timer_msec (&bfad->hal_tmo,BFA_TIMER_FREQ ); }int
drivers/scsi/cxgb3i/cxgb3i_offload.c +1 -1
@@ -838,7 +838,7 @@ static void process_act_open_rpl(struct s3_conn *c3cn, struct sk_buff *skb)if (rpl->status ==CPL_ERR_CONN_EXIST && c3cn->retry_timer.function != act_open_retry_timer) { c3cn->retry_timer.function = act_open_retry_timer; -if (!mod_timer (&c3cn->retry_timer, jiffies +HZ /2 )) +if (!mod_timer_msec (&c3cn->retry_timer,500 ))c3cn_hold (c3cn); }else fail_act_open (c3cn,act_open_rpl_status_to_errno (rpl->status));
drivers/staging/otus/usbdrv.c +2 -2
@@ -397,7 +397,7 @@ int usbdrv_open(struct net_device *dev)zfLnxCreateThread (dev); -mod_timer (&(macp->hbTimer10ms), jiffies + (1 *HZ )/100 );/* 10 ms */ +mod_timer_msec (&(macp->hbTimer10ms),10 );netif_carrier_on (dev);
@@ -711,7 +711,7 @@ void zfLnx10msTimer(struct net_device* dev) {struct usbdrv_private *macp = dev->ml_priv; -mod_timer (&(macp->hbTimer10ms), jiffies + (1 *HZ )/100 );//10 ms +mod_timer_msec (&(macp->hbTimer10ms),10 );zfiHeartBeat (dev);return ; }
drivers/usb/atm/speedtch.c +4 -4
@@ -582,7 +582,7 @@ static void speedtch_status_poll(unsigned long data)/* The following check is racy, but the race is harmless */ if (instance->poll_delay <MAX_POLL_DELAY ) -mod_timer (&instance->status_checker.timer, jiffies +msecs_to_jiffies (instance->poll_delay)); +mod_timer_msec (&instance->status_checker.timer, instance->poll_delay);else atm_warn (instance->usbatm,"Too many failures - disabling line status polling\n" ); }
@@ -601,7 +601,7 @@ static void speedtch_resubmit_int(unsigned long data)schedule_delayed_work (&instance->status_checker,0 ); else {atm_dbg (instance->usbatm,"%s: usb_submit_urb failed with result %d\n" , __func__, ret); -mod_timer (&instance->resubmit_timer, jiffies +msecs_to_jiffies (RESUBMIT_DELAY )); +mod_timer_msec (&instance->resubmit_timer,RESUBMIT_DELAY ); } } }
@@ -654,7 +654,7 @@ static void speedtch_handle_int(struct urb *int_urb) fail:if ((int_urb = instance->int_urb)) -mod_timer (&instance->resubmit_timer, jiffies +msecs_to_jiffies (RESUBMIT_DELAY )); +mod_timer_msec (&instance->resubmit_timer,RESUBMIT_DELAY ); }static int speedtch_atm_start (struct usbatm_data *usbatm,struct atm_dev *atm_dev)
@@ -688,7 +688,7 @@ static int speedtch_atm_start(struct usbatm_data *usbatm, struct atm_dev *atm_de }/* Start status polling */ -mod_timer (&instance->status_checker.timer, jiffies +msecs_to_jiffies (1000 )); +mod_timer_msec (&instance->status_checker.timer,1000 );return 0 ; }
drivers/usb/atm/usbatm.c +2 -2
@@ -248,7 +248,7 @@ static int usbatm_submit_urb(struct urb *urb)spin_unlock_irq (&channel->lock);/* make sure the channel doesn't stall */ -mod_timer (&channel->delay, jiffies +msecs_to_jiffies (THROTTLE_MSECS )); +mod_timer_msec (&channel->delay,THROTTLE_MSECS ); }return ret;
@@ -282,7 +282,7 @@ static void usbatm_complete(struct urb *urb)atm_warn (channel->usbatm,"%s: urb 0x%p failed (%d)!\n" , __func__, urb, status);/* throttle processing in case of an error */ -mod_timer (&channel->delay, jiffies +msecs_to_jiffies (THROTTLE_MSECS )); +mod_timer_msec (&channel->delay,THROTTLE_MSECS ); }else tasklet_schedule (&channel->tasklet); }
drivers/usb/core/hcd.c +1 -1
@@ -1901,7 +1901,7 @@ int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num)* it may issue others, until at least 50 msecs have passed. */ if (status ==0 ) -mod_timer (&hcd->rh_timer, jiffies +msecs_to_jiffies (10 )); +mod_timer_msec (&hcd->rh_timer,10 );return status; }EXPORT_SYMBOL_GPL (usb_bus_start_enum);
drivers/usb/gadget/dummy_hcd.c +1 -1
@@ -1520,7 +1520,7 @@ return_urb: dum->udev =NULL ; }else if (dum->rh_state ==DUMMY_RH_RUNNING ) {/* want a 1 msec delay here */ -mod_timer (&dum->timer, jiffies +msecs_to_jiffies (1 )); +mod_timer_msec (&dum->timer,1 ); }spin_unlock_irqrestore (&dum->lock, flags);
drivers/usb/gadget/m66592-udc.c +4 -7
@@ -1229,8 +1229,7 @@ static irqreturn_t m66592_irq(int irq, void *_m66592) &M66592_VBSTS ; m66592->scount =M66592_MAX_SAMPLING ; -mod_timer (&m66592->timer, - jiffies +msecs_to_jiffies (50 )); +mod_timer_msec (&m66592->timer,50 ); }if (intsts0 &M66592_DVSQ )irq_device_state (m66592);
@@ -1277,14 +1276,12 @@ static void m66592_timer(unsigned long _m66592)else m66592_usb_disconnect (m66592); }else { -mod_timer (&m66592->timer, - jiffies +msecs_to_jiffies (50 )); +mod_timer_msec (&m66592->timer,50 ); } }else { m66592->scount =M66592_MAX_SAMPLING ; m66592->old_vbus = tmp; -mod_timer (&m66592->timer, - jiffies +msecs_to_jiffies (50 )); +mod_timer_msec (&m66592->timer,50 ); } }spin_unlock_irqrestore (&m66592->lock, flags);
@@ -1493,7 +1490,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) m66592->old_vbus =m66592_read (m66592,M66592_INTSTS0 ) &M66592_VBSTS ; m66592->scount =M66592_MAX_SAMPLING ; -mod_timer (&m66592->timer, jiffies +msecs_to_jiffies (50 )); +mod_timer_msec (&m66592->timer,50 ); }return 0 ;
drivers/usb/gadget/r8a66597-udc.c +4 -7
@@ -1167,8 +1167,7 @@ static irqreturn_t r8a66597_irq(int irq, void *_r8a66597) &VBSTS ; r8a66597->scount =R8A66597_MAX_SAMPLING ; -mod_timer (&r8a66597->timer, - jiffies +msecs_to_jiffies (50 )); +mod_timer_msec (&r8a66597->timer,50 ); }if (intsts0 &DVSQ )irq_device_state (r8a66597);
@@ -1208,14 +1207,12 @@ static void r8a66597_timer(unsigned long _r8a66597)else r8a66597_usb_disconnect (r8a66597); }else { -mod_timer (&r8a66597->timer, - jiffies +msecs_to_jiffies (50 )); +mod_timer_msec (&r8a66597->timer,50 ); } }else { r8a66597->scount =R8A66597_MAX_SAMPLING ; r8a66597->old_vbus = tmp; -mod_timer (&r8a66597->timer, - jiffies +msecs_to_jiffies (50 )); +mod_timer_msec (&r8a66597->timer,50 ); } }spin_unlock_irqrestore (&r8a66597->lock, flags);
@@ -1443,7 +1440,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) r8a66597->old_vbus =r8a66597_read (r8a66597,INTSTS0 ) &VBSTS ; r8a66597->scount =R8A66597_MAX_SAMPLING ; -mod_timer (&r8a66597->timer, jiffies +msecs_to_jiffies (50 )); +mod_timer_msec (&r8a66597->timer,50 ); }return 0 ;
drivers/usb/host/ohci-hcd.c +1 -1
@@ -485,7 +485,7 @@ static void unlink_watchdog_func(unsigned long _ohci) out:kfree (seen);if (ohci->eds_scheduled) -mod_timer (&ohci->unlink_watchdog,round_jiffies (jiffies +HZ )); +mod_timer_msec (&ohci->unlink_watchdog,1000 ); done:spin_unlock_irqrestore (&ohci->lock, flags); }
drivers/usb/host/xhci-hcd.c +1 -1
@@ -365,7 +365,7 @@ void xhci_event_ring_work(unsigned long arg)spin_unlock_irqrestore (&xhci->lock, flags);if (!xhci->zombie) -mod_timer (&xhci->event_ring_timer, jiffies +POLL_TIMEOUT *HZ ); +mod_timer_msec (&xhci->event_ring_timer,POLL_TIMEOUT *1000 );else xhci_dbg (xhci,"Quit polling the event ring.\n" ); }
drivers/watchdog/bcm47xx_wdt.c +1 -1
@@ -66,7 +66,7 @@ static void bcm47xx_timer_tick(unsigned long unused) {if (!atomic_dec_and_test (&ticks)) {bcm47xx_wdt_hw_start (); -mod_timer (&wdt_timer, jiffies +HZ ); +mod_timer_msec (&wdt_timer,1000 ); }else { printk(KERN_CRIT DRV_NAME "Watchdog will fire soon!!!\n"); }
drivers/watchdog/mixcomwd.c +2 -2
@@ -122,7 +122,7 @@ static void mixcomwd_ping(void)static void mixcomwd_timerfun (unsigned long d) {mixcomwd_ping (); -mod_timer (&mixcomwd_timer, jiffies +5 *HZ ); +mod_timer_msec (&mixcomwd_timer,5000 ); }/*
@@ -161,7 +161,7 @@ static int mixcomwd_release(struct inode *inode, struct file *file)return -EBUSY ; } mixcomwd_timer_alive =1 ; -mod_timer (&mixcomwd_timer, jiffies +5 *HZ ); +mod_timer_msec (&mixcomwd_timer,5000 ); }else printk(KERN_CRIT PFX"WDT device closed unexpectedly. WDT will not stop!\n" );
drivers/watchdog/softdog.c +1 -1
@@ -111,7 +111,7 @@ static void watchdog_fire(unsigned long data)static int softdog_keepalive (void ) { -mod_timer (&watchdog_ticktock, jiffies+(soft_margin*HZ )); +mod_timer_msec (&watchdog_ticktock, soft_margin*1000 );return 0 ; }
drivers/xen/balloon.c +1 -1
@@ -347,7 +347,7 @@ static void balloon_process(struct work_struct *work)/* Schedule more work if there is some still to be done. */ if (current_target () != balloon_stats.current_pages) -mod_timer (&balloon_timer, jiffies +HZ ); +mod_timer_msec (&balloon_timer,1000 );mutex_unlock (&balloon_mutex); }
net/atm/lec.c +1 -1
@@ -1766,7 +1766,7 @@ static void lec_arp_expire_arp(unsigned long data) entry->mac_addr, NULL, NULL); entry->no_tries++; } -mod_timer (&entry->timer, jiffies + (1 *HZ )); +mod_timer_msec (&entry->timer,1000 ); } }
net/ax25/ax25_ds_timer.c +1 -1
@@ -59,7 +59,7 @@ void ax25_ds_set_timer(ax25_dev *ax25_dev) ax25_dev->dama.slave_timeout =msecs_to_jiffies (ax25_dev->values[AX25_VALUES_DS_TIMEOUT ]) /10 ; -mod_timer (&ax25_dev->dama.slave_timer, jiffies +HZ ); +mod_timer_msec (&ax25_dev->dama.slave_timer,1000 ); }/*
net/ax25/ax25_timer.c +1 -1
@@ -52,7 +52,7 @@ void ax25_setup_timers(ax25_cb *ax25)void ax25_start_heartbeat (ax25_cb *ax25) { -mod_timer (&ax25->timer, jiffies +5 *HZ ); +mod_timer_msec (&ax25->timer,5000 ); }void ax25_start_t1timer (ax25_cb *ax25)
net/dsa/mv88e6xxx.c +1 -1
@@ -309,7 +309,7 @@ static void mv88e6xxx_ppu_access_put(struct dsa_switch *ds)/* * Schedule a timer to re-enable the PHY polling unit. */ -mod_timer (&ps->ppu_timer, jiffies +msecs_to_jiffies (10 )); +mod_timer_msec (&ps->ppu_timer,10 );mutex_unlock (&ps->ppu_mutex); }
net/ipv4/ipmr.c +1 -1
@@ -372,7 +372,7 @@ static void ipmr_expire_process(unsigned long dummy)struct mfc_cache *c, **cp;if (!spin_trylock (&mfc_unres_lock)) { -mod_timer (&ipmr_expire_timer, jiffies+HZ /10 ); +mod_timer_msec (&ipmr_expire_timer,100 );return ; }
net/ipv6/ip6_fib.c +1 -1
@@ -1445,7 +1445,7 @@ void fib6_run_gc(unsigned long expires, struct net *net) net->ipv6.sysctl.ip6_rt_gc_interval; }else {if (!spin_trylock_bh (&fib6_gc_lock)) { -mod_timer (&net->ipv6.ip6_fib_timer, jiffies +HZ ); +mod_timer_msec (&net->ipv6.ip6_fib_timer,1000 );return ; } gc_args.timeout = net->ipv6.sysctl.ip6_rt_gc_interval;
net/netrom/nr_timer.c +1 -1
@@ -81,7 +81,7 @@ void nr_start_idletimer(struct sock *sk)void nr_start_heartbeat (struct sock *sk) { -mod_timer (&sk->sk_timer, jiffies +5 *HZ ); +mod_timer_msec (&sk->sk_timer,5000 ); }void nr_stop_t1timer (struct sock *sk)
net/sctp/sm_sideeffect.c +3 -3
@@ -254,7 +254,7 @@ void sctp_generate_t3_rtx_event(unsigned long peer)SCTP_DEBUG_PRINTK ("%s:Sock is busy.\n" , __func__);/* Try again later. */ -if (!mod_timer (&transport->T3_rtx_timer, jiffies + (HZ /20 ))) +if (!mod_timer_msec (&transport->T3_rtx_timer,50 ))sctp_transport_hold (transport); goto out_unlock; }
@@ -295,7 +295,7 @@ static void sctp_generate_timeout_event(struct sctp_association *asoc, timeout_type);/* Try again later. */ -if (!mod_timer (&asoc->timers[timeout_type], jiffies + (HZ /20 ))) +if (!mod_timer_msec (&asoc->timers[timeout_type],50 ))sctp_association_hold (asoc); goto out_unlock; }
@@ -372,7 +372,7 @@ void sctp_generate_heartbeat_event(unsigned long data)SCTP_DEBUG_PRINTK ("%s:Sock is busy.\n" , __func__);/* Try again later. */ -if (!mod_timer (&transport->hb_timer, jiffies + (HZ /20 ))) +if (!mod_timer_msec (&transport->hb_timer,50 ))sctp_transport_hold (transport); goto out_unlock; }
net/sunrpc/svc_xprt.c +4 -4
@@ -718,8 +718,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)setup_timer (&serv->sv_temptimer, svc_age_temp_xprts, (unsigned long )serv); -mod_timer (&serv->sv_temptimer, - jiffies + svc_conn_age_period *HZ ); +mod_timer_msec (&serv->sv_temptimer, + svc_conn_age_period *1000 ); }spin_unlock_bh (&serv->sv_lock);svc_xprt_received (newxpt);
@@ -823,7 +823,7 @@ static void svc_age_temp_xprts(unsigned long closure)if (!spin_trylock_bh (&serv->sv_lock)) {/* busy, try again 1 sec later */ dprintk ("svc_age_temp_xprts: busy\n" ); -mod_timer (&serv->sv_temptimer, jiffies +HZ ); +mod_timer_msec (&serv->sv_temptimer,1000 );return ; }
@@ -857,7 +857,7 @@ static void svc_age_temp_xprts(unsigned long closure)svc_xprt_put (xprt); } -mod_timer (&serv->sv_temptimer, jiffies + svc_conn_age_period *HZ ); +mod_timer_msec (&serv->sv_temptimer, svc_conn_age_period *1000 ); }/*
net/x25/x25_timer.c +1 -1
@@ -42,7 +42,7 @@ void x25_init_timers(struct sock *sk)void x25_start_heartbeat (struct sock *sk) { -mod_timer (&sk->sk_timer, jiffies +5 *HZ ); +mod_timer_msec (&sk->sk_timer,5000 ); }void x25_stop_heartbeat (struct sock *sk)
net/xfrm/xfrm_policy.c +1 -1
@@ -593,7 +593,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)hlist_add_head (&policy->byidx, net->xfrm.policy_byidx+idx_hash (net, policy->index)); policy->curlft.add_time =get_seconds (); policy->curlft.use_time =0 ; -if (!mod_timer (&policy->timer, jiffies +HZ )) +if (!mod_timer_msec (&policy->timer,1000 ))xfrm_pol_hold (policy);list_add (&policy->walk.all, &net->xfrm.policy_all);write_unlock_bh (&xfrm_policy_lock);
sound/soc/omap/ams-delta.c +1 -1
@@ -338,7 +338,7 @@ static void cx81801_receive(struct tty_struct *tty,/* Complete modem response received, apply config to codec */ spin_lock_bh (&ams_delta_lock); -mod_timer (&cx81801_timer, jiffies +msecs_to_jiffies (150 )); +mod_timer_msec (&cx81801_timer,150 ); apply = !ams_delta_muted && !cx81801_cmd_pending; cx81801_cmd_pending =1 ;spin_unlock_bh (&ams_delta_lock);
Signature · 3 lines
Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org
Re: users of mod_timer_msec()
drivers/ata/ahci.c static void ahci_sw_activity(struct ata_link *link) · line 1370
Quoted 4 lines · Arjan van de Ven
drivers/ata/ahci.c +1
-1emp->activity++;if (!timer_pending (&emp->timer)) -mod_timer (&emp->timer, jiffies +msecs_to_jiffies (10 )); +mod_timer_msec (&emp->timer,10 );
... but your original patch does
+int mod_timer_msec(struct timer_list *timer, unsigned long delay_ms) +{
+ return mod_timer(timer, msecs_to_jiffies(delay_ms));
That doesn't look equivalent.
mod_timer_msec should mod_timer_msec_plus_jiffies?
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Re: users of mod_timer_msec()
Quoted 11 lines · On Sat, 02 Jan 2010 20:11:45 +0100 Andi Kleen <[email protected]> wrote:
drivers/ata/ahci.c static void ahci_sw_activity(struct ata_link *link) · line 1370
Quoted 5 lines · Arjan van de Ven
drivers/ata/ahci.c +0
-1emp->activity++;if (!timer_pending (&emp->timer)) - mod_timer(&emp->timer, jiffies +
msecs_to_jiffies(10));drivers/ata/ahci.c +1
-0+mod_timer_msec (&emp->timer,10 );... but your original patch does
Review
Quoted 3 lines
(quoted diff) +3
-0+int mod_timer_msec(struct timer_list *timer, unsigned long delay_ms) +{ + return mod_timer(timer, msecs_to_jiffies(delay_ms));
eh last minute typo
this is supposed to be jiffies + msecs_to_jiffies()
good catch; thanks!
Signature · 3 lines
Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org
PATCH v2 1/1 timer: Introduce mod_timer_msec()
In reply to Andi KleenQuoted 1 line
From
00075f95043a8f9bafebad5e6f3ab06c81431768Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Sat, 2 Jan 2010 10:37:57 -0800
Subject: [PATCH] timer: Introduce mod_timer_msec()
It is a common paradigm in drivers to want to set/change a timer for a relative amount of milliseconds.
This patch adds a mod_timer_msec() API function to make this easier and to remove the awareness of both "jiffies" and the HZ value from various drivers that don't care about such implementation detail.
Conversion of various users of the API are done in separate patches that will go via the various maintainers separately.
--- include/linux/timer.h | 1 + kernel/timer.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-)
include/linux/timer.h +1 -0
@@ -162,6 +162,7 @@ static inline int timer_pending(const struct timer_list * timer)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_msec (struct timer_list *timer,unsigned long delay_ms);extern int mod_timer_pending (struct timer_list *timer,unsigned long expires);extern int mod_timer_pinned (struct timer_list *timer,unsigned long expires);
kernel/timer.c +20 -0
@@ -749,6 +749,26 @@ int mod_timer(struct timer_list *timer, unsigned long expires)EXPORT_SYMBOL (mod_timer);/** +* mod_timer_msec - modify a timer's timeout, using relative milliseconds +* @timer: the timer to be modified +* @delay_ms: the desired minimum delay in milliseconds +* +* Changes the timeout of a timer similar to mod_timer(). +* +* mod_timer_msec() takes relative milliseconds rather than absolute +* jiffies as argument. +* +* The function returns whether it has modified a pending timer or not. +* (ie. mod_timer_msec() of an inactive timer returns 0, mod_timer_msec() of +* an active timer returns 1.) +*/ +int mod_timer_msec (struct timer_list *timer,unsigned long delay_ms) +{ +return mod_timer (timer, jiffies +msecs_to_jiffies (delay_ms)); +} +EXPORT_SYMBOL (mod_timer_msec); + +/** * mod_timer_pinned - modify a timer's timeout * @timer: the timer to be modified * @expires: new timeout in jiffies
Signature · 8 lines
1.6.2.5 -- Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org
Dmitry Torokhov
maintainerQuoted 14 lines · Arjan van de Ven
/**
+ *mod_timer_msec- modify a timer's timeout, using relative milliseconds
+ * @timer: the timer to be modified
+ * @delay_ms: the desired minimum delay in milliseconds
+ *
+ * Changes the timeout of a timer similar tomod_timer().
+ *
+ *mod_timer_msec()takes relative milliseconds rather than absolute
+ * jiffies as argument.
+ *
+ * The function returns whether it has modified a pending timer or not.
+ * (ie.mod_timer_msec()of an inactive timer returns 0,mod_timer_msec()of
+ * an active timer returns 1.)
+ */
kernel/timer.c int mod_timer(struct timer_list *timer, unsigned long expires) · line 769
Quoted 5 lines
kernel/timer.c +5
-0+int mod_timer_msec (struct timer_list *timer,unsigned long delay_ms) +{ +return mod_timer (timer, jiffies +msecs_to_jiffies (delay_ms)); +} +EXPORT_SYMBOL (mod_timer_msec);
I wonder why isn't this an inline function? Seems tiny enough... Other than that - I'll gladly take input conversion patches.
Thanks.
Signature · 1 line
Dmitry
On Sat, 2 Jan 2010 11:30:13 -0800
Dmitry Torokhov <[email protected]> wrote:
timer returns 1.)
Quoted 8 lines
kernel/timer.c int mod_timer(struct timer_list *timer, unsigned long expires) · line 769
Quoted 6 lines
+ */
kernel/timer.c +5
-0+int mod_timer_msec (struct timer_list *timer,unsigned long delay_ms) +{ +return mod_timer (timer, jiffies +msecs_to_jiffies (delay_ms)); +} +EXPORT_SYMBOL (mod_timer_msec);I wonder why isn't this an inline function? Seems tiny enough...
the next step I want to do is to add some more smarts here, around rounding/grouping etc; it'll take some more infrastructure work in the timer system first, but if I'd made this inline now I'd just have to uninline it a bit later...
Quoted 1 line
Other than that - I'll gladly take input conversion patches.
great!
Signature · 3 lines
Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org