summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Stezenbach <devnull@localhost>2004-12-19 17:52:47 +0000
committerJohannes Stezenbach <devnull@localhost>2004-12-19 17:52:47 +0000
commit90019e6129b6d234bd991a89e1f78a6011e4ad55 (patch)
treebe409a26cc747ca809d48be90cf43bace6056440
parentc2657f48961d73311fa2245ba20916a88e523f52 (diff)
downloadmediapointer-dvb-s2-90019e6129b6d234bd991a89e1f78a6011e4ad55.tar.gz
mediapointer-dvb-s2-90019e6129b6d234bd991a89e1f78a6011e4ad55.tar.bz2
Factor out duplicated code in free_dma_queue.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
-rw-r--r--linux/drivers/media/dvb/b2c2/skystar2.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/linux/drivers/media/dvb/b2c2/skystar2.c b/linux/drivers/media/dvb/b2c2/skystar2.c
index 775b3a37a..000c84a76 100644
--- a/linux/drivers/media/dvb/b2c2/skystar2.c
+++ b/linux/drivers/media/dvb/b2c2/skystar2.c
@@ -1725,27 +1725,25 @@ static int init_dma_queue(struct adapter *adapter)
return (adapter->dma_status & 0x30000000) ? 0 : -ENOMEM;
}
-static void free_dma_queue(struct adapter *adapter)
+static void free_dma_queue_one(struct adapter *adapter, struct dmaq *dmaq)
{
- if (adapter->dmaq1.buffer != 0) {
- pci_free_consistent(adapter->pdev, SIZE_OF_BUF_DMA1 + 0x80, adapter->dmaq1.buffer, adapter->dmaq1.bus_addr);
-
- adapter->dmaq1.bus_addr = 0;
- adapter->dmaq1.head = 0;
- adapter->dmaq1.tail = 0;
- adapter->dmaq1.buffer_size = 0;
- adapter->dmaq1.buffer = NULL;
+ if (dmaq->buffer) {
+ pci_free_consistent(adapter->pdev, dmaq->buffer_size + 0x80,
+ dmaq->buffer, dmaq->bus_addr);
+ memset(dmaq, 0, sizeof(*dmaq));
}
+}
- if (adapter->dmaq2.buffer != 0) {
- pci_free_consistent(adapter->pdev, SIZE_OF_BUF_DMA2 + 0x80, adapter->dmaq2.buffer, adapter->dmaq2.bus_addr);
+static void free_dma_queue(struct adapter *adapter)
+{
+ struct dmaq *dmaq[] = {
+ &adapter->dmaq1,
+ &adapter->dmaq2,
+ NULL
+ }, **p;
- adapter->dmaq2.bus_addr = 0;
- adapter->dmaq2.head = 0;
- adapter->dmaq2.tail = 0;
- adapter->dmaq2.buffer_size = 0;
- adapter->dmaq2.buffer = NULL;
- }
+ for (p = dmaq; *p; p++)
+ free_dma_queue_one(adapter, *p);
}
static void free_adapter_object(struct adapter *adapter)