aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ivtv/ivtv-fileops.c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2011-10-12 04:36:04 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-01-16 07:00:10 -0500
commit61bb725ef5a646d3fc8a64e41b020a65542cdae1 (patch)
tree5f35434d19ea58ae4ae32c5218bbdd43916978c4 /drivers/media/video/ivtv/ivtv-fileops.c
parentcdc037817cc15caf931cd3476970860d62f1985c (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/video/ivtv/ivtv-fileops.c')
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c19
1 files changed, 9 insertions, 10 deletions
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