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

media: pvrusb2: 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: Mike Isely <isely@pobox.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-By: Mike Isely <isely@pobox.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

+36 -28
+36 -28
drivers/media/usb/pvrusb2/pvrusb2-hdw.c
··· 330 330 static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl); 331 331 static int pvr2_hdw_commit_setup(struct pvr2_hdw *hdw); 332 332 static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw); 333 - static void pvr2_hdw_quiescent_timeout(unsigned long); 334 - static void pvr2_hdw_decoder_stabilization_timeout(unsigned long); 335 - static void pvr2_hdw_encoder_wait_timeout(unsigned long); 336 - static void pvr2_hdw_encoder_run_timeout(unsigned long); 333 + static void pvr2_hdw_quiescent_timeout(struct timer_list *); 334 + static void pvr2_hdw_decoder_stabilization_timeout(struct timer_list *); 335 + static void pvr2_hdw_encoder_wait_timeout(struct timer_list *); 336 + static void pvr2_hdw_encoder_run_timeout(struct timer_list *); 337 337 static int pvr2_issue_simple_cmd(struct pvr2_hdw *,u32); 338 338 static int pvr2_send_request_ex(struct pvr2_hdw *hdw, 339 339 unsigned int timeout,int probe_fl, ··· 2373 2373 } 2374 2374 if (!hdw) goto fail; 2375 2375 2376 - setup_timer(&hdw->quiescent_timer, pvr2_hdw_quiescent_timeout, 2377 - (unsigned long)hdw); 2376 + timer_setup(&hdw->quiescent_timer, pvr2_hdw_quiescent_timeout, 0); 2378 2377 2379 - setup_timer(&hdw->decoder_stabilization_timer, 2380 - pvr2_hdw_decoder_stabilization_timeout, 2381 - (unsigned long)hdw); 2378 + timer_setup(&hdw->decoder_stabilization_timer, 2379 + pvr2_hdw_decoder_stabilization_timeout, 0); 2382 2380 2383 - setup_timer(&hdw->encoder_wait_timer, pvr2_hdw_encoder_wait_timeout, 2384 - (unsigned long)hdw); 2381 + timer_setup(&hdw->encoder_wait_timer, pvr2_hdw_encoder_wait_timeout, 2382 + 0); 2385 2383 2386 - setup_timer(&hdw->encoder_run_timer, pvr2_hdw_encoder_run_timeout, 2387 - (unsigned long)hdw); 2384 + timer_setup(&hdw->encoder_run_timer, pvr2_hdw_encoder_run_timeout, 0); 2388 2385 2389 2386 hdw->master_state = PVR2_STATE_DEAD; 2390 2387 ··· 3536 3539 complete(&hdw->ctl_done); 3537 3540 } 3538 3541 3542 + struct hdw_timer { 3543 + struct timer_list timer; 3544 + struct pvr2_hdw *hdw; 3545 + }; 3539 3546 3540 - static void pvr2_ctl_timeout(unsigned long data) 3547 + static void pvr2_ctl_timeout(struct timer_list *t) 3541 3548 { 3542 - struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; 3549 + struct hdw_timer *timer = from_timer(timer, t, timer); 3550 + struct pvr2_hdw *hdw = timer->hdw; 3551 + 3543 3552 if (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) { 3544 3553 hdw->ctl_timeout_flag = !0; 3545 3554 if (hdw->ctl_write_pend_flag) ··· 3567 3564 { 3568 3565 unsigned int idx; 3569 3566 int status = 0; 3570 - struct timer_list timer; 3567 + struct hdw_timer timer = { 3568 + .hdw = hdw, 3569 + }; 3570 + 3571 3571 if (!hdw->ctl_lock_held) { 3572 3572 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 3573 3573 "Attempted to execute control transfer without lock!!"); ··· 3627 3621 hdw->ctl_timeout_flag = 0; 3628 3622 hdw->ctl_write_pend_flag = 0; 3629 3623 hdw->ctl_read_pend_flag = 0; 3630 - setup_timer(&timer, pvr2_ctl_timeout, (unsigned long)hdw); 3631 - timer.expires = jiffies + timeout; 3624 + timer_setup_on_stack(&timer.timer, pvr2_ctl_timeout, 0); 3625 + timer.timer.expires = jiffies + timeout; 3632 3626 3633 3627 if (write_len && write_data) { 3634 3628 hdw->cmd_debug_state = 2; ··· 3683 3677 } 3684 3678 3685 3679 /* Start timer */ 3686 - add_timer(&timer); 3680 + add_timer(&timer.timer); 3687 3681 3688 3682 /* Now wait for all I/O to complete */ 3689 3683 hdw->cmd_debug_state = 4; ··· 3693 3687 hdw->cmd_debug_state = 5; 3694 3688 3695 3689 /* Stop timer */ 3696 - del_timer_sync(&timer); 3690 + del_timer_sync(&timer.timer); 3697 3691 3698 3692 hdw->cmd_debug_state = 6; 3699 3693 status = 0; ··· 3775 3769 if ((status < 0) && (!probe_fl)) { 3776 3770 pvr2_hdw_render_useless(hdw); 3777 3771 } 3772 + destroy_timer_on_stack(&timer.timer); 3773 + 3778 3774 return status; 3779 3775 } 3780 3776 ··· 4374 4366 4375 4367 4376 4368 /* Timeout function for quiescent timer. */ 4377 - static void pvr2_hdw_quiescent_timeout(unsigned long data) 4369 + static void pvr2_hdw_quiescent_timeout(struct timer_list *t) 4378 4370 { 4379 - struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; 4371 + struct pvr2_hdw *hdw = from_timer(hdw, t, quiescent_timer); 4380 4372 hdw->state_decoder_quiescent = !0; 4381 4373 trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent); 4382 4374 hdw->state_stale = !0; ··· 4385 4377 4386 4378 4387 4379 /* Timeout function for decoder stabilization timer. */ 4388 - static void pvr2_hdw_decoder_stabilization_timeout(unsigned long data) 4380 + static void pvr2_hdw_decoder_stabilization_timeout(struct timer_list *t) 4389 4381 { 4390 - struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; 4382 + struct pvr2_hdw *hdw = from_timer(hdw, t, decoder_stabilization_timer); 4391 4383 hdw->state_decoder_ready = !0; 4392 4384 trace_stbit("state_decoder_ready", hdw->state_decoder_ready); 4393 4385 hdw->state_stale = !0; ··· 4396 4388 4397 4389 4398 4390 /* Timeout function for encoder wait timer. */ 4399 - static void pvr2_hdw_encoder_wait_timeout(unsigned long data) 4391 + static void pvr2_hdw_encoder_wait_timeout(struct timer_list *t) 4400 4392 { 4401 - struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; 4393 + struct pvr2_hdw *hdw = from_timer(hdw, t, encoder_wait_timer); 4402 4394 hdw->state_encoder_waitok = !0; 4403 4395 trace_stbit("state_encoder_waitok",hdw->state_encoder_waitok); 4404 4396 hdw->state_stale = !0; ··· 4407 4399 4408 4400 4409 4401 /* Timeout function for encoder run timer. */ 4410 - static void pvr2_hdw_encoder_run_timeout(unsigned long data) 4402 + static void pvr2_hdw_encoder_run_timeout(struct timer_list *t) 4411 4403 { 4412 - struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; 4404 + struct pvr2_hdw *hdw = from_timer(hdw, t, encoder_run_timer); 4413 4405 if (!hdw->state_encoder_runok) { 4414 4406 hdw->state_encoder_runok = !0; 4415 4407 trace_stbit("state_encoder_runok",hdw->state_encoder_runok);