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

speedtch: don't abuse struct delayed_work

speedtch directly uses the internal timer and work members of a struct
delayed_work. Use a separate work item and timer instead.

* Nicolas Kaiser discovered that timer init was missing. Fixed.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Tested-by: Nicolas Kaiser <nikai@nikai.net>
Cc: Duncan Sands <duncan.sands@free.fr>
Cc: linux-usb@vger.kernel.org

Tejun Heo 37c95bfe 8c71778c

+14 -12
+14 -12
drivers/usb/atm/speedtch.c
··· 139 139 140 140 struct speedtch_params params; /* set in probe, constant afterwards */ 141 141 142 - struct delayed_work status_checker; 142 + struct timer_list status_check_timer; 143 + struct work_struct status_check_work; 143 144 144 145 unsigned char last_status; 145 146 ··· 499 498 { 500 499 struct speedtch_instance_data *instance = 501 500 container_of(work, struct speedtch_instance_data, 502 - status_checker.work); 501 + status_check_work); 503 502 struct usbatm_data *usbatm = instance->usbatm; 504 503 struct atm_dev *atm_dev = usbatm->atm_dev; 505 504 unsigned char *buf = instance->scratch_buffer; ··· 576 575 { 577 576 struct speedtch_instance_data *instance = (void *)data; 578 577 579 - schedule_delayed_work(&instance->status_checker, 0); 578 + schedule_work(&instance->status_check_work); 580 579 581 580 /* The following check is racy, but the race is harmless */ 582 581 if (instance->poll_delay < MAX_POLL_DELAY) 583 - mod_timer(&instance->status_checker.timer, jiffies + msecs_to_jiffies(instance->poll_delay)); 582 + mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(instance->poll_delay)); 584 583 else 585 584 atm_warn(instance->usbatm, "Too many failures - disabling line status polling\n"); 586 585 } ··· 596 595 if (int_urb) { 597 596 ret = usb_submit_urb(int_urb, GFP_ATOMIC); 598 597 if (!ret) 599 - schedule_delayed_work(&instance->status_checker, 0); 598 + schedule_work(&instance->status_check_work); 600 599 else { 601 600 atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); 602 601 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY)); ··· 625 624 } 626 625 627 626 if ((count == 6) && !memcmp(up_int, instance->int_data, 6)) { 628 - del_timer(&instance->status_checker.timer); 627 + del_timer(&instance->status_check_timer); 629 628 atm_info(usbatm, "DSL line goes up\n"); 630 629 } else if ((count == 6) && !memcmp(down_int, instance->int_data, 6)) { 631 630 atm_info(usbatm, "DSL line goes down\n"); ··· 641 640 642 641 if ((int_urb = instance->int_urb)) { 643 642 ret = usb_submit_urb(int_urb, GFP_ATOMIC); 644 - schedule_delayed_work(&instance->status_checker, 0); 643 + schedule_work(&instance->status_check_work); 645 644 if (ret < 0) { 646 645 atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); 647 646 goto fail; ··· 687 686 } 688 687 689 688 /* Start status polling */ 690 - mod_timer(&instance->status_checker.timer, jiffies + msecs_to_jiffies(1000)); 689 + mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(1000)); 691 690 692 691 return 0; 693 692 } ··· 699 698 700 699 atm_dbg(usbatm, "%s entered\n", __func__); 701 700 702 - del_timer_sync(&instance->status_checker.timer); 701 + del_timer_sync(&instance->status_check_timer); 703 702 704 703 /* 705 704 * Since resubmit_timer and int_urb can schedule themselves and ··· 870 869 871 870 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); 872 871 873 - INIT_DELAYED_WORK(&instance->status_checker, speedtch_check_status); 872 + INIT_WORK(&instance->status_check_work, speedtch_check_status); 873 + init_timer(&instance->status_check_timer); 874 874 875 - instance->status_checker.timer.function = speedtch_status_poll; 876 - instance->status_checker.timer.data = (unsigned long)instance; 875 + instance->status_check_timer.function = speedtch_status_poll; 876 + instance->status_check_timer.data = (unsigned long)instance; 877 877 instance->last_status = 0xff; 878 878 instance->poll_delay = MIN_POLL_DELAY; 879 879