[Linux1394-cvslog] rev 609 - trunk
Brought to you by:
aeb,
bencollins
From: SVN U. <ben...@li...> - 2002-10-14 03:50:26
|
Author: bencollins Date: 2002-10-13 23:50:22 -0400 (Sun, 13 Oct 2002) New Revision: 609 Modified: trunk/ieee1394_core.c trunk/ieee1394_core.h trunk/raw1394.c trunk/raw1394.h trunk/sbp2.c trunk/sbp2.h Log: Change packet complete_work interface to a much simpler one. Modified: trunk/ieee1394_core.c ============================================================================== --- trunk/ieee1394_core.c (original) +++ trunk/ieee1394_core.c 2002-10-13 23:50:24.000000000 -0400 @@ -76,31 +76,31 @@ printk("\n"); } -static void process_complete_tasks(struct hpsb_packet *packet) +static void run_packet_complete(struct hpsb_packet *packet) { - struct list_head *lh, *next; - - list_for_each_safe(lh, next, &packet->complete_work) { - struct hpsb_packet_work *work = - list_entry(lh, struct hpsb_packet_work, list); - - list_del(&work->list); - - if (work->routine) - work->routine(work->data); + if (packet->complete_routine != NULL) { + packet->complete_routine(packet->complete_data); + packet->complete_routine = NULL; + packet->complete_data = NULL; } - return; } /** - * hpsb_add_packet_complete_task - add a new task for when a packet completes + * hpsb_set_packet_complete_task - set the task that runs when a packet + * completes. You cannot call this more than once on a single packet + * before it is sent. + * * @packet: the packet whose completion we want the task added to - * @work: the hpsb_queue_struct describing the task to add + * @routine: function to call + * @data: data (if any) to pass to the above function */ -void hpsb_add_packet_complete_task(struct hpsb_packet *packet, struct hpsb_packet_work *work) +void hpsb_set_packet_complete_task(struct hpsb_packet *packet, + void (*routine)(void *), void *data) { - list_add_tail(&work->list, &packet->complete_work); + BUG_ON(packet->complete_routine != NULL); + packet->complete_routine = routine; + packet->complete_data = data; return; } @@ -148,9 +148,10 @@ packet->data_size = data_size; } - INIT_LIST_HEAD(&packet->complete_work); INIT_LIST_HEAD(&packet->list); sema_init(&packet->state_change, 0); + packet->complete_routine = NULL; + packet->complete_data = NULL; packet->state = hpsb_unused; packet->generation = -1; packet->data_be = 1; @@ -428,7 +429,7 @@ packet->state = hpsb_complete; up(&packet->state_change); up(&packet->state_change); - process_complete_tasks(packet); + run_packet_complete(packet); return; } @@ -617,7 +618,7 @@ packet->state = hpsb_complete; up(&packet->state_change); - process_complete_tasks(packet); + run_packet_complete(packet); } @@ -851,7 +852,7 @@ packet->state = hpsb_complete; packet->ack_code = ACKX_ABORTED; up(&packet->state_change); - process_complete_tasks(packet); + run_packet_complete(packet); } } @@ -893,7 +894,7 @@ packet->state = hpsb_complete; packet->ack_code = ACKX_TIMEOUT; up(&packet->state_change); - process_complete_tasks(packet); + run_packet_complete(packet); } } @@ -1152,7 +1153,7 @@ EXPORT_SYMBOL(hpsb_ref_host); EXPORT_SYMBOL(hpsb_unref_host); EXPORT_SYMBOL(hpsb_speedto_str); -EXPORT_SYMBOL(hpsb_add_packet_complete_task); +EXPORT_SYMBOL(hpsb_set_packet_complete_task); EXPORT_SYMBOL(alloc_hpsb_packet); EXPORT_SYMBOL(free_hpsb_packet); Modified: trunk/ieee1394_core.h ============================================================================== --- trunk/ieee1394_core.h (original) +++ trunk/ieee1394_core.h 2002-10-13 23:50:24.000000000 -0400 @@ -68,7 +68,10 @@ /* Very core internal, don't care. */ struct semaphore state_change; - struct list_head complete_work; + /* Function (and possible data to pass to it) to call when this + * packet is completed. */ + void (*complete_routine)(void *); + void *complete_data; /* Store jiffies for implementing bus timeouts. */ unsigned long sendtime; @@ -76,31 +79,9 @@ quadlet_t embedded_header[5]; }; -/* TODO: When we drop 2.4.x support into it's own branch, I want to complete - * switch this over to a workqueue interface somehow. -- BenC */ - -/* Used to pass a function/arg that is called when a packet completes */ -struct hpsb_packet_work { - struct list_head list; /* linked list of active bh's */ - void (*routine)(void *); /* function to call */ - void *data; /* argument to function */ -}; - -#define HPSB_PACKET_WORK_INIT(_work, _routine, _data) \ -do { \ - INIT_LIST_HEAD(&(_work)->list); \ - HPSB_PACKET_WORK_PREPARE((_work), (_routine), (_data)); \ -} while (0) - -#define HPSB_PACKET_WORK_PREPARE(_work, _routine, _data) \ -do { \ - (_work)->routine = _routine; \ - (_work)->data = _data; \ -} while (0) - - -/* Add a new task for when a packet completes */ -void hpsb_add_packet_complete_task(struct hpsb_packet *packet, struct hpsb_packet_work *work); +/* Set a task for when a packet completes */ +void hpsb_set_packet_complete_task(struct hpsb_packet *packet, + void (*routine)(void *), void *data); static inline struct hpsb_packet *driver_packet(struct list_head *l) { Modified: trunk/raw1394.c ============================================================================== --- trunk/raw1394.c (original) +++ trunk/raw1394.c 2002-10-13 23:50:24.000000000 -0400 @@ -107,8 +107,6 @@ if (req != NULL) { memset(req, 0, sizeof(struct pending_request)); INIT_LIST_HEAD(&req->list); - HPSB_PACKET_WORK_INIT(&req->work, - (void(*)(void*))queue_complete_cb, req); } return req; @@ -754,7 +752,6 @@ return sizeof(struct raw1394_request); } - hpsb_add_packet_complete_task(packet, &req->work); spin_lock_irq(&fi->reqlists_lock); list_add_tail(&req->list, &fi->req_pending); @@ -794,10 +791,8 @@ return sizeof(struct raw1394_request); } - HPSB_PACKET_WORK_PREPARE(&req->work, - (void (*)(void*))queue_complete_req, req); req->req.length = 0; - hpsb_add_packet_complete_task(packet, &req->work); + hpsb_set_packet_complete_task(packet, (void (*)(void*))queue_complete_req, req); spin_lock_irq(&fi->reqlists_lock); list_add_tail(&req->list, &fi->req_pending); @@ -858,10 +853,8 @@ packet->header_size=header_length; packet->data_size=req->req.length-header_length; - HPSB_PACKET_WORK_PREPARE(&req->work, - (void (*)(void*))queue_complete_req, req); req->req.length = 0; - hpsb_add_packet_complete_task(packet, &req->work); + hpsb_set_packet_complete_task(packet, (void(*)(void*))queue_complete_cb, req); spin_lock_irq(&fi->reqlists_lock); list_add_tail(&req->list, &fi->req_pending); @@ -1808,7 +1801,7 @@ if (!packet) return -ENOMEM; req->req.length=0; req->packet=packet; - hpsb_add_packet_complete_task(packet, &req->work); + hpsb_set_packet_complete_task(packet, (void(*)(void*))queue_complete_cb, req); spin_lock_irq(&fi->reqlists_lock); list_add_tail(&req->list, &fi->req_pending); spin_unlock_irq(&fi->reqlists_lock); Modified: trunk/raw1394.h ============================================================================== --- trunk/raw1394.h (original) +++ trunk/raw1394.h 2002-10-13 23:50:24.000000000 -0400 @@ -164,7 +164,6 @@ struct list_head list; struct file_info *file_info; struct hpsb_packet *packet; - struct hpsb_packet_work work; struct iso_block_store *ibs; quadlet_t *data; int free_data; Modified: trunk/sbp2.c ============================================================================== --- trunk/sbp2.c (original) +++ trunk/sbp2.c 2002-10-13 23:50:24.000000000 -0400 @@ -705,13 +705,6 @@ */ INIT_LIST_HEAD(&hi->request_packet[i].list); hi->request_packet[i].packet = packet; - /* - * Set up a task queue completion routine, which returns - * the packet to the free list and releases the tlabel. - */ - HPSB_PACKET_WORK_INIT(&hi->request_packet[i].work, - (void (*)(void*))sbp2util_free_request_packet, - &hi->request_packet[i]); list_add_tail(&hi->request_packet[i].list, &hi->sbp2_req_free); @@ -806,8 +799,10 @@ } request_packet->hi_context = hi; + /* Calls the packet completion to return this to the free list */ - hpsb_add_packet_complete_task(packet, &request_packet->work); + hpsb_set_packet_complete_task(packet, (void (*)(void*))sbp2util_free_request_packet, + request_packet); /* * Now, put the packet on the in-use list. Modified: trunk/sbp2.h ============================================================================== --- trunk/sbp2.h (original) +++ trunk/sbp2.h 2002-10-13 23:50:24.000000000 -0400 @@ -324,7 +324,6 @@ struct list_head list; struct hpsb_packet *packet; - struct hpsb_packet_work work; void *hi_context; }; |