Commit 61bb725e authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[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: default avatarHans Verkuil <hans.verkuil@cisco.com>
Acked-by: default avatarAndy Walls <awalls@md.metrocast.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent cdc03781
...@@ -731,9 +731,6 @@ static int __devinit ivtv_init_struct1(struct ivtv *itv) ...@@ -731,9 +731,6 @@ static int __devinit ivtv_init_struct1(struct ivtv *itv)
init_kthread_work(&itv->irq_work, ivtv_irq_work_handler); init_kthread_work(&itv->irq_work, ivtv_irq_work_handler);
/* start counting open_id at 1 */
itv->open_id = 1;
/* Initial settings */ /* Initial settings */
itv->cxhdl.port = CX2341X_PORT_MEMORY; itv->cxhdl.port = CX2341X_PORT_MEMORY;
itv->cxhdl.capabilities = CX2341X_CAP_HAS_SLICED_VBI; itv->cxhdl.capabilities = CX2341X_CAP_HAS_SLICED_VBI;
......
...@@ -332,7 +332,7 @@ struct ivtv_stream { ...@@ -332,7 +332,7 @@ struct ivtv_stream {
const char *name; /* name of the stream */ const char *name; /* name of the stream */
int type; /* stream type */ int type; /* stream type */
u32 id; struct v4l2_fh *fh; /* pointer to the streaming filehandle */
spinlock_t qlock; /* locks access to the queues */ spinlock_t qlock; /* locks access to the queues */
unsigned long s_flags; /* status flags, see above */ unsigned long s_flags; /* status flags, see above */
int dma; /* can be PCI_DMA_TODEVICE, PCI_DMA_FROMDEVICE or PCI_DMA_NONE */ int dma; /* can be PCI_DMA_TODEVICE, PCI_DMA_FROMDEVICE or PCI_DMA_NONE */
...@@ -379,7 +379,6 @@ struct ivtv_stream { ...@@ -379,7 +379,6 @@ struct ivtv_stream {
struct ivtv_open_id { struct ivtv_open_id {
struct v4l2_fh fh; struct v4l2_fh fh;
u32 open_id; /* unique ID for this file descriptor */
int type; /* stream type */ int type; /* stream type */
int yuv_frames; /* 1: started OUT_UDMA_YUV output mode */ int yuv_frames; /* 1: started OUT_UDMA_YUV output mode */
struct ivtv *itv; struct ivtv *itv;
......
...@@ -50,16 +50,16 @@ static int ivtv_claim_stream(struct ivtv_open_id *id, int type) ...@@ -50,16 +50,16 @@ static int ivtv_claim_stream(struct ivtv_open_id *id, int type)
if (test_and_set_bit(IVTV_F_S_CLAIMED, &s->s_flags)) { if (test_and_set_bit(IVTV_F_S_CLAIMED, &s->s_flags)) {
/* someone already claimed this stream */ /* someone already claimed this stream */
if (s->id == id->open_id) { if (s->fh == &id->fh) {
/* yes, this file descriptor did. So that's OK. */ /* yes, this file descriptor did. So that's OK. */
return 0; return 0;
} }
if (s->id == -1 && (type == IVTV_DEC_STREAM_TYPE_VBI || if (s->fh == NULL && (type == IVTV_DEC_STREAM_TYPE_VBI ||
type == IVTV_ENC_STREAM_TYPE_VBI)) { type == IVTV_ENC_STREAM_TYPE_VBI)) {
/* VBI is handled already internally, now also assign /* VBI is handled already internally, now also assign
the file descriptor to this stream for external the file descriptor to this stream for external
reading of the stream. */ reading of the stream. */
s->id = id->open_id; s->fh = &id->fh;
IVTV_DEBUG_INFO("Start Read VBI\n"); IVTV_DEBUG_INFO("Start Read VBI\n");
return 0; return 0;
} }
...@@ -67,7 +67,7 @@ static int ivtv_claim_stream(struct ivtv_open_id *id, int type) ...@@ -67,7 +67,7 @@ static int ivtv_claim_stream(struct ivtv_open_id *id, int type)
IVTV_DEBUG_INFO("Stream %d is busy\n", type); IVTV_DEBUG_INFO("Stream %d is busy\n", type);
return -EBUSY; return -EBUSY;
} }
s->id = id->open_id; s->fh = &id->fh;
if (type == IVTV_DEC_STREAM_TYPE_VBI) { if (type == IVTV_DEC_STREAM_TYPE_VBI) {
/* Enable reinsertion interrupt */ /* Enable reinsertion interrupt */
ivtv_clear_irq_mask(itv, IVTV_IRQ_DEC_VBI_RE_INSERT); ivtv_clear_irq_mask(itv, IVTV_IRQ_DEC_VBI_RE_INSERT);
...@@ -104,7 +104,7 @@ void ivtv_release_stream(struct ivtv_stream *s) ...@@ -104,7 +104,7 @@ void ivtv_release_stream(struct ivtv_stream *s)
struct ivtv *itv = s->itv; struct ivtv *itv = s->itv;
struct ivtv_stream *s_vbi; struct ivtv_stream *s_vbi;
s->id = -1; s->fh = NULL;
if ((s->type == IVTV_DEC_STREAM_TYPE_VBI || s->type == IVTV_ENC_STREAM_TYPE_VBI) && if ((s->type == IVTV_DEC_STREAM_TYPE_VBI || s->type == IVTV_ENC_STREAM_TYPE_VBI) &&
test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) { test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) {
/* this stream is still in use internally */ /* this stream is still in use internally */
...@@ -136,7 +136,7 @@ void ivtv_release_stream(struct ivtv_stream *s) ...@@ -136,7 +136,7 @@ void ivtv_release_stream(struct ivtv_stream *s)
/* was already cleared */ /* was already cleared */
return; return;
} }
if (s_vbi->id != -1) { if (s_vbi->fh) {
/* VBI stream still claimed by a file descriptor */ /* VBI stream still claimed by a file descriptor */
return; return;
} }
...@@ -359,7 +359,7 @@ static ssize_t ivtv_read(struct ivtv_stream *s, char __user *ubuf, size_t tot_co ...@@ -359,7 +359,7 @@ static ssize_t ivtv_read(struct ivtv_stream *s, char __user *ubuf, size_t tot_co
size_t tot_written = 0; size_t tot_written = 0;
int single_frame = 0; int single_frame = 0;
if (atomic_read(&itv->capturing) == 0 && s->id == -1) { if (atomic_read(&itv->capturing) == 0 && s->fh == NULL) {
/* shouldn't happen */ /* shouldn't happen */
IVTV_DEBUG_WARN("Stream %s not initialized before read\n", s->name); IVTV_DEBUG_WARN("Stream %s not initialized before read\n", s->name);
return -EIO; return -EIO;
...@@ -808,7 +808,7 @@ void ivtv_stop_capture(struct ivtv_open_id *id, int gop_end) ...@@ -808,7 +808,7 @@ void ivtv_stop_capture(struct ivtv_open_id *id, int gop_end)
id->type == IVTV_ENC_STREAM_TYPE_VBI) && id->type == IVTV_ENC_STREAM_TYPE_VBI) &&
test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) { test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) {
/* Also used internally, don't stop capturing */ /* Also used internally, don't stop capturing */
s->id = -1; s->fh = NULL;
} }
else { else {
ivtv_stop_v4l2_encode_stream(s, gop_end); ivtv_stop_v4l2_encode_stream(s, gop_end);
...@@ -890,7 +890,7 @@ int ivtv_v4l2_close(struct file *filp) ...@@ -890,7 +890,7 @@ int ivtv_v4l2_close(struct file *filp)
v4l2_fh_exit(fh); v4l2_fh_exit(fh);
/* Easy case first: this stream was never claimed by us */ /* Easy case first: this stream was never claimed by us */
if (s->id != id->open_id) { if (s->fh != &id->fh) {
kfree(id); kfree(id);
return 0; return 0;
} }
...@@ -974,7 +974,6 @@ int ivtv_v4l2_open(struct file *filp) ...@@ -974,7 +974,6 @@ int ivtv_v4l2_open(struct file *filp)
item->itv = itv; item->itv = itv;
item->type = s->type; item->type = s->type;
item->open_id = itv->open_id++;
filp->private_data = &item->fh; filp->private_data = &item->fh;
v4l2_fh_add(&item->fh); v4l2_fh_add(&item->fh);
......
...@@ -288,13 +288,13 @@ static void dma_post(struct ivtv_stream *s) ...@@ -288,13 +288,13 @@ static void dma_post(struct ivtv_stream *s)
ivtv_process_vbi_data(itv, buf, 0, s->type); ivtv_process_vbi_data(itv, buf, 0, s->type);
s->q_dma.bytesused += buf->bytesused; s->q_dma.bytesused += buf->bytesused;
} }
if (s->id == -1) { if (s->fh == NULL) {
ivtv_queue_move(s, &s->q_dma, NULL, &s->q_free, 0); ivtv_queue_move(s, &s->q_dma, NULL, &s->q_free, 0);
return; return;
} }
} }
ivtv_queue_move(s, &s->q_dma, NULL, &s->q_full, s->q_dma.bytesused); ivtv_queue_move(s, &s->q_dma, NULL, &s->q_full, s->q_dma.bytesused);
if (s->id != -1) if (s->fh)
wake_up(&s->waitq); wake_up(&s->waitq);
} }
......
...@@ -159,7 +159,6 @@ static void ivtv_stream_init(struct ivtv *itv, int type) ...@@ -159,7 +159,6 @@ static void ivtv_stream_init(struct ivtv *itv, int type)
s->buffers = (itv->options.kilobytes[type] * 1024 + s->buf_size - 1) / s->buf_size; s->buffers = (itv->options.kilobytes[type] * 1024 + s->buf_size - 1) / s->buf_size;
spin_lock_init(&s->qlock); spin_lock_init(&s->qlock);
init_waitqueue_head(&s->waitq); init_waitqueue_head(&s->waitq);
s->id = -1;
s->sg_handle = IVTV_DMA_UNMAPPED; s->sg_handle = IVTV_DMA_UNMAPPED;
ivtv_queue_init(&s->q_free); ivtv_queue_init(&s->q_free);
ivtv_queue_init(&s->q_full); ivtv_queue_init(&s->q_full);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment