diff options
author | Holger Waechtler <devnull@localhost> | 2002-11-07 20:07:44 +0000 |
---|---|---|
committer | Holger Waechtler <devnull@localhost> | 2002-11-07 20:07:44 +0000 |
commit | 5f5397e7b4d5c2a6db28b6d6ba95195fd8f3c323 (patch) | |
tree | 00c558b4226215fc454fe225fc4a77135584b396 /linux/drivers/media/dvb | |
parent | 14bc091fc1614e131758b2c03f7c75492bff7112 (diff) | |
download | mediapointer-dvb-s2-5f5397e7b4d5c2a6db28b6d6ba95195fd8f3c323.tar.gz mediapointer-dvb-s2-5f5397e7b4d5c2a6db28b6d6ba95195fd8f3c323.tar.bz2 |
applied filter mutex patch by <matt@Helius.COM>
Diffstat (limited to 'linux/drivers/media/dvb')
-rw-r--r-- | linux/drivers/media/dvb/dvb-core/dmxdev.c | 69 | ||||
-rw-r--r-- | linux/drivers/media/dvb/dvb-core/dmxdev.h | 2 |
2 files changed, 56 insertions, 15 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dmxdev.c b/linux/drivers/media/dvb/dvb-core/dmxdev.c index db4cb8b81..13e8beab3 100644 --- a/linux/drivers/media/dvb/dvb-core/dmxdev.c +++ b/linux/drivers/media/dvb/dvb-core/dmxdev.c @@ -557,11 +557,11 @@ dvb_dmxdev_filter_start(dmxdev_filter_t *dmxdevfilter) if (dmxdevfilter->state<DMXDEV_STATE_SET) return -EINVAL; - if (dmxdevfilter->state>=DMXDEV_STATE_GO) + + if (dmxdevfilter->state>=DMXDEV_STATE_GO) dvb_dmxdev_filter_stop(dmxdevfilter); - mem=dmxdevfilter->buffer.data; - if (!mem) { + if (!(mem = dmxdevfilter->buffer.data)) { mem=vmalloc(dmxdevfilter->buffer.size); spin_lock_irq(&dmxdevfilter->dev->lock); dmxdevfilter->buffer.data=mem; @@ -702,16 +702,21 @@ static int dvb_demux_open(struct inode *inode, struct file *file) if (!dmxdev->filter) return -EINVAL; - if (down_interruptible(&dmxdev->mutex)) + + if (down_interruptible(&dmxdev->mutex)) return -ERESTARTSYS; - for (i=0; i<dmxdev->filternum; i++) + + for (i=0; i<dmxdev->filternum; i++) if (dmxdev->filter[i].state==DMXDEV_STATE_FREE) break; - if (i==dmxdev->filternum) { + + if (i==dmxdev->filternum) { up(&dmxdev->mutex); return -EMFILE; } - dmxdevfilter=&dmxdev->filter[i]; + + dmxdevfilter=&dmxdev->filter[i]; + sema_init(&dmxdevfilter->mutex, 1); dmxdevfilter->dvbdev=dmxdev->dvbdev; file->private_data=dmxdevfilter; @@ -725,12 +730,18 @@ static int dvb_demux_open(struct inode *inode, struct file *file) return 0; } -int -dvb_dmxdev_filter_free(dmxdev_t *dmxdev, dmxdev_filter_t *dmxdevfilter) + +static +int dvb_dmxdev_filter_free(dmxdev_t *dmxdev, dmxdev_filter_t *dmxdevfilter) { if (down_interruptible(&dmxdev->mutex)) return -ERESTARTSYS; + if (down_interruptible(&dmxdevfilter->mutex)) { + up(&dmxdev->mutex); + return -ERESTARTSYS; + } + dvb_dmxdev_filter_stop(dmxdevfilter); dvb_dmxdev_filter_reset(dmxdevfilter); @@ -742,8 +753,10 @@ dvb_dmxdev_filter_free(dmxdev_t *dmxdev, dmxdev_filter_t *dmxdevfilter) spin_unlock_irq(&dmxdev->lock); vfree(mem); } + dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_FREE); wake_up(&dmxdevfilter->buffer.queue); + up(&dmxdevfilter->mutex); up(&dmxdev->mutex); return 0; } @@ -846,18 +859,19 @@ ssize_t dvb_demux_read(struct file *file, char *buf, size_t count, loff_t *ppos) { dmxdev_filter_t *dmxdevfilter=dvb_dmxdev_file_to_filter(file); - //dmxdev_t *dmxdev=dmxdevfilter->dev; int ret=0; - // semaphore should not be necessary (I hope ...) - //down(&dmxdev->mutex); + if (down_interruptible(&dmxdevfilter->mutex)) + return -ERESTARTSYS; + if (dmxdevfilter->type==DMXDEV_TYPE_SEC) ret=dvb_dmxdev_read_sec(dmxdevfilter, file, buf, count, ppos); else ret=dvb_dmxdev_buffer_read(&dmxdevfilter->buffer, file->f_flags&O_NONBLOCK, buf, count, ppos); - //up(&dmxdev->mutex); + + up(&dmxdevfilter->mutex); return ret; } @@ -874,29 +888,54 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, return -ERESTARTSYS; switch (cmd) { - case DMX_START: + case DMX_START: + if (down_interruptible(&dmxdevfilter->mutex)) { + up(&dmxdev->mutex); + return -ERESTARTSYS; + } if (dmxdevfilter->state<DMXDEV_STATE_SET) ret=-EINVAL; else ret=dvb_dmxdev_filter_start(dmxdevfilter); + up(&dmxdevfilter->mutex); break; - case DMX_STOP: + case DMX_STOP: + if (down_interruptible(&dmxdevfilter->mutex)) { + up(&dmxdev->mutex); + return -ERESTARTSYS; + } ret=dvb_dmxdev_filter_stop(dmxdevfilter); + up(&dmxdevfilter->mutex); break; case DMX_SET_FILTER: + if (down_interruptible(&dmxdevfilter->mutex)) { + up(&dmxdev->mutex); + return -ERESTARTSYS; + } ret=dvb_dmxdev_filter_set(dmxdev, dmxdevfilter, (struct dmx_sct_filter_params *)parg); + up(&dmxdevfilter->mutex); break; case DMX_SET_PES_FILTER: + if (down_interruptible(&dmxdevfilter->mutex)) { + up(&dmxdev->mutex); + return -ERESTARTSYS; + } ret=dvb_dmxdev_pes_filter_set(dmxdev, dmxdevfilter, (struct dmx_pes_filter_params *)parg); + up(&dmxdevfilter->mutex); break; case DMX_SET_BUFFER_SIZE: + if (down_interruptible(&dmxdevfilter->mutex)) { + up(&dmxdev->mutex); + return -ERESTARTSYS; + } ret=dvb_dmxdev_set_buffer_size(dmxdevfilter, arg); + up(&dmxdevfilter->mutex); break; case DMX_GET_EVENT: diff --git a/linux/drivers/media/dvb/dvb-core/dmxdev.h b/linux/drivers/media/dvb/dvb-core/dmxdev.h index d37a9f706..e56aafc2f 100644 --- a/linux/drivers/media/dvb/dvb-core/dmxdev.h +++ b/linux/drivers/media/dvb/dvb-core/dmxdev.h @@ -85,6 +85,8 @@ typedef struct dmxdev_filter_s { struct dmxdev_s *dev; dmxdev_buffer_t buffer; + struct semaphore mutex; + // only for sections struct timer_list timer; int todo; |