diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2011-10-12 04:36:04 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-16 07:00:10 -0500 |
commit | 61bb725ef5a646d3fc8a64e41b020a65542cdae1 (patch) | |
tree | 5f35434d19ea58ae4ae32c5218bbdd43916978c4 /drivers/media | |
parent | cdc037817cc15caf931cd3476970860d62f1985c (diff) |
[media] ivtv: remove open_id/id from the filehandle code
Instead of messing around with id's it's much easier to just compare
against a filehandle pointer.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/ivtv/ivtv-driver.c | 3 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-driver.h | 3 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-fileops.c | 19 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-irq.c | 4 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-streams.c | 1 |
5 files changed, 12 insertions, 18 deletions
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index 41108a9a195e..461ae449cb43 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
@@ -731,9 +731,6 @@ static int __devinit ivtv_init_struct1(struct ivtv *itv) | |||
731 | 731 | ||
732 | init_kthread_work(&itv->irq_work, ivtv_irq_work_handler); | 732 | init_kthread_work(&itv->irq_work, ivtv_irq_work_handler); |
733 | 733 | ||
734 | /* start counting open_id at 1 */ | ||
735 | itv->open_id = 1; | ||
736 | |||
737 | /* Initial settings */ | 734 | /* Initial settings */ |
738 | itv->cxhdl.port = CX2341X_PORT_MEMORY; | 735 | itv->cxhdl.port = CX2341X_PORT_MEMORY; |
739 | itv->cxhdl.capabilities = CX2341X_CAP_HAS_SLICED_VBI; | 736 | itv->cxhdl.capabilities = CX2341X_CAP_HAS_SLICED_VBI; |
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h index 8f9cc17b518e..06f3d78389bf 100644 --- a/drivers/media/video/ivtv/ivtv-driver.h +++ b/drivers/media/video/ivtv/ivtv-driver.h | |||
@@ -332,7 +332,7 @@ struct ivtv_stream { | |||
332 | const char *name; /* name of the stream */ | 332 | const char *name; /* name of the stream */ |
333 | int type; /* stream type */ | 333 | int type; /* stream type */ |
334 | 334 | ||
335 | u32 id; | 335 | struct v4l2_fh *fh; /* pointer to the streaming filehandle */ |
336 | spinlock_t qlock; /* locks access to the queues */ | 336 | spinlock_t qlock; /* locks access to the queues */ |
337 | unsigned long s_flags; /* status flags, see above */ | 337 | unsigned long s_flags; /* status flags, see above */ |
338 | int dma; /* can be PCI_DMA_TODEVICE, PCI_DMA_FROMDEVICE or PCI_DMA_NONE */ | 338 | int dma; /* can be PCI_DMA_TODEVICE, PCI_DMA_FROMDEVICE or PCI_DMA_NONE */ |
@@ -379,7 +379,6 @@ struct ivtv_stream { | |||
379 | 379 | ||
380 | struct ivtv_open_id { | 380 | struct ivtv_open_id { |
381 | struct v4l2_fh fh; | 381 | struct v4l2_fh fh; |
382 | u32 open_id; /* unique ID for this file descriptor */ | ||
383 | int type; /* stream type */ | 382 | int type; /* stream type */ |
384 | int yuv_frames; /* 1: started OUT_UDMA_YUV output mode */ | 383 | int yuv_frames; /* 1: started OUT_UDMA_YUV output mode */ |
385 | struct ivtv *itv; | 384 | struct ivtv *itv; |
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index 116ece4d6f27..2cd6c89b7d91 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c | |||
@@ -50,16 +50,16 @@ static int ivtv_claim_stream(struct ivtv_open_id *id, int type) | |||
50 | 50 | ||
51 | if (test_and_set_bit(IVTV_F_S_CLAIMED, &s->s_flags)) { | 51 | if (test_and_set_bit(IVTV_F_S_CLAIMED, &s->s_flags)) { |
52 | /* someone already claimed this stream */ | 52 | /* someone already claimed this stream */ |
53 | if (s->id == id->open_id) { | 53 | if (s->fh == &id->fh) { |
54 | /* yes, this file descriptor did. So that's OK. */ | 54 | /* yes, this file descriptor did. So that's OK. */ |
55 | return 0; | 55 | return 0; |
56 | } | 56 | } |
57 | if (s->id == -1 && (type == IVTV_DEC_STREAM_TYPE_VBI || | 57 | if (s->fh == NULL && (type == IVTV_DEC_STREAM_TYPE_VBI || |
58 | type == IVTV_ENC_STREAM_TYPE_VBI)) { | 58 | type == IVTV_ENC_STREAM_TYPE_VBI)) { |
59 | /* VBI is handled already internally, now also assign | 59 | /* VBI is handled already internally, now also assign |
60 | the file descriptor to this stream for external | 60 | the file descriptor to this stream for external |
61 | reading of the stream. */ | 61 | reading of the stream. */ |
62 | s->id = id->open_id; | 62 | s->fh = &id->fh; |
63 | IVTV_DEBUG_INFO("Start Read VBI\n"); | 63 | IVTV_DEBUG_INFO("Start Read VBI\n"); |
64 | return 0; | 64 | return 0; |
65 | } | 65 | } |
@@ -67,7 +67,7 @@ static int ivtv_claim_stream(struct ivtv_open_id *id, int type) | |||
67 | IVTV_DEBUG_INFO("Stream %d is busy\n", type); | 67 | IVTV_DEBUG_INFO("Stream %d is busy\n", type); |
68 | return -EBUSY; | 68 | return -EBUSY; |
69 | } | 69 | } |
70 | s->id = id->open_id; | 70 | s->fh = &id->fh; |
71 | if (type == IVTV_DEC_STREAM_TYPE_VBI) { | 71 | if (type == IVTV_DEC_STREAM_TYPE_VBI) { |
72 | /* Enable reinsertion interrupt */ | 72 | /* Enable reinsertion interrupt */ |
73 | ivtv_clear_irq_mask(itv, IVTV_IRQ_DEC_VBI_RE_INSERT); | 73 | ivtv_clear_irq_mask(itv, IVTV_IRQ_DEC_VBI_RE_INSERT); |
@@ -104,7 +104,7 @@ void ivtv_release_stream(struct ivtv_stream *s) | |||
104 | struct ivtv *itv = s->itv; | 104 | struct ivtv *itv = s->itv; |
105 | struct ivtv_stream *s_vbi; | 105 | struct ivtv_stream *s_vbi; |
106 | 106 | ||
107 | s->id = -1; | 107 | s->fh = NULL; |
108 | if ((s->type == IVTV_DEC_STREAM_TYPE_VBI || s->type == IVTV_ENC_STREAM_TYPE_VBI) && | 108 | if ((s->type == IVTV_DEC_STREAM_TYPE_VBI || s->type == IVTV_ENC_STREAM_TYPE_VBI) && |
109 | test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) { | 109 | test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) { |
110 | /* this stream is still in use internally */ | 110 | /* this stream is still in use internally */ |
@@ -136,7 +136,7 @@ void ivtv_release_stream(struct ivtv_stream *s) | |||
136 | /* was already cleared */ | 136 | /* was already cleared */ |
137 | return; | 137 | return; |
138 | } | 138 | } |
139 | if (s_vbi->id != -1) { | 139 | if (s_vbi->fh) { |
140 | /* VBI stream still claimed by a file descriptor */ | 140 | /* VBI stream still claimed by a file descriptor */ |
141 | return; | 141 | return; |
142 | } | 142 | } |
@@ -359,7 +359,7 @@ static ssize_t ivtv_read(struct ivtv_stream *s, char __user *ubuf, size_t tot_co | |||
359 | size_t tot_written = 0; | 359 | size_t tot_written = 0; |
360 | int single_frame = 0; | 360 | int single_frame = 0; |
361 | 361 | ||
362 | if (atomic_read(&itv->capturing) == 0 && s->id == -1) { | 362 | if (atomic_read(&itv->capturing) == 0 && s->fh == NULL) { |
363 | /* shouldn't happen */ | 363 | /* shouldn't happen */ |
364 | IVTV_DEBUG_WARN("Stream %s not initialized before read\n", s->name); | 364 | IVTV_DEBUG_WARN("Stream %s not initialized before read\n", s->name); |
365 | return -EIO; | 365 | return -EIO; |
@@ -808,7 +808,7 @@ void ivtv_stop_capture(struct ivtv_open_id *id, int gop_end) | |||
808 | id->type == IVTV_ENC_STREAM_TYPE_VBI) && | 808 | id->type == IVTV_ENC_STREAM_TYPE_VBI) && |
809 | test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) { | 809 | test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) { |
810 | /* Also used internally, don't stop capturing */ | 810 | /* Also used internally, don't stop capturing */ |
811 | s->id = -1; | 811 | s->fh = NULL; |
812 | } | 812 | } |
813 | else { | 813 | else { |
814 | ivtv_stop_v4l2_encode_stream(s, gop_end); | 814 | ivtv_stop_v4l2_encode_stream(s, gop_end); |
@@ -890,7 +890,7 @@ int ivtv_v4l2_close(struct file *filp) | |||
890 | v4l2_fh_exit(fh); | 890 | v4l2_fh_exit(fh); |
891 | 891 | ||
892 | /* Easy case first: this stream was never claimed by us */ | 892 | /* Easy case first: this stream was never claimed by us */ |
893 | if (s->id != id->open_id) { | 893 | if (s->fh != &id->fh) { |
894 | kfree(id); | 894 | kfree(id); |
895 | return 0; | 895 | return 0; |
896 | } | 896 | } |
@@ -974,7 +974,6 @@ int ivtv_v4l2_open(struct file *filp) | |||
974 | item->itv = itv; | 974 | item->itv = itv; |
975 | item->type = s->type; | 975 | item->type = s->type; |
976 | 976 | ||
977 | item->open_id = itv->open_id++; | ||
978 | filp->private_data = &item->fh; | 977 | filp->private_data = &item->fh; |
979 | v4l2_fh_add(&item->fh); | 978 | v4l2_fh_add(&item->fh); |
980 | 979 | ||
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c index 9c29e964d400..1b3b9578bf47 100644 --- a/drivers/media/video/ivtv/ivtv-irq.c +++ b/drivers/media/video/ivtv/ivtv-irq.c | |||
@@ -288,13 +288,13 @@ static void dma_post(struct ivtv_stream *s) | |||
288 | ivtv_process_vbi_data(itv, buf, 0, s->type); | 288 | ivtv_process_vbi_data(itv, buf, 0, s->type); |
289 | s->q_dma.bytesused += buf->bytesused; | 289 | s->q_dma.bytesused += buf->bytesused; |
290 | } | 290 | } |
291 | if (s->id == -1) { | 291 | if (s->fh == NULL) { |
292 | ivtv_queue_move(s, &s->q_dma, NULL, &s->q_free, 0); | 292 | ivtv_queue_move(s, &s->q_dma, NULL, &s->q_free, 0); |
293 | return; | 293 | return; |
294 | } | 294 | } |
295 | } | 295 | } |
296 | ivtv_queue_move(s, &s->q_dma, NULL, &s->q_full, s->q_dma.bytesused); | 296 | ivtv_queue_move(s, &s->q_dma, NULL, &s->q_full, s->q_dma.bytesused); |
297 | if (s->id != -1) | 297 | if (s->fh) |
298 | wake_up(&s->waitq); | 298 | wake_up(&s->waitq); |
299 | } | 299 | } |
300 | 300 | ||
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index d598df046605..c6e28b4ebbed 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c | |||
@@ -159,7 +159,6 @@ static void ivtv_stream_init(struct ivtv *itv, int type) | |||
159 | s->buffers = (itv->options.kilobytes[type] * 1024 + s->buf_size - 1) / s->buf_size; | 159 | s->buffers = (itv->options.kilobytes[type] * 1024 + s->buf_size - 1) / s->buf_size; |
160 | spin_lock_init(&s->qlock); | 160 | spin_lock_init(&s->qlock); |
161 | init_waitqueue_head(&s->waitq); | 161 | init_waitqueue_head(&s->waitq); |
162 | s->id = -1; | ||
163 | s->sg_handle = IVTV_DMA_UNMAPPED; | 162 | s->sg_handle = IVTV_DMA_UNMAPPED; |
164 | ivtv_queue_init(&s->q_free); | 163 | ivtv_queue_init(&s->q_free); |
165 | ivtv_queue_init(&s->q_full); | 164 | ivtv_queue_init(&s->q_full); |