From 3593cab5d62c4c7abced1076710f9bc2d8847433 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Tue, 7 Feb 2006 06:49:14 -0200 Subject: V4L/DVB (3318b): sem2mutex: drivers/media/, #2 Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/b2c2/flexcop-common.h | 4 +- drivers/media/dvb/b2c2/flexcop-i2c.c | 6 +- drivers/media/dvb/bt8xx/bt878.c | 4 +- drivers/media/dvb/bt8xx/bt878.h | 4 +- drivers/media/dvb/bt8xx/dst.c | 14 +-- drivers/media/dvb/bt8xx/dst_ca.c | 6 +- drivers/media/dvb/bt8xx/dst_common.h | 3 +- drivers/media/dvb/bt8xx/dvb-bt8xx.c | 12 +-- drivers/media/dvb/bt8xx/dvb-bt8xx.h | 3 +- drivers/media/dvb/cinergyT2/cinergyT2.c | 47 +++++----- drivers/media/dvb/dvb-core/dmxdev.c | 86 +++++++++--------- drivers/media/dvb/dvb-core/dmxdev.h | 6 +- drivers/media/dvb/dvb-core/dvb_demux.c | 104 +++++++++++----------- drivers/media/dvb/dvb-core/dvb_demux.h | 4 +- drivers/media/dvb/dvb-core/dvb_frontend.c | 13 ++- drivers/media/dvb/dvb-core/dvb_net.c | 14 +-- drivers/media/dvb/dvb-usb/cxusb.c | 4 +- drivers/media/dvb/dvb-usb/dibusb-common.c | 4 +- drivers/media/dvb/dvb-usb/digitv.c | 4 +- drivers/media/dvb/dvb-usb/dvb-usb-init.c | 4 +- drivers/media/dvb/dvb-usb/dvb-usb-urb.c | 4 +- drivers/media/dvb/dvb-usb/dvb-usb.h | 9 +- drivers/media/dvb/dvb-usb/vp702x.c | 4 +- drivers/media/dvb/dvb-usb/vp7045.c | 4 +- drivers/media/dvb/frontends/bcm3510.c | 9 +- drivers/media/dvb/ttpci/av7110.c | 23 +++-- drivers/media/dvb/ttpci/av7110.h | 7 +- drivers/media/dvb/ttpci/av7110_hw.c | 40 ++++----- drivers/media/dvb/ttpci/budget.h | 4 +- drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | 32 +++---- drivers/media/dvb/ttusb-dec/ttusb_dec.c | 31 +++---- 31 files changed, 262 insertions(+), 251 deletions(-) (limited to 'drivers/media/dvb') diff --git a/drivers/media/dvb/b2c2/flexcop-common.h b/drivers/media/dvb/b2c2/flexcop-common.h index 7d7e1613c5a..b3dd0603cd9 100644 --- a/drivers/media/dvb/b2c2/flexcop-common.h +++ b/drivers/media/dvb/b2c2/flexcop-common.h @@ -10,6 +10,7 @@ #include #include +#include #include "flexcop-reg.h" @@ -73,8 +74,7 @@ struct flexcop_device { int (*fe_sleep) (struct dvb_frontend *); struct i2c_adapter i2c_adap; - struct semaphore i2c_sem; - + struct mutex i2c_mutex; struct module *owner; /* options and status */ diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c index 56495cb6cd0..e0bd2d8f0f0 100644 --- a/drivers/media/dvb/b2c2/flexcop-i2c.c +++ b/drivers/media/dvb/b2c2/flexcop-i2c.c @@ -135,7 +135,7 @@ static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs struct flexcop_device *fc = i2c_get_adapdata(i2c_adap); int i, ret = 0; - if (down_interruptible(&fc->i2c_sem)) + if (mutex_lock_interruptible(&fc->i2c_mutex)) return -ERESTARTSYS; /* reading */ @@ -161,7 +161,7 @@ static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs else ret = num; - up(&fc->i2c_sem); + mutex_unlock(&fc->i2c_mutex); return ret; } @@ -180,7 +180,7 @@ int flexcop_i2c_init(struct flexcop_device *fc) { int ret; - sema_init(&fc->i2c_sem,1); + mutex_init(&fc->i2c_mutex); memset(&fc->i2c_adap, 0, sizeof(struct i2c_adapter)); strncpy(fc->i2c_adap.name, "B2C2 FlexCop device",I2C_NAME_SIZE); diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c index 34c3189a1a3..d276ce6b366 100644 --- a/drivers/media/dvb/bt8xx/bt878.c +++ b/drivers/media/dvb/bt8xx/bt878.c @@ -344,7 +344,7 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet * int retval; retval = 0; - if (down_interruptible (&bt->gpio_lock)) + if (mutex_lock_interruptible(&bt->gpio_lock)) return -ERESTARTSYS; /* special gpio signal */ switch (cmd) { @@ -375,7 +375,7 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet * retval = -EINVAL; break; } - up(&bt->gpio_lock); + mutex_unlock(&bt->gpio_lock); return retval; } diff --git a/drivers/media/dvb/bt8xx/bt878.h b/drivers/media/dvb/bt8xx/bt878.h index 9faf93770d0..f685bc12960 100644 --- a/drivers/media/dvb/bt8xx/bt878.h +++ b/drivers/media/dvb/bt8xx/bt878.h @@ -25,6 +25,8 @@ #include #include #include +#include + #include "bt848.h" #include "bttv.h" @@ -108,7 +110,7 @@ struct cards { extern int bt878_num; struct bt878 { - struct semaphore gpio_lock; + struct mutex gpio_lock; unsigned int nr; unsigned int bttv_nr; struct i2c_adapter *adapter; diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 3a2ff1cc24b..d800df1212c 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -910,7 +910,7 @@ static int dst_get_device_id(struct dst_state *state) static int dst_probe(struct dst_state *state) { - sema_init(&state->dst_mutex, 1); + mutex_init(&state->dst_mutex); if ((rdc_8820_reset(state)) < 0) { dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed."); return -1; @@ -962,7 +962,7 @@ int dst_command(struct dst_state *state, u8 *data, u8 len) { u8 reply; - down(&state->dst_mutex); + mutex_lock(&state->dst_mutex); if ((dst_comm_init(state)) < 0) { dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed."); goto error; @@ -1013,11 +1013,11 @@ int dst_command(struct dst_state *state, u8 *data, u8 len) dprintk(verbose, DST_INFO, 1, "checksum failure"); goto error; } - up(&state->dst_mutex); + mutex_unlock(&state->dst_mutex); return 0; error: - up(&state->dst_mutex); + mutex_unlock(&state->dst_mutex); return -EIO; } @@ -1128,7 +1128,7 @@ static int dst_write_tuna(struct dvb_frontend *fe) dst_set_voltage(fe, SEC_VOLTAGE_13); } state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); - down(&state->dst_mutex); + mutex_lock(&state->dst_mutex); if ((dst_comm_init(state)) < 0) { dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed."); goto error; @@ -1160,11 +1160,11 @@ static int dst_write_tuna(struct dvb_frontend *fe) state->diseq_flags |= ATTEMPT_TUNE; retval = dst_get_tuna(state); werr: - up(&state->dst_mutex); + mutex_unlock(&state->dst_mutex); return retval; error: - up(&state->dst_mutex); + mutex_unlock(&state->dst_mutex); return -EIO; } diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index c650b4bf7f5..f6b49a801eb 100644 --- a/drivers/media/dvb/bt8xx/dst_ca.c +++ b/drivers/media/dvb/bt8xx/dst_ca.c @@ -81,7 +81,7 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8 { u8 reply; - down(&state->dst_mutex); + mutex_lock(&state->dst_mutex); dst_comm_init(state); msleep(65); @@ -110,11 +110,11 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8 goto error; } } - up(&state->dst_mutex); + mutex_unlock(&state->dst_mutex); return 0; error: - up(&state->dst_mutex); + mutex_unlock(&state->dst_mutex); return -EIO; } diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h index 81557f38fe3..51d4e043716 100644 --- a/drivers/media/dvb/bt8xx/dst_common.h +++ b/drivers/media/dvb/bt8xx/dst_common.h @@ -25,6 +25,7 @@ #include #include #include +#include #include "bt878.h" #include "dst_ca.h" @@ -121,7 +122,7 @@ struct dst_state { u8 vendor[8]; u8 board_info[8]; - struct semaphore dst_mutex; + struct mutex dst_mutex; }; struct dst_types { diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index ea27b15007e..1649846f9ce 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c @@ -76,13 +76,13 @@ static int dvb_bt8xx_start_feed(struct dvb_demux_feed *dvbdmxfeed) if (!dvbdmx->dmx.frontend) return -EINVAL; - down(&card->lock); + mutex_lock(&card->lock); card->nfeeds++; rc = card->nfeeds; if (card->nfeeds == 1) bt878_start(card->bt, card->gpio_mode, card->op_sync_orin, card->irq_err_ignore); - up(&card->lock); + mutex_unlock(&card->lock); return rc; } @@ -96,11 +96,11 @@ static int dvb_bt8xx_stop_feed(struct dvb_demux_feed *dvbdmxfeed) if (!dvbdmx->dmx.frontend) return -EINVAL; - down(&card->lock); + mutex_lock(&card->lock); card->nfeeds--; if (card->nfeeds == 0) bt878_stop(card->bt); - up(&card->lock); + mutex_unlock(&card->lock); return 0; } @@ -788,7 +788,7 @@ static int dvb_bt8xx_probe(struct bttv_sub_device *sub) if (!(card = kzalloc(sizeof(struct dvb_bt8xx_card), GFP_KERNEL))) return -ENOMEM; - init_MUTEX(&card->lock); + mutex_init(&card->lock); card->bttv_nr = sub->core->nr; strncpy(card->card_name, sub->core->name, sizeof(sub->core->name)); card->i2c_adapter = &sub->core->i2c_adap; @@ -881,7 +881,7 @@ static int dvb_bt8xx_probe(struct bttv_sub_device *sub) return -EFAULT; } - init_MUTEX(&card->bt->gpio_lock); + mutex_init(&card->bt->gpio_lock); card->bt->bttv_nr = sub->core->nr; if ( (ret = dvb_bt8xx_load_card(card, sub->core->type)) ) { diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.h b/drivers/media/dvb/bt8xx/dvb-bt8xx.h index cf035a80361..00dd9fa54c8 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.h +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.h @@ -26,6 +26,7 @@ #define DVB_BT8XX_H #include +#include #include "dvbdev.h" #include "dvb_net.h" #include "bttv.h" @@ -38,7 +39,7 @@ #include "lgdt330x.h" struct dvb_bt8xx_card { - struct semaphore lock; + struct mutex lock; int nfeeds; char card_name[32]; struct dvb_adapter dvb_adapter; diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index c4b4c5b6b7c..29b7be5271d 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "dmxdev.h" #include "dvb_demux.h" @@ -116,7 +117,7 @@ static struct dvb_frontend_info cinergyt2_fe_info = { struct cinergyt2 { struct dvb_demux demux; struct usb_device *udev; - struct semaphore sem; + struct mutex sem; struct dvb_adapter adapter; struct dvb_device *fedev; struct dmxdev dmxdev; @@ -345,14 +346,14 @@ static int cinergyt2_start_feed(struct dvb_demux_feed *dvbdmxfeed) struct dvb_demux *demux = dvbdmxfeed->demux; struct cinergyt2 *cinergyt2 = demux->priv; - if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) + if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) return -ERESTARTSYS; if (cinergyt2->streaming == 0) cinergyt2_start_stream_xfer(cinergyt2); cinergyt2->streaming++; - up(&cinergyt2->sem); + mutex_unlock(&cinergyt2->sem); return 0; } @@ -361,13 +362,13 @@ static int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed) struct dvb_demux *demux = dvbdmxfeed->demux; struct cinergyt2 *cinergyt2 = demux->priv; - if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) + if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) return -ERESTARTSYS; if (--cinergyt2->streaming == 0) cinergyt2_stop_stream_xfer(cinergyt2); - up(&cinergyt2->sem); + mutex_unlock(&cinergyt2->sem); return 0; } @@ -483,11 +484,11 @@ static int cinergyt2_open (struct inode *inode, struct file *file) struct cinergyt2 *cinergyt2 = dvbdev->priv; int err = -ERESTARTSYS; - if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) + if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) return -ERESTARTSYS; if ((err = dvb_generic_open(inode, file))) { - up(&cinergyt2->sem); + mutex_unlock(&cinergyt2->sem); return err; } @@ -499,7 +500,7 @@ static int cinergyt2_open (struct inode *inode, struct file *file) atomic_inc(&cinergyt2->inuse); - up(&cinergyt2->sem); + mutex_unlock(&cinergyt2->sem); return 0; } @@ -517,7 +518,7 @@ static int cinergyt2_release (struct inode *inode, struct file *file) struct dvb_device *dvbdev = file->private_data; struct cinergyt2 *cinergyt2 = dvbdev->priv; - if (down_interruptible(&cinergyt2->sem)) + if (mutex_lock_interruptible(&cinergyt2->sem)) return -ERESTARTSYS; if (!cinergyt2->disconnect_pending && (file->f_flags & O_ACCMODE) != O_RDONLY) { @@ -526,7 +527,7 @@ static int cinergyt2_release (struct inode *inode, struct file *file) cinergyt2_sleep(cinergyt2, 1); } - up(&cinergyt2->sem); + mutex_unlock(&cinergyt2->sem); if (atomic_dec_and_test(&cinergyt2->inuse) && cinergyt2->disconnect_pending) { warn("delayed unregister in release"); @@ -541,12 +542,12 @@ static unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct struct dvb_device *dvbdev = file->private_data; struct cinergyt2 *cinergyt2 = dvbdev->priv; - if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) + if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) return -ERESTARTSYS; poll_wait(file, &cinergyt2->poll_wq, wait); - up(&cinergyt2->sem); + mutex_unlock(&cinergyt2->sem); return (POLLIN | POLLRDNORM | POLLPRI); } @@ -613,7 +614,7 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file, if (copy_from_user(&p, (void __user*) arg, sizeof(p))) return -EFAULT; - if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) + if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) return -ERESTARTSYS; param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; @@ -629,7 +630,7 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file, (char *) param, sizeof(*param), NULL, 0); - up(&cinergyt2->sem); + mutex_unlock(&cinergyt2->sem); return (err < 0) ? err : 0; } @@ -724,7 +725,7 @@ static void cinergyt2_query_rc (void *data) struct cinergyt2_rc_event rc_events[12]; int n, len, i; - if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) + if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) return; len = cinergyt2_command(cinergyt2, buf, sizeof(buf), @@ -784,7 +785,7 @@ out: schedule_delayed_work(&cinergyt2->rc_query_work, msecs_to_jiffies(RC_QUERY_INTERVAL)); - up(&cinergyt2->sem); + mutex_unlock(&cinergyt2->sem); } static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2) @@ -849,7 +850,7 @@ static void cinergyt2_query (void *data) uint8_t lock_bits; uint32_t unc; - if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) + if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) return; unc = s->uncorrected_block_count; @@ -868,7 +869,7 @@ static void cinergyt2_query (void *data) schedule_delayed_work(&cinergyt2->query_work, msecs_to_jiffies(QUERY_INTERVAL)); - up(&cinergyt2->sem); + mutex_unlock(&cinergyt2->sem); } static int cinergyt2_probe (struct usb_interface *intf, @@ -885,7 +886,7 @@ static int cinergyt2_probe (struct usb_interface *intf, memset (cinergyt2, 0, sizeof (struct cinergyt2)); usb_set_intfdata (intf, (void *) cinergyt2); - init_MUTEX(&cinergyt2->sem); + mutex_init(&cinergyt2->sem); init_waitqueue_head (&cinergyt2->poll_wq); INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2); @@ -967,7 +968,7 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state) { struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); - if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) + if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) return -ERESTARTSYS; if (state.event > PM_EVENT_ON) { @@ -981,7 +982,7 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state) cinergyt2_sleep(cinergyt2, 1); } - up(&cinergyt2->sem); + mutex_unlock(&cinergyt2->sem); return 0; } @@ -990,7 +991,7 @@ static int cinergyt2_resume (struct usb_interface *intf) struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); struct dvbt_set_parameters_msg *param = &cinergyt2->param; - if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) + if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) return -ERESTARTSYS; if (!cinergyt2->sleeping) { @@ -1003,7 +1004,7 @@ static int cinergyt2_resume (struct usb_interface *intf) cinergyt2_resume_rc(cinergyt2); - up(&cinergyt2->sem); + mutex_unlock(&cinergyt2->sem); return 0; } diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 7b8373ad121..ead5343d770 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c @@ -175,12 +175,12 @@ static int dvb_dvr_open(struct inode *inode, struct file *file) dprintk ("function : %s\n", __FUNCTION__); - if (down_interruptible (&dmxdev->mutex)) + if (mutex_lock_interruptible(&dmxdev->mutex)) return -ERESTARTSYS; if ((file->f_flags&O_ACCMODE)==O_RDWR) { if (!(dmxdev->capabilities&DMXDEV_CAP_DUPLEX)) { - up(&dmxdev->mutex); + mutex_unlock(&dmxdev->mutex); return -EOPNOTSUPP; } } @@ -190,7 +190,7 @@ static int dvb_dvr_open(struct inode *inode, struct file *file) dmxdev->dvr_buffer.size=DVR_BUFFER_SIZE; dmxdev->dvr_buffer.data=vmalloc(DVR_BUFFER_SIZE); if (!dmxdev->dvr_buffer.data) { - up(&dmxdev->mutex); + mutex_unlock(&dmxdev->mutex); return -ENOMEM; } } @@ -199,20 +199,20 @@ static int dvb_dvr_open(struct inode *inode, struct file *file) dmxdev->dvr_orig_fe=dmxdev->demux->frontend; if (!dmxdev->demux->write) { - up(&dmxdev->mutex); + mutex_unlock(&dmxdev->mutex); return -EOPNOTSUPP; } front=get_fe(dmxdev->demux, DMX_MEMORY_FE); if (!front) { - up(&dmxdev->mutex); + mutex_unlock(&dmxdev->mutex); return -EINVAL; } dmxdev->demux->disconnect_frontend(dmxdev->demux); dmxdev->demux->connect_frontend(dmxdev->demux, front); } - up(&dmxdev->mutex); + mutex_unlock(&dmxdev->mutex); return 0; } @@ -221,7 +221,7 @@ static int dvb_dvr_release(struct inode *inode, struct file *file) struct dvb_device *dvbdev = file->private_data; struct dmxdev *dmxdev = dvbdev->priv; - if (down_interruptible (&dmxdev->mutex)) + if (mutex_lock_interruptible(&dmxdev->mutex)) return -ERESTARTSYS; if ((file->f_flags&O_ACCMODE)==O_WRONLY) { @@ -239,7 +239,7 @@ static int dvb_dvr_release(struct inode *inode, struct file *file) vfree(mem); } } - up(&dmxdev->mutex); + mutex_unlock(&dmxdev->mutex); return 0; } @@ -254,10 +254,10 @@ static ssize_t dvb_dvr_write(struct file *file, const char __user *buf, return -EOPNOTSUPP; if ((file->f_flags&O_ACCMODE)!=O_WRONLY) return -EINVAL; - if (down_interruptible (&dmxdev->mutex)) + if (mutex_lock_interruptible(&dmxdev->mutex)) return -ERESTARTSYS; ret=dmxdev->demux->write(dmxdev->demux, buf, count); - up(&dmxdev->mutex); + mutex_unlock(&dmxdev->mutex); return ret; } @@ -268,11 +268,11 @@ static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count, struct dmxdev *dmxdev = dvbdev->priv; int ret; - //down(&dmxdev->mutex); + //mutex_lock(&dmxdev->mutex); ret= dvb_dmxdev_buffer_read(&dmxdev->dvr_buffer, file->f_flags&O_NONBLOCK, buf, count, ppos); - //up(&dmxdev->mutex); + //mutex_unlock(&dmxdev->mutex); return ret; } @@ -688,7 +688,7 @@ static int dvb_demux_open(struct inode *inode, struct file *file) if (!dmxdev->filter) return -EINVAL; - if (down_interruptible(&dmxdev->mutex)) + if (mutex_lock_interruptible(&dmxdev->mutex)) return -ERESTARTSYS; for (i=0; ifilternum; i++) @@ -696,12 +696,12 @@ static int dvb_demux_open(struct inode *inode, struct file *file) break; if (i==dmxdev->filternum) { - up(&dmxdev->mutex); + mutex_unlock(&dmxdev->mutex); return -EMFILE; } dmxdevfilter=&dmxdev->filter[i]; - sema_init(&dmxdevfilter->mutex, 1); + mutex_init(&dmxdevfilter->mutex); dmxdevfilter->dvbdev=dmxdev->dvbdev; file->private_data=dmxdevfilter; @@ -711,18 +711,18 @@ static int dvb_demux_open(struct inode *inode, struct file *file) dmxdevfilter->feed.ts=NULL; init_timer(&dmxdevfilter->timer); - up(&dmxdev->mutex); + mutex_unlock(&dmxdev->mutex); return 0; } static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev, struct dmxdev_filter *dmxdevfilter) { - if (down_interruptible(&dmxdev->mutex)) + if (mutex_lock_interruptible(&dmxdev->mutex)) return -ERESTARTSYS; - if (down_interruptible(&dmxdevfilter->mutex)) { - up(&dmxdev->mutex); + if (mutex_lock_interruptible(&dmxdevfilter->mutex)) { + mutex_unlock(&dmxdev->mutex); return -ERESTARTSYS; } @@ -740,8 +740,8 @@ static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev, struct dmxdev_filter *d dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_FREE); wake_up(&dmxdevfilter->buffer.queue); - up(&dmxdevfilter->mutex); - up(&dmxdev->mutex); + mutex_unlock(&dmxdevfilter->mutex); + mutex_unlock(&dmxdev->mutex); return 0; } @@ -841,7 +841,7 @@ dvb_demux_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) struct dmxdev_filter *dmxdevfilter= file->private_data; int ret=0; - if (down_interruptible(&dmxdevfilter->mutex)) + if (mutex_lock_interruptible(&dmxdevfilter->mutex)) return -ERESTARTSYS; if (dmxdevfilter->type==DMXDEV_TYPE_SEC) @@ -851,7 +851,7 @@ dvb_demux_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) file->f_flags&O_NONBLOCK, buf, count, ppos); - up(&dmxdevfilter->mutex); + mutex_unlock(&dmxdevfilter->mutex); return ret; } @@ -864,58 +864,58 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, unsigned long arg=(unsigned long) parg; int ret=0; - if (down_interruptible (&dmxdev->mutex)) + if (mutex_lock_interruptible(&dmxdev->mutex)) return -ERESTARTSYS; switch (cmd) { case DMX_START: - if (down_interruptible(&dmxdevfilter->mutex)) { - up(&dmxdev->mutex); + if (mutex_lock_interruptible(&dmxdevfilter->mutex)) { + mutex_unlock(&dmxdev->mutex); return -ERESTARTSYS; } if (dmxdevfilter->statemutex); + mutex_unlock(&dmxdevfilter->mutex); break; case DMX_STOP: - if (down_interruptible(&dmxdevfilter->mutex)) { - up(&dmxdev->mutex); + if (mutex_lock_interruptible(&dmxdevfilter->mutex)) { + mutex_unlock(&dmxdev->mutex); return -ERESTARTSYS; } ret=dvb_dmxdev_filter_stop(dmxdevfilter); - up(&dmxdevfilter->mutex); + mutex_unlock(&dmxdevfilter->mutex); break; case DMX_SET_FILTER: - if (down_interruptible(&dmxdevfilter->mutex)) { - up(&dmxdev->mutex); + if (mutex_lock_interruptible(&dmxdevfilter->mutex)) { + mutex_unlock(&dmxdev->mutex); return -ERESTARTSYS; } ret = dvb_dmxdev_filter_set(dmxdev, dmxdevfilter, (struct dmx_sct_filter_params *)parg); - up(&dmxdevfilter->mutex); + mutex_unlock(&dmxdevfilter->mutex); break; case DMX_SET_PES_FILTER: - if (down_interruptible(&dmxdevfilter->mutex)) { - up(&dmxdev->mutex); + if (mutex_lock_interruptible(&dmxdevfilter->mutex)) { + mutex_unlock(&dmxdev->mutex); return -ERESTARTSYS; } ret=dvb_dmxdev_pes_filter_set(dmxdev, dmxdevfilter, (struct dmx_pes_filter_params *)parg); - up(&dmxdevfilter->mutex); + mutex_unlock(&dmxdevfilter->mutex); break; case DMX_SET_BUFFER_SIZE: - if (down_interruptible(&dmxdevfilter->mutex)) { - up(&dmxdev->mutex); + if (mutex_lock_interruptible(&dmxdevfilter->mutex)) { + mutex_unlock(&dmxdev->mutex); return -ERESTARTSYS; } ret=dvb_dmxdev_set_buffer_size(dmxdevfilter, arg); - up(&dmxdevfilter->mutex); + mutex_unlock(&dmxdevfilter->mutex); break; case DMX_GET_EVENT: @@ -959,7 +959,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, default: ret=-EINVAL; } - up(&dmxdev->mutex); + mutex_unlock(&dmxdev->mutex); return ret; } @@ -1030,7 +1030,7 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file, int ret=0; - if (down_interruptible (&dmxdev->mutex)) + if (mutex_lock_interruptible(&dmxdev->mutex)) return -ERESTARTSYS; switch (cmd) { @@ -1042,7 +1042,7 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file, default: ret=-EINVAL; } - up(&dmxdev->mutex); + mutex_unlock(&dmxdev->mutex); return ret; } @@ -1113,7 +1113,7 @@ dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter) return -ENOMEM; } - sema_init(&dmxdev->mutex, 1); + mutex_init(&dmxdev->mutex); spin_lock_init(&dmxdev->lock); for (i=0; ifilternum; i++) { dmxdev->filter[i].dev=dmxdev; diff --git a/drivers/media/dvb/dvb-core/dmxdev.h b/drivers/media/dvb/dvb-core/dmxdev.h index fd72920c219..ec2a7a4da5e 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.h +++ b/drivers/media/dvb/dvb-core/dmxdev.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include @@ -83,7 +83,7 @@ struct dmxdev_filter { struct dmxdev *dev; struct dmxdev_buffer buffer; - struct semaphore mutex; + struct mutex mutex; /* only for sections */ struct timer_list timer; @@ -117,7 +117,7 @@ struct dmxdev { struct dmxdev_buffer dvr_buffer; #define DVR_BUFFER_SIZE (10*188*1024) - struct semaphore mutex; + struct mutex mutex; spinlock_t lock; }; diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index b4c899b1595..83ec5e06c48 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c @@ -589,18 +589,18 @@ static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type, if (pid > DMX_MAX_PID) return -EINVAL; - if (down_interruptible(&demux->mutex)) + if (mutex_lock_interruptible(&demux->mutex)) return -ERESTARTSYS; if (ts_type & TS_DECODER) { if (pes_type >= DMX_TS_PES_OTHER) { - up(&demux->mutex); + mutex_unlock(&demux->mutex); return -EINVAL; } if (demux->pesfilter[pes_type] && demux->pesfilter[pes_type] != feed) { - up(&demux->mutex); + mutex_unlock(&demux->mutex); return -EINVAL; } @@ -622,14 +622,14 @@ static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type, #else feed->buffer = vmalloc(feed->buffer_size); if (!feed->buffer) { - up(&demux->mutex); + mutex_unlock(&demux->mutex); return -ENOMEM; } #endif } feed->state = DMX_STATE_READY; - up(&demux->mutex); + mutex_unlock(&demux->mutex); return 0; } @@ -640,21 +640,21 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed) struct dvb_demux *demux = feed->demux; int ret; - if (down_interruptible(&demux->mutex)) + if (mutex_lock_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) { - up(&demux->mutex); + mutex_unlock(&demux->mutex); return -EINVAL; } if (!demux->start_feed) { - up(&demux->mutex); + mutex_unlock(&demux->mutex); return -ENODEV; } if ((ret = demux->start_feed(feed)) < 0) { - up(&demux->mutex); + mutex_unlock(&demux->mutex); return ret; } @@ -662,7 +662,7 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed) ts_feed->is_filtering = 1; feed->state = DMX_STATE_GO; spin_unlock_irq(&demux->lock); - up(&demux->mutex); + mutex_unlock(&demux->mutex); return 0; } @@ -673,16 +673,16 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed) struct dvb_demux *demux = feed->demux; int ret; - if (down_interruptible(&demux->mutex)) + if (mutex_lock_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state < DMX_STATE_GO) { - up(&demux->mutex); + mutex_unlock(&demux->mutex); return -EINVAL; } if (!demux->stop_feed) { - up(&demux->mutex); + mutex_unlock(&demux->mutex); return -ENODEV; } @@ -692,7 +692,7 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed) ts_feed->is_filtering = 0; feed->state = DMX_STATE_ALLOCATED; spin_unlock_irq(&demux->lock); - up(&demux->mutex); + mutex_unlock(&demux->mutex); return ret; } @@ -704,11 +704,11 @@ static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx, struct dvb_demux *demux = (struct dvb_demux *)dmx; struct dvb_demux_feed *feed; - if (down_interruptible(&demux->mutex)) + if (mutex_lock_interruptible(&demux->mutex)) return -ERESTARTSYS; if (!(feed = dvb_dmx_feed_alloc(demux))) { - up(&demux->mutex); + mutex_unlock(&demux->mutex); return -EBUSY; } @@ -729,7 +729,7 @@ static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx, if (!(feed->filter = dvb_dmx_filter_alloc(demux))) { feed->state = DMX_STATE_FREE; - up(&demux->mutex); + mutex_unlock(&demux->mutex); return -EBUSY; } @@ -737,7 +737,7 @@ static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx, feed->filter->feed = feed; feed->filter->state = DMX_STATE_READY; - up(&demux->mutex); + mutex_unlock(&demux->mutex); return 0; } @@ -748,11 +748,11 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dvb_demux *demux = (struct dvb_demux *)dmx; struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; - if (down_interruptible(&demux->mutex)) + if (mutex_lock_interruptible(&demux->mutex)) return -ERESTARTSYS; if (feed->state == DMX_STATE_FREE) { - up(&demux->mutex); + mutex_unlock(&demux->mutex); return -EINVAL; } #ifndef NOBUFS @@ -770,7 +770,7 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, if (feed->ts_type & TS_DECODER && feed->pes_type < DMX_TS_PES_OTHER) demux->pesfilter[feed->pes_type] = NULL; - up(&demux->mutex); + mutex_unlock(&demux->mutex); return 0; } @@ -785,12 +785,12 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed, struct dvb_demux *dvbdemux = dvbdmxfeed->demux; struct dvb_demux_filter *dvbdmxfilter; - if (down_interruptible(&dvbdemux->mutex)) + if (mutex_lock_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux); if (!dvbdmxfilter) { - up(&dvbdemux->mutex); + mutex_unlock(&dvbdemux->mutex); return -EBUSY; } @@ -805,7 +805,7 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed, dvbdmxfeed->filter = dvbdmxfilter; spin_unlock_irq(&dvbdemux->lock); - up(&dvbdemux->mutex); + mutex_unlock(&dvbdemux->mutex); return 0; } @@ -819,7 +819,7 @@ static int dmx_section_feed_set(struct dmx_section_feed *feed, if (pid > 0x1fff) return -EINVAL; - if (down_interruptible(&dvbdmx->mutex)) + if (mutex_lock_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; dvb_demux_feed_add(dvbdmxfeed); @@ -833,13 +833,13 @@ static int dmx_section_feed_set(struct dmx_section_feed *feed, #else dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size); if (!dvbdmxfeed->buffer) { - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return -ENOMEM; } #endif dvbdmxfeed->state = DMX_STATE_READY; - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return 0; } @@ -871,16 +871,16 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) struct dvb_demux *dvbdmx = dvbdmxfeed->demux; int ret; - if (down_interruptible(&dvbdmx->mutex)) + if (mutex_lock_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (feed->is_filtering) { - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return -EBUSY; } if (!dvbdmxfeed->filter) { - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return -EINVAL; } @@ -890,14 +890,14 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) dvbdmxfeed->feed.sec.seclen = 0; if (!dvbdmx->start_feed) { - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return -ENODEV; } prepare_secfilters(dvbdmxfeed); if ((ret = dvbdmx->start_feed(dvbdmxfeed)) < 0) { - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return ret; } @@ -906,7 +906,7 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) dvbdmxfeed->state = DMX_STATE_GO; spin_unlock_irq(&dvbdmx->lock); - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return 0; } @@ -916,11 +916,11 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed) struct dvb_demux *dvbdmx = dvbdmxfeed->demux; int ret; - if (down_interruptible(&dvbdmx->mutex)) + if (mutex_lock_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (!dvbdmx->stop_feed) { - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return -ENODEV; } @@ -931,7 +931,7 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed) feed->is_filtering = 0; spin_unlock_irq(&dvbdmx->lock); - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return ret; } @@ -942,11 +942,11 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = dvbdmxfeed->demux; - if (down_interruptible(&dvbdmx->mutex)) + if (mutex_lock_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (dvbdmxfilter->feed != dvbdmxfeed) { - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return -EINVAL; } @@ -966,7 +966,7 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, dvbdmxfilter->state = DMX_STATE_FREE; spin_unlock_irq(&dvbdmx->lock); - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return 0; } @@ -977,11 +977,11 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; struct dvb_demux_feed *dvbdmxfeed; - if (down_interruptible(&dvbdmx->mutex)) + if (mutex_lock_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) { - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return -EBUSY; } @@ -1006,7 +1006,7 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, (*feed)->stop_filtering = dmx_section_feed_stop_filtering; (*feed)->release_filter = dmx_section_feed_release_filter; - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return 0; } @@ -1016,11 +1016,11 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux, struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; - if (down_interruptible(&dvbdmx->mutex)) + if (mutex_lock_interruptible(&dvbdmx->mutex)) return -ERESTARTSYS; if (dvbdmxfeed->state == DMX_STATE_FREE) { - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return -EINVAL; } #ifndef NOBUFS @@ -1033,7 +1033,7 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux, dvbdmxfeed->pid = 0xffff; - up(&dvbdmx->mutex); + mutex_unlock(&dvbdmx->mutex); return 0; } @@ -1071,10 +1071,10 @@ static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE)) return -EINVAL; - if (down_interruptible(&dvbdemux->mutex)) + if (mutex_lock_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; dvb_dmx_swfilter(dvbdemux, buf, count); - up(&dvbdemux->mutex); + mutex_unlock(&dvbdemux->mutex); if (signal_pending(current)) return -EINTR; @@ -1126,11 +1126,11 @@ static int dvbdmx_connect_frontend(struct dmx_demux *demux, if (demux->frontend) return -EINVAL; - if (down_interruptible(&dvbdemux->mutex)) + if (mutex_lock_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; demux->frontend = frontend; - up(&dvbdemux->mutex); + mutex_unlock(&dvbdemux->mutex); return 0; } @@ -1138,11 +1138,11 @@ static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) { struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; - if (down_interruptible(&dvbdemux->mutex)) + if (mutex_lock_interruptible(&dvbdemux->mutex)) return -ERESTARTSYS; demux->frontend = NULL; - up(&dvbdemux->mutex); + mutex_unlock(&dvbdemux->mutex); return 0; } @@ -1215,7 +1215,7 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) dmx->disconnect_frontend = dvbdmx_disconnect_frontend; dmx->get_pes_pids = dvbdmx_get_pes_pids; - sema_init(&dvbdemux->mutex, 1); + mutex_init(&dvbdemux->mutex); spin_lock_init(&dvbdemux->lock); return 0; diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h index 0cc888339d5..2c5f915329c 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.h +++ b/drivers/media/dvb/dvb-core/dvb_demux.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include "demux.h" @@ -125,7 +125,7 @@ struct dvb_demux { u8 tsbuf[204]; int tsbufp; - struct semaphore mutex; + struct mutex mutex; spinlock_t lock; }; diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index 771f32d889e..22e96cf8497 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "dvb_frontend.h" #include "dvbdev.h" @@ -88,7 +87,7 @@ MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB vola * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again. */ -static DECLARE_MUTEX(frontend_mutex); +static DEFINE_MUTEX(frontend_mutex); struct dvb_frontend_private { @@ -1021,12 +1020,12 @@ int dvb_register_frontend(struct dvb_adapter* dvb, dprintk ("%s\n", __FUNCTION__); - if (down_interruptible (&frontend_mutex)) + if (mutex_lock_interruptible(&frontend_mutex)) return -ERESTARTSYS; fe->frontend_priv = kzalloc(sizeof(struct dvb_frontend_private), GFP_KERNEL); if (fe->frontend_priv == NULL) { - up(&frontend_mutex); + mutex_unlock(&frontend_mutex); return -ENOMEM; } fepriv = fe->frontend_priv; @@ -1045,7 +1044,7 @@ int dvb_register_frontend(struct dvb_adapter* dvb, dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template, fe, DVB_DEVICE_FRONTEND); - up (&frontend_mutex); + mutex_unlock(&frontend_mutex); return 0; } EXPORT_SYMBOL(dvb_register_frontend); @@ -1055,7 +1054,7 @@ int dvb_unregister_frontend(struct dvb_frontend* fe) struct dvb_frontend_private *fepriv = fe->frontend_priv; dprintk ("%s\n", __FUNCTION__); - down (&frontend_mutex); + mutex_lock(&frontend_mutex); dvb_unregister_device (fepriv->dvbdev); dvb_frontend_stop (fe); if (fe->ops->release) @@ -1064,7 +1063,7 @@ int dvb_unregister_frontend(struct dvb_frontend* fe) printk("dvb_frontend: Demodulator (%s) does not have a release callback!\n", fe->ops->info.name); /* fe is invalid now */ kfree(fepriv); - up (&frontend_mutex); + mutex_unlock(&frontend_mutex); return 0; } EXPORT_SYMBOL(dvb_unregister_frontend); diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index 6711eb6a058..2f0f35811bf 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c @@ -62,6 +62,7 @@ #include #include #include +#include #include "dvb_demux.h" #include "dvb_net.h" @@ -151,8 +152,7 @@ struct dvb_net_priv { unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */ int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */ unsigned long ts_count; /* Current ts cell counter. */ - - struct semaphore mutex; + struct mutex mutex; }; @@ -889,7 +889,7 @@ static int dvb_net_feed_start(struct net_device *dev) unsigned char *mac = (unsigned char *) dev->dev_addr; dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode); - down(&priv->mutex); + mutex_lock(&priv->mutex); if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0]) printk("%s: BUG %d\n", __FUNCTION__, __LINE__); @@ -974,7 +974,7 @@ static int dvb_net_feed_start(struct net_device *dev) ret = -EINVAL; error: - up(&priv->mutex); + mutex_unlock(&priv->mutex); return ret; } @@ -984,7 +984,7 @@ static int dvb_net_feed_stop(struct net_device *dev) int i, ret = 0; dprintk("%s\n", __FUNCTION__); - down(&priv->mutex); + mutex_lock(&priv->mutex); if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) { if (priv->secfeed) { if (priv->secfeed->is_filtering) { @@ -1026,7 +1026,7 @@ static int dvb_net_feed_stop(struct net_device *dev) printk("%s: no ts feed to stop\n", dev->name); } else ret = -EINVAL; - up(&priv->mutex); + mutex_unlock(&priv->mutex); return ret; } @@ -1208,7 +1208,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype) INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net); INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net); - init_MUTEX(&priv->mutex); + mutex_init(&priv->mutex); net->base_addr = pid; diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index f327fac1688..e62a293c7e5 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -77,7 +77,7 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) struct dvb_usb_device *d = i2c_get_adapdata(adap); int i; - if (down_interruptible(&d->i2c_sem) < 0) + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) return -EAGAIN; if (num > 2) @@ -126,7 +126,7 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) } } - up(&d->i2c_sem); + mutex_unlock(&d->i2c_mutex); return i; } diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c index 269d899da48..2d52b76671d 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-common.c +++ b/drivers/media/dvb/dvb-usb/dibusb-common.c @@ -128,7 +128,7 @@ static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num struct dvb_usb_device *d = i2c_get_adapdata(adap); int i; - if (down_interruptible(&d->i2c_sem) < 0) + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) return -EAGAIN; if (num > 2) @@ -146,7 +146,7 @@ static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num break; } - up(&d->i2c_sem); + mutex_unlock(&d->i2c_mutex); return i; } diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index caa1346e306..91136c00ce9 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -48,7 +48,7 @@ static int digitv_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num struct dvb_usb_device *d = i2c_get_adapdata(adap); int i; - if (down_interruptible(&d->i2c_sem) < 0) + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) return -EAGAIN; if (num > 2) @@ -67,7 +67,7 @@ static int digitv_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num break; } - up(&d->i2c_sem); + mutex_unlock(&d->i2c_mutex); return i; } diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c index 716f8bf528c..4258a995dce 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c @@ -42,8 +42,8 @@ static int dvb_usb_init(struct dvb_usb_device *d) { int ret = 0; - sema_init(&d->usb_sem, 1); - sema_init(&d->i2c_sem, 1); + mutex_init(&d->usb_mutex); + mutex_init(&d->i2c_mutex); d->state = DVB_USB_STATE_INIT; diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c index ee821974dc6..9002f35aa95 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c @@ -21,7 +21,7 @@ int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, if (wbuf == NULL || wlen == 0) return -EINVAL; - if ((ret = down_interruptible(&d->usb_sem))) + if ((ret = mutex_lock_interruptible(&d->usb_mutex))) return ret; deb_xfer(">>> "); @@ -53,7 +53,7 @@ int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, } } - up(&d->usb_sem); + mutex_unlock(&d->usb_mutex); return ret; } EXPORT_SYMBOL(dvb_usb_generic_rw); diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index 5e5d21ad93c..d2be37cc43b 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "dvb_frontend.h" #include "dvb_demux.h" @@ -227,8 +228,8 @@ struct dvb_usb_properties { * @feedcount: number of reqested feeds (used for streaming-activation) * @pid_filtering: is hardware pid_filtering used or not. * - * @usb_sem: semaphore of USB control messages (reading needs two messages) - * @i2c_sem: semaphore for i2c-transfers + * @usb_mutex: semaphore of USB control messages (reading needs two messages) + * @i2c_mutex: semaphore for i2c-transfers * * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB * @pll_addr: I2C address of the tuner for programming @@ -283,10 +284,10 @@ struct dvb_usb_device { int pid_filtering; /* locking */ - struct semaphore usb_sem; + struct mutex usb_mutex; /* i2c */ - struct semaphore i2c_sem; + struct mutex i2c_mutex; struct i2c_adapter i2c_adap; /* tuner programming information */ diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c index 4a95eca81c5..b2f098a2d5f 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.c +++ b/drivers/media/dvb/dvb-usb/vp702x.c @@ -75,7 +75,7 @@ int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int il { int ret; - if ((ret = down_interruptible(&d->usb_sem))) + if ((ret = mutex_lock_interruptible(&d->usb_mutex))) return ret; if ((ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen)) < 0) @@ -84,7 +84,7 @@ int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int il ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen); unlock: - up(&d->usb_sem); + mutex_unlock(&d->usb_mutex); return ret; } diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 028204956bb..7fa656b108c 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c @@ -38,7 +38,7 @@ int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, deb_xfer("out buffer: "); debug_dump(outbuf,outlen+1,deb_xfer); - if ((ret = down_interruptible(&d->usb_sem))) + if ((ret = mutex_lock_interruptible(&d->usb_mutex))) return ret; if (usb_control_msg(d->udev, @@ -68,7 +68,7 @@ int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, memcpy(in,&inbuf[1],inlen); unlock: - up(&d->usb_sem); + mutex_unlock(&d->usb_mutex); return ret; } diff --git a/drivers/media/dvb/frontends/bcm3510.c b/drivers/media/dvb/frontends/bcm3510.c index caaee893ca7..1708a1d4893 100644 --- a/drivers/media/dvb/frontends/bcm3510.c +++ b/drivers/media/dvb/frontends/bcm3510.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "dvb_frontend.h" #include "bcm3510.h" @@ -52,7 +53,7 @@ struct bcm3510_state { struct dvb_frontend frontend; /* demodulator private data */ - struct semaphore hab_sem; + struct mutex hab_mutex; u8 firmware_loaded:1; unsigned long next_status_check; @@ -213,7 +214,7 @@ static int bcm3510_do_hab_cmd(struct bcm3510_state *st, u8 cmd, u8 msgid, u8 *ob dbufout(ob,olen+2,deb_hab); deb_hab("\n"); - if (down_interruptible(&st->hab_sem) < 0) + if (mutex_lock_interruptible(&st->hab_mutex) < 0) return -EAGAIN; if ((ret = bcm3510_hab_send_request(st, ob, olen+2)) < 0 || @@ -226,7 +227,7 @@ static int bcm3510_do_hab_cmd(struct bcm3510_state *st, u8 cmd, u8 msgid, u8 *ob memcpy(ibuf,&ib[2],ilen); error: - up(&st->hab_sem); + mutex_unlock(&st->hab_mutex); return ret; } @@ -796,7 +797,7 @@ struct dvb_frontend* bcm3510_attach(const struct bcm3510_config *config, state->frontend.ops = &state->ops; state->frontend.demodulator_priv = state; - sema_init(&state->hab_sem, 1); + mutex_init(&state->hab_mutex); if ((ret = bcm3510_readB(state,0xe0,&v)) < 0) goto error; diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index d36369e9e88..1aa61bf29ad 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c @@ -54,7 +54,6 @@ #include #include -#include #include @@ -242,10 +241,10 @@ static int arm_thread(void *data) if (!av7110->arm_ready) continue; - if (down_interruptible(&av7110->dcomlock)) + if (mutex_lock_interruptible(&av7110->dcomlock)) break; newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); if (newloops == av7110->arm_loops || av7110->arm_errors > 3) { printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n", @@ -253,10 +252,10 @@ static int arm_thread(void *data) recover_arm(av7110); - if (down_interruptible(&av7110->dcomlock)) + if (mutex_lock_interruptible(&av7110->dcomlock)) break; newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1; - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); } av7110->arm_loops = newloops; av7110->arm_errors = 0; @@ -741,7 +740,7 @@ int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, int ret = 0; dprintk(4, "%p\n", av7110); - if (down_interruptible(&av7110->pid_mutex)) + if (mutex_lock_interruptible(&av7110->pid_mutex)) return -ERESTARTSYS; if (!(vpid & 0x8000)) @@ -760,7 +759,7 @@ int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid); } - up(&av7110->pid_mutex); + mutex_unlock(&av7110->pid_mutex); return ret; } @@ -2096,7 +2095,7 @@ static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status) if (av7110->playing) return 0; - if (down_interruptible(&av7110->pid_mutex)) + if (mutex_lock_interruptible(&av7110->pid_mutex)) return -ERESTARTSYS; if (synced) { @@ -2118,7 +2117,7 @@ static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status) if (!ret) av7110->fe_synced = synced; - up(&av7110->pid_mutex); + mutex_unlock(&av7110->pid_mutex); return ret; } @@ -2713,16 +2712,16 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110); tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110); - sema_init(&av7110->pid_mutex, 1); + mutex_init(&av7110->pid_mutex); /* locks for data transfers from/to AV7110 */ spin_lock_init(&av7110->debilock); - sema_init(&av7110->dcomlock, 1); + mutex_init(&av7110->dcomlock); av7110->debitype = -1; /* default OSD window */ av7110->osdwin = 1; - sema_init(&av7110->osd_sema, 1); + mutex_init(&av7110->osd_mutex); /* ARM "watchdog" */ init_waitqueue_head(&av7110->arm_wait); diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h index fafd25fab83..3e2e12124ba 100644 --- a/drivers/media/dvb/ttpci/av7110.h +++ b/drivers/media/dvb/ttpci/av7110.h @@ -16,6 +16,7 @@ #include #include #include +#include #include "dvbdev.h" #include "demux.h" @@ -127,7 +128,7 @@ struct av7110 { /* DEBI and polled command interface */ spinlock_t debilock; - struct semaphore dcomlock; + struct mutex dcomlock; volatile int debitype; volatile int debilen; @@ -146,7 +147,7 @@ struct av7110 { int osdwin; /* currently active window */ u16 osdbpp[8]; - struct semaphore osd_sema; + struct mutex osd_mutex; /* CA */ @@ -172,7 +173,7 @@ struct av7110 { struct tasklet_struct vpe_tasklet; int fe_synced; - struct semaphore pid_mutex; + struct mutex pid_mutex; int video_blank; struct video_status videostate; diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index b2e63e9fc05..3c5366d15a8 100644 --- a/drivers/media/dvb/ttpci/av7110_hw.c +++ b/drivers/media/dvb/ttpci/av7110_hw.c @@ -324,10 +324,10 @@ int av7110_wait_msgstate(struct av7110 *av7110, u16 flags) start = jiffies; for (;;) { err = time_after(jiffies, start + ARM_WAIT_FREE); - if (down_interruptible(&av7110->dcomlock)) + if (mutex_lock_interruptible(&av7110->dcomlock)) return -ERESTARTSYS; stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); if ((stat & flags) == 0) break; if (err) { @@ -484,11 +484,11 @@ static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) dprintk(1, "arm not ready.\n"); return -1; } - if (down_interruptible(&av7110->dcomlock)) + if (mutex_lock_interruptible(&av7110->dcomlock)) return -ERESTARTSYS; ret = __av7110_send_fw_cmd(av7110, buf, length); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); if (ret && ret!=-ERESTARTSYS) printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n", __FUNCTION__, ret); @@ -560,11 +560,11 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, return -1; } - if (down_interruptible(&av7110->dcomlock)) + if (mutex_lock_interruptible(&av7110->dcomlock)) return -ERESTARTSYS; if ((err = __av7110_send_fw_cmd(av7110, request_buf, request_buf_len)) < 0) { - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); printk(KERN_ERR "dvb-ttpci: av7110_fw_request error %d\n", err); return err; } @@ -576,7 +576,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, break; if (err) { printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); return -ETIMEDOUT; } #ifdef _NOHANDSHAKE @@ -592,7 +592,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, break; if (err) { printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); return -ETIMEDOUT; } msleep(1); @@ -603,12 +603,12 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); if (stat & GPMQOver) { printk(KERN_ERR "%s: GPMQOver\n", __FUNCTION__); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); return -1; } else if (stat & OSDQOver) { printk(KERN_ERR "%s: OSDQOver\n", __FUNCTION__); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); return -1; } #endif @@ -616,7 +616,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, for (i = 0; i < reply_buf_len; i++) reply_buf[i] = rdebi(av7110, DEBINOSWAP, COM_BUFF + 2 * i, 0, 2); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); return 0; } @@ -732,7 +732,7 @@ static int FlushText(struct av7110 *av7110) unsigned long start; int err; - if (down_interruptible(&av7110->dcomlock)) + if (mutex_lock_interruptible(&av7110->dcomlock)) return -ERESTARTSYS; start = jiffies; while (1) { @@ -742,12 +742,12 @@ static int FlushText(struct av7110 *av7110) if (err) { printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n", __FUNCTION__); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); return -ETIMEDOUT; } msleep(1); } - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); return 0; } @@ -758,7 +758,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf) int length = strlen(buf) + 1; u16 cbuf[5] = { (COMTYPE_OSD << 8) + DText, 3, win, x, y }; - if (down_interruptible(&av7110->dcomlock)) + if (mutex_lock_interruptible(&av7110->dcomlock)) return -ERESTARTSYS; start = jiffies; @@ -769,7 +769,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf) if (ret) { printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n", __FUNCTION__); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); return -ETIMEDOUT; } msleep(1); @@ -783,7 +783,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf) if (ret) { printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); return -ETIMEDOUT; } msleep(1); @@ -795,7 +795,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf) if (length & 1) wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2); ret = __av7110_send_fw_cmd(av7110, cbuf, 5); - up(&av7110->dcomlock); + mutex_unlock(&av7110->dcomlock); if (ret && ret!=-ERESTARTSYS) printk(KERN_ERR "dvb-ttpci: WriteText error %d\n", ret); return ret; @@ -1059,7 +1059,7 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc) { int ret; - if (down_interruptible(&av7110->osd_sema)) + if (mutex_lock_interruptible(&av7110->osd_mutex)) return -ERESTARTSYS; switch (dc->cmd) { @@ -1195,7 +1195,7 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc) break; } - up(&av7110->osd_sema); + mutex_unlock(&av7110->osd_mutex); if (ret==-ERESTARTSYS) dprintk(1, "av7110_osd_cmd(%d) returns with -ERESTARTSYS\n",dc->cmd); else if (ret) diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h index c7bb63c4d98..4ac0f4d0802 100644 --- a/drivers/media/dvb/ttpci/budget.h +++ b/drivers/media/dvb/ttpci/budget.h @@ -10,6 +10,8 @@ #include "dvb_net.h" #include +#include + #include extern int budget_debug; @@ -51,7 +53,7 @@ struct budget { struct dmx_frontend mem_frontend; int fe_synced; - struct semaphore pid_mutex; + struct mutex pid_mutex; int ci_present; int video_port; diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 5a13c4744f6..ecb15d4ecf8 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include "dvb_frontend.h" #include "dmxdev.h" @@ -35,7 +35,6 @@ #include #include - /* TTUSB_HWSECTIONS: the DSP supports filtering in hardware, however, since the "muxstream" @@ -83,8 +82,8 @@ struct ttusb { struct dvb_net dvbnet; /* and one for USB access. */ - struct semaphore semi2c; - struct semaphore semusb; + struct mutex semi2c; + struct mutex semusb; struct dvb_adapter adapter; struct usb_device *dev; @@ -150,7 +149,7 @@ static int ttusb_cmd(struct ttusb *ttusb, printk("\n"); #endif - if (down_interruptible(&ttusb->semusb) < 0) + if (mutex_lock_interruptible(&ttusb->semusb) < 0) return -EAGAIN; err = usb_bulk_msg(ttusb->dev, ttusb->bulk_out_pipe, @@ -158,13 +157,13 @@ static int ttusb_cmd(struct ttusb *ttusb, if (err != 0) { dprintk("%s: usb_bulk_msg(send) failed, err == %i!\n", __FUNCTION__, err); - up(&ttusb->semusb); + mutex_unlock(&ttusb->semusb); return err; } if (actual_len != len) { dprintk("%s: only wrote %d of %d bytes\n", __FUNCTION__, actual_len, len); - up(&ttusb->semusb); + mutex_unlock(&ttusb->semusb); return -1; } @@ -174,7 +173,7 @@ static int ttusb_cmd(struct ttusb *ttusb, if (err != 0) { printk("%s: failed, receive error %d\n", __FUNCTION__, err); - up(&ttusb->semusb); + mutex_unlock(&ttusb->semusb); return err; } #if DEBUG >= 3 @@ -185,14 +184,14 @@ static int ttusb_cmd(struct ttusb *ttusb, printk("\n"); #endif if (!needresult) - up(&ttusb->semusb); + mutex_unlock(&ttusb->semusb); return 0; } static int ttusb_result(struct ttusb *ttusb, u8 * data, int len) { memcpy(data, ttusb->last_result, len); - up(&ttusb->semusb); + mutex_unlock(&ttusb->semusb); return 0; } @@ -250,7 +249,7 @@ static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, int num int i = 0; int inc; - if (down_interruptible(&ttusb->semi2c) < 0) + if (mutex_lock_interruptible(&ttusb->semi2c) < 0) return -EAGAIN; while (i < num) { @@ -284,7 +283,7 @@ static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, int num i += inc; } - up(&ttusb->semi2c); + mutex_unlock(&ttusb->semi2c); return i; } @@ -1495,8 +1494,11 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i ttusb->dev = udev; ttusb->c = 0; ttusb->mux_state = 0; - sema_init(&ttusb->semi2c, 0); - sema_init(&ttusb->semusb, 1); + mutex_init(&ttusb->semi2c); + + mutex_lock(&ttusb->semi2c); + + mutex_init(&ttusb->semusb); ttusb_setup_interfaces(ttusb); @@ -1504,7 +1506,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i if (ttusb_init_controller(ttusb)) printk("ttusb_init_controller: error\n"); - up(&ttusb->semi2c); + mutex_unlock(&ttusb->semi2c); dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE); ttusb->adapter.priv = ttusb; diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index df831171e03..44dea321184 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c @@ -20,7 +20,8 @@ * */ -#include +#include + #include #include #include @@ -115,7 +116,7 @@ struct ttusb_dec { unsigned int out_pipe; unsigned int irq_pipe; enum ttusb_dec_interface interface; - struct semaphore usb_sem; + struct mutex usb_mutex; void *irq_buffer; struct urb *irq_urb; @@ -124,7 +125,7 @@ struct ttusb_dec { dma_addr_t iso_dma_handle; struct urb *iso_urb[ISO_BUF_COUNT]; int iso_stream_count; - struct semaphore iso_sem; + struct mutex iso_mutex; u8 packet[MAX_PVA_LENGTH + 4]; enum ttusb_dec_packet_type packet_type; @@ -273,9 +274,9 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, if (!b) return -ENOMEM; - if ((result = down_interruptible(&dec->usb_sem))) { + if ((result = mutex_lock_interruptible(&dec->usb_mutex))) { kfree(b); - printk("%s: Failed to down usb semaphore.\n", __FUNCTION__); + printk("%s: Failed to lock usb mutex.\n", __FUNCTION__); return result; } @@ -300,7 +301,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, if (result) { printk("%s: command bulk message failed: error %d\n", __FUNCTION__, result); - up(&dec->usb_sem); + mutex_unlock(&dec->usb_mutex); kfree(b); return result; } @@ -311,7 +312,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, if (result) { printk("%s: result bulk message failed: error %d\n", __FUNCTION__, result); - up(&dec->usb_sem); + mutex_unlock(&dec->usb_mutex); kfree(b); return result; } else { @@ -327,7 +328,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, if (cmd_result && b[3] > 0) memcpy(cmd_result, &b[4], b[3]); - up(&dec->usb_sem); + mutex_unlock(&dec->usb_mutex); kfree(b); return 0; @@ -835,7 +836,7 @@ static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec) dprintk("%s\n", __FUNCTION__); - if (down_interruptible(&dec->iso_sem)) + if (mutex_lock_interruptible(&dec->iso_mutex)) return; dec->iso_stream_count--; @@ -845,7 +846,7 @@ static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec) usb_kill_urb(dec->iso_urb[i]); } - up(&dec->iso_sem); + mutex_unlock(&dec->iso_mutex); } /* Setting the interface of the DEC tends to take down the USB communications @@ -890,7 +891,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) dprintk("%s\n", __FUNCTION__); - if (down_interruptible(&dec->iso_sem)) + if (mutex_lock_interruptible(&dec->iso_mutex)) return -EAGAIN; if (!dec->iso_stream_count) { @@ -911,7 +912,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) i--; } - up(&dec->iso_sem); + mutex_unlock(&dec->iso_mutex); return result; } } @@ -919,7 +920,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) dec->iso_stream_count++; - up(&dec->iso_sem); + mutex_unlock(&dec->iso_mutex); return 0; } @@ -1229,8 +1230,8 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec) { dprintk("%s\n", __FUNCTION__); - sema_init(&dec->usb_sem, 1); - sema_init(&dec->iso_sem, 1); + mutex_init(&dec->usb_mutex); + mutex_init(&dec->iso_mutex); dec->command_pipe = usb_sndbulkpipe(dec->udev, COMMAND_PIPE); dec->result_pipe = usb_rcvbulkpipe(dec->udev, RESULT_PIPE); -- cgit v1.2.3