media: pci: Convert timers to use timer_setup()
Subsystems (6)
Media (V4L/DVB) Ivtv VIDEO4LINUX driver CX18 VIDEO4LINUX driver Bttv VIDEO4LINUX driver +2 more subsystems
PATCH 1/1 media: pci: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly.
Cc Mauro Carvalho Chehab <[email protected]>
Cc Andy Walls <[email protected]>
Cc Sergey Kozlov <[email protected]>
Cc Abylay Ospan <[email protected]>
Cc Ezequiel Garcia <[email protected]>
Cc Hans Verkuil <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Geliang Tang <[email protected]>
Cc Sean Young <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc "Pali Rohár" <[email protected]>
Signed-off-by Kees Cook <[email protected]>
--- drivers/media/pci/bt8xx/bttv-driver.c | 6 +++--- drivers/media/pci/bt8xx/bttv-input.c | 19 ++++++++++--------- drivers/media/pci/bt8xx/bttvp.h | 1 + drivers/media/pci/cx18/cx18-fileops.c | 4 ++-- drivers/media/pci/cx18/cx18-fileops.h | 2 +- drivers/media/pci/cx18/cx18-streams.c | 2 +- drivers/media/pci/ivtv/ivtv-driver.c | 3 +-- drivers/media/pci/ivtv/ivtv-irq.c | 4 ++-- drivers/media/pci/ivtv/ivtv-irq.h | 2 +- drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 7 +++---- drivers/media/pci/ttpci/av7110_ir.c | 7 +++---- drivers/media/pci/tw686x/tw686x-core.c | 7 +++---- 12 files changed, 31 insertions(+), 33 deletions(-)
drivers/media/pci/bt8xx/bttv-driver.c +3 -3
@@ -3652,9 +3652,9 @@ bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup,wake_up (&wakeup->vb.done); } -static void bttv_irq_timeout (unsigned long data) +static void bttv_irq_timeout (struct timer_list *t) { -struct bttv *btv = (struct bttv *)data; +struct bttv *btv =from_timer (btv, t, timeout);struct bttv_buffer_set old,new;struct bttv_buffer *ovbi;struct bttv_buffer *item;
@@ -4043,7 +4043,7 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)INIT_LIST_HEAD (&btv->capture);INIT_LIST_HEAD (&btv->vcapture); -setup_timer (&btv->timeout, bttv_irq_timeout, (unsigned long )btv); +timer_setup (&btv->timeout, bttv_irq_timeout,0 ); btv->i2c_rc =-1 ; btv->tuner_type =UNSET ;
drivers/media/pci/bt8xx/bttv-input.c +10 -9
@@ -133,10 +133,10 @@ void bttv_input_irq(struct bttv *btv)ir_handle_key (btv); } -static void bttv_input_timer (unsigned long data) +static void bttv_input_timer (struct timer_list *t) { -struct bttv *btv = (struct bttv *)data; -struct bttv_ir *ir = btv->remote; +struct bttv_ir *ir =from_timer (ir, t, timer); +struct bttv *btv = ir->btv;if (btv->c.type ==BTTV_BOARD_ENLTV_FM_2 )ir_enltv_handle_key (btv);
@@ -189,9 +189,9 @@ static u32 bttv_rc5_decode(unsigned int code)return rc5; } -static void bttv_rc5_timer_end (unsigned long data) +static void bttv_rc5_timer_end (struct timer_list *t) { -struct bttv_ir *ir = (struct bttv_ir *)data; +struct bttv_ir *ir =from_timer (ir, t, timer);ktime_t tv;u32 gap, rc5, scancode;u8 toggle, command, system;
@@ -296,15 +296,15 @@ static int bttv_rc5_irq(struct bttv *btv)/* ---------------------------------------------------------------------- */ -static void bttv_ir_start (struct bttv *btv,struct bttv_ir *ir) +static void bttv_ir_start (struct bttv_ir *ir) {if (ir->polling) { -setup_timer (&ir->timer, bttv_input_timer, (unsigned long )btv); +timer_setup (&ir->timer, bttv_input_timer,0 ); ir->timer.expires = jiffies +msecs_to_jiffies (1000 );add_timer (&ir->timer); }else if (ir->rc5_gpio) {/* set timer_end for code completion */ -setup_timer (&ir->timer, bttv_rc5_timer_end, (unsigned long )ir); +timer_setup (&ir->timer, bttv_rc5_timer_end,0 ); ir->shift_by =1 ; ir->rc5_remote_gap = ir_rc5_remote_gap; }
@@ -531,6 +531,7 @@ int bttv_input_init(struct bttv *btv)/* init input device */ ir->dev = rc; + ir->btv = btv;snprintf (ir->name,sizeof (ir->name),"bttv IR (card=%d)" , btv->c.type);
@@ -553,7 +554,7 @@ int bttv_input_init(struct bttv *btv) rc->driver_name =MODULE_NAME ; btv->remote = ir; -bttv_ir_start (btv, ir); +bttv_ir_start (ir);/* all done */ err =rc_register_device (rc);
drivers/media/pci/bt8xx/bttvp.h +1 -0
@@ -122,6 +122,7 @@ struct bttv_format {struct bttv_ir {struct rc_dev *dev; +struct bttv *btv;struct timer_list timer;char name[32 ];
drivers/media/pci/cx18/cx18-fileops.c +2 -2
@@ -684,9 +684,9 @@ int cx18_v4l2_mmap(struct file *file, struct vm_area_struct *vma)return -EINVAL ; } -void cx18_vb_timeout (unsigned long data) +void cx18_vb_timeout (struct timer_list *t) { -struct cx18_stream *s = (struct cx18_stream *)data; +struct cx18_stream *s =from_timer (s, t, vb_timeout);struct cx18_videobuf_buffer *buf;unsigned long flags;
drivers/media/pci/cx18/cx18-fileops.h +1 -1
@@ -29,7 +29,7 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end);void cx18_mute (struct cx18 *cx);void cx18_unmute (struct cx18 *cx);int cx18_v4l2_mmap (struct file *file,struct vm_area_struct *vma); -void cx18_vb_timeout (unsigned long data); +void cx18_vb_timeout (struct timer_list *t);/* Shared with cx18-alsa module */ int cx18_claim_stream (struct cx18_open_id *id,int type);
drivers/media/pci/cx18/cx18-streams.c +1 -1
@@ -282,7 +282,7 @@ static void cx18_stream_init(struct cx18 *cx, int type)INIT_WORK (&s->out_work_order, cx18_out_work_handler);INIT_LIST_HEAD (&s->vb_capture); -setup_timer (&s->vb_timeout, cx18_vb_timeout, (unsigned long )s); +timer_setup (&s->vb_timeout, cx18_vb_timeout,0 );spin_lock_init (&s->vb_lock);if (type ==CX18_ENC_STREAM_TYPE_YUV ) {spin_lock_init (&s->vbuf_q_lock);
drivers/media/pci/ivtv/ivtv-driver.c +1 -2
@@ -770,8 +770,7 @@ static int ivtv_init_struct1(struct ivtv *itv)init_waitqueue_head (&itv->event_waitq);init_waitqueue_head (&itv->vsync_waitq);init_waitqueue_head (&itv->dma_waitq); -setup_timer (&itv->dma_timer, ivtv_unfinished_dma, - (unsigned long )itv); +timer_setup (&itv->dma_timer, ivtv_unfinished_dma,0 ); itv->cur_dma_stream =-1 ; itv->cur_pio_stream =-1 ;
drivers/media/pci/ivtv/ivtv-irq.c +2 -2
@@ -1074,9 +1074,9 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id)return vsync_force ?IRQ_NONE :IRQ_HANDLED ; } -void ivtv_unfinished_dma (unsigned long arg) +void ivtv_unfinished_dma (struct timer_list *t) { -struct ivtv *itv = (struct ivtv *)arg; +struct ivtv *itv =from_timer (itv, t, dma_timer);if (!test_bit (IVTV_F_I_DMA , &itv->i_flags))return ;
drivers/media/pci/ivtv/ivtv-irq.h +1 -1
@@ -48,6 +48,6 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id);void ivtv_irq_work_handler (struct kthread_work *work);void ivtv_dma_stream_dec_prepare (struct ivtv_stream *s,u32 offset,int lock); -void ivtv_unfinished_dma (unsigned long arg); +void ivtv_unfinished_dma (struct timer_list *t);#endif
drivers/media/pci/netup_unidvb/netup_unidvb_core.c +3 -4
@@ -638,9 +638,9 @@ static void netup_unidvb_queue_cleanup(struct netup_dma *dma)spin_unlock_irqrestore (&dma->lock, flags); } -static void netup_unidvb_dma_timeout (unsigned long data) +static void netup_unidvb_dma_timeout (struct timer_list *t) { -struct netup_dma *dma = (struct netup_dma *)data; +struct netup_dma *dma =from_timer (dma, t, timeout);struct netup_unidvb_dev *ndev = dma->ndev;dev_dbg (&ndev->pci_dev->dev,"%s()\n" , __func__);
@@ -664,8 +664,7 @@ static int netup_unidvb_dma_init(struct netup_unidvb_dev *ndev, int num)spin_lock_init (&dma->lock);INIT_WORK (&dma->work, netup_unidvb_dma_worker);INIT_LIST_HEAD (&dma->free_buffers); -setup_timer (&dma->timeout, netup_unidvb_dma_timeout, - (unsigned long )dma); +timer_setup (&dma->timeout, netup_unidvb_dma_timeout,0 ); dma->ring_buffer_size = ndev->dma_size /2 ; dma->addr_virt = ndev->dma_virt + dma->ring_buffer_size * num; dma->addr_phys = (dma_addr_t)((u64)ndev->dma_phys +
drivers/media/pci/ttpci/av7110_ir.c +3 -4
@@ -84,9 +84,9 @@ static u16 default_key_map [256] = {/* key-up timer */ -static void av7110_emit_keyup (unsigned long parm) +static void av7110_emit_keyup (struct timer_list *t) { -struct infrared *ir = (struct infrared *) parm; +struct infrared *ir =from_timer (ir, t, keyup_timer);if (!ir || !test_bit (ir->last_key, ir->input_dev->key))return ;
@@ -334,8 +334,7 @@ int av7110_ir_init(struct av7110 *av7110) av_list[av_cnt++] = av7110;av7110_check_ir_config (av7110, true); -setup_timer (&av7110->ir.keyup_timer, av7110_emit_keyup, - (unsigned long )&av7110->ir); +timer_setup (&av7110->ir.keyup_timer, av7110_emit_keyup,0 ); input_dev =input_allocate_device ();if (!input_dev)
drivers/media/pci/tw686x/tw686x-core.c +3 -4
@@ -126,9 +126,9 @@ void tw686x_enable_channel(struct tw686x_dev *dev, unsigned int channel)* channels "too fast" which makes some TW686x devices very * angry and freeze the CPU (see note 1). */ -static void tw686x_dma_delay (unsigned long data) +static void tw686x_dma_delay (struct timer_list *t) { -struct tw686x_dev *dev = (struct tw686x_dev *)data; +struct tw686x_dev *dev =from_timer (dev, t, dma_delay_timer);unsigned long flags;spin_lock_irqsave (&dev->lock, flags);
@@ -325,8 +325,7 @@ static int tw686x_probe(struct pci_dev *pci_dev, goto iounmap; } -setup_timer (&dev->dma_delay_timer, - tw686x_dma_delay, (unsigned long ) dev); +timer_setup (&dev->dma_delay_timer, tw686x_dma_delay,0 );/* * This must be set right before initializing v4l2_dev.
Signature · 6 lines
2.7.4 -- Kees Cook Pixel Security
Hi Kees,
Quoted 17 lines · Kees Cook
In preparation for unconditionally passing the struct
timer_listpointer to all timer callbacks, switch to using the newtimer_setup()andfrom_timer()to pass the timer pointer explicitly.Cc Mauro Carvalho Chehab <[email protected]>Cc Andy Walls <[email protected]>Cc Sergey Kozlov <[email protected]>Cc Abylay Ospan <[email protected]>Cc Ezequiel Garcia <[email protected]>Cc Hans Verkuil <[email protected]>Cc Arvind Yadav <[email protected]>Cc Geliang Tang <[email protected]>Cc Sean Young <[email protected]>Cc Sakari Ailus <[email protected]>Cc "Pali Rohár" <[email protected]>Signed-off-by Kees Cook <[email protected]>
Quoted 12 lines
--- drivers/media/pci/bt8xx/bttv-driver.c | 6 +++--- drivers/media/pci/bt8xx/bttv-input.c | 19 ++++++++++--------- drivers/media/pci/bt8xx/bttvp.h | 1 + drivers/media/pci/cx18/cx18-fileops.c | 4 ++-- drivers/media/pci/cx18/cx18-fileops.h | 2 +- drivers/media/pci/cx18/cx18-streams.c | 2 +- drivers/media/pci/ivtv/ivtv-driver.c | 3 +-- drivers/media/pci/ivtv/ivtv-irq.c | 4 ++-- drivers/media/pci/ivtv/ivtv-irq.h | 2 +- drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 7 +++---- drivers/media/pci/ttpci/av7110_ir.c | 7 +++----
FYI: I'm merging all except for this av7110_ir.c patch.
There are a number of other patches that appear to address this and I think this driver should be handled separately.
Regards,
Hans
Quoted 269 lines
drivers/media/pci/tw686x/tw686x-core.c | 7 +++---- 12 files changed, 31 insertions(+), 33 deletions(-)drivers/media/pci/bt8xx/bttv-driver.c +3
-3@@ -3652,9 +3652,9 @@ bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup,wake_up (&wakeup->vb.done); } -static void bttv_irq_timeout (unsigned long data) +static void bttv_irq_timeout (struct timer_list *t) { -struct bttv *btv = (struct bttv *)data; +struct bttv *btv =from_timer (btv, t, timeout);struct bttv_buffer_set old,new;struct bttv_buffer *ovbi;struct bttv_buffer *item;@@ -4043,7 +4043,7 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)INIT_LIST_HEAD (&btv->capture);INIT_LIST_HEAD (&btv->vcapture); -setup_timer (&btv->timeout, bttv_irq_timeout, (unsigned long )btv); +timer_setup (&btv->timeout, bttv_irq_timeout,0 ); btv->i2c_rc =-1 ; btv->tuner_type =UNSET ;drivers/media/pci/bt8xx/bttv-input.c +10
-9@@ -133,10 +133,10 @@ void bttv_input_irq(struct bttv *btv)ir_handle_key (btv); } -static void bttv_input_timer (unsigned long data) +static void bttv_input_timer (struct timer_list *t) { -struct bttv *btv = (struct bttv *)data; -struct bttv_ir *ir = btv->remote; +struct bttv_ir *ir =from_timer (ir, t, timer); +struct bttv *btv = ir->btv;if (btv->c.type ==BTTV_BOARD_ENLTV_FM_2 )ir_enltv_handle_key (btv);@@ -189,9 +189,9 @@ static u32 bttv_rc5_decode(unsigned int code)return rc5; } -static void bttv_rc5_timer_end (unsigned long data) +static void bttv_rc5_timer_end (struct timer_list *t) { -struct bttv_ir *ir = (struct bttv_ir *)data; +struct bttv_ir *ir =from_timer (ir, t, timer);ktime_t tv;u32 gap, rc5, scancode;u8 toggle, command, system;@@ -296,15 +296,15 @@ static int bttv_rc5_irq(struct bttv *btv)/* ---------------------------------------------------------------------- */ -static void bttv_ir_start (struct bttv *btv,struct bttv_ir *ir) +static void bttv_ir_start (struct bttv_ir *ir) {if (ir->polling) { -setup_timer (&ir->timer, bttv_input_timer, (unsigned long )btv); +timer_setup (&ir->timer, bttv_input_timer,0 ); ir->timer.expires = jiffies +msecs_to_jiffies (1000 );add_timer (&ir->timer); }else if (ir->rc5_gpio) {/* set timer_end for code completion */ -setup_timer (&ir->timer, bttv_rc5_timer_end, (unsigned long )ir); +timer_setup (&ir->timer, bttv_rc5_timer_end,0 ); ir->shift_by =1 ; ir->rc5_remote_gap = ir_rc5_remote_gap; }@@ -531,6 +531,7 @@ int bttv_input_init(struct bttv *btv)/* init input device */ ir->dev = rc; + ir->btv = btv;snprintf (ir->name,sizeof (ir->name),"bttv IR (card=%d)" , btv->c.type);@@ -553,7 +554,7 @@ int bttv_input_init(struct bttv *btv) rc->driver_name =MODULE_NAME ; btv->remote = ir; -bttv_ir_start (btv, ir); +bttv_ir_start (ir);/* all done */ err =rc_register_device (rc);drivers/media/pci/bt8xx/bttvp.h +1
-0@@ -122,6 +122,7 @@ struct bttv_format {struct bttv_ir {struct rc_dev *dev; +struct bttv *btv;struct timer_list timer;char name[32 ];drivers/media/pci/cx18/cx18-fileops.c +2
-2@@ -684,9 +684,9 @@ int cx18_v4l2_mmap(struct file *file, struct vm_area_struct *vma)return -EINVAL ; } -void cx18_vb_timeout (unsigned long data) +void cx18_vb_timeout (struct timer_list *t) { -struct cx18_stream *s = (struct cx18_stream *)data; +struct cx18_stream *s =from_timer (s, t, vb_timeout);struct cx18_videobuf_buffer *buf;unsigned long flags;drivers/media/pci/cx18/cx18-fileops.h +1
-1@@ -29,7 +29,7 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end);void cx18_mute (struct cx18 *cx);void cx18_unmute (struct cx18 *cx);int cx18_v4l2_mmap (struct file *file,struct vm_area_struct *vma); -void cx18_vb_timeout (unsigned long data); +void cx18_vb_timeout (struct timer_list *t);/* Shared with cx18-alsa module */ int cx18_claim_stream (struct cx18_open_id *id,int type);drivers/media/pci/cx18/cx18-streams.c +1
-1@@ -282,7 +282,7 @@ static void cx18_stream_init(struct cx18 *cx, int type)INIT_WORK (&s->out_work_order, cx18_out_work_handler);INIT_LIST_HEAD (&s->vb_capture); -setup_timer (&s->vb_timeout, cx18_vb_timeout, (unsigned long )s); +timer_setup (&s->vb_timeout, cx18_vb_timeout,0 );spin_lock_init (&s->vb_lock);if (type ==CX18_ENC_STREAM_TYPE_YUV ) {spin_lock_init (&s->vbuf_q_lock);drivers/media/pci/ivtv/ivtv-driver.c +1
-2@@ -770,8 +770,7 @@ static int ivtv_init_struct1(struct ivtv *itv)init_waitqueue_head (&itv->event_waitq);init_waitqueue_head (&itv->vsync_waitq);init_waitqueue_head (&itv->dma_waitq); -setup_timer (&itv->dma_timer, ivtv_unfinished_dma, - (unsigned long )itv); +timer_setup (&itv->dma_timer, ivtv_unfinished_dma,0 ); itv->cur_dma_stream =-1 ; itv->cur_pio_stream =-1 ;drivers/media/pci/ivtv/ivtv-irq.c +2
-2@@ -1074,9 +1074,9 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id)return vsync_force ?IRQ_NONE :IRQ_HANDLED ; } -void ivtv_unfinished_dma (unsigned long arg) +void ivtv_unfinished_dma (struct timer_list *t) { -struct ivtv *itv = (struct ivtv *)arg; +struct ivtv *itv =from_timer (itv, t, dma_timer);if (!test_bit (IVTV_F_I_DMA , &itv->i_flags))return ;drivers/media/pci/ivtv/ivtv-irq.h +1
-1@@ -48,6 +48,6 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id);void ivtv_irq_work_handler (struct kthread_work *work);void ivtv_dma_stream_dec_prepare (struct ivtv_stream *s,u32 offset,int lock); -void ivtv_unfinished_dma (unsigned long arg); +void ivtv_unfinished_dma (struct timer_list *t);#endif drivers/media/pci/netup_unidvb/netup_unidvb_core.c +3
-4@@ -638,9 +638,9 @@ static void netup_unidvb_queue_cleanup(struct netup_dma *dma)spin_unlock_irqrestore (&dma->lock, flags); } -static void netup_unidvb_dma_timeout (unsigned long data) +static void netup_unidvb_dma_timeout (struct timer_list *t) { -struct netup_dma *dma = (struct netup_dma *)data; +struct netup_dma *dma =from_timer (dma, t, timeout);struct netup_unidvb_dev *ndev = dma->ndev;dev_dbg (&ndev->pci_dev->dev,"%s()\n" , __func__);@@ -664,8 +664,7 @@ static int netup_unidvb_dma_init(struct netup_unidvb_dev *ndev, int num)spin_lock_init (&dma->lock);INIT_WORK (&dma->work, netup_unidvb_dma_worker);INIT_LIST_HEAD (&dma->free_buffers); -setup_timer (&dma->timeout, netup_unidvb_dma_timeout, - (unsigned long )dma); +timer_setup (&dma->timeout, netup_unidvb_dma_timeout,0 ); dma->ring_buffer_size = ndev->dma_size /2 ; dma->addr_virt = ndev->dma_virt + dma->ring_buffer_size * num; dma->addr_phys = (dma_addr_t)((u64)ndev->dma_phys +drivers/media/pci/ttpci/av7110_ir.c +3
-4@@ -84,9 +84,9 @@ static u16 default_key_map [256] = {/* key-up timer */ -static void av7110_emit_keyup (unsigned long parm) +static void av7110_emit_keyup (struct timer_list *t) { -struct infrared *ir = (struct infrared *) parm; +struct infrared *ir =from_timer (ir, t, keyup_timer);if (!ir || !test_bit (ir->last_key, ir->input_dev->key))return ;@@ -334,8 +334,7 @@ int av7110_ir_init(struct av7110 *av7110) av_list[av_cnt++] = av7110;av7110_check_ir_config (av7110, true); -setup_timer (&av7110->ir.keyup_timer, av7110_emit_keyup, - (unsigned long )&av7110->ir); +timer_setup (&av7110->ir.keyup_timer, av7110_emit_keyup,0 ); input_dev =input_allocate_device ();if (!input_dev)drivers/media/pci/tw686x/tw686x-core.c +3
-4@@ -126,9 +126,9 @@ void tw686x_enable_channel(struct tw686x_dev *dev, unsigned int channel)* channels "too fast" which makes some TW686x devices very * angry and freeze the CPU (see note 1). */ -static void tw686x_dma_delay (unsigned long data) +static void tw686x_dma_delay (struct timer_list *t) { -struct tw686x_dev *dev = (struct tw686x_dev *)data; +struct tw686x_dev *dev =from_timer (dev, t, dma_delay_timer);unsigned long flags;spin_lock_irqsave (&dev->lock, flags);@@ -325,8 +325,7 @@ static int tw686x_probe(struct pci_dev *pci_dev, goto iounmap; } -setup_timer (&dev->dma_delay_timer, - tw686x_dma_delay, (unsigned long ) dev); +timer_setup (&dev->dma_delay_timer, tw686x_dma_delay,0 );/* * This must be set right before initializing v4l2_dev.