aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18/cx18-driver.c
diff options
context:
space:
mode:
authorAndy Walls <awalls@radix.net>2009-04-15 19:45:10 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 17:20:44 -0400
commit21a278b85d3c6b8064af0c03aec3205e28aad3b7 (patch)
treeefa0ee9cdfc303b03faf5b080b7f5721cf13c765 /drivers/media/video/cx18/cx18-driver.c
parent40c5520f55924ba87090d0d93222baad74202559 (diff)
V4L/DVB (11619): cx18: Simplify the work handler for outgoing mailbox commands
Simplify the way outgoing work handler gets scheduled to send empty buffers back to the firmware for use. Also reduced the memory required for scheduling this outgoing work, by using a single, per stream work object. Signed-off-by: Andy Walls <awalls@radix.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx18/cx18-driver.c')
-rw-r--r--drivers/media/video/cx18/cx18-driver.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 658cfbb1b97..f0006edc635 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -30,6 +30,7 @@
30#include "cx18-irq.h" 30#include "cx18-irq.h"
31#include "cx18-gpio.h" 31#include "cx18-gpio.h"
32#include "cx18-firmware.h" 32#include "cx18-firmware.h"
33#include "cx18-queue.h"
33#include "cx18-streams.h" 34#include "cx18-streams.h"
34#include "cx18-av-core.h" 35#include "cx18-av-core.h"
35#include "cx18-scb.h" 36#include "cx18-scb.h"
@@ -580,13 +581,6 @@ static void __devinit cx18_init_in_work_orders(struct cx18 *cx)
580 } 581 }
581} 582}
582 583
583static void __devinit cx18_init_out_work_orders(struct cx18 *cx)
584{
585 int i;
586 for (i = 0; i < CX18_MAX_OUT_WORK_ORDERS; i++)
587 INIT_WORK(&cx->out_work_order[i].work, cx18_out_work_handler);
588}
589
590/* Precondition: the cx18 structure has been memset to 0. Only 584/* Precondition: the cx18 structure has been memset to 0. Only
591 the dev and instance fields have been filled in. 585 the dev and instance fields have been filled in.
592 No assumptions on the card type may be made here (see cx18_init_struct2 586 No assumptions on the card type may be made here (see cx18_init_struct2
@@ -613,7 +607,6 @@ static int __devinit cx18_init_struct1(struct cx18 *cx)
613 return ret; 607 return ret;
614 } 608 }
615 609
616 cx18_init_out_work_orders(cx);
617 cx18_init_in_work_orders(cx); 610 cx18_init_in_work_orders(cx);
618 611
619 /* start counting open_id at 1 */ 612 /* start counting open_id at 1 */
@@ -1103,6 +1096,14 @@ static void cx18_cancel_in_work_orders(struct cx18 *cx)
1103 cancel_work_sync(&cx->in_work_order[i].work); 1096 cancel_work_sync(&cx->in_work_order[i].work);
1104} 1097}
1105 1098
1099static void cx18_cancel_out_work_orders(struct cx18 *cx)
1100{
1101 int i;
1102 for (i = 0; i < CX18_MAX_STREAMS; i++)
1103 if (&cx->streams[i].video_dev != NULL)
1104 cancel_work_sync(&cx->streams[i].out_work_order);
1105}
1106
1106static void cx18_remove(struct pci_dev *pci_dev) 1107static void cx18_remove(struct pci_dev *pci_dev)
1107{ 1108{
1108 struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); 1109 struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
@@ -1121,13 +1122,7 @@ static void cx18_remove(struct pci_dev *pci_dev)
1121 1122
1122 /* Incoming work can cause outgoing work, so clean up incoming first */ 1123 /* Incoming work can cause outgoing work, so clean up incoming first */
1123 cx18_cancel_in_work_orders(cx); 1124 cx18_cancel_in_work_orders(cx);
1124 1125 cx18_cancel_out_work_orders(cx);
1125 /*
1126 * An outgoing work order can have the only pointer to a dynamically
1127 * allocated buffer, so we need to flush outgoing work and not just
1128 * cancel it, so we don't lose the pointer and leak memory.
1129 */
1130 flush_workqueue(cx->out_work_queue);
1131 1126
1132 /* Stop ack interrupts that may have been needed for work to finish */ 1127 /* Stop ack interrupts that may have been needed for work to finish */
1133 cx18_sw2_irq_disable(cx, IRQ_CPU_TO_EPU_ACK | IRQ_APU_TO_EPU_ACK); 1128 cx18_sw2_irq_disable(cx, IRQ_CPU_TO_EPU_ACK | IRQ_APU_TO_EPU_ACK);