diff options
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-queue.c')
-rw-r--r-- | drivers/media/video/ivtv/ivtv-queue.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/drivers/media/video/ivtv/ivtv-queue.c b/drivers/media/video/ivtv/ivtv-queue.c index ccfcef1ad91a..a04f9387f63d 100644 --- a/drivers/media/video/ivtv/ivtv-queue.c +++ b/drivers/media/video/ivtv/ivtv-queue.c | |||
@@ -195,14 +195,26 @@ int ivtv_stream_alloc(struct ivtv_stream *s) | |||
195 | s->dma != PCI_DMA_NONE ? "DMA " : "", | 195 | s->dma != PCI_DMA_NONE ? "DMA " : "", |
196 | s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024); | 196 | s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024); |
197 | 197 | ||
198 | /* Allocate DMA SG Arrays */ | 198 | if (ivtv_might_use_pio(s)) { |
199 | if (s->dma != PCI_DMA_NONE) { | 199 | s->PIOarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL); |
200 | s->SGarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL); | 200 | if (s->PIOarray == NULL) { |
201 | if (s->SGarray == NULL) { | 201 | IVTV_ERR("Could not allocate PIOarray for %s stream\n", s->name); |
202 | IVTV_ERR("Could not allocate SGarray for %s stream\n", s->name); | ||
203 | return -ENOMEM; | 202 | return -ENOMEM; |
204 | } | 203 | } |
205 | s->SG_length = 0; | 204 | } |
205 | |||
206 | /* Allocate DMA SG Arrays */ | ||
207 | s->SGarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL); | ||
208 | if (s->SGarray == NULL) { | ||
209 | IVTV_ERR("Could not allocate SGarray for %s stream\n", s->name); | ||
210 | if (ivtv_might_use_pio(s)) { | ||
211 | kfree(s->PIOarray); | ||
212 | s->PIOarray = NULL; | ||
213 | } | ||
214 | return -ENOMEM; | ||
215 | } | ||
216 | s->SG_length = 0; | ||
217 | if (ivtv_might_use_dma(s)) { | ||
206 | s->SG_handle = pci_map_single(itv->dev, s->SGarray, SGsize, s->dma); | 218 | s->SG_handle = pci_map_single(itv->dev, s->SGarray, SGsize, s->dma); |
207 | ivtv_stream_sync_for_cpu(s); | 219 | ivtv_stream_sync_for_cpu(s); |
208 | } | 220 | } |
@@ -219,7 +231,7 @@ int ivtv_stream_alloc(struct ivtv_stream *s) | |||
219 | break; | 231 | break; |
220 | } | 232 | } |
221 | INIT_LIST_HEAD(&buf->list); | 233 | INIT_LIST_HEAD(&buf->list); |
222 | if (s->dma != PCI_DMA_NONE) { | 234 | if (ivtv_might_use_dma(s)) { |
223 | buf->dma_handle = pci_map_single(s->itv->dev, | 235 | buf->dma_handle = pci_map_single(s->itv->dev, |
224 | buf->buf, s->buf_size + 256, s->dma); | 236 | buf->buf, s->buf_size + 256, s->dma); |
225 | ivtv_buf_sync_for_cpu(s, buf); | 237 | ivtv_buf_sync_for_cpu(s, buf); |
@@ -242,7 +254,7 @@ void ivtv_stream_free(struct ivtv_stream *s) | |||
242 | 254 | ||
243 | /* empty q_free */ | 255 | /* empty q_free */ |
244 | while ((buf = ivtv_dequeue(s, &s->q_free))) { | 256 | while ((buf = ivtv_dequeue(s, &s->q_free))) { |
245 | if (s->dma != PCI_DMA_NONE) | 257 | if (ivtv_might_use_dma(s)) |
246 | pci_unmap_single(s->itv->dev, buf->dma_handle, | 258 | pci_unmap_single(s->itv->dev, buf->dma_handle, |
247 | s->buf_size + 256, s->dma); | 259 | s->buf_size + 256, s->dma); |
248 | kfree(buf->buf); | 260 | kfree(buf->buf); |
@@ -256,6 +268,9 @@ void ivtv_stream_free(struct ivtv_stream *s) | |||
256 | sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE); | 268 | sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE); |
257 | s->SG_handle = IVTV_DMA_UNMAPPED; | 269 | s->SG_handle = IVTV_DMA_UNMAPPED; |
258 | } | 270 | } |
271 | kfree(s->SGarray); | ||
272 | kfree(s->PIOarray); | ||
273 | s->PIOarray = NULL; | ||
259 | s->SGarray = NULL; | 274 | s->SGarray = NULL; |
260 | s->SG_length = 0; | 275 | s->SG_length = 0; |
261 | } | 276 | } |