Skip to content

Commit 37c95bf

Browse files
committed
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 <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Tested-by: Nicolas Kaiser <[email protected]> Cc: Duncan Sands <[email protected]> Cc: [email protected]
1 parent 8c71778 commit 37c95bf

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

drivers/usb/atm/speedtch.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ struct speedtch_instance_data {
139139

140140
struct speedtch_params params; /* set in probe, constant afterwards */
141141

142-
struct delayed_work status_checker;
142+
struct timer_list status_check_timer;
143+
struct work_struct status_check_work;
143144

144145
unsigned char last_status;
145146

@@ -498,7 +499,7 @@ static void speedtch_check_status(struct work_struct *work)
498499
{
499500
struct speedtch_instance_data *instance =
500501
container_of(work, struct speedtch_instance_data,
501-
status_checker.work);
502+
status_check_work);
502503
struct usbatm_data *usbatm = instance->usbatm;
503504
struct atm_dev *atm_dev = usbatm->atm_dev;
504505
unsigned char *buf = instance->scratch_buffer;
@@ -575,11 +576,11 @@ static void speedtch_status_poll(unsigned long data)
575576
{
576577
struct speedtch_instance_data *instance = (void *)data;
577578

578-
schedule_delayed_work(&instance->status_checker, 0);
579+
schedule_work(&instance->status_check_work);
579580

580581
/* The following check is racy, but the race is harmless */
581582
if (instance->poll_delay < MAX_POLL_DELAY)
582-
mod_timer(&instance->status_checker.timer, jiffies + msecs_to_jiffies(instance->poll_delay));
583+
mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(instance->poll_delay));
583584
else
584585
atm_warn(instance->usbatm, "Too many failures - disabling line status polling\n");
585586
}
@@ -595,7 +596,7 @@ static void speedtch_resubmit_int(unsigned long data)
595596
if (int_urb) {
596597
ret = usb_submit_urb(int_urb, GFP_ATOMIC);
597598
if (!ret)
598-
schedule_delayed_work(&instance->status_checker, 0);
599+
schedule_work(&instance->status_check_work);
599600
else {
600601
atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
601602
mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY));
@@ -624,7 +625,7 @@ static void speedtch_handle_int(struct urb *int_urb)
624625
}
625626

626627
if ((count == 6) && !memcmp(up_int, instance->int_data, 6)) {
627-
del_timer(&instance->status_checker.timer);
628+
del_timer(&instance->status_check_timer);
628629
atm_info(usbatm, "DSL line goes up\n");
629630
} else if ((count == 6) && !memcmp(down_int, instance->int_data, 6)) {
630631
atm_info(usbatm, "DSL line goes down\n");
@@ -640,7 +641,7 @@ static void speedtch_handle_int(struct urb *int_urb)
640641

641642
if ((int_urb = instance->int_urb)) {
642643
ret = usb_submit_urb(int_urb, GFP_ATOMIC);
643-
schedule_delayed_work(&instance->status_checker, 0);
644+
schedule_work(&instance->status_check_work);
644645
if (ret < 0) {
645646
atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
646647
goto fail;
@@ -686,7 +687,7 @@ static int speedtch_atm_start(struct usbatm_data *usbatm, struct atm_dev *atm_de
686687
}
687688

688689
/* Start status polling */
689-
mod_timer(&instance->status_checker.timer, jiffies + msecs_to_jiffies(1000));
690+
mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(1000));
690691

691692
return 0;
692693
}
@@ -698,7 +699,7 @@ static void speedtch_atm_stop(struct usbatm_data *usbatm, struct atm_dev *atm_de
698699

699700
atm_dbg(usbatm, "%s entered\n", __func__);
700701

701-
del_timer_sync(&instance->status_checker.timer);
702+
del_timer_sync(&instance->status_check_timer);
702703

703704
/*
704705
* Since resubmit_timer and int_urb can schedule themselves and
@@ -869,10 +870,11 @@ static int speedtch_bind(struct usbatm_data *usbatm,
869870

870871
usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
871872

872-
INIT_DELAYED_WORK(&instance->status_checker, speedtch_check_status);
873+
INIT_WORK(&instance->status_check_work, speedtch_check_status);
874+
init_timer(&instance->status_check_timer);
873875

874-
instance->status_checker.timer.function = speedtch_status_poll;
875-
instance->status_checker.timer.data = (unsigned long)instance;
876+
instance->status_check_timer.function = speedtch_status_poll;
877+
instance->status_check_timer.data = (unsigned long)instance;
876878
instance->last_status = 0xff;
877879
instance->poll_delay = MIN_POLL_DELAY;
878880

0 commit comments

Comments
 (0)