usbatm cxacru.c,1.27,1.28
kagan at infradead.org
kagan at infradead.org
Fri Apr 22 05:09:27 EDT 2005
Update of /home/cvs/usbatm
In directory phoenix.infradead.org:/tmp/cvs-serv24886
Modified Files:
cxacru.c
Log Message:
Use kernel facilities for periodically scheduling work rather than our own.
Index: cxacru.c
===================================================================
RCS file: /home/cvs/usbatm/cxacru.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- cxacru.c 7 Apr 2005 16:05:15 -0000 1.27
+++ cxacru.c 22 Apr 2005 09:09:24 -0000 1.28
@@ -62,8 +62,8 @@
/* Values */
#define SDRAM_ENA 0x1
-/* Timeout in msecs */
-#define CMD_TIMEOUT 2000
+#define CMD_TIMEOUT 2000 /* msecs */
+#define POLL_INTERVAL 5000 /* msecs */
/* commands for interaction with the modem through the control channel before
* firmware is loaded */
@@ -158,7 +158,6 @@
int line_status;
struct work_struct poll_work;
- struct timer_list poll_timer;
/* contol handles */
struct semaphore cm_serialize;
@@ -337,17 +336,6 @@
return ret;
}
-static void cxacru_do_timer_poll(struct cxacru_data *instance)
-{
- schedule_work(&instance->poll_work);
- mod_timer(&instance->poll_timer, jiffies + msecs_to_jiffies(5000));
-}
-
-static void cxacru_timer_poll(unsigned long data)
-{
- cxacru_do_timer_poll((struct cxacru_data *)data);
-}
-
static int cxacru_card_status(struct cxacru_data *instance)
{
int ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0);
@@ -358,6 +346,8 @@
return 0;
}
+static void cxacru_poll_status(struct cxacru_data *instance);
+
static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
struct atm_dev *atm_dev)
{
@@ -386,7 +376,7 @@
}
/* Start status polling */
- cxacru_do_timer_poll(instance);
+ cxacru_poll_status(instance);
return 0;
}
@@ -400,11 +390,11 @@
ret = cxacru_cm_get_array(instance, CM_REQUEST_CARD_INFO_GET, buf, CXINF_MAX);
if (ret < 0) {
dev_warn(dev, "poll status: error %d\n", ret);
- return;
+ goto reschedule;
}
if (instance->line_status == buf[CXINF_LINE_STATUS])
- return;
+ goto reschedule;
instance->line_status = buf[CXINF_LINE_STATUS];
switch (instance->line_status) {
@@ -456,6 +446,8 @@
dev_info(dev, "Unknown line state %02x\n", instance->line_status);
break;
}
+reschedule:
+ schedule_delayed_work(&instance->poll_work, msecs_to_jiffies(POLL_INTERVAL));
}
static int cxacru_fw(struct usb_device *usb_dev, enum cxacru_fw_request fw,
@@ -733,10 +725,6 @@
init_MUTEX(&instance->cm_serialize);
- init_timer(&instance->poll_timer);
- instance->poll_timer.function = cxacru_timer_poll;
- instance->poll_timer.data = (unsigned long)instance;
-
INIT_WORK(&instance->poll_work, (void *)cxacru_poll_status, instance);
wmb();
@@ -768,7 +756,7 @@
return;
}
- del_timer_sync(&instance->poll_timer);
+ cancel_delayed_work(&instance->poll_work);
wmb();
flush_scheduled_work();
More information about the Usbatm-commits
mailing list