CXINF_MAX = 0x1c,
};
+enum poll_state {
+ CX_INIT,
+ CX_POLLING,
+ CX_ABORT
+};
+
struct cxacru_modem_type {
u32 pll_f_clk;
u32 pll_b_clk;
int line_status;
struct delayed_work poll_work;
+ struct mutex poll_state_serialize;
+ enum poll_state poll_state;
/* contol handles */
struct mutex cm_serialize;
/*
struct atm_dev *atm_dev = usbatm_instance->atm_dev;
*/
- int ret;
+ int ret, start_polling = 1;
dbg("cxacru_atm_start");
}
/* Start status polling */
- cxacru_poll_status(&instance->poll_work.work);
+ mutex_lock(&instance->poll_state_serialize);
+ if (instance->poll_state == CX_INIT)
+ instance->poll_state = CX_POLLING;
+ else /* poll_state == CX_ABORT */
+ start_polling = 0;
+ mutex_unlock(&instance->poll_state_serialize);
+
+ if (start_polling)
+ cxacru_poll_status(&instance->poll_work.work);
return 0;
}
instance->usbatm = usbatm_instance;
instance->modem_type = (struct cxacru_modem_type *) id->driver_info;
+ mutex_init(&instance->poll_state_serialize);
+ instance->poll_state = CX_INIT;
+
instance->rcv_buf = (u8 *) __get_free_page(GFP_KERNEL);
if (!instance->rcv_buf) {
dbg("cxacru_bind: no memory for rcv_buf");
struct usb_interface *intf)
{
struct cxacru_data *instance = usbatm_instance->driver_data;
+ int stop_polling = 1;
dbg("cxacru_unbind entered");
return;
}
- while (!cancel_delayed_work(&instance->poll_work))
- flush_scheduled_work();
+ mutex_lock(&instance->poll_state_serialize);
+ if (instance->poll_state != CX_POLLING) {
+ /* Polling hasn't started yet and with
+ * the mutex locked it can be prevented
+ * from starting.
+ */
+ instance->poll_state = CX_ABORT;
+ stop_polling = 0;
+ }
+ mutex_unlock(&instance->poll_state_serialize);
+
+ if (stop_polling)
+ while (!cancel_delayed_work(&instance->poll_work))
+ flush_scheduled_work();
usb_kill_urb(instance->snd_urb);
usb_kill_urb(instance->rcv_urb);