aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/common/saa7146_core.c6
-rw-r--r--drivers/media/common/saa7146_fops.c18
-rw-r--r--drivers/media/common/saa7146_i2c.c4
-rw-r--r--drivers/media/common/saa7146_vbi.c2
-rw-r--r--drivers/media/common/saa7146_video.c30
-rw-r--r--drivers/media/dvb/b2c2/flexcop-common.h4
-rw-r--r--drivers/media/dvb/b2c2/flexcop-i2c.c6
-rw-r--r--drivers/media/dvb/bt8xx/bt878.c4
-rw-r--r--drivers/media/dvb/bt8xx/bt878.h4
-rw-r--r--drivers/media/dvb/bt8xx/dst.c14
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c6
-rw-r--r--drivers/media/dvb/bt8xx/dst_common.h3
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c12
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.h3
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c47
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c86
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.h6
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.c104
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.h4
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c13
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c14
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c4
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c4
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c4
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c4
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-urb.c4
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h9
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x.c4
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045.c4
-rw-r--r--drivers/media/dvb/frontends/bcm3510.c9
-rw-r--r--drivers/media/dvb/ttpci/av7110.c23
-rw-r--r--drivers/media/dvb/ttpci/av7110.h7
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.c40
-rw-r--r--drivers/media/dvb/ttpci/budget.h4
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c32
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c31
-rw-r--r--drivers/media/radio/miropcm20-rds-core.c11
-rw-r--r--drivers/media/radio/radio-aimslab.c20
-rw-r--r--drivers/media/radio/radio-aztech.c12
-rw-r--r--drivers/media/radio/radio-maestro.c11
-rw-r--r--drivers/media/radio/radio-maxiradio.c11
-rw-r--r--drivers/media/radio/radio-sf16fmi.c22
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c22
-rw-r--r--drivers/media/radio/radio-typhoon.c12
-rw-r--r--drivers/media/radio/radio-zoltrix.c26
-rw-r--r--drivers/media/video/arv.c16
-rw-r--r--drivers/media/video/bttv-driver.c48
-rw-r--r--drivers/media/video/bw-qcam.c16
-rw-r--r--drivers/media/video/bw-qcam.h2
-rw-r--r--drivers/media/video/c-qcam.c19
-rw-r--r--drivers/media/video/cpia.c102
-rw-r--r--drivers/media/video/cpia.h5
-rw-r--r--drivers/media/video/cx88/cx88-core.c2
-rw-r--r--drivers/media/video/cx88/cx88-video.c26
-rw-r--r--drivers/media/video/cx88/cx88.h4
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c106
-rw-r--r--drivers/media/video/em28xx/em28xx.h3
-rw-r--r--drivers/media/video/meye.c112
-rw-r--r--drivers/media/video/meye.h4
-rw-r--r--drivers/media/video/mxb.c4
-rw-r--r--drivers/media/video/planb.c8
-rw-r--r--drivers/media/video/planb.h2
-rw-r--r--drivers/media/video/pms.c28
-rw-r--r--drivers/media/video/saa5246a.c10
-rw-r--r--drivers/media/video/saa5249.c10
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c8
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c40
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c40
-rw-r--r--drivers/media/video/saa7134/saa7134.h5
-rw-r--r--drivers/media/video/video-buf-dvb.c10
-rw-r--r--drivers/media/video/video-buf.c42
-rw-r--r--drivers/media/video/videodev.c6
-rw-r--r--drivers/media/video/vino.c33
75 files changed, 733 insertions, 706 deletions
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 04c1938b9c91..ee16c042ef6e 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -21,7 +21,7 @@
21#include <media/saa7146.h> 21#include <media/saa7146.h>
22 22
23LIST_HEAD(saa7146_devices); 23LIST_HEAD(saa7146_devices);
24DECLARE_MUTEX(saa7146_devices_lock); 24DEFINE_MUTEX(saa7146_devices_lock);
25 25
26static int saa7146_num; 26static int saa7146_num;
27 27
@@ -402,11 +402,11 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
402 402
403 pci_set_drvdata(pci, dev); 403 pci_set_drvdata(pci, dev);
404 404
405 init_MUTEX(&dev->lock); 405 mutex_init(&dev->lock);
406 spin_lock_init(&dev->int_slock); 406 spin_lock_init(&dev->int_slock);
407 spin_lock_init(&dev->slock); 407 spin_lock_init(&dev->slock);
408 408
409 init_MUTEX(&dev->i2c_lock); 409 mutex_init(&dev->i2c_lock);
410 410
411 dev->module = THIS_MODULE; 411 dev->module = THIS_MODULE;
412 init_waitqueue_head(&dev->i2c_wq); 412 init_waitqueue_head(&dev->i2c_wq);
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index f8cf73ed49ad..dc7fb20f47b5 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -17,18 +17,18 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit)
17 } 17 }
18 18
19 /* is it free? */ 19 /* is it free? */
20 down(&dev->lock); 20 mutex_lock(&dev->lock);
21 if (vv->resources & bit) { 21 if (vv->resources & bit) {
22 DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit)); 22 DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit));
23 /* no, someone else uses it */ 23 /* no, someone else uses it */
24 up(&dev->lock); 24 mutex_unlock(&dev->lock);
25 return 0; 25 return 0;
26 } 26 }
27 /* it's free, grab it */ 27 /* it's free, grab it */
28 fh->resources |= bit; 28 fh->resources |= bit;
29 vv->resources |= bit; 29 vv->resources |= bit;
30 DEB_D(("res: get 0x%02x, cur:0x%02x\n",bit,vv->resources)); 30 DEB_D(("res: get 0x%02x, cur:0x%02x\n",bit,vv->resources));
31 up(&dev->lock); 31 mutex_unlock(&dev->lock);
32 return 1; 32 return 1;
33} 33}
34 34
@@ -40,11 +40,11 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
40 if ((fh->resources & bits) != bits) 40 if ((fh->resources & bits) != bits)
41 BUG(); 41 BUG();
42 42
43 down(&dev->lock); 43 mutex_lock(&dev->lock);
44 fh->resources &= ~bits; 44 fh->resources &= ~bits;
45 vv->resources &= ~bits; 45 vv->resources &= ~bits;
46 DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources)); 46 DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources));
47 up(&dev->lock); 47 mutex_unlock(&dev->lock);
48} 48}
49 49
50 50
@@ -204,7 +204,7 @@ static int fops_open(struct inode *inode, struct file *file)
204 204
205 DEB_EE(("inode:%p, file:%p, minor:%d\n",inode,file,minor)); 205 DEB_EE(("inode:%p, file:%p, minor:%d\n",inode,file,minor));
206 206
207 if (down_interruptible(&saa7146_devices_lock)) 207 if (mutex_lock_interruptible(&saa7146_devices_lock))
208 return -ERESTARTSYS; 208 return -ERESTARTSYS;
209 209
210 list_for_each(list,&saa7146_devices) { 210 list_for_each(list,&saa7146_devices) {
@@ -276,7 +276,7 @@ out:
276 kfree(fh); 276 kfree(fh);
277 file->private_data = NULL; 277 file->private_data = NULL;
278 } 278 }
279 up(&saa7146_devices_lock); 279 mutex_unlock(&saa7146_devices_lock);
280 return result; 280 return result;
281} 281}
282 282
@@ -287,7 +287,7 @@ static int fops_release(struct inode *inode, struct file *file)
287 287
288 DEB_EE(("inode:%p, file:%p\n",inode,file)); 288 DEB_EE(("inode:%p, file:%p\n",inode,file));
289 289
290 if (down_interruptible(&saa7146_devices_lock)) 290 if (mutex_lock_interruptible(&saa7146_devices_lock))
291 return -ERESTARTSYS; 291 return -ERESTARTSYS;
292 292
293 if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { 293 if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
@@ -303,7 +303,7 @@ static int fops_release(struct inode *inode, struct file *file)
303 file->private_data = NULL; 303 file->private_data = NULL;
304 kfree(fh); 304 kfree(fh);
305 305
306 up(&saa7146_devices_lock); 306 mutex_unlock(&saa7146_devices_lock);
307 307
308 return 0; 308 return 0;
309} 309}
diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c
index 8aabdd8fb3c5..d9953f7a8b6b 100644
--- a/drivers/media/common/saa7146_i2c.c
+++ b/drivers/media/common/saa7146_i2c.c
@@ -279,7 +279,7 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *msgs, in
279 int address_err = 0; 279 int address_err = 0;
280 int short_delay = 0; 280 int short_delay = 0;
281 281
282 if (down_interruptible (&dev->i2c_lock)) 282 if (mutex_lock_interruptible(&dev->i2c_lock))
283 return -ERESTARTSYS; 283 return -ERESTARTSYS;
284 284
285 for(i=0;i<num;i++) { 285 for(i=0;i<num;i++) {
@@ -366,7 +366,7 @@ out:
366 } 366 }
367 } 367 }
368 368
369 up(&dev->i2c_lock); 369 mutex_unlock(&dev->i2c_lock);
370 return err; 370 return err;
371} 371}
372 372
diff --git a/drivers/media/common/saa7146_vbi.c b/drivers/media/common/saa7146_vbi.c
index 468d3c959075..500bd3f05e16 100644
--- a/drivers/media/common/saa7146_vbi.c
+++ b/drivers/media/common/saa7146_vbi.c
@@ -410,7 +410,7 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file)
410 V4L2_FIELD_SEQ_TB, // FIXME: does this really work? 410 V4L2_FIELD_SEQ_TB, // FIXME: does this really work?
411 sizeof(struct saa7146_buf), 411 sizeof(struct saa7146_buf),
412 file); 412 file);
413 init_MUTEX(&fh->vbi_q.lock); 413 mutex_init(&fh->vbi_q.lock);
414 414
415 init_timer(&fh->vbi_read_timeout); 415 init_timer(&fh->vbi_read_timeout);
416 fh->vbi_read_timeout.function = vbi_read_timeout; 416 fh->vbi_read_timeout.function = vbi_read_timeout;
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 7ebac7949df3..6b42713d97f4 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -378,20 +378,20 @@ static int s_fmt(struct saa7146_fh *fh, struct v4l2_format *f)
378 err = try_win(dev,&f->fmt.win); 378 err = try_win(dev,&f->fmt.win);
379 if (0 != err) 379 if (0 != err)
380 return err; 380 return err;
381 down(&dev->lock); 381 mutex_lock(&dev->lock);
382 fh->ov.win = f->fmt.win; 382 fh->ov.win = f->fmt.win;
383 fh->ov.nclips = f->fmt.win.clipcount; 383 fh->ov.nclips = f->fmt.win.clipcount;
384 if (fh->ov.nclips > 16) 384 if (fh->ov.nclips > 16)
385 fh->ov.nclips = 16; 385 fh->ov.nclips = 16;
386 if (copy_from_user(fh->ov.clips,f->fmt.win.clips,sizeof(struct v4l2_clip)*fh->ov.nclips)) { 386 if (copy_from_user(fh->ov.clips,f->fmt.win.clips,sizeof(struct v4l2_clip)*fh->ov.nclips)) {
387 up(&dev->lock); 387 mutex_unlock(&dev->lock);
388 return -EFAULT; 388 return -EFAULT;
389 } 389 }
390 390
391 /* fh->ov.fh is used to indicate that we have valid overlay informations, too */ 391 /* fh->ov.fh is used to indicate that we have valid overlay informations, too */
392 fh->ov.fh = fh; 392 fh->ov.fh = fh;
393 393
394 up(&dev->lock); 394 mutex_unlock(&dev->lock);
395 395
396 /* check if our current overlay is active */ 396 /* check if our current overlay is active */
397 if (IS_OVERLAY_ACTIVE(fh) != 0) { 397 if (IS_OVERLAY_ACTIVE(fh) != 0) {
@@ -516,7 +516,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
516 return -EINVAL; 516 return -EINVAL;
517 } 517 }
518 518
519 down(&dev->lock); 519 mutex_lock(&dev->lock);
520 520
521 switch (ctrl->type) { 521 switch (ctrl->type) {
522 case V4L2_CTRL_TYPE_BOOLEAN: 522 case V4L2_CTRL_TYPE_BOOLEAN:
@@ -560,7 +560,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
560 /* fixme: we can support changing VFLIP and HFLIP here... */ 560 /* fixme: we can support changing VFLIP and HFLIP here... */
561 if (IS_CAPTURE_ACTIVE(fh) != 0) { 561 if (IS_CAPTURE_ACTIVE(fh) != 0) {
562 DEB_D(("V4L2_CID_HFLIP while active capture.\n")); 562 DEB_D(("V4L2_CID_HFLIP while active capture.\n"));
563 up(&dev->lock); 563 mutex_unlock(&dev->lock);
564 return -EINVAL; 564 return -EINVAL;
565 } 565 }
566 vv->hflip = c->value; 566 vv->hflip = c->value;
@@ -568,7 +568,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
568 case V4L2_CID_VFLIP: 568 case V4L2_CID_VFLIP:
569 if (IS_CAPTURE_ACTIVE(fh) != 0) { 569 if (IS_CAPTURE_ACTIVE(fh) != 0) {
570 DEB_D(("V4L2_CID_VFLIP while active capture.\n")); 570 DEB_D(("V4L2_CID_VFLIP while active capture.\n"));
571 up(&dev->lock); 571 mutex_unlock(&dev->lock);
572 return -EINVAL; 572 return -EINVAL;
573 } 573 }
574 vv->vflip = c->value; 574 vv->vflip = c->value;
@@ -577,7 +577,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
577 return -EINVAL; 577 return -EINVAL;
578 } 578 }
579 } 579 }
580 up(&dev->lock); 580 mutex_unlock(&dev->lock);
581 581
582 if (IS_OVERLAY_ACTIVE(fh) != 0) { 582 if (IS_OVERLAY_ACTIVE(fh) != 0) {
583 saa7146_stop_preview(fh); 583 saa7146_stop_preview(fh);
@@ -939,7 +939,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
939 } 939 }
940 } 940 }
941 941
942 down(&dev->lock); 942 mutex_lock(&dev->lock);
943 943
944 /* ok, accept it */ 944 /* ok, accept it */
945 vv->ov_fb = *fb; 945 vv->ov_fb = *fb;
@@ -948,7 +948,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
948 vv->ov_fb.fmt.bytesperline = 948 vv->ov_fb.fmt.bytesperline =
949 vv->ov_fb.fmt.width*fmt->depth/8; 949 vv->ov_fb.fmt.width*fmt->depth/8;
950 950
951 up(&dev->lock); 951 mutex_unlock(&dev->lock);
952 952
953 return 0; 953 return 0;
954 } 954 }
@@ -1086,7 +1086,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
1086 } 1086 }
1087 } 1087 }
1088 1088
1089 down(&dev->lock); 1089 mutex_lock(&dev->lock);
1090 1090
1091 for(i = 0; i < dev->ext_vv_data->num_stds; i++) 1091 for(i = 0; i < dev->ext_vv_data->num_stds; i++)
1092 if (*id & dev->ext_vv_data->stds[i].id) 1092 if (*id & dev->ext_vv_data->stds[i].id)
@@ -1098,7 +1098,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
1098 found = 1; 1098 found = 1;
1099 } 1099 }
1100 1100
1101 up(&dev->lock); 1101 mutex_unlock(&dev->lock);
1102 1102
1103 if (vv->ov_suspend != NULL) { 1103 if (vv->ov_suspend != NULL) {
1104 saa7146_start_preview(vv->ov_suspend); 1104 saa7146_start_preview(vv->ov_suspend);
@@ -1201,11 +1201,11 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
1201 DEB_D(("VIDIOCGMBUF \n")); 1201 DEB_D(("VIDIOCGMBUF \n"));
1202 1202
1203 q = &fh->video_q; 1203 q = &fh->video_q;
1204 down(&q->lock); 1204 mutex_lock(&q->lock);
1205 err = videobuf_mmap_setup(q,gbuffers,gbufsize, 1205 err = videobuf_mmap_setup(q,gbuffers,gbufsize,
1206 V4L2_MEMORY_MMAP); 1206 V4L2_MEMORY_MMAP);
1207 if (err < 0) { 1207 if (err < 0) {
1208 up(&q->lock); 1208 mutex_unlock(&q->lock);
1209 return err; 1209 return err;
1210 } 1210 }
1211 memset(mbuf,0,sizeof(*mbuf)); 1211 memset(mbuf,0,sizeof(*mbuf));
@@ -1213,7 +1213,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
1213 mbuf->size = gbuffers * gbufsize; 1213 mbuf->size = gbuffers * gbufsize;
1214 for (i = 0; i < gbuffers; i++) 1214 for (i = 0; i < gbuffers; i++)
1215 mbuf->offsets[i] = i * gbufsize; 1215 mbuf->offsets[i] = i * gbufsize;
1216 up(&q->lock); 1216 mutex_unlock(&q->lock);
1217 return 0; 1217 return 0;
1218 } 1218 }
1219 default: 1219 default:
@@ -1414,7 +1414,7 @@ static int video_open(struct saa7146_dev *dev, struct file *file)
1414 sizeof(struct saa7146_buf), 1414 sizeof(struct saa7146_buf),
1415 file); 1415 file);
1416 1416
1417 init_MUTEX(&fh->video_q.lock); 1417 mutex_init(&fh->video_q.lock);
1418 1418
1419 return 0; 1419 return 0;
1420} 1420}
diff --git a/drivers/media/dvb/b2c2/flexcop-common.h b/drivers/media/dvb/b2c2/flexcop-common.h
index 7d7e1613c5a7..b3dd0603cd92 100644
--- a/drivers/media/dvb/b2c2/flexcop-common.h
+++ b/drivers/media/dvb/b2c2/flexcop-common.h
@@ -10,6 +10,7 @@
10 10
11#include <linux/config.h> 11#include <linux/config.h>
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <linux/mutex.h>
13 14
14#include "flexcop-reg.h" 15#include "flexcop-reg.h"
15 16
@@ -73,8 +74,7 @@ struct flexcop_device {
73 int (*fe_sleep) (struct dvb_frontend *); 74 int (*fe_sleep) (struct dvb_frontend *);
74 75
75 struct i2c_adapter i2c_adap; 76 struct i2c_adapter i2c_adap;
76 struct semaphore i2c_sem; 77 struct mutex i2c_mutex;
77
78 struct module *owner; 78 struct module *owner;
79 79
80 /* options and status */ 80 /* options and status */
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c
index 56495cb6cd02..e0bd2d8f0f0c 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
135 struct flexcop_device *fc = i2c_get_adapdata(i2c_adap); 135 struct flexcop_device *fc = i2c_get_adapdata(i2c_adap);
136 int i, ret = 0; 136 int i, ret = 0;
137 137
138 if (down_interruptible(&fc->i2c_sem)) 138 if (mutex_lock_interruptible(&fc->i2c_mutex))
139 return -ERESTARTSYS; 139 return -ERESTARTSYS;
140 140
141 /* reading */ 141 /* reading */
@@ -161,7 +161,7 @@ static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs
161 else 161 else
162 ret = num; 162 ret = num;
163 163
164 up(&fc->i2c_sem); 164 mutex_unlock(&fc->i2c_mutex);
165 165
166 return ret; 166 return ret;
167} 167}
@@ -180,7 +180,7 @@ int flexcop_i2c_init(struct flexcop_device *fc)
180{ 180{
181 int ret; 181 int ret;
182 182
183 sema_init(&fc->i2c_sem,1); 183 mutex_init(&fc->i2c_mutex);
184 184
185 memset(&fc->i2c_adap, 0, sizeof(struct i2c_adapter)); 185 memset(&fc->i2c_adap, 0, sizeof(struct i2c_adapter));
186 strncpy(fc->i2c_adap.name, "B2C2 FlexCop device",I2C_NAME_SIZE); 186 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 34c3189a1a33..d276ce6b3661 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 *
344 int retval; 344 int retval;
345 345
346 retval = 0; 346 retval = 0;
347 if (down_interruptible (&bt->gpio_lock)) 347 if (mutex_lock_interruptible(&bt->gpio_lock))
348 return -ERESTARTSYS; 348 return -ERESTARTSYS;
349 /* special gpio signal */ 349 /* special gpio signal */
350 switch (cmd) { 350 switch (cmd) {
@@ -375,7 +375,7 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *
375 retval = -EINVAL; 375 retval = -EINVAL;
376 break; 376 break;
377 } 377 }
378 up(&bt->gpio_lock); 378 mutex_unlock(&bt->gpio_lock);
379 return retval; 379 return retval;
380} 380}
381 381
diff --git a/drivers/media/dvb/bt8xx/bt878.h b/drivers/media/dvb/bt8xx/bt878.h
index 9faf93770d08..f685bc129609 100644
--- a/drivers/media/dvb/bt8xx/bt878.h
+++ b/drivers/media/dvb/bt8xx/bt878.h
@@ -25,6 +25,8 @@
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/mutex.h>
29
28#include "bt848.h" 30#include "bt848.h"
29#include "bttv.h" 31#include "bttv.h"
30 32
@@ -108,7 +110,7 @@ struct cards {
108extern int bt878_num; 110extern int bt878_num;
109 111
110struct bt878 { 112struct bt878 {
111 struct semaphore gpio_lock; 113 struct mutex gpio_lock;
112 unsigned int nr; 114 unsigned int nr;
113 unsigned int bttv_nr; 115 unsigned int bttv_nr;
114 struct i2c_adapter *adapter; 116 struct i2c_adapter *adapter;
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 3a2ff1cc24b7..d800df1212c5 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)
910 910
911static int dst_probe(struct dst_state *state) 911static int dst_probe(struct dst_state *state)
912{ 912{
913 sema_init(&state->dst_mutex, 1); 913 mutex_init(&state->dst_mutex);
914 if ((rdc_8820_reset(state)) < 0) { 914 if ((rdc_8820_reset(state)) < 0) {
915 dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed."); 915 dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed.");
916 return -1; 916 return -1;
@@ -962,7 +962,7 @@ int dst_command(struct dst_state *state, u8 *data, u8 len)
962{ 962{
963 u8 reply; 963 u8 reply;
964 964
965 down(&state->dst_mutex); 965 mutex_lock(&state->dst_mutex);
966 if ((dst_comm_init(state)) < 0) { 966 if ((dst_comm_init(state)) < 0) {
967 dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed."); 967 dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed.");
968 goto error; 968 goto error;
@@ -1013,11 +1013,11 @@ int dst_command(struct dst_state *state, u8 *data, u8 len)
1013 dprintk(verbose, DST_INFO, 1, "checksum failure"); 1013 dprintk(verbose, DST_INFO, 1, "checksum failure");
1014 goto error; 1014 goto error;
1015 } 1015 }
1016 up(&state->dst_mutex); 1016 mutex_unlock(&state->dst_mutex);
1017 return 0; 1017 return 0;
1018 1018
1019error: 1019error:
1020 up(&state->dst_mutex); 1020 mutex_unlock(&state->dst_mutex);
1021 return -EIO; 1021 return -EIO;
1022 1022
1023} 1023}
@@ -1128,7 +1128,7 @@ static int dst_write_tuna(struct dvb_frontend *fe)
1128 dst_set_voltage(fe, SEC_VOLTAGE_13); 1128 dst_set_voltage(fe, SEC_VOLTAGE_13);
1129 } 1129 }
1130 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); 1130 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
1131 down(&state->dst_mutex); 1131 mutex_lock(&state->dst_mutex);
1132 if ((dst_comm_init(state)) < 0) { 1132 if ((dst_comm_init(state)) < 0) {
1133 dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed."); 1133 dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed.");
1134 goto error; 1134 goto error;
@@ -1160,11 +1160,11 @@ static int dst_write_tuna(struct dvb_frontend *fe)
1160 state->diseq_flags |= ATTEMPT_TUNE; 1160 state->diseq_flags |= ATTEMPT_TUNE;
1161 retval = dst_get_tuna(state); 1161 retval = dst_get_tuna(state);
1162werr: 1162werr:
1163 up(&state->dst_mutex); 1163 mutex_unlock(&state->dst_mutex);
1164 return retval; 1164 return retval;
1165 1165
1166error: 1166error:
1167 up(&state->dst_mutex); 1167 mutex_unlock(&state->dst_mutex);
1168 return -EIO; 1168 return -EIO;
1169} 1169}
1170 1170
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
index c650b4bf7f5f..f6b49a801eba 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
81{ 81{
82 u8 reply; 82 u8 reply;
83 83
84 down(&state->dst_mutex); 84 mutex_lock(&state->dst_mutex);
85 dst_comm_init(state); 85 dst_comm_init(state);
86 msleep(65); 86 msleep(65);
87 87
@@ -110,11 +110,11 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8
110 goto error; 110 goto error;
111 } 111 }
112 } 112 }
113 up(&state->dst_mutex); 113 mutex_unlock(&state->dst_mutex);
114 return 0; 114 return 0;
115 115
116error: 116error:
117 up(&state->dst_mutex); 117 mutex_unlock(&state->dst_mutex);
118 return -EIO; 118 return -EIO;
119} 119}
120 120
diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h
index 81557f38fe38..51d4e043716c 100644
--- a/drivers/media/dvb/bt8xx/dst_common.h
+++ b/drivers/media/dvb/bt8xx/dst_common.h
@@ -25,6 +25,7 @@
25#include <linux/smp_lock.h> 25#include <linux/smp_lock.h>
26#include <linux/dvb/frontend.h> 26#include <linux/dvb/frontend.h>
27#include <linux/device.h> 27#include <linux/device.h>
28#include <linux/mutex.h>
28#include "bt878.h" 29#include "bt878.h"
29 30
30#include "dst_ca.h" 31#include "dst_ca.h"
@@ -121,7 +122,7 @@ struct dst_state {
121 u8 vendor[8]; 122 u8 vendor[8];
122 u8 board_info[8]; 123 u8 board_info[8];
123 124
124 struct semaphore dst_mutex; 125 struct mutex dst_mutex;
125}; 126};
126 127
127struct dst_types { 128struct dst_types {
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index ea27b15007e9..1649846f9ceb 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)
76 if (!dvbdmx->dmx.frontend) 76 if (!dvbdmx->dmx.frontend)
77 return -EINVAL; 77 return -EINVAL;
78 78
79 down(&card->lock); 79 mutex_lock(&card->lock);
80 card->nfeeds++; 80 card->nfeeds++;
81 rc = card->nfeeds; 81 rc = card->nfeeds;
82 if (card->nfeeds == 1) 82 if (card->nfeeds == 1)
83 bt878_start(card->bt, card->gpio_mode, 83 bt878_start(card->bt, card->gpio_mode,
84 card->op_sync_orin, card->irq_err_ignore); 84 card->op_sync_orin, card->irq_err_ignore);
85 up(&card->lock); 85 mutex_unlock(&card->lock);
86 return rc; 86 return rc;
87} 87}
88 88
@@ -96,11 +96,11 @@ static int dvb_bt8xx_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
96 if (!dvbdmx->dmx.frontend) 96 if (!dvbdmx->dmx.frontend)
97 return -EINVAL; 97 return -EINVAL;
98 98
99 down(&card->lock); 99 mutex_lock(&card->lock);
100 card->nfeeds--; 100 card->nfeeds--;
101 if (card->nfeeds == 0) 101 if (card->nfeeds == 0)
102 bt878_stop(card->bt); 102 bt878_stop(card->bt);
103 up(&card->lock); 103 mutex_unlock(&card->lock);
104 104
105 return 0; 105 return 0;
106} 106}
@@ -788,7 +788,7 @@ static int dvb_bt8xx_probe(struct bttv_sub_device *sub)
788 if (!(card = kzalloc(sizeof(struct dvb_bt8xx_card), GFP_KERNEL))) 788 if (!(card = kzalloc(sizeof(struct dvb_bt8xx_card), GFP_KERNEL)))
789 return -ENOMEM; 789 return -ENOMEM;
790 790
791 init_MUTEX(&card->lock); 791 mutex_init(&card->lock);
792 card->bttv_nr = sub->core->nr; 792 card->bttv_nr = sub->core->nr;
793 strncpy(card->card_name, sub->core->name, sizeof(sub->core->name)); 793 strncpy(card->card_name, sub->core->name, sizeof(sub->core->name));
794 card->i2c_adapter = &sub->core->i2c_adap; 794 card->i2c_adapter = &sub->core->i2c_adap;
@@ -881,7 +881,7 @@ static int dvb_bt8xx_probe(struct bttv_sub_device *sub)
881 return -EFAULT; 881 return -EFAULT;
882 } 882 }
883 883
884 init_MUTEX(&card->bt->gpio_lock); 884 mutex_init(&card->bt->gpio_lock);
885 card->bt->bttv_nr = sub->core->nr; 885 card->bt->bttv_nr = sub->core->nr;
886 886
887 if ( (ret = dvb_bt8xx_load_card(card, sub->core->type)) ) { 887 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 cf035a80361c..00dd9fa54c82 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.h
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.h
@@ -26,6 +26,7 @@
26#define DVB_BT8XX_H 26#define DVB_BT8XX_H
27 27
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/mutex.h>
29#include "dvbdev.h" 30#include "dvbdev.h"
30#include "dvb_net.h" 31#include "dvb_net.h"
31#include "bttv.h" 32#include "bttv.h"
@@ -38,7 +39,7 @@
38#include "lgdt330x.h" 39#include "lgdt330x.h"
39 40
40struct dvb_bt8xx_card { 41struct dvb_bt8xx_card {
41 struct semaphore lock; 42 struct mutex lock;
42 int nfeeds; 43 int nfeeds;
43 char card_name[32]; 44 char card_name[32];
44 struct dvb_adapter dvb_adapter; 45 struct dvb_adapter dvb_adapter;
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index c4b4c5b6b7c8..29b7be5271d4 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -30,6 +30,7 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/dvb/frontend.h> 32#include <linux/dvb/frontend.h>
33#include <linux/mutex.h>
33 34
34#include "dmxdev.h" 35#include "dmxdev.h"
35#include "dvb_demux.h" 36#include "dvb_demux.h"
@@ -116,7 +117,7 @@ static struct dvb_frontend_info cinergyt2_fe_info = {
116struct cinergyt2 { 117struct cinergyt2 {
117 struct dvb_demux demux; 118 struct dvb_demux demux;
118 struct usb_device *udev; 119 struct usb_device *udev;
119 struct semaphore sem; 120 struct mutex sem;
120 struct dvb_adapter adapter; 121 struct dvb_adapter adapter;
121 struct dvb_device *fedev; 122 struct dvb_device *fedev;
122 struct dmxdev dmxdev; 123 struct dmxdev dmxdev;
@@ -345,14 +346,14 @@ static int cinergyt2_start_feed(struct dvb_demux_feed *dvbdmxfeed)
345 struct dvb_demux *demux = dvbdmxfeed->demux; 346 struct dvb_demux *demux = dvbdmxfeed->demux;
346 struct cinergyt2 *cinergyt2 = demux->priv; 347 struct cinergyt2 *cinergyt2 = demux->priv;
347 348
348 if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 349 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
349 return -ERESTARTSYS; 350 return -ERESTARTSYS;
350 351
351 if (cinergyt2->streaming == 0) 352 if (cinergyt2->streaming == 0)
352 cinergyt2_start_stream_xfer(cinergyt2); 353 cinergyt2_start_stream_xfer(cinergyt2);
353 354
354 cinergyt2->streaming++; 355 cinergyt2->streaming++;
355 up(&cinergyt2->sem); 356 mutex_unlock(&cinergyt2->sem);
356 return 0; 357 return 0;
357} 358}
358 359
@@ -361,13 +362,13 @@ static int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
361 struct dvb_demux *demux = dvbdmxfeed->demux; 362 struct dvb_demux *demux = dvbdmxfeed->demux;
362 struct cinergyt2 *cinergyt2 = demux->priv; 363 struct cinergyt2 *cinergyt2 = demux->priv;
363 364
364 if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 365 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
365 return -ERESTARTSYS; 366 return -ERESTARTSYS;
366 367
367 if (--cinergyt2->streaming == 0) 368 if (--cinergyt2->streaming == 0)
368 cinergyt2_stop_stream_xfer(cinergyt2); 369 cinergyt2_stop_stream_xfer(cinergyt2);
369 370
370 up(&cinergyt2->sem); 371 mutex_unlock(&cinergyt2->sem);
371 return 0; 372 return 0;
372} 373}
373 374
@@ -483,11 +484,11 @@ static int cinergyt2_open (struct inode *inode, struct file *file)
483 struct cinergyt2 *cinergyt2 = dvbdev->priv; 484 struct cinergyt2 *cinergyt2 = dvbdev->priv;
484 int err = -ERESTARTSYS; 485 int err = -ERESTARTSYS;
485 486
486 if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 487 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
487 return -ERESTARTSYS; 488 return -ERESTARTSYS;
488 489
489 if ((err = dvb_generic_open(inode, file))) { 490 if ((err = dvb_generic_open(inode, file))) {
490 up(&cinergyt2->sem); 491 mutex_unlock(&cinergyt2->sem);
491 return err; 492 return err;
492 } 493 }
493 494
@@ -499,7 +500,7 @@ static int cinergyt2_open (struct inode *inode, struct file *file)
499 500
500 atomic_inc(&cinergyt2->inuse); 501 atomic_inc(&cinergyt2->inuse);
501 502
502 up(&cinergyt2->sem); 503 mutex_unlock(&cinergyt2->sem);
503 return 0; 504 return 0;
504} 505}
505 506
@@ -517,7 +518,7 @@ static int cinergyt2_release (struct inode *inode, struct file *file)
517 struct dvb_device *dvbdev = file->private_data; 518 struct dvb_device *dvbdev = file->private_data;
518 struct cinergyt2 *cinergyt2 = dvbdev->priv; 519 struct cinergyt2 *cinergyt2 = dvbdev->priv;
519 520
520 if (down_interruptible(&cinergyt2->sem)) 521 if (mutex_lock_interruptible(&cinergyt2->sem))
521 return -ERESTARTSYS; 522 return -ERESTARTSYS;
522 523
523 if (!cinergyt2->disconnect_pending && (file->f_flags & O_ACCMODE) != O_RDONLY) { 524 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)
526 cinergyt2_sleep(cinergyt2, 1); 527 cinergyt2_sleep(cinergyt2, 1);
527 } 528 }
528 529
529 up(&cinergyt2->sem); 530 mutex_unlock(&cinergyt2->sem);
530 531
531 if (atomic_dec_and_test(&cinergyt2->inuse) && cinergyt2->disconnect_pending) { 532 if (atomic_dec_and_test(&cinergyt2->inuse) && cinergyt2->disconnect_pending) {
532 warn("delayed unregister in release"); 533 warn("delayed unregister in release");
@@ -541,12 +542,12 @@ static unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct
541 struct dvb_device *dvbdev = file->private_data; 542 struct dvb_device *dvbdev = file->private_data;
542 struct cinergyt2 *cinergyt2 = dvbdev->priv; 543 struct cinergyt2 *cinergyt2 = dvbdev->priv;
543 544
544 if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 545 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
545 return -ERESTARTSYS; 546 return -ERESTARTSYS;
546 547
547 poll_wait(file, &cinergyt2->poll_wq, wait); 548 poll_wait(file, &cinergyt2->poll_wq, wait);
548 549
549 up(&cinergyt2->sem); 550 mutex_unlock(&cinergyt2->sem);
550 551
551 return (POLLIN | POLLRDNORM | POLLPRI); 552 return (POLLIN | POLLRDNORM | POLLPRI);
552} 553}
@@ -613,7 +614,7 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file,
613 if (copy_from_user(&p, (void __user*) arg, sizeof(p))) 614 if (copy_from_user(&p, (void __user*) arg, sizeof(p)))
614 return -EFAULT; 615 return -EFAULT;
615 616
616 if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 617 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
617 return -ERESTARTSYS; 618 return -ERESTARTSYS;
618 619
619 param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; 620 param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
@@ -629,7 +630,7 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file,
629 (char *) param, sizeof(*param), 630 (char *) param, sizeof(*param),
630 NULL, 0); 631 NULL, 0);
631 632
632 up(&cinergyt2->sem); 633 mutex_unlock(&cinergyt2->sem);
633 634
634 return (err < 0) ? err : 0; 635 return (err < 0) ? err : 0;
635 } 636 }
@@ -724,7 +725,7 @@ static void cinergyt2_query_rc (void *data)
724 struct cinergyt2_rc_event rc_events[12]; 725 struct cinergyt2_rc_event rc_events[12];
725 int n, len, i; 726 int n, len, i;
726 727
727 if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 728 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
728 return; 729 return;
729 730
730 len = cinergyt2_command(cinergyt2, buf, sizeof(buf), 731 len = cinergyt2_command(cinergyt2, buf, sizeof(buf),
@@ -784,7 +785,7 @@ out:
784 schedule_delayed_work(&cinergyt2->rc_query_work, 785 schedule_delayed_work(&cinergyt2->rc_query_work,
785 msecs_to_jiffies(RC_QUERY_INTERVAL)); 786 msecs_to_jiffies(RC_QUERY_INTERVAL));
786 787
787 up(&cinergyt2->sem); 788 mutex_unlock(&cinergyt2->sem);
788} 789}
789 790
790static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2) 791static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2)
@@ -849,7 +850,7 @@ static void cinergyt2_query (void *data)
849 uint8_t lock_bits; 850 uint8_t lock_bits;
850 uint32_t unc; 851 uint32_t unc;
851 852
852 if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 853 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
853 return; 854 return;
854 855
855 unc = s->uncorrected_block_count; 856 unc = s->uncorrected_block_count;
@@ -868,7 +869,7 @@ static void cinergyt2_query (void *data)
868 schedule_delayed_work(&cinergyt2->query_work, 869 schedule_delayed_work(&cinergyt2->query_work,
869 msecs_to_jiffies(QUERY_INTERVAL)); 870 msecs_to_jiffies(QUERY_INTERVAL));
870 871
871 up(&cinergyt2->sem); 872 mutex_unlock(&cinergyt2->sem);
872} 873}
873 874
874static int cinergyt2_probe (struct usb_interface *intf, 875static int cinergyt2_probe (struct usb_interface *intf,
@@ -885,7 +886,7 @@ static int cinergyt2_probe (struct usb_interface *intf,
885 memset (cinergyt2, 0, sizeof (struct cinergyt2)); 886 memset (cinergyt2, 0, sizeof (struct cinergyt2));
886 usb_set_intfdata (intf, (void *) cinergyt2); 887 usb_set_intfdata (intf, (void *) cinergyt2);
887 888
888 init_MUTEX(&cinergyt2->sem); 889 mutex_init(&cinergyt2->sem);
889 init_waitqueue_head (&cinergyt2->poll_wq); 890 init_waitqueue_head (&cinergyt2->poll_wq);
890 INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2); 891 INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2);
891 892
@@ -967,7 +968,7 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
967{ 968{
968 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); 969 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
969 970
970 if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 971 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
971 return -ERESTARTSYS; 972 return -ERESTARTSYS;
972 973
973 if (state.event > PM_EVENT_ON) { 974 if (state.event > PM_EVENT_ON) {
@@ -981,7 +982,7 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
981 cinergyt2_sleep(cinergyt2, 1); 982 cinergyt2_sleep(cinergyt2, 1);
982 } 983 }
983 984
984 up(&cinergyt2->sem); 985 mutex_unlock(&cinergyt2->sem);
985 return 0; 986 return 0;
986} 987}
987 988
@@ -990,7 +991,7 @@ static int cinergyt2_resume (struct usb_interface *intf)
990 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); 991 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
991 struct dvbt_set_parameters_msg *param = &cinergyt2->param; 992 struct dvbt_set_parameters_msg *param = &cinergyt2->param;
992 993
993 if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem)) 994 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
994 return -ERESTARTSYS; 995 return -ERESTARTSYS;
995 996
996 if (!cinergyt2->sleeping) { 997 if (!cinergyt2->sleeping) {
@@ -1003,7 +1004,7 @@ static int cinergyt2_resume (struct usb_interface *intf)
1003 1004
1004 cinergyt2_resume_rc(cinergyt2); 1005 cinergyt2_resume_rc(cinergyt2);
1005 1006
1006 up(&cinergyt2->sem); 1007 mutex_unlock(&cinergyt2->sem);
1007 return 0; 1008 return 0;
1008} 1009}
1009 1010
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 7b8373ad121b..ead5343d7706 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)
175 175
176 dprintk ("function : %s\n", __FUNCTION__); 176 dprintk ("function : %s\n", __FUNCTION__);
177 177
178 if (down_interruptible (&dmxdev->mutex)) 178 if (mutex_lock_interruptible(&dmxdev->mutex))
179 return -ERESTARTSYS; 179 return -ERESTARTSYS;
180 180
181 if ((file->f_flags&O_ACCMODE)==O_RDWR) { 181 if ((file->f_flags&O_ACCMODE)==O_RDWR) {
182 if (!(dmxdev->capabilities&DMXDEV_CAP_DUPLEX)) { 182 if (!(dmxdev->capabilities&DMXDEV_CAP_DUPLEX)) {
183 up(&dmxdev->mutex); 183 mutex_unlock(&dmxdev->mutex);
184 return -EOPNOTSUPP; 184 return -EOPNOTSUPP;
185 } 185 }
186 } 186 }
@@ -190,7 +190,7 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
190 dmxdev->dvr_buffer.size=DVR_BUFFER_SIZE; 190 dmxdev->dvr_buffer.size=DVR_BUFFER_SIZE;
191 dmxdev->dvr_buffer.data=vmalloc(DVR_BUFFER_SIZE); 191 dmxdev->dvr_buffer.data=vmalloc(DVR_BUFFER_SIZE);
192 if (!dmxdev->dvr_buffer.data) { 192 if (!dmxdev->dvr_buffer.data) {
193 up(&dmxdev->mutex); 193 mutex_unlock(&dmxdev->mutex);
194 return -ENOMEM; 194 return -ENOMEM;
195 } 195 }
196 } 196 }
@@ -199,20 +199,20 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
199 dmxdev->dvr_orig_fe=dmxdev->demux->frontend; 199 dmxdev->dvr_orig_fe=dmxdev->demux->frontend;
200 200
201 if (!dmxdev->demux->write) { 201 if (!dmxdev->demux->write) {
202 up(&dmxdev->mutex); 202 mutex_unlock(&dmxdev->mutex);
203 return -EOPNOTSUPP; 203 return -EOPNOTSUPP;
204 } 204 }
205 205
206 front=get_fe(dmxdev->demux, DMX_MEMORY_FE); 206 front=get_fe(dmxdev->demux, DMX_MEMORY_FE);
207 207
208 if (!front) { 208 if (!front) {
209 up(&dmxdev->mutex); 209 mutex_unlock(&dmxdev->mutex);
210 return -EINVAL; 210 return -EINVAL;
211 } 211 }
212 dmxdev->demux->disconnect_frontend(dmxdev->demux); 212 dmxdev->demux->disconnect_frontend(dmxdev->demux);
213 dmxdev->demux->connect_frontend(dmxdev->demux, front); 213 dmxdev->demux->connect_frontend(dmxdev->demux, front);
214 } 214 }
215 up(&dmxdev->mutex); 215 mutex_unlock(&dmxdev->mutex);
216 return 0; 216 return 0;
217} 217}
218 218
@@ -221,7 +221,7 @@ static int dvb_dvr_release(struct inode *inode, struct file *file)
221 struct dvb_device *dvbdev = file->private_data; 221 struct dvb_device *dvbdev = file->private_data;
222 struct dmxdev *dmxdev = dvbdev->priv; 222 struct dmxdev *dmxdev = dvbdev->priv;
223 223
224 if (down_interruptible (&dmxdev->mutex)) 224 if (mutex_lock_interruptible(&dmxdev->mutex))
225 return -ERESTARTSYS; 225 return -ERESTARTSYS;
226 226
227 if ((file->f_flags&O_ACCMODE)==O_WRONLY) { 227 if ((file->f_flags&O_ACCMODE)==O_WRONLY) {
@@ -239,7 +239,7 @@ static int dvb_dvr_release(struct inode *inode, struct file *file)
239 vfree(mem); 239 vfree(mem);
240 } 240 }
241 } 241 }
242 up(&dmxdev->mutex); 242 mutex_unlock(&dmxdev->mutex);
243 return 0; 243 return 0;
244} 244}
245 245
@@ -254,10 +254,10 @@ static ssize_t dvb_dvr_write(struct file *file, const char __user *buf,
254 return -EOPNOTSUPP; 254 return -EOPNOTSUPP;
255 if ((file->f_flags&O_ACCMODE)!=O_WRONLY) 255 if ((file->f_flags&O_ACCMODE)!=O_WRONLY)
256 return -EINVAL; 256 return -EINVAL;
257 if (down_interruptible (&dmxdev->mutex)) 257 if (mutex_lock_interruptible(&dmxdev->mutex))
258 return -ERESTARTSYS; 258 return -ERESTARTSYS;
259 ret=dmxdev->demux->write(dmxdev->demux, buf, count); 259 ret=dmxdev->demux->write(dmxdev->demux, buf, count);
260 up(&dmxdev->mutex); 260 mutex_unlock(&dmxdev->mutex);
261 return ret; 261 return ret;
262} 262}
263 263
@@ -268,11 +268,11 @@ static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count,
268 struct dmxdev *dmxdev = dvbdev->priv; 268 struct dmxdev *dmxdev = dvbdev->priv;
269 int ret; 269 int ret;
270 270
271 //down(&dmxdev->mutex); 271 //mutex_lock(&dmxdev->mutex);
272 ret= dvb_dmxdev_buffer_read(&dmxdev->dvr_buffer, 272 ret= dvb_dmxdev_buffer_read(&dmxdev->dvr_buffer,
273 file->f_flags&O_NONBLOCK, 273 file->f_flags&O_NONBLOCK,
274 buf, count, ppos); 274 buf, count, ppos);
275 //up(&dmxdev->mutex); 275 //mutex_unlock(&dmxdev->mutex);
276 return ret; 276 return ret;
277} 277}
278 278
@@ -688,7 +688,7 @@ static int dvb_demux_open(struct inode *inode, struct file *file)
688 if (!dmxdev->filter) 688 if (!dmxdev->filter)
689 return -EINVAL; 689 return -EINVAL;
690 690
691 if (down_interruptible(&dmxdev->mutex)) 691 if (mutex_lock_interruptible(&dmxdev->mutex))
692 return -ERESTARTSYS; 692 return -ERESTARTSYS;
693 693
694 for (i=0; i<dmxdev->filternum; i++) 694 for (i=0; i<dmxdev->filternum; i++)
@@ -696,12 +696,12 @@ static int dvb_demux_open(struct inode *inode, struct file *file)
696 break; 696 break;
697 697
698 if (i==dmxdev->filternum) { 698 if (i==dmxdev->filternum) {
699 up(&dmxdev->mutex); 699 mutex_unlock(&dmxdev->mutex);
700 return -EMFILE; 700 return -EMFILE;
701 } 701 }
702 702
703 dmxdevfilter=&dmxdev->filter[i]; 703 dmxdevfilter=&dmxdev->filter[i];
704 sema_init(&dmxdevfilter->mutex, 1); 704 mutex_init(&dmxdevfilter->mutex);
705 dmxdevfilter->dvbdev=dmxdev->dvbdev; 705 dmxdevfilter->dvbdev=dmxdev->dvbdev;
706 file->private_data=dmxdevfilter; 706 file->private_data=dmxdevfilter;
707 707
@@ -711,18 +711,18 @@ static int dvb_demux_open(struct inode *inode, struct file *file)
711 dmxdevfilter->feed.ts=NULL; 711 dmxdevfilter->feed.ts=NULL;
712 init_timer(&dmxdevfilter->timer); 712 init_timer(&dmxdevfilter->timer);
713 713
714 up(&dmxdev->mutex); 714 mutex_unlock(&dmxdev->mutex);
715 return 0; 715 return 0;
716} 716}
717 717
718 718
719static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev, struct dmxdev_filter *dmxdevfilter) 719static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev, struct dmxdev_filter *dmxdevfilter)
720{ 720{
721 if (down_interruptible(&dmxdev->mutex)) 721 if (mutex_lock_interruptible(&dmxdev->mutex))
722 return -ERESTARTSYS; 722 return -ERESTARTSYS;
723 723
724 if (down_interruptible(&dmxdevfilter->mutex)) { 724 if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
725 up(&dmxdev->mutex); 725 mutex_unlock(&dmxdev->mutex);
726 return -ERESTARTSYS; 726 return -ERESTARTSYS;
727 } 727 }
728 728
@@ -740,8 +740,8 @@ static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev, struct dmxdev_filter *d
740 740
741 dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_FREE); 741 dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_FREE);
742 wake_up(&dmxdevfilter->buffer.queue); 742 wake_up(&dmxdevfilter->buffer.queue);
743 up(&dmxdevfilter->mutex); 743 mutex_unlock(&dmxdevfilter->mutex);
744 up(&dmxdev->mutex); 744 mutex_unlock(&dmxdev->mutex);
745 return 0; 745 return 0;
746} 746}
747 747
@@ -841,7 +841,7 @@ dvb_demux_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
841 struct dmxdev_filter *dmxdevfilter= file->private_data; 841 struct dmxdev_filter *dmxdevfilter= file->private_data;
842 int ret=0; 842 int ret=0;
843 843
844 if (down_interruptible(&dmxdevfilter->mutex)) 844 if (mutex_lock_interruptible(&dmxdevfilter->mutex))
845 return -ERESTARTSYS; 845 return -ERESTARTSYS;
846 846
847 if (dmxdevfilter->type==DMXDEV_TYPE_SEC) 847 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)
851 file->f_flags&O_NONBLOCK, 851 file->f_flags&O_NONBLOCK,
852 buf, count, ppos); 852 buf, count, ppos);
853 853
854 up(&dmxdevfilter->mutex); 854 mutex_unlock(&dmxdevfilter->mutex);
855 return ret; 855 return ret;
856} 856}
857 857
@@ -864,58 +864,58 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
864 unsigned long arg=(unsigned long) parg; 864 unsigned long arg=(unsigned long) parg;
865 int ret=0; 865 int ret=0;
866 866
867 if (down_interruptible (&dmxdev->mutex)) 867 if (mutex_lock_interruptible(&dmxdev->mutex))
868 return -ERESTARTSYS; 868 return -ERESTARTSYS;
869 869
870 switch (cmd) { 870 switch (cmd) {
871 case DMX_START: 871 case DMX_START:
872 if (down_interruptible(&dmxdevfilter->mutex)) { 872 if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
873 up(&dmxdev->mutex); 873 mutex_unlock(&dmxdev->mutex);
874 return -ERESTARTSYS; 874 return -ERESTARTSYS;
875 } 875 }
876 if (dmxdevfilter->state<DMXDEV_STATE_SET) 876 if (dmxdevfilter->state<DMXDEV_STATE_SET)
877 ret = -EINVAL; 877 ret = -EINVAL;
878 else 878 else
879 ret = dvb_dmxdev_filter_start(dmxdevfilter); 879 ret = dvb_dmxdev_filter_start(dmxdevfilter);
880 up(&dmxdevfilter->mutex); 880 mutex_unlock(&dmxdevfilter->mutex);
881 break; 881 break;
882 882
883 case DMX_STOP: 883 case DMX_STOP:
884 if (down_interruptible(&dmxdevfilter->mutex)) { 884 if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
885 up(&dmxdev->mutex); 885 mutex_unlock(&dmxdev->mutex);
886 return -ERESTARTSYS; 886 return -ERESTARTSYS;
887 } 887 }
888 ret=dvb_dmxdev_filter_stop(dmxdevfilter); 888 ret=dvb_dmxdev_filter_stop(dmxdevfilter);
889 up(&dmxdevfilter->mutex); 889 mutex_unlock(&dmxdevfilter->mutex);
890 break; 890 break;
891 891
892 case DMX_SET_FILTER: 892 case DMX_SET_FILTER:
893 if (down_interruptible(&dmxdevfilter->mutex)) { 893 if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
894 up(&dmxdev->mutex); 894 mutex_unlock(&dmxdev->mutex);
895 return -ERESTARTSYS; 895 return -ERESTARTSYS;
896 } 896 }
897 ret = dvb_dmxdev_filter_set(dmxdev, dmxdevfilter, 897 ret = dvb_dmxdev_filter_set(dmxdev, dmxdevfilter,
898 (struct dmx_sct_filter_params *)parg); 898 (struct dmx_sct_filter_params *)parg);
899 up(&dmxdevfilter->mutex); 899 mutex_unlock(&dmxdevfilter->mutex);
900 break; 900 break;
901 901
902 case DMX_SET_PES_FILTER: 902 case DMX_SET_PES_FILTER:
903 if (down_interruptible(&dmxdevfilter->mutex)) { 903 if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
904 up(&dmxdev->mutex); 904 mutex_unlock(&dmxdev->mutex);
905 return -ERESTARTSYS; 905 return -ERESTARTSYS;
906 } 906 }
907 ret=dvb_dmxdev_pes_filter_set(dmxdev, dmxdevfilter, 907 ret=dvb_dmxdev_pes_filter_set(dmxdev, dmxdevfilter,
908 (struct dmx_pes_filter_params *)parg); 908 (struct dmx_pes_filter_params *)parg);
909 up(&dmxdevfilter->mutex); 909 mutex_unlock(&dmxdevfilter->mutex);
910 break; 910 break;
911 911
912 case DMX_SET_BUFFER_SIZE: 912 case DMX_SET_BUFFER_SIZE:
913 if (down_interruptible(&dmxdevfilter->mutex)) { 913 if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
914 up(&dmxdev->mutex); 914 mutex_unlock(&dmxdev->mutex);
915 return -ERESTARTSYS; 915 return -ERESTARTSYS;
916 } 916 }
917 ret=dvb_dmxdev_set_buffer_size(dmxdevfilter, arg); 917 ret=dvb_dmxdev_set_buffer_size(dmxdevfilter, arg);
918 up(&dmxdevfilter->mutex); 918 mutex_unlock(&dmxdevfilter->mutex);
919 break; 919 break;
920 920
921 case DMX_GET_EVENT: 921 case DMX_GET_EVENT:
@@ -959,7 +959,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
959 default: 959 default:
960 ret=-EINVAL; 960 ret=-EINVAL;
961 } 961 }
962 up(&dmxdev->mutex); 962 mutex_unlock(&dmxdev->mutex);
963 return ret; 963 return ret;
964} 964}
965 965
@@ -1030,7 +1030,7 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
1030 1030
1031 int ret=0; 1031 int ret=0;
1032 1032
1033 if (down_interruptible (&dmxdev->mutex)) 1033 if (mutex_lock_interruptible(&dmxdev->mutex))
1034 return -ERESTARTSYS; 1034 return -ERESTARTSYS;
1035 1035
1036 switch (cmd) { 1036 switch (cmd) {
@@ -1042,7 +1042,7 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
1042 default: 1042 default:
1043 ret=-EINVAL; 1043 ret=-EINVAL;
1044 } 1044 }
1045 up(&dmxdev->mutex); 1045 mutex_unlock(&dmxdev->mutex);
1046 return ret; 1046 return ret;
1047} 1047}
1048 1048
@@ -1113,7 +1113,7 @@ dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
1113 return -ENOMEM; 1113 return -ENOMEM;
1114 } 1114 }
1115 1115
1116 sema_init(&dmxdev->mutex, 1); 1116 mutex_init(&dmxdev->mutex);
1117 spin_lock_init(&dmxdev->lock); 1117 spin_lock_init(&dmxdev->lock);
1118 for (i=0; i<dmxdev->filternum; i++) { 1118 for (i=0; i<dmxdev->filternum; i++) {
1119 dmxdev->filter[i].dev=dmxdev; 1119 dmxdev->filter[i].dev=dmxdev;
diff --git a/drivers/media/dvb/dvb-core/dmxdev.h b/drivers/media/dvb/dvb-core/dmxdev.h
index fd72920c2199..ec2a7a4da5e4 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.h
+++ b/drivers/media/dvb/dvb-core/dmxdev.h
@@ -30,7 +30,7 @@
30#include <linux/wait.h> 30#include <linux/wait.h>
31#include <linux/fs.h> 31#include <linux/fs.h>
32#include <linux/string.h> 32#include <linux/string.h>
33#include <asm/semaphore.h> 33#include <linux/mutex.h>
34 34
35#include <linux/dvb/dmx.h> 35#include <linux/dvb/dmx.h>
36 36
@@ -83,7 +83,7 @@ struct dmxdev_filter {
83 struct dmxdev *dev; 83 struct dmxdev *dev;
84 struct dmxdev_buffer buffer; 84 struct dmxdev_buffer buffer;
85 85
86 struct semaphore mutex; 86 struct mutex mutex;
87 87
88 /* only for sections */ 88 /* only for sections */
89 struct timer_list timer; 89 struct timer_list timer;
@@ -117,7 +117,7 @@ struct dmxdev {
117 struct dmxdev_buffer dvr_buffer; 117 struct dmxdev_buffer dvr_buffer;
118#define DVR_BUFFER_SIZE (10*188*1024) 118#define DVR_BUFFER_SIZE (10*188*1024)
119 119
120 struct semaphore mutex; 120 struct mutex mutex;
121 spinlock_t lock; 121 spinlock_t lock;
122}; 122};
123 123
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
index b4c899b15959..83ec5e06c482 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,
589 if (pid > DMX_MAX_PID) 589 if (pid > DMX_MAX_PID)
590 return -EINVAL; 590 return -EINVAL;
591 591
592 if (down_interruptible(&demux->mutex)) 592 if (mutex_lock_interruptible(&demux->mutex))
593 return -ERESTARTSYS; 593 return -ERESTARTSYS;
594 594
595 if (ts_type & TS_DECODER) { 595 if (ts_type & TS_DECODER) {
596 if (pes_type >= DMX_TS_PES_OTHER) { 596 if (pes_type >= DMX_TS_PES_OTHER) {
597 up(&demux->mutex); 597 mutex_unlock(&demux->mutex);
598 return -EINVAL; 598 return -EINVAL;
599 } 599 }
600 600
601 if (demux->pesfilter[pes_type] && 601 if (demux->pesfilter[pes_type] &&
602 demux->pesfilter[pes_type] != feed) { 602 demux->pesfilter[pes_type] != feed) {
603 up(&demux->mutex); 603 mutex_unlock(&demux->mutex);
604 return -EINVAL; 604 return -EINVAL;
605 } 605 }
606 606
@@ -622,14 +622,14 @@ static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type,
622#else 622#else
623 feed->buffer = vmalloc(feed->buffer_size); 623 feed->buffer = vmalloc(feed->buffer_size);
624 if (!feed->buffer) { 624 if (!feed->buffer) {
625 up(&demux->mutex); 625 mutex_unlock(&demux->mutex);
626 return -ENOMEM; 626 return -ENOMEM;
627 } 627 }
628#endif 628#endif
629 } 629 }
630 630
631 feed->state = DMX_STATE_READY; 631 feed->state = DMX_STATE_READY;
632 up(&demux->mutex); 632 mutex_unlock(&demux->mutex);
633 633
634 return 0; 634 return 0;
635} 635}
@@ -640,21 +640,21 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed)
640 struct dvb_demux *demux = feed->demux; 640 struct dvb_demux *demux = feed->demux;
641 int ret; 641 int ret;
642 642
643 if (down_interruptible(&demux->mutex)) 643 if (mutex_lock_interruptible(&demux->mutex))
644 return -ERESTARTSYS; 644 return -ERESTARTSYS;
645 645
646 if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) { 646 if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) {
647 up(&demux->mutex); 647 mutex_unlock(&demux->mutex);
648 return -EINVAL; 648 return -EINVAL;
649 } 649 }
650 650
651 if (!demux->start_feed) { 651 if (!demux->start_feed) {
652 up(&demux->mutex); 652 mutex_unlock(&demux->mutex);
653 return -ENODEV; 653 return -ENODEV;
654 } 654 }
655 655
656 if ((ret = demux->start_feed(feed)) < 0) { 656 if ((ret = demux->start_feed(feed)) < 0) {
657 up(&demux->mutex); 657 mutex_unlock(&demux->mutex);
658 return ret; 658 return ret;
659 } 659 }
660 660
@@ -662,7 +662,7 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed)
662 ts_feed->is_filtering = 1; 662 ts_feed->is_filtering = 1;
663 feed->state = DMX_STATE_GO; 663 feed->state = DMX_STATE_GO;
664 spin_unlock_irq(&demux->lock); 664 spin_unlock_irq(&demux->lock);
665 up(&demux->mutex); 665 mutex_unlock(&demux->mutex);
666 666
667 return 0; 667 return 0;
668} 668}
@@ -673,16 +673,16 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed)
673 struct dvb_demux *demux = feed->demux; 673 struct dvb_demux *demux = feed->demux;
674 int ret; 674 int ret;
675 675
676 if (down_interruptible(&demux->mutex)) 676 if (mutex_lock_interruptible(&demux->mutex))
677 return -ERESTARTSYS; 677 return -ERESTARTSYS;
678 678
679 if (feed->state < DMX_STATE_GO) { 679 if (feed->state < DMX_STATE_GO) {
680 up(&demux->mutex); 680 mutex_unlock(&demux->mutex);
681 return -EINVAL; 681 return -EINVAL;
682 } 682 }
683 683
684 if (!demux->stop_feed) { 684 if (!demux->stop_feed) {
685 up(&demux->mutex); 685 mutex_unlock(&demux->mutex);
686 return -ENODEV; 686 return -ENODEV;
687 } 687 }
688 688
@@ -692,7 +692,7 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed)
692 ts_feed->is_filtering = 0; 692 ts_feed->is_filtering = 0;
693 feed->state = DMX_STATE_ALLOCATED; 693 feed->state = DMX_STATE_ALLOCATED;
694 spin_unlock_irq(&demux->lock); 694 spin_unlock_irq(&demux->lock);
695 up(&demux->mutex); 695 mutex_unlock(&demux->mutex);
696 696
697 return ret; 697 return ret;
698} 698}
@@ -704,11 +704,11 @@ static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx,
704 struct dvb_demux *demux = (struct dvb_demux *)dmx; 704 struct dvb_demux *demux = (struct dvb_demux *)dmx;
705 struct dvb_demux_feed *feed; 705 struct dvb_demux_feed *feed;
706 706
707 if (down_interruptible(&demux->mutex)) 707 if (mutex_lock_interruptible(&demux->mutex))
708 return -ERESTARTSYS; 708 return -ERESTARTSYS;
709 709
710 if (!(feed = dvb_dmx_feed_alloc(demux))) { 710 if (!(feed = dvb_dmx_feed_alloc(demux))) {
711 up(&demux->mutex); 711 mutex_unlock(&demux->mutex);
712 return -EBUSY; 712 return -EBUSY;
713 } 713 }
714 714
@@ -729,7 +729,7 @@ static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx,
729 729
730 if (!(feed->filter = dvb_dmx_filter_alloc(demux))) { 730 if (!(feed->filter = dvb_dmx_filter_alloc(demux))) {
731 feed->state = DMX_STATE_FREE; 731 feed->state = DMX_STATE_FREE;
732 up(&demux->mutex); 732 mutex_unlock(&demux->mutex);
733 return -EBUSY; 733 return -EBUSY;
734 } 734 }
735 735
@@ -737,7 +737,7 @@ static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx,
737 feed->filter->feed = feed; 737 feed->filter->feed = feed;
738 feed->filter->state = DMX_STATE_READY; 738 feed->filter->state = DMX_STATE_READY;
739 739
740 up(&demux->mutex); 740 mutex_unlock(&demux->mutex);
741 741
742 return 0; 742 return 0;
743} 743}
@@ -748,11 +748,11 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx,
748 struct dvb_demux *demux = (struct dvb_demux *)dmx; 748 struct dvb_demux *demux = (struct dvb_demux *)dmx;
749 struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; 749 struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
750 750
751 if (down_interruptible(&demux->mutex)) 751 if (mutex_lock_interruptible(&demux->mutex))
752 return -ERESTARTSYS; 752 return -ERESTARTSYS;
753 753
754 if (feed->state == DMX_STATE_FREE) { 754 if (feed->state == DMX_STATE_FREE) {
755 up(&demux->mutex); 755 mutex_unlock(&demux->mutex);
756 return -EINVAL; 756 return -EINVAL;
757 } 757 }
758#ifndef NOBUFS 758#ifndef NOBUFS
@@ -770,7 +770,7 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx,
770 if (feed->ts_type & TS_DECODER && feed->pes_type < DMX_TS_PES_OTHER) 770 if (feed->ts_type & TS_DECODER && feed->pes_type < DMX_TS_PES_OTHER)
771 demux->pesfilter[feed->pes_type] = NULL; 771 demux->pesfilter[feed->pes_type] = NULL;
772 772
773 up(&demux->mutex); 773 mutex_unlock(&demux->mutex);
774 return 0; 774 return 0;
775} 775}
776 776
@@ -785,12 +785,12 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed,
785 struct dvb_demux *dvbdemux = dvbdmxfeed->demux; 785 struct dvb_demux *dvbdemux = dvbdmxfeed->demux;
786 struct dvb_demux_filter *dvbdmxfilter; 786 struct dvb_demux_filter *dvbdmxfilter;
787 787
788 if (down_interruptible(&dvbdemux->mutex)) 788 if (mutex_lock_interruptible(&dvbdemux->mutex))
789 return -ERESTARTSYS; 789 return -ERESTARTSYS;
790 790
791 dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux); 791 dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux);
792 if (!dvbdmxfilter) { 792 if (!dvbdmxfilter) {
793 up(&dvbdemux->mutex); 793 mutex_unlock(&dvbdemux->mutex);
794 return -EBUSY; 794 return -EBUSY;
795 } 795 }
796 796
@@ -805,7 +805,7 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed,
805 dvbdmxfeed->filter = dvbdmxfilter; 805 dvbdmxfeed->filter = dvbdmxfilter;
806 spin_unlock_irq(&dvbdemux->lock); 806 spin_unlock_irq(&dvbdemux->lock);
807 807
808 up(&dvbdemux->mutex); 808 mutex_unlock(&dvbdemux->mutex);
809 return 0; 809 return 0;
810} 810}
811 811
@@ -819,7 +819,7 @@ static int dmx_section_feed_set(struct dmx_section_feed *feed,
819 if (pid > 0x1fff) 819 if (pid > 0x1fff)
820 return -EINVAL; 820 return -EINVAL;
821 821
822 if (down_interruptible(&dvbdmx->mutex)) 822 if (mutex_lock_interruptible(&dvbdmx->mutex))
823 return -ERESTARTSYS; 823 return -ERESTARTSYS;
824 824
825 dvb_demux_feed_add(dvbdmxfeed); 825 dvb_demux_feed_add(dvbdmxfeed);
@@ -833,13 +833,13 @@ static int dmx_section_feed_set(struct dmx_section_feed *feed,
833#else 833#else
834 dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size); 834 dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size);
835 if (!dvbdmxfeed->buffer) { 835 if (!dvbdmxfeed->buffer) {
836 up(&dvbdmx->mutex); 836 mutex_unlock(&dvbdmx->mutex);
837 return -ENOMEM; 837 return -ENOMEM;
838 } 838 }
839#endif 839#endif
840 840
841 dvbdmxfeed->state = DMX_STATE_READY; 841 dvbdmxfeed->state = DMX_STATE_READY;
842 up(&dvbdmx->mutex); 842 mutex_unlock(&dvbdmx->mutex);
843 return 0; 843 return 0;
844} 844}
845 845
@@ -871,16 +871,16 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed)
871 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 871 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
872 int ret; 872 int ret;
873 873
874 if (down_interruptible(&dvbdmx->mutex)) 874 if (mutex_lock_interruptible(&dvbdmx->mutex))
875 return -ERESTARTSYS; 875 return -ERESTARTSYS;
876 876
877 if (feed->is_filtering) { 877 if (feed->is_filtering) {
878 up(&dvbdmx->mutex); 878 mutex_unlock(&dvbdmx->mutex);
879 return -EBUSY; 879 return -EBUSY;
880 } 880 }
881 881
882 if (!dvbdmxfeed->filter) { 882 if (!dvbdmxfeed->filter) {
883 up(&dvbdmx->mutex); 883 mutex_unlock(&dvbdmx->mutex);
884 return -EINVAL; 884 return -EINVAL;
885 } 885 }
886 886
@@ -890,14 +890,14 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed)
890 dvbdmxfeed->feed.sec.seclen = 0; 890 dvbdmxfeed->feed.sec.seclen = 0;
891 891
892 if (!dvbdmx->start_feed) { 892 if (!dvbdmx->start_feed) {
893 up(&dvbdmx->mutex); 893 mutex_unlock(&dvbdmx->mutex);
894 return -ENODEV; 894 return -ENODEV;
895 } 895 }
896 896
897 prepare_secfilters(dvbdmxfeed); 897 prepare_secfilters(dvbdmxfeed);
898 898
899 if ((ret = dvbdmx->start_feed(dvbdmxfeed)) < 0) { 899 if ((ret = dvbdmx->start_feed(dvbdmxfeed)) < 0) {
900 up(&dvbdmx->mutex); 900 mutex_unlock(&dvbdmx->mutex);
901 return ret; 901 return ret;
902 } 902 }
903 903
@@ -906,7 +906,7 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed)
906 dvbdmxfeed->state = DMX_STATE_GO; 906 dvbdmxfeed->state = DMX_STATE_GO;
907 spin_unlock_irq(&dvbdmx->lock); 907 spin_unlock_irq(&dvbdmx->lock);
908 908
909 up(&dvbdmx->mutex); 909 mutex_unlock(&dvbdmx->mutex);
910 return 0; 910 return 0;
911} 911}
912 912
@@ -916,11 +916,11 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed)
916 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 916 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
917 int ret; 917 int ret;
918 918
919 if (down_interruptible(&dvbdmx->mutex)) 919 if (mutex_lock_interruptible(&dvbdmx->mutex))
920 return -ERESTARTSYS; 920 return -ERESTARTSYS;
921 921
922 if (!dvbdmx->stop_feed) { 922 if (!dvbdmx->stop_feed) {
923 up(&dvbdmx->mutex); 923 mutex_unlock(&dvbdmx->mutex);
924 return -ENODEV; 924 return -ENODEV;
925 } 925 }
926 926
@@ -931,7 +931,7 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed)
931 feed->is_filtering = 0; 931 feed->is_filtering = 0;
932 spin_unlock_irq(&dvbdmx->lock); 932 spin_unlock_irq(&dvbdmx->lock);
933 933
934 up(&dvbdmx->mutex); 934 mutex_unlock(&dvbdmx->mutex);
935 return ret; 935 return ret;
936} 936}
937 937
@@ -942,11 +942,11 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
942 struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; 942 struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
943 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 943 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
944 944
945 if (down_interruptible(&dvbdmx->mutex)) 945 if (mutex_lock_interruptible(&dvbdmx->mutex))
946 return -ERESTARTSYS; 946 return -ERESTARTSYS;
947 947
948 if (dvbdmxfilter->feed != dvbdmxfeed) { 948 if (dvbdmxfilter->feed != dvbdmxfeed) {
949 up(&dvbdmx->mutex); 949 mutex_unlock(&dvbdmx->mutex);
950 return -EINVAL; 950 return -EINVAL;
951 } 951 }
952 952
@@ -966,7 +966,7 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
966 966
967 dvbdmxfilter->state = DMX_STATE_FREE; 967 dvbdmxfilter->state = DMX_STATE_FREE;
968 spin_unlock_irq(&dvbdmx->lock); 968 spin_unlock_irq(&dvbdmx->lock);
969 up(&dvbdmx->mutex); 969 mutex_unlock(&dvbdmx->mutex);
970 return 0; 970 return 0;
971} 971}
972 972
@@ -977,11 +977,11 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux,
977 struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; 977 struct dvb_demux *dvbdmx = (struct dvb_demux *)demux;
978 struct dvb_demux_feed *dvbdmxfeed; 978 struct dvb_demux_feed *dvbdmxfeed;
979 979
980 if (down_interruptible(&dvbdmx->mutex)) 980 if (mutex_lock_interruptible(&dvbdmx->mutex))
981 return -ERESTARTSYS; 981 return -ERESTARTSYS;
982 982
983 if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) { 983 if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) {
984 up(&dvbdmx->mutex); 984 mutex_unlock(&dvbdmx->mutex);
985 return -EBUSY; 985 return -EBUSY;
986 } 986 }
987 987
@@ -1006,7 +1006,7 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux,
1006 (*feed)->stop_filtering = dmx_section_feed_stop_filtering; 1006 (*feed)->stop_filtering = dmx_section_feed_stop_filtering;
1007 (*feed)->release_filter = dmx_section_feed_release_filter; 1007 (*feed)->release_filter = dmx_section_feed_release_filter;
1008 1008
1009 up(&dvbdmx->mutex); 1009 mutex_unlock(&dvbdmx->mutex);
1010 return 0; 1010 return 0;
1011} 1011}
1012 1012
@@ -1016,11 +1016,11 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux,
1016 struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; 1016 struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
1017 struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; 1017 struct dvb_demux *dvbdmx = (struct dvb_demux *)demux;
1018 1018
1019 if (down_interruptible(&dvbdmx->mutex)) 1019 if (mutex_lock_interruptible(&dvbdmx->mutex))
1020 return -ERESTARTSYS; 1020 return -ERESTARTSYS;
1021 1021
1022 if (dvbdmxfeed->state == DMX_STATE_FREE) { 1022 if (dvbdmxfeed->state == DMX_STATE_FREE) {
1023 up(&dvbdmx->mutex); 1023 mutex_unlock(&dvbdmx->mutex);
1024 return -EINVAL; 1024 return -EINVAL;
1025 } 1025 }
1026#ifndef NOBUFS 1026#ifndef NOBUFS
@@ -1033,7 +1033,7 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux,
1033 1033
1034 dvbdmxfeed->pid = 0xffff; 1034 dvbdmxfeed->pid = 0xffff;
1035 1035
1036 up(&dvbdmx->mutex); 1036 mutex_unlock(&dvbdmx->mutex);
1037 return 0; 1037 return 0;
1038} 1038}
1039 1039
@@ -1071,10 +1071,10 @@ static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count)
1071 if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE)) 1071 if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE))
1072 return -EINVAL; 1072 return -EINVAL;
1073 1073
1074 if (down_interruptible(&dvbdemux->mutex)) 1074 if (mutex_lock_interruptible(&dvbdemux->mutex))
1075 return -ERESTARTSYS; 1075 return -ERESTARTSYS;
1076 dvb_dmx_swfilter(dvbdemux, buf, count); 1076 dvb_dmx_swfilter(dvbdemux, buf, count);
1077 up(&dvbdemux->mutex); 1077 mutex_unlock(&dvbdemux->mutex);
1078 1078
1079 if (signal_pending(current)) 1079 if (signal_pending(current))
1080 return -EINTR; 1080 return -EINTR;
@@ -1126,11 +1126,11 @@ static int dvbdmx_connect_frontend(struct dmx_demux *demux,
1126 if (demux->frontend) 1126 if (demux->frontend)
1127 return -EINVAL; 1127 return -EINVAL;
1128 1128
1129 if (down_interruptible(&dvbdemux->mutex)) 1129 if (mutex_lock_interruptible(&dvbdemux->mutex))
1130 return -ERESTARTSYS; 1130 return -ERESTARTSYS;
1131 1131
1132 demux->frontend = frontend; 1132 demux->frontend = frontend;
1133 up(&dvbdemux->mutex); 1133 mutex_unlock(&dvbdemux->mutex);
1134 return 0; 1134 return 0;
1135} 1135}
1136 1136
@@ -1138,11 +1138,11 @@ static int dvbdmx_disconnect_frontend(struct dmx_demux *demux)
1138{ 1138{
1139 struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; 1139 struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
1140 1140
1141 if (down_interruptible(&dvbdemux->mutex)) 1141 if (mutex_lock_interruptible(&dvbdemux->mutex))
1142 return -ERESTARTSYS; 1142 return -ERESTARTSYS;
1143 1143
1144 demux->frontend = NULL; 1144 demux->frontend = NULL;
1145 up(&dvbdemux->mutex); 1145 mutex_unlock(&dvbdemux->mutex);
1146 return 0; 1146 return 0;
1147} 1147}
1148 1148
@@ -1215,7 +1215,7 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
1215 dmx->disconnect_frontend = dvbdmx_disconnect_frontend; 1215 dmx->disconnect_frontend = dvbdmx_disconnect_frontend;
1216 dmx->get_pes_pids = dvbdmx_get_pes_pids; 1216 dmx->get_pes_pids = dvbdmx_get_pes_pids;
1217 1217
1218 sema_init(&dvbdemux->mutex, 1); 1218 mutex_init(&dvbdemux->mutex);
1219 spin_lock_init(&dvbdemux->lock); 1219 spin_lock_init(&dvbdemux->lock);
1220 1220
1221 return 0; 1221 return 0;
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h
index 0cc888339d52..2c5f915329ca 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.h
+++ b/drivers/media/dvb/dvb-core/dvb_demux.h
@@ -26,7 +26,7 @@
26#include <linux/time.h> 26#include <linux/time.h>
27#include <linux/timer.h> 27#include <linux/timer.h>
28#include <linux/spinlock.h> 28#include <linux/spinlock.h>
29#include <asm/semaphore.h> 29#include <linux/mutex.h>
30 30
31#include "demux.h" 31#include "demux.h"
32 32
@@ -125,7 +125,7 @@ struct dvb_demux {
125 u8 tsbuf[204]; 125 u8 tsbuf[204];
126 int tsbufp; 126 int tsbufp;
127 127
128 struct semaphore mutex; 128 struct mutex mutex;
129 spinlock_t lock; 129 spinlock_t lock;
130}; 130};
131 131
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 771f32d889e6..22e96cf8497a 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -37,7 +37,6 @@
37#include <linux/suspend.h> 37#include <linux/suspend.h>
38#include <linux/jiffies.h> 38#include <linux/jiffies.h>
39#include <asm/processor.h> 39#include <asm/processor.h>
40#include <asm/semaphore.h>
41 40
42#include "dvb_frontend.h" 41#include "dvb_frontend.h"
43#include "dvbdev.h" 42#include "dvbdev.h"
@@ -88,7 +87,7 @@ MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB vola
88 * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again. 87 * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again.
89 */ 88 */
90 89
91static DECLARE_MUTEX(frontend_mutex); 90static DEFINE_MUTEX(frontend_mutex);
92 91
93struct dvb_frontend_private { 92struct dvb_frontend_private {
94 93
@@ -1021,12 +1020,12 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
1021 1020
1022 dprintk ("%s\n", __FUNCTION__); 1021 dprintk ("%s\n", __FUNCTION__);
1023 1022
1024 if (down_interruptible (&frontend_mutex)) 1023 if (mutex_lock_interruptible(&frontend_mutex))
1025 return -ERESTARTSYS; 1024 return -ERESTARTSYS;
1026 1025
1027 fe->frontend_priv = kzalloc(sizeof(struct dvb_frontend_private), GFP_KERNEL); 1026 fe->frontend_priv = kzalloc(sizeof(struct dvb_frontend_private), GFP_KERNEL);
1028 if (fe->frontend_priv == NULL) { 1027 if (fe->frontend_priv == NULL) {
1029 up(&frontend_mutex); 1028 mutex_unlock(&frontend_mutex);
1030 return -ENOMEM; 1029 return -ENOMEM;
1031 } 1030 }
1032 fepriv = fe->frontend_priv; 1031 fepriv = fe->frontend_priv;
@@ -1045,7 +1044,7 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
1045 dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template, 1044 dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template,
1046 fe, DVB_DEVICE_FRONTEND); 1045 fe, DVB_DEVICE_FRONTEND);
1047 1046
1048 up (&frontend_mutex); 1047 mutex_unlock(&frontend_mutex);
1049 return 0; 1048 return 0;
1050} 1049}
1051EXPORT_SYMBOL(dvb_register_frontend); 1050EXPORT_SYMBOL(dvb_register_frontend);
@@ -1055,7 +1054,7 @@ int dvb_unregister_frontend(struct dvb_frontend* fe)
1055 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1054 struct dvb_frontend_private *fepriv = fe->frontend_priv;
1056 dprintk ("%s\n", __FUNCTION__); 1055 dprintk ("%s\n", __FUNCTION__);
1057 1056
1058 down (&frontend_mutex); 1057 mutex_lock(&frontend_mutex);
1059 dvb_unregister_device (fepriv->dvbdev); 1058 dvb_unregister_device (fepriv->dvbdev);
1060 dvb_frontend_stop (fe); 1059 dvb_frontend_stop (fe);
1061 if (fe->ops->release) 1060 if (fe->ops->release)
@@ -1064,7 +1063,7 @@ int dvb_unregister_frontend(struct dvb_frontend* fe)
1064 printk("dvb_frontend: Demodulator (%s) does not have a release callback!\n", fe->ops->info.name); 1063 printk("dvb_frontend: Demodulator (%s) does not have a release callback!\n", fe->ops->info.name);
1065 /* fe is invalid now */ 1064 /* fe is invalid now */
1066 kfree(fepriv); 1065 kfree(fepriv);
1067 up (&frontend_mutex); 1066 mutex_unlock(&frontend_mutex);
1068 return 0; 1067 return 0;
1069} 1068}
1070EXPORT_SYMBOL(dvb_unregister_frontend); 1069EXPORT_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 6711eb6a058c..2f0f35811bf7 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -62,6 +62,7 @@
62#include <linux/uio.h> 62#include <linux/uio.h>
63#include <asm/uaccess.h> 63#include <asm/uaccess.h>
64#include <linux/crc32.h> 64#include <linux/crc32.h>
65#include <linux/mutex.h>
65 66
66#include "dvb_demux.h" 67#include "dvb_demux.h"
67#include "dvb_net.h" 68#include "dvb_net.h"
@@ -151,8 +152,7 @@ struct dvb_net_priv {
151 unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */ 152 unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */
152 int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */ 153 int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */
153 unsigned long ts_count; /* Current ts cell counter. */ 154 unsigned long ts_count; /* Current ts cell counter. */
154 155 struct mutex mutex;
155 struct semaphore mutex;
156}; 156};
157 157
158 158
@@ -889,7 +889,7 @@ static int dvb_net_feed_start(struct net_device *dev)
889 unsigned char *mac = (unsigned char *) dev->dev_addr; 889 unsigned char *mac = (unsigned char *) dev->dev_addr;
890 890
891 dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode); 891 dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode);
892 down(&priv->mutex); 892 mutex_lock(&priv->mutex);
893 if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0]) 893 if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
894 printk("%s: BUG %d\n", __FUNCTION__, __LINE__); 894 printk("%s: BUG %d\n", __FUNCTION__, __LINE__);
895 895
@@ -974,7 +974,7 @@ static int dvb_net_feed_start(struct net_device *dev)
974 ret = -EINVAL; 974 ret = -EINVAL;
975 975
976error: 976error:
977 up(&priv->mutex); 977 mutex_unlock(&priv->mutex);
978 return ret; 978 return ret;
979} 979}
980 980
@@ -984,7 +984,7 @@ static int dvb_net_feed_stop(struct net_device *dev)
984 int i, ret = 0; 984 int i, ret = 0;
985 985
986 dprintk("%s\n", __FUNCTION__); 986 dprintk("%s\n", __FUNCTION__);
987 down(&priv->mutex); 987 mutex_lock(&priv->mutex);
988 if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) { 988 if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) {
989 if (priv->secfeed) { 989 if (priv->secfeed) {
990 if (priv->secfeed->is_filtering) { 990 if (priv->secfeed->is_filtering) {
@@ -1026,7 +1026,7 @@ static int dvb_net_feed_stop(struct net_device *dev)
1026 printk("%s: no ts feed to stop\n", dev->name); 1026 printk("%s: no ts feed to stop\n", dev->name);
1027 } else 1027 } else
1028 ret = -EINVAL; 1028 ret = -EINVAL;
1029 up(&priv->mutex); 1029 mutex_unlock(&priv->mutex);
1030 return ret; 1030 return ret;
1031} 1031}
1032 1032
@@ -1208,7 +1208,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1208 1208
1209 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net); 1209 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net);
1210 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net); 1210 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net);
1211 init_MUTEX(&priv->mutex); 1211 mutex_init(&priv->mutex);
1212 1212
1213 net->base_addr = pid; 1213 net->base_addr = pid;
1214 1214
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index f327fac1688e..e62a293c7e5a 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)
77 struct dvb_usb_device *d = i2c_get_adapdata(adap); 77 struct dvb_usb_device *d = i2c_get_adapdata(adap);
78 int i; 78 int i;
79 79
80 if (down_interruptible(&d->i2c_sem) < 0) 80 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
81 return -EAGAIN; 81 return -EAGAIN;
82 82
83 if (num > 2) 83 if (num > 2)
@@ -126,7 +126,7 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
126 } 126 }
127 } 127 }
128 128
129 up(&d->i2c_sem); 129 mutex_unlock(&d->i2c_mutex);
130 return i; 130 return i;
131} 131}
132 132
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index 269d899da488..2d52b76671d3 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
128 struct dvb_usb_device *d = i2c_get_adapdata(adap); 128 struct dvb_usb_device *d = i2c_get_adapdata(adap);
129 int i; 129 int i;
130 130
131 if (down_interruptible(&d->i2c_sem) < 0) 131 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
132 return -EAGAIN; 132 return -EAGAIN;
133 133
134 if (num > 2) 134 if (num > 2)
@@ -146,7 +146,7 @@ static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
146 break; 146 break;
147 } 147 }
148 148
149 up(&d->i2c_sem); 149 mutex_unlock(&d->i2c_mutex);
150 return i; 150 return i;
151} 151}
152 152
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index caa1346e3063..91136c00ce9d 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
48 struct dvb_usb_device *d = i2c_get_adapdata(adap); 48 struct dvb_usb_device *d = i2c_get_adapdata(adap);
49 int i; 49 int i;
50 50
51 if (down_interruptible(&d->i2c_sem) < 0) 51 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
52 return -EAGAIN; 52 return -EAGAIN;
53 53
54 if (num > 2) 54 if (num > 2)
@@ -67,7 +67,7 @@ static int digitv_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
67 break; 67 break;
68 } 68 }
69 69
70 up(&d->i2c_sem); 70 mutex_unlock(&d->i2c_mutex);
71 return i; 71 return i;
72} 72}
73 73
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index 716f8bf528cd..4258a995dce1 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)
42{ 42{
43 int ret = 0; 43 int ret = 0;
44 44
45 sema_init(&d->usb_sem, 1); 45 mutex_init(&d->usb_mutex);
46 sema_init(&d->i2c_sem, 1); 46 mutex_init(&d->i2c_mutex);
47 47
48 d->state = DVB_USB_STATE_INIT; 48 d->state = DVB_USB_STATE_INIT;
49 49
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
index ee821974dc60..9002f35aa952 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,
21 if (wbuf == NULL || wlen == 0) 21 if (wbuf == NULL || wlen == 0)
22 return -EINVAL; 22 return -EINVAL;
23 23
24 if ((ret = down_interruptible(&d->usb_sem))) 24 if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
25 return ret; 25 return ret;
26 26
27 deb_xfer(">>> "); 27 deb_xfer(">>> ");
@@ -53,7 +53,7 @@ int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
53 } 53 }
54 } 54 }
55 55
56 up(&d->usb_sem); 56 mutex_unlock(&d->usb_mutex);
57 return ret; 57 return ret;
58} 58}
59EXPORT_SYMBOL(dvb_usb_generic_rw); 59EXPORT_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 5e5d21ad93c9..d2be37cc43b7 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -12,6 +12,7 @@
12#include <linux/input.h> 12#include <linux/input.h>
13#include <linux/usb.h> 13#include <linux/usb.h>
14#include <linux/firmware.h> 14#include <linux/firmware.h>
15#include <linux/mutex.h>
15 16
16#include "dvb_frontend.h" 17#include "dvb_frontend.h"
17#include "dvb_demux.h" 18#include "dvb_demux.h"
@@ -227,8 +228,8 @@ struct dvb_usb_properties {
227 * @feedcount: number of reqested feeds (used for streaming-activation) 228 * @feedcount: number of reqested feeds (used for streaming-activation)
228 * @pid_filtering: is hardware pid_filtering used or not. 229 * @pid_filtering: is hardware pid_filtering used or not.
229 * 230 *
230 * @usb_sem: semaphore of USB control messages (reading needs two messages) 231 * @usb_mutex: semaphore of USB control messages (reading needs two messages)
231 * @i2c_sem: semaphore for i2c-transfers 232 * @i2c_mutex: semaphore for i2c-transfers
232 * 233 *
233 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB 234 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB
234 * @pll_addr: I2C address of the tuner for programming 235 * @pll_addr: I2C address of the tuner for programming
@@ -283,10 +284,10 @@ struct dvb_usb_device {
283 int pid_filtering; 284 int pid_filtering;
284 285
285 /* locking */ 286 /* locking */
286 struct semaphore usb_sem; 287 struct mutex usb_mutex;
287 288
288 /* i2c */ 289 /* i2c */
289 struct semaphore i2c_sem; 290 struct mutex i2c_mutex;
290 struct i2c_adapter i2c_adap; 291 struct i2c_adapter i2c_adap;
291 292
292 /* tuner programming information */ 293 /* tuner programming information */
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c
index 4a95eca81c5c..b2f098a2d5f7 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
75{ 75{
76 int ret; 76 int ret;
77 77
78 if ((ret = down_interruptible(&d->usb_sem))) 78 if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
79 return ret; 79 return ret;
80 80
81 if ((ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen)) < 0) 81 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
84 ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen); 84 ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen);
85 85
86unlock: 86unlock:
87 up(&d->usb_sem); 87 mutex_unlock(&d->usb_mutex);
88 88
89 return ret; 89 return ret;
90} 90}
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c
index 028204956bb0..7fa656b108cc 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,
38 deb_xfer("out buffer: "); 38 deb_xfer("out buffer: ");
39 debug_dump(outbuf,outlen+1,deb_xfer); 39 debug_dump(outbuf,outlen+1,deb_xfer);
40 40
41 if ((ret = down_interruptible(&d->usb_sem))) 41 if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
42 return ret; 42 return ret;
43 43
44 if (usb_control_msg(d->udev, 44 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,
68 memcpy(in,&inbuf[1],inlen); 68 memcpy(in,&inbuf[1],inlen);
69 69
70unlock: 70unlock:
71 up(&d->usb_sem); 71 mutex_unlock(&d->usb_mutex);
72 72
73 return ret; 73 return ret;
74} 74}
diff --git a/drivers/media/dvb/frontends/bcm3510.c b/drivers/media/dvb/frontends/bcm3510.c
index caaee893ca76..1708a1d4893e 100644
--- a/drivers/media/dvb/frontends/bcm3510.c
+++ b/drivers/media/dvb/frontends/bcm3510.c
@@ -39,6 +39,7 @@
39#include <linux/jiffies.h> 39#include <linux/jiffies.h>
40#include <linux/string.h> 40#include <linux/string.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/mutex.h>
42 43
43#include "dvb_frontend.h" 44#include "dvb_frontend.h"
44#include "bcm3510.h" 45#include "bcm3510.h"
@@ -52,7 +53,7 @@ struct bcm3510_state {
52 struct dvb_frontend frontend; 53 struct dvb_frontend frontend;
53 54
54 /* demodulator private data */ 55 /* demodulator private data */
55 struct semaphore hab_sem; 56 struct mutex hab_mutex;
56 u8 firmware_loaded:1; 57 u8 firmware_loaded:1;
57 58
58 unsigned long next_status_check; 59 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
213 dbufout(ob,olen+2,deb_hab); 214 dbufout(ob,olen+2,deb_hab);
214 deb_hab("\n"); 215 deb_hab("\n");
215 216
216 if (down_interruptible(&st->hab_sem) < 0) 217 if (mutex_lock_interruptible(&st->hab_mutex) < 0)
217 return -EAGAIN; 218 return -EAGAIN;
218 219
219 if ((ret = bcm3510_hab_send_request(st, ob, olen+2)) < 0 || 220 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
226 227
227 memcpy(ibuf,&ib[2],ilen); 228 memcpy(ibuf,&ib[2],ilen);
228error: 229error:
229 up(&st->hab_sem); 230 mutex_unlock(&st->hab_mutex);
230 return ret; 231 return ret;
231} 232}
232 233
@@ -796,7 +797,7 @@ struct dvb_frontend* bcm3510_attach(const struct bcm3510_config *config,
796 state->frontend.ops = &state->ops; 797 state->frontend.ops = &state->ops;
797 state->frontend.demodulator_priv = state; 798 state->frontend.demodulator_priv = state;
798 799
799 sema_init(&state->hab_sem, 1); 800 mutex_init(&state->hab_mutex);
800 801
801 if ((ret = bcm3510_readB(state,0xe0,&v)) < 0) 802 if ((ret = bcm3510_readB(state,0xe0,&v)) < 0)
802 goto error; 803 goto error;
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index d36369e9e88f..1aa61bf29ad6 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -54,7 +54,6 @@
54#include <linux/i2c.h> 54#include <linux/i2c.h>
55 55
56#include <asm/system.h> 56#include <asm/system.h>
57#include <asm/semaphore.h>
58 57
59#include <linux/dvb/frontend.h> 58#include <linux/dvb/frontend.h>
60 59
@@ -242,10 +241,10 @@ static int arm_thread(void *data)
242 if (!av7110->arm_ready) 241 if (!av7110->arm_ready)
243 continue; 242 continue;
244 243
245 if (down_interruptible(&av7110->dcomlock)) 244 if (mutex_lock_interruptible(&av7110->dcomlock))
246 break; 245 break;
247 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2); 246 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2);
248 up(&av7110->dcomlock); 247 mutex_unlock(&av7110->dcomlock);
249 248
250 if (newloops == av7110->arm_loops || av7110->arm_errors > 3) { 249 if (newloops == av7110->arm_loops || av7110->arm_errors > 3) {
251 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n", 250 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n",
@@ -253,10 +252,10 @@ static int arm_thread(void *data)
253 252
254 recover_arm(av7110); 253 recover_arm(av7110);
255 254
256 if (down_interruptible(&av7110->dcomlock)) 255 if (mutex_lock_interruptible(&av7110->dcomlock))
257 break; 256 break;
258 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1; 257 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1;
259 up(&av7110->dcomlock); 258 mutex_unlock(&av7110->dcomlock);
260 } 259 }
261 av7110->arm_loops = newloops; 260 av7110->arm_loops = newloops;
262 av7110->arm_errors = 0; 261 av7110->arm_errors = 0;
@@ -741,7 +740,7 @@ int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
741 int ret = 0; 740 int ret = 0;
742 dprintk(4, "%p\n", av7110); 741 dprintk(4, "%p\n", av7110);
743 742
744 if (down_interruptible(&av7110->pid_mutex)) 743 if (mutex_lock_interruptible(&av7110->pid_mutex))
745 return -ERESTARTSYS; 744 return -ERESTARTSYS;
746 745
747 if (!(vpid & 0x8000)) 746 if (!(vpid & 0x8000))
@@ -760,7 +759,7 @@ int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
760 ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid); 759 ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid);
761 } 760 }
762 761
763 up(&av7110->pid_mutex); 762 mutex_unlock(&av7110->pid_mutex);
764 return ret; 763 return ret;
765} 764}
766 765
@@ -2096,7 +2095,7 @@ static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
2096 if (av7110->playing) 2095 if (av7110->playing)
2097 return 0; 2096 return 0;
2098 2097
2099 if (down_interruptible(&av7110->pid_mutex)) 2098 if (mutex_lock_interruptible(&av7110->pid_mutex))
2100 return -ERESTARTSYS; 2099 return -ERESTARTSYS;
2101 2100
2102 if (synced) { 2101 if (synced) {
@@ -2118,7 +2117,7 @@ static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
2118 if (!ret) 2117 if (!ret)
2119 av7110->fe_synced = synced; 2118 av7110->fe_synced = synced;
2120 2119
2121 up(&av7110->pid_mutex); 2120 mutex_unlock(&av7110->pid_mutex);
2122 return ret; 2121 return ret;
2123} 2122}
2124 2123
@@ -2713,16 +2712,16 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
2713 tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110); 2712 tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110);
2714 tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110); 2713 tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110);
2715 2714
2716 sema_init(&av7110->pid_mutex, 1); 2715 mutex_init(&av7110->pid_mutex);
2717 2716
2718 /* locks for data transfers from/to AV7110 */ 2717 /* locks for data transfers from/to AV7110 */
2719 spin_lock_init(&av7110->debilock); 2718 spin_lock_init(&av7110->debilock);
2720 sema_init(&av7110->dcomlock, 1); 2719 mutex_init(&av7110->dcomlock);
2721 av7110->debitype = -1; 2720 av7110->debitype = -1;
2722 2721
2723 /* default OSD window */ 2722 /* default OSD window */
2724 av7110->osdwin = 1; 2723 av7110->osdwin = 1;
2725 sema_init(&av7110->osd_sema, 1); 2724 mutex_init(&av7110->osd_mutex);
2726 2725
2727 /* ARM "watchdog" */ 2726 /* ARM "watchdog" */
2728 init_waitqueue_head(&av7110->arm_wait); 2727 init_waitqueue_head(&av7110->arm_wait);
diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h
index fafd25fab835..3e2e12124bae 100644
--- a/drivers/media/dvb/ttpci/av7110.h
+++ b/drivers/media/dvb/ttpci/av7110.h
@@ -16,6 +16,7 @@
16#include <linux/dvb/ca.h> 16#include <linux/dvb/ca.h>
17#include <linux/dvb/osd.h> 17#include <linux/dvb/osd.h>
18#include <linux/dvb/net.h> 18#include <linux/dvb/net.h>
19#include <linux/mutex.h>
19 20
20#include "dvbdev.h" 21#include "dvbdev.h"
21#include "demux.h" 22#include "demux.h"
@@ -127,7 +128,7 @@ struct av7110 {
127 /* DEBI and polled command interface */ 128 /* DEBI and polled command interface */
128 129
129 spinlock_t debilock; 130 spinlock_t debilock;
130 struct semaphore dcomlock; 131 struct mutex dcomlock;
131 volatile int debitype; 132 volatile int debitype;
132 volatile int debilen; 133 volatile int debilen;
133 134
@@ -146,7 +147,7 @@ struct av7110 {
146 147
147 int osdwin; /* currently active window */ 148 int osdwin; /* currently active window */
148 u16 osdbpp[8]; 149 u16 osdbpp[8];
149 struct semaphore osd_sema; 150 struct mutex osd_mutex;
150 151
151 /* CA */ 152 /* CA */
152 153
@@ -172,7 +173,7 @@ struct av7110 {
172 struct tasklet_struct vpe_tasklet; 173 struct tasklet_struct vpe_tasklet;
173 174
174 int fe_synced; 175 int fe_synced;
175 struct semaphore pid_mutex; 176 struct mutex pid_mutex;
176 177
177 int video_blank; 178 int video_blank;
178 struct video_status videostate; 179 struct video_status videostate;
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c
index b2e63e9fc053..3c5366d15a8a 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)
324 start = jiffies; 324 start = jiffies;
325 for (;;) { 325 for (;;) {
326 err = time_after(jiffies, start + ARM_WAIT_FREE); 326 err = time_after(jiffies, start + ARM_WAIT_FREE);
327 if (down_interruptible(&av7110->dcomlock)) 327 if (mutex_lock_interruptible(&av7110->dcomlock))
328 return -ERESTARTSYS; 328 return -ERESTARTSYS;
329 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); 329 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
330 up(&av7110->dcomlock); 330 mutex_unlock(&av7110->dcomlock);
331 if ((stat & flags) == 0) 331 if ((stat & flags) == 0)
332 break; 332 break;
333 if (err) { 333 if (err) {
@@ -484,11 +484,11 @@ static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
484 dprintk(1, "arm not ready.\n"); 484 dprintk(1, "arm not ready.\n");
485 return -1; 485 return -1;
486 } 486 }
487 if (down_interruptible(&av7110->dcomlock)) 487 if (mutex_lock_interruptible(&av7110->dcomlock))
488 return -ERESTARTSYS; 488 return -ERESTARTSYS;
489 489
490 ret = __av7110_send_fw_cmd(av7110, buf, length); 490 ret = __av7110_send_fw_cmd(av7110, buf, length);
491 up(&av7110->dcomlock); 491 mutex_unlock(&av7110->dcomlock);
492 if (ret && ret!=-ERESTARTSYS) 492 if (ret && ret!=-ERESTARTSYS)
493 printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n", 493 printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n",
494 __FUNCTION__, ret); 494 __FUNCTION__, ret);
@@ -560,11 +560,11 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
560 return -1; 560 return -1;
561 } 561 }
562 562
563 if (down_interruptible(&av7110->dcomlock)) 563 if (mutex_lock_interruptible(&av7110->dcomlock))
564 return -ERESTARTSYS; 564 return -ERESTARTSYS;
565 565
566 if ((err = __av7110_send_fw_cmd(av7110, request_buf, request_buf_len)) < 0) { 566 if ((err = __av7110_send_fw_cmd(av7110, request_buf, request_buf_len)) < 0) {
567 up(&av7110->dcomlock); 567 mutex_unlock(&av7110->dcomlock);
568 printk(KERN_ERR "dvb-ttpci: av7110_fw_request error %d\n", err); 568 printk(KERN_ERR "dvb-ttpci: av7110_fw_request error %d\n", err);
569 return err; 569 return err;
570 } 570 }
@@ -576,7 +576,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
576 break; 576 break;
577 if (err) { 577 if (err) {
578 printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__); 578 printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__);
579 up(&av7110->dcomlock); 579 mutex_unlock(&av7110->dcomlock);
580 return -ETIMEDOUT; 580 return -ETIMEDOUT;
581 } 581 }
582#ifdef _NOHANDSHAKE 582#ifdef _NOHANDSHAKE
@@ -592,7 +592,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
592 break; 592 break;
593 if (err) { 593 if (err) {
594 printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); 594 printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__);
595 up(&av7110->dcomlock); 595 mutex_unlock(&av7110->dcomlock);
596 return -ETIMEDOUT; 596 return -ETIMEDOUT;
597 } 597 }
598 msleep(1); 598 msleep(1);
@@ -603,12 +603,12 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
603 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); 603 stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
604 if (stat & GPMQOver) { 604 if (stat & GPMQOver) {
605 printk(KERN_ERR "%s: GPMQOver\n", __FUNCTION__); 605 printk(KERN_ERR "%s: GPMQOver\n", __FUNCTION__);
606 up(&av7110->dcomlock); 606 mutex_unlock(&av7110->dcomlock);
607 return -1; 607 return -1;
608 } 608 }
609 else if (stat & OSDQOver) { 609 else if (stat & OSDQOver) {
610 printk(KERN_ERR "%s: OSDQOver\n", __FUNCTION__); 610 printk(KERN_ERR "%s: OSDQOver\n", __FUNCTION__);
611 up(&av7110->dcomlock); 611 mutex_unlock(&av7110->dcomlock);
612 return -1; 612 return -1;
613 } 613 }
614#endif 614#endif
@@ -616,7 +616,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
616 for (i = 0; i < reply_buf_len; i++) 616 for (i = 0; i < reply_buf_len; i++)
617 reply_buf[i] = rdebi(av7110, DEBINOSWAP, COM_BUFF + 2 * i, 0, 2); 617 reply_buf[i] = rdebi(av7110, DEBINOSWAP, COM_BUFF + 2 * i, 0, 2);
618 618
619 up(&av7110->dcomlock); 619 mutex_unlock(&av7110->dcomlock);
620 return 0; 620 return 0;
621} 621}
622 622
@@ -732,7 +732,7 @@ static int FlushText(struct av7110 *av7110)
732 unsigned long start; 732 unsigned long start;
733 int err; 733 int err;
734 734
735 if (down_interruptible(&av7110->dcomlock)) 735 if (mutex_lock_interruptible(&av7110->dcomlock))
736 return -ERESTARTSYS; 736 return -ERESTARTSYS;
737 start = jiffies; 737 start = jiffies;
738 while (1) { 738 while (1) {
@@ -742,12 +742,12 @@ static int FlushText(struct av7110 *av7110)
742 if (err) { 742 if (err) {
743 printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n", 743 printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n",
744 __FUNCTION__); 744 __FUNCTION__);
745 up(&av7110->dcomlock); 745 mutex_unlock(&av7110->dcomlock);
746 return -ETIMEDOUT; 746 return -ETIMEDOUT;
747 } 747 }
748 msleep(1); 748 msleep(1);
749 } 749 }
750 up(&av7110->dcomlock); 750 mutex_unlock(&av7110->dcomlock);
751 return 0; 751 return 0;
752} 752}
753 753
@@ -758,7 +758,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
758 int length = strlen(buf) + 1; 758 int length = strlen(buf) + 1;
759 u16 cbuf[5] = { (COMTYPE_OSD << 8) + DText, 3, win, x, y }; 759 u16 cbuf[5] = { (COMTYPE_OSD << 8) + DText, 3, win, x, y };
760 760
761 if (down_interruptible(&av7110->dcomlock)) 761 if (mutex_lock_interruptible(&av7110->dcomlock))
762 return -ERESTARTSYS; 762 return -ERESTARTSYS;
763 763
764 start = jiffies; 764 start = jiffies;
@@ -769,7 +769,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
769 if (ret) { 769 if (ret) {
770 printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n", 770 printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n",
771 __FUNCTION__); 771 __FUNCTION__);
772 up(&av7110->dcomlock); 772 mutex_unlock(&av7110->dcomlock);
773 return -ETIMEDOUT; 773 return -ETIMEDOUT;
774 } 774 }
775 msleep(1); 775 msleep(1);
@@ -783,7 +783,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
783 if (ret) { 783 if (ret) {
784 printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n", 784 printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n",
785 __FUNCTION__); 785 __FUNCTION__);
786 up(&av7110->dcomlock); 786 mutex_unlock(&av7110->dcomlock);
787 return -ETIMEDOUT; 787 return -ETIMEDOUT;
788 } 788 }
789 msleep(1); 789 msleep(1);
@@ -795,7 +795,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
795 if (length & 1) 795 if (length & 1)
796 wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2); 796 wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2);
797 ret = __av7110_send_fw_cmd(av7110, cbuf, 5); 797 ret = __av7110_send_fw_cmd(av7110, cbuf, 5);
798 up(&av7110->dcomlock); 798 mutex_unlock(&av7110->dcomlock);
799 if (ret && ret!=-ERESTARTSYS) 799 if (ret && ret!=-ERESTARTSYS)
800 printk(KERN_ERR "dvb-ttpci: WriteText error %d\n", ret); 800 printk(KERN_ERR "dvb-ttpci: WriteText error %d\n", ret);
801 return ret; 801 return ret;
@@ -1059,7 +1059,7 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
1059{ 1059{
1060 int ret; 1060 int ret;
1061 1061
1062 if (down_interruptible(&av7110->osd_sema)) 1062 if (mutex_lock_interruptible(&av7110->osd_mutex))
1063 return -ERESTARTSYS; 1063 return -ERESTARTSYS;
1064 1064
1065 switch (dc->cmd) { 1065 switch (dc->cmd) {
@@ -1195,7 +1195,7 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
1195 break; 1195 break;
1196 } 1196 }
1197 1197
1198 up(&av7110->osd_sema); 1198 mutex_unlock(&av7110->osd_mutex);
1199 if (ret==-ERESTARTSYS) 1199 if (ret==-ERESTARTSYS)
1200 dprintk(1, "av7110_osd_cmd(%d) returns with -ERESTARTSYS\n",dc->cmd); 1200 dprintk(1, "av7110_osd_cmd(%d) returns with -ERESTARTSYS\n",dc->cmd);
1201 else if (ret) 1201 else if (ret)
diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h
index c7bb63c4d98d..4ac0f4d08025 100644
--- a/drivers/media/dvb/ttpci/budget.h
+++ b/drivers/media/dvb/ttpci/budget.h
@@ -10,6 +10,8 @@
10#include "dvb_net.h" 10#include "dvb_net.h"
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/mutex.h>
14
13#include <media/saa7146.h> 15#include <media/saa7146.h>
14 16
15extern int budget_debug; 17extern int budget_debug;
@@ -51,7 +53,7 @@ struct budget {
51 struct dmx_frontend mem_frontend; 53 struct dmx_frontend mem_frontend;
52 54
53 int fe_synced; 55 int fe_synced;
54 struct semaphore pid_mutex; 56 struct mutex pid_mutex;
55 57
56 int ci_present; 58 int ci_present;
57 int video_port; 59 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 5a13c4744f61..ecb15d4ecf81 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 @@
19#include <linux/time.h> 19#include <linux/time.h>
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/jiffies.h> 21#include <linux/jiffies.h>
22#include <asm/semaphore.h> 22#include <linux/mutex.h>
23 23
24#include "dvb_frontend.h" 24#include "dvb_frontend.h"
25#include "dmxdev.h" 25#include "dmxdev.h"
@@ -35,7 +35,6 @@
35#include <linux/dvb/dmx.h> 35#include <linux/dvb/dmx.h>
36#include <linux/pci.h> 36#include <linux/pci.h>
37 37
38
39/* 38/*
40 TTUSB_HWSECTIONS: 39 TTUSB_HWSECTIONS:
41 the DSP supports filtering in hardware, however, since the "muxstream" 40 the DSP supports filtering in hardware, however, since the "muxstream"
@@ -83,8 +82,8 @@ struct ttusb {
83 struct dvb_net dvbnet; 82 struct dvb_net dvbnet;
84 83
85 /* and one for USB access. */ 84 /* and one for USB access. */
86 struct semaphore semi2c; 85 struct mutex semi2c;
87 struct semaphore semusb; 86 struct mutex semusb;
88 87
89 struct dvb_adapter adapter; 88 struct dvb_adapter adapter;
90 struct usb_device *dev; 89 struct usb_device *dev;
@@ -150,7 +149,7 @@ static int ttusb_cmd(struct ttusb *ttusb,
150 printk("\n"); 149 printk("\n");
151#endif 150#endif
152 151
153 if (down_interruptible(&ttusb->semusb) < 0) 152 if (mutex_lock_interruptible(&ttusb->semusb) < 0)
154 return -EAGAIN; 153 return -EAGAIN;
155 154
156 err = usb_bulk_msg(ttusb->dev, ttusb->bulk_out_pipe, 155 err = usb_bulk_msg(ttusb->dev, ttusb->bulk_out_pipe,
@@ -158,13 +157,13 @@ static int ttusb_cmd(struct ttusb *ttusb,
158 if (err != 0) { 157 if (err != 0) {
159 dprintk("%s: usb_bulk_msg(send) failed, err == %i!\n", 158 dprintk("%s: usb_bulk_msg(send) failed, err == %i!\n",
160 __FUNCTION__, err); 159 __FUNCTION__, err);
161 up(&ttusb->semusb); 160 mutex_unlock(&ttusb->semusb);
162 return err; 161 return err;
163 } 162 }
164 if (actual_len != len) { 163 if (actual_len != len) {
165 dprintk("%s: only wrote %d of %d bytes\n", __FUNCTION__, 164 dprintk("%s: only wrote %d of %d bytes\n", __FUNCTION__,
166 actual_len, len); 165 actual_len, len);
167 up(&ttusb->semusb); 166 mutex_unlock(&ttusb->semusb);
168 return -1; 167 return -1;
169 } 168 }
170 169
@@ -174,7 +173,7 @@ static int ttusb_cmd(struct ttusb *ttusb,
174 if (err != 0) { 173 if (err != 0) {
175 printk("%s: failed, receive error %d\n", __FUNCTION__, 174 printk("%s: failed, receive error %d\n", __FUNCTION__,
176 err); 175 err);
177 up(&ttusb->semusb); 176 mutex_unlock(&ttusb->semusb);
178 return err; 177 return err;
179 } 178 }
180#if DEBUG >= 3 179#if DEBUG >= 3
@@ -185,14 +184,14 @@ static int ttusb_cmd(struct ttusb *ttusb,
185 printk("\n"); 184 printk("\n");
186#endif 185#endif
187 if (!needresult) 186 if (!needresult)
188 up(&ttusb->semusb); 187 mutex_unlock(&ttusb->semusb);
189 return 0; 188 return 0;
190} 189}
191 190
192static int ttusb_result(struct ttusb *ttusb, u8 * data, int len) 191static int ttusb_result(struct ttusb *ttusb, u8 * data, int len)
193{ 192{
194 memcpy(data, ttusb->last_result, len); 193 memcpy(data, ttusb->last_result, len);
195 up(&ttusb->semusb); 194 mutex_unlock(&ttusb->semusb);
196 return 0; 195 return 0;
197} 196}
198 197
@@ -250,7 +249,7 @@ static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, int num
250 int i = 0; 249 int i = 0;
251 int inc; 250 int inc;
252 251
253 if (down_interruptible(&ttusb->semi2c) < 0) 252 if (mutex_lock_interruptible(&ttusb->semi2c) < 0)
254 return -EAGAIN; 253 return -EAGAIN;
255 254
256 while (i < num) { 255 while (i < num) {
@@ -284,7 +283,7 @@ static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, int num
284 i += inc; 283 i += inc;
285 } 284 }
286 285
287 up(&ttusb->semi2c); 286 mutex_unlock(&ttusb->semi2c);
288 return i; 287 return i;
289} 288}
290 289
@@ -1495,8 +1494,11 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1495 ttusb->dev = udev; 1494 ttusb->dev = udev;
1496 ttusb->c = 0; 1495 ttusb->c = 0;
1497 ttusb->mux_state = 0; 1496 ttusb->mux_state = 0;
1498 sema_init(&ttusb->semi2c, 0); 1497 mutex_init(&ttusb->semi2c);
1499 sema_init(&ttusb->semusb, 1); 1498
1499 mutex_lock(&ttusb->semi2c);
1500
1501 mutex_init(&ttusb->semusb);
1500 1502
1501 ttusb_setup_interfaces(ttusb); 1503 ttusb_setup_interfaces(ttusb);
1502 1504
@@ -1504,7 +1506,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1504 if (ttusb_init_controller(ttusb)) 1506 if (ttusb_init_controller(ttusb))
1505 printk("ttusb_init_controller: error\n"); 1507 printk("ttusb_init_controller: error\n");
1506 1508
1507 up(&ttusb->semi2c); 1509 mutex_unlock(&ttusb->semi2c);
1508 1510
1509 dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE); 1511 dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE);
1510 ttusb->adapter.priv = ttusb; 1512 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 df831171e03c..44dea3211848 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -20,7 +20,8 @@
20 * 20 *
21 */ 21 */
22 22
23#include <asm/semaphore.h> 23#include <linux/mutex.h>
24
24#include <linux/list.h> 25#include <linux/list.h>
25#include <linux/module.h> 26#include <linux/module.h>
26#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
@@ -115,7 +116,7 @@ struct ttusb_dec {
115 unsigned int out_pipe; 116 unsigned int out_pipe;
116 unsigned int irq_pipe; 117 unsigned int irq_pipe;
117 enum ttusb_dec_interface interface; 118 enum ttusb_dec_interface interface;
118 struct semaphore usb_sem; 119 struct mutex usb_mutex;
119 120
120 void *irq_buffer; 121 void *irq_buffer;
121 struct urb *irq_urb; 122 struct urb *irq_urb;
@@ -124,7 +125,7 @@ struct ttusb_dec {
124 dma_addr_t iso_dma_handle; 125 dma_addr_t iso_dma_handle;
125 struct urb *iso_urb[ISO_BUF_COUNT]; 126 struct urb *iso_urb[ISO_BUF_COUNT];
126 int iso_stream_count; 127 int iso_stream_count;
127 struct semaphore iso_sem; 128 struct mutex iso_mutex;
128 129
129 u8 packet[MAX_PVA_LENGTH + 4]; 130 u8 packet[MAX_PVA_LENGTH + 4];
130 enum ttusb_dec_packet_type packet_type; 131 enum ttusb_dec_packet_type packet_type;
@@ -273,9 +274,9 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
273 if (!b) 274 if (!b)
274 return -ENOMEM; 275 return -ENOMEM;
275 276
276 if ((result = down_interruptible(&dec->usb_sem))) { 277 if ((result = mutex_lock_interruptible(&dec->usb_mutex))) {
277 kfree(b); 278 kfree(b);
278 printk("%s: Failed to down usb semaphore.\n", __FUNCTION__); 279 printk("%s: Failed to lock usb mutex.\n", __FUNCTION__);
279 return result; 280 return result;
280 } 281 }
281 282
@@ -300,7 +301,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
300 if (result) { 301 if (result) {
301 printk("%s: command bulk message failed: error %d\n", 302 printk("%s: command bulk message failed: error %d\n",
302 __FUNCTION__, result); 303 __FUNCTION__, result);
303 up(&dec->usb_sem); 304 mutex_unlock(&dec->usb_mutex);
304 kfree(b); 305 kfree(b);
305 return result; 306 return result;
306 } 307 }
@@ -311,7 +312,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
311 if (result) { 312 if (result) {
312 printk("%s: result bulk message failed: error %d\n", 313 printk("%s: result bulk message failed: error %d\n",
313 __FUNCTION__, result); 314 __FUNCTION__, result);
314 up(&dec->usb_sem); 315 mutex_unlock(&dec->usb_mutex);
315 kfree(b); 316 kfree(b);
316 return result; 317 return result;
317 } else { 318 } else {
@@ -327,7 +328,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
327 if (cmd_result && b[3] > 0) 328 if (cmd_result && b[3] > 0)
328 memcpy(cmd_result, &b[4], b[3]); 329 memcpy(cmd_result, &b[4], b[3]);
329 330
330 up(&dec->usb_sem); 331 mutex_unlock(&dec->usb_mutex);
331 332
332 kfree(b); 333 kfree(b);
333 return 0; 334 return 0;
@@ -835,7 +836,7 @@ static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec)
835 836
836 dprintk("%s\n", __FUNCTION__); 837 dprintk("%s\n", __FUNCTION__);
837 838
838 if (down_interruptible(&dec->iso_sem)) 839 if (mutex_lock_interruptible(&dec->iso_mutex))
839 return; 840 return;
840 841
841 dec->iso_stream_count--; 842 dec->iso_stream_count--;
@@ -845,7 +846,7 @@ static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec)
845 usb_kill_urb(dec->iso_urb[i]); 846 usb_kill_urb(dec->iso_urb[i]);
846 } 847 }
847 848
848 up(&dec->iso_sem); 849 mutex_unlock(&dec->iso_mutex);
849} 850}
850 851
851/* Setting the interface of the DEC tends to take down the USB communications 852/* 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)
890 891
891 dprintk("%s\n", __FUNCTION__); 892 dprintk("%s\n", __FUNCTION__);
892 893
893 if (down_interruptible(&dec->iso_sem)) 894 if (mutex_lock_interruptible(&dec->iso_mutex))
894 return -EAGAIN; 895 return -EAGAIN;
895 896
896 if (!dec->iso_stream_count) { 897 if (!dec->iso_stream_count) {
@@ -911,7 +912,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec)
911 i--; 912 i--;
912 } 913 }
913 914
914 up(&dec->iso_sem); 915 mutex_unlock(&dec->iso_mutex);
915 return result; 916 return result;
916 } 917 }
917 } 918 }
@@ -919,7 +920,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec)
919 920
920 dec->iso_stream_count++; 921 dec->iso_stream_count++;
921 922
922 up(&dec->iso_sem); 923 mutex_unlock(&dec->iso_mutex);
923 924
924 return 0; 925 return 0;
925} 926}
@@ -1229,8 +1230,8 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec)
1229{ 1230{
1230 dprintk("%s\n", __FUNCTION__); 1231 dprintk("%s\n", __FUNCTION__);
1231 1232
1232 sema_init(&dec->usb_sem, 1); 1233 mutex_init(&dec->usb_mutex);
1233 sema_init(&dec->iso_sem, 1); 1234 mutex_init(&dec->iso_mutex);
1234 1235
1235 dec->command_pipe = usb_sndbulkpipe(dec->udev, COMMAND_PIPE); 1236 dec->command_pipe = usb_sndbulkpipe(dec->udev, COMMAND_PIPE);
1236 dec->result_pipe = usb_rcvbulkpipe(dec->udev, RESULT_PIPE); 1237 dec->result_pipe = usb_rcvbulkpipe(dec->udev, RESULT_PIPE);
diff --git a/drivers/media/radio/miropcm20-rds-core.c b/drivers/media/radio/miropcm20-rds-core.c
index a917a90cb5dc..b602c73e2309 100644
--- a/drivers/media/radio/miropcm20-rds-core.c
+++ b/drivers/media/radio/miropcm20-rds-core.c
@@ -18,14 +18,15 @@
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <asm/semaphore.h> 21#include <linux/mutex.h>
22
22#include <asm/io.h> 23#include <asm/io.h>
23#include "../../../sound/oss/aci.h" 24#include "../../../sound/oss/aci.h"
24#include "miropcm20-rds-core.h" 25#include "miropcm20-rds-core.h"
25 26
26#define DEBUG 0 27#define DEBUG 0
27 28
28static struct semaphore aci_rds_sem; 29static struct mutex aci_rds_mutex;
29 30
30#define RDS_DATASHIFT 2 /* Bit 2 */ 31#define RDS_DATASHIFT 2 /* Bit 2 */
31#define RDS_DATAMASK (1 << RDS_DATASHIFT) 32#define RDS_DATAMASK (1 << RDS_DATASHIFT)
@@ -181,7 +182,7 @@ int aci_rds_cmd(unsigned char cmd, unsigned char databuffer[], int datasize)
181{ 182{
182 int ret; 183 int ret;
183 184
184 if (down_interruptible(&aci_rds_sem)) 185 if (mutex_lock_interruptible(&aci_rds_mutex))
185 return -EINTR; 186 return -EINTR;
186 187
187 rds_write(cmd); 188 rds_write(cmd);
@@ -192,7 +193,7 @@ int aci_rds_cmd(unsigned char cmd, unsigned char databuffer[], int datasize)
192 else 193 else
193 ret = 0; 194 ret = 0;
194 195
195 up(&aci_rds_sem); 196 mutex_unlock(&aci_rds_mutex);
196 197
197 return ret; 198 return ret;
198} 199}
@@ -200,7 +201,7 @@ EXPORT_SYMBOL(aci_rds_cmd);
200 201
201int __init attach_aci_rds(void) 202int __init attach_aci_rds(void)
202{ 203{
203 init_MUTEX(&aci_rds_sem); 204 mutex_init(&aci_rds_mutex);
204 return 0; 205 return 0;
205} 206}
206 207
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 914deab4e044..557fb5c4af38 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -43,7 +43,7 @@
43 43
44static int io = CONFIG_RADIO_RTRACK_PORT; 44static int io = CONFIG_RADIO_RTRACK_PORT;
45static int radio_nr = -1; 45static int radio_nr = -1;
46static struct semaphore lock; 46static struct mutex lock;
47 47
48struct rt_device 48struct rt_device
49{ 49{
@@ -83,23 +83,23 @@ static void rt_incvol(void)
83static void rt_mute(struct rt_device *dev) 83static void rt_mute(struct rt_device *dev)
84{ 84{
85 dev->muted = 1; 85 dev->muted = 1;
86 down(&lock); 86 mutex_lock(&lock);
87 outb(0xd0, io); /* volume steady, off */ 87 outb(0xd0, io); /* volume steady, off */
88 up(&lock); 88 mutex_unlock(&lock);
89} 89}
90 90
91static int rt_setvol(struct rt_device *dev, int vol) 91static int rt_setvol(struct rt_device *dev, int vol)
92{ 92{
93 int i; 93 int i;
94 94
95 down(&lock); 95 mutex_lock(&lock);
96 96
97 if(vol == dev->curvol) { /* requested volume = current */ 97 if(vol == dev->curvol) { /* requested volume = current */
98 if (dev->muted) { /* user is unmuting the card */ 98 if (dev->muted) { /* user is unmuting the card */
99 dev->muted = 0; 99 dev->muted = 0;
100 outb (0xd8, io); /* enable card */ 100 outb (0xd8, io); /* enable card */
101 } 101 }
102 up(&lock); 102 mutex_unlock(&lock);
103 return 0; 103 return 0;
104 } 104 }
105 105
@@ -108,7 +108,7 @@ static int rt_setvol(struct rt_device *dev, int vol)
108 sleep_delay(2000000); /* make sure it's totally down */ 108 sleep_delay(2000000); /* make sure it's totally down */
109 outb(0xd0, io); /* volume steady, off */ 109 outb(0xd0, io); /* volume steady, off */
110 dev->curvol = 0; /* track the volume state! */ 110 dev->curvol = 0; /* track the volume state! */
111 up(&lock); 111 mutex_unlock(&lock);
112 return 0; 112 return 0;
113 } 113 }
114 114
@@ -121,7 +121,7 @@ static int rt_setvol(struct rt_device *dev, int vol)
121 rt_decvol(); 121 rt_decvol();
122 122
123 dev->curvol = vol; 123 dev->curvol = vol;
124 up(&lock); 124 mutex_unlock(&lock);
125 return 0; 125 return 0;
126} 126}
127 127
@@ -168,7 +168,7 @@ static int rt_setfreq(struct rt_device *dev, unsigned long freq)
168 freq += 171200; /* Add 10.7 MHz IF */ 168 freq += 171200; /* Add 10.7 MHz IF */
169 freq /= 800; /* Convert to 50 kHz units */ 169 freq /= 800; /* Convert to 50 kHz units */
170 170
171 down(&lock); /* Stop other ops interfering */ 171 mutex_lock(&lock); /* Stop other ops interfering */
172 172
173 send_0_byte (io, dev); /* 0: LSB of frequency */ 173 send_0_byte (io, dev); /* 0: LSB of frequency */
174 174
@@ -196,7 +196,7 @@ static int rt_setfreq(struct rt_device *dev, unsigned long freq)
196 else 196 else
197 outb (0xd8, io); /* volume steady + sigstr + on */ 197 outb (0xd8, io); /* volume steady + sigstr + on */
198 198
199 up(&lock); 199 mutex_unlock(&lock);
200 200
201 return 0; 201 return 0;
202} 202}
@@ -337,7 +337,7 @@ static int __init rtrack_init(void)
337 337
338 /* Set up the I/O locking */ 338 /* Set up the I/O locking */
339 339
340 init_MUTEX(&lock); 340 mutex_init(&lock);
341 341
342 /* mute card - prevents noisy bootups */ 342 /* mute card - prevents noisy bootups */
343 343
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index 523be820f9c6..83bdae23417d 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -42,7 +42,7 @@
42static int io = CONFIG_RADIO_AZTECH_PORT; 42static int io = CONFIG_RADIO_AZTECH_PORT;
43static int radio_nr = -1; 43static int radio_nr = -1;
44static int radio_wait_time = 1000; 44static int radio_wait_time = 1000;
45static struct semaphore lock; 45static struct mutex lock;
46 46
47struct az_device 47struct az_device
48{ 48{
@@ -87,9 +87,9 @@ static void send_1_byte (struct az_device *dev)
87 87
88static int az_setvol(struct az_device *dev, int vol) 88static int az_setvol(struct az_device *dev, int vol)
89{ 89{
90 down(&lock); 90 mutex_lock(&lock);
91 outb (volconvert(vol), io); 91 outb (volconvert(vol), io);
92 up(&lock); 92 mutex_unlock(&lock);
93 return 0; 93 return 0;
94} 94}
95 95
@@ -122,7 +122,7 @@ static int az_setfreq(struct az_device *dev, unsigned long frequency)
122 frequency += 171200; /* Add 10.7 MHz IF */ 122 frequency += 171200; /* Add 10.7 MHz IF */
123 frequency /= 800; /* Convert to 50 kHz units */ 123 frequency /= 800; /* Convert to 50 kHz units */
124 124
125 down(&lock); 125 mutex_lock(&lock);
126 126
127 send_0_byte (dev); /* 0: LSB of frequency */ 127 send_0_byte (dev); /* 0: LSB of frequency */
128 128
@@ -152,7 +152,7 @@ static int az_setfreq(struct az_device *dev, unsigned long frequency)
152 udelay (radio_wait_time); 152 udelay (radio_wait_time);
153 outb_p(128+64+volconvert(dev->curvol), io); 153 outb_p(128+64+volconvert(dev->curvol), io);
154 154
155 up(&lock); 155 mutex_unlock(&lock);
156 156
157 return 0; 157 return 0;
158} 158}
@@ -283,7 +283,7 @@ static int __init aztech_init(void)
283 return -EBUSY; 283 return -EBUSY;
284 } 284 }
285 285
286 init_MUTEX(&lock); 286 mutex_init(&lock);
287 aztech_radio.priv=&aztech_unit; 287 aztech_radio.priv=&aztech_unit;
288 288
289 if(video_register_device(&aztech_radio, VFL_TYPE_RADIO, radio_nr)==-1) 289 if(video_register_device(&aztech_radio, VFL_TYPE_RADIO, radio_nr)==-1)
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index 36c9f5bf8cdd..39c1d9118636 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -23,10 +23,11 @@
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <asm/io.h> 24#include <asm/io.h>
25#include <asm/uaccess.h> 25#include <asm/uaccess.h>
26#include <asm/semaphore.h> 26#include <linux/mutex.h>
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/videodev.h> 28#include <linux/videodev.h>
29 29
30
30#define DRIVER_VERSION "0.05" 31#define DRIVER_VERSION "0.05"
31 32
32#define GPIO_DATA 0x60 /* port offset from ESS_IO_BASE */ 33#define GPIO_DATA 0x60 /* port offset from ESS_IO_BASE */
@@ -104,7 +105,7 @@ struct radio_device {
104 muted, /* VIDEO_AUDIO_MUTE */ 105 muted, /* VIDEO_AUDIO_MUTE */
105 stereo, /* VIDEO_TUNER_STEREO_ON */ 106 stereo, /* VIDEO_TUNER_STEREO_ON */
106 tuned; /* signal strength (0 or 0xffff) */ 107 tuned; /* signal strength (0 or 0xffff) */
107 struct semaphore lock; 108 struct mutex lock;
108}; 109};
109 110
110static u32 radio_bits_get(struct radio_device *dev) 111static u32 radio_bits_get(struct radio_device *dev)
@@ -258,9 +259,9 @@ static int radio_ioctl(struct inode *inode, struct file *file,
258 struct radio_device *card = video_get_drvdata(dev); 259 struct radio_device *card = video_get_drvdata(dev);
259 int ret; 260 int ret;
260 261
261 down(&card->lock); 262 mutex_lock(&card->lock);
262 ret = video_usercopy(inode, file, cmd, arg, radio_function); 263 ret = video_usercopy(inode, file, cmd, arg, radio_function);
263 up(&card->lock); 264 mutex_unlock(&card->lock);
264 265
265 return ret; 266 return ret;
266} 267}
@@ -311,7 +312,7 @@ static int __devinit maestro_probe(struct pci_dev *pdev,
311 } 312 }
312 313
313 radio_unit->io = pci_resource_start(pdev, 0) + GPIO_DATA; 314 radio_unit->io = pci_resource_start(pdev, 0) + GPIO_DATA;
314 init_MUTEX(&radio_unit->lock); 315 mutex_init(&radio_unit->lock);
315 316
316 maestro_radio_inst = video_device_alloc(); 317 maestro_radio_inst = video_device_alloc();
317 if (maestro_radio_inst == NULL) { 318 if (maestro_radio_inst == NULL) {
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index c975ddd86cd5..f0bf47bcb64c 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -37,7 +37,8 @@
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <asm/io.h> 38#include <asm/io.h>
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40#include <asm/semaphore.h> 40#include <linux/mutex.h>
41
41#include <linux/pci.h> 42#include <linux/pci.h>
42#include <linux/videodev.h> 43#include <linux/videodev.h>
43 44
@@ -101,7 +102,7 @@ static struct radio_device
101 102
102 unsigned long freq; 103 unsigned long freq;
103 104
104 struct semaphore lock; 105 struct mutex lock;
105} radio_unit = {0, 0, 0, 0, }; 106} radio_unit = {0, 0, 0, 0, };
106 107
107 108
@@ -267,9 +268,9 @@ static int radio_ioctl(struct inode *inode, struct file *file,
267 struct radio_device *card=dev->priv; 268 struct radio_device *card=dev->priv;
268 int ret; 269 int ret;
269 270
270 down(&card->lock); 271 mutex_lock(&card->lock);
271 ret = video_usercopy(inode, file, cmd, arg, radio_function); 272 ret = video_usercopy(inode, file, cmd, arg, radio_function);
272 up(&card->lock); 273 mutex_unlock(&card->lock);
273 return ret; 274 return ret;
274} 275}
275 276
@@ -290,7 +291,7 @@ static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_d
290 goto err_out_free_region; 291 goto err_out_free_region;
291 292
292 radio_unit.io = pci_resource_start(pdev, 0); 293 radio_unit.io = pci_resource_start(pdev, 0);
293 init_MUTEX(&radio_unit.lock); 294 mutex_init(&radio_unit.lock);
294 maxiradio_radio.priv = &radio_unit; 295 maxiradio_radio.priv = &radio_unit;
295 296
296 if(video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr)==-1) { 297 if(video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr)==-1) {
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 0229f792a059..53073b424107 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -24,7 +24,7 @@
24#include <linux/isapnp.h> 24#include <linux/isapnp.h>
25#include <asm/io.h> /* outb, outb_p */ 25#include <asm/io.h> /* outb, outb_p */
26#include <asm/uaccess.h> /* copy to/from user */ 26#include <asm/uaccess.h> /* copy to/from user */
27#include <asm/semaphore.h> 27#include <linux/mutex.h>
28 28
29struct fmi_device 29struct fmi_device
30{ 30{
@@ -37,7 +37,7 @@ struct fmi_device
37static int io = -1; 37static int io = -1;
38static int radio_nr = -1; 38static int radio_nr = -1;
39static struct pnp_dev *dev = NULL; 39static struct pnp_dev *dev = NULL;
40static struct semaphore lock; 40static struct mutex lock;
41 41
42/* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */ 42/* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */
43/* It is only useful to give freq in intervall of 800 (=0.05Mhz), 43/* It is only useful to give freq in intervall of 800 (=0.05Mhz),
@@ -68,16 +68,16 @@ static void outbits(int bits, unsigned int data, int port)
68 68
69static inline void fmi_mute(int port) 69static inline void fmi_mute(int port)
70{ 70{
71 down(&lock); 71 mutex_lock(&lock);
72 outb(0x00, port); 72 outb(0x00, port);
73 up(&lock); 73 mutex_unlock(&lock);
74} 74}
75 75
76static inline void fmi_unmute(int port) 76static inline void fmi_unmute(int port)
77{ 77{
78 down(&lock); 78 mutex_lock(&lock);
79 outb(0x08, port); 79 outb(0x08, port);
80 up(&lock); 80 mutex_unlock(&lock);
81} 81}
82 82
83static inline int fmi_setfreq(struct fmi_device *dev) 83static inline int fmi_setfreq(struct fmi_device *dev)
@@ -85,12 +85,12 @@ static inline int fmi_setfreq(struct fmi_device *dev)
85 int myport = dev->port; 85 int myport = dev->port;
86 unsigned long freq = dev->curfreq; 86 unsigned long freq = dev->curfreq;
87 87
88 down(&lock); 88 mutex_lock(&lock);
89 89
90 outbits(16, RSF16_ENCODE(freq), myport); 90 outbits(16, RSF16_ENCODE(freq), myport);
91 outbits(8, 0xC0, myport); 91 outbits(8, 0xC0, myport);
92 msleep(143); /* was schedule_timeout(HZ/7) */ 92 msleep(143); /* was schedule_timeout(HZ/7) */
93 up(&lock); 93 mutex_unlock(&lock);
94 if (dev->curvol) fmi_unmute(myport); 94 if (dev->curvol) fmi_unmute(myport);
95 return 0; 95 return 0;
96} 96}
@@ -102,7 +102,7 @@ static inline int fmi_getsigstr(struct fmi_device *dev)
102 int myport = dev->port; 102 int myport = dev->port;
103 103
104 104
105 down(&lock); 105 mutex_lock(&lock);
106 val = dev->curvol ? 0x08 : 0x00; /* unmute/mute */ 106 val = dev->curvol ? 0x08 : 0x00; /* unmute/mute */
107 outb(val, myport); 107 outb(val, myport);
108 outb(val | 0x10, myport); 108 outb(val | 0x10, myport);
@@ -110,7 +110,7 @@ static inline int fmi_getsigstr(struct fmi_device *dev)
110 res = (int)inb(myport+1); 110 res = (int)inb(myport+1);
111 outb(val, myport); 111 outb(val, myport);
112 112
113 up(&lock); 113 mutex_unlock(&lock);
114 return (res & 2) ? 0 : 0xFFFF; 114 return (res & 2) ? 0 : 0xFFFF;
115} 115}
116 116
@@ -296,7 +296,7 @@ static int __init fmi_init(void)
296 fmi_unit.flags = VIDEO_TUNER_LOW; 296 fmi_unit.flags = VIDEO_TUNER_LOW;
297 fmi_radio.priv = &fmi_unit; 297 fmi_radio.priv = &fmi_unit;
298 298
299 init_MUTEX(&lock); 299 mutex_init(&lock);
300 300
301 if (video_register_device(&fmi_radio, VFL_TYPE_RADIO, radio_nr) == -1) { 301 if (video_register_device(&fmi_radio, VFL_TYPE_RADIO, radio_nr) == -1) {
302 release_region(io, 2); 302 release_region(io, 2);
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index 099ffb3b9c71..bcebd8cb19ad 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -19,9 +19,9 @@
19#include <asm/io.h> /* outb, outb_p */ 19#include <asm/io.h> /* outb, outb_p */
20#include <asm/uaccess.h> /* copy to/from user */ 20#include <asm/uaccess.h> /* copy to/from user */
21#include <linux/videodev.h> /* kernel radio structs */ 21#include <linux/videodev.h> /* kernel radio structs */
22#include <asm/semaphore.h> 22#include <linux/mutex.h>
23 23
24static struct semaphore lock; 24static struct mutex lock;
25 25
26#undef DEBUG 26#undef DEBUG
27//#define DEBUG 1 27//#define DEBUG 1
@@ -238,9 +238,9 @@ static int fmr2_do_ioctl(struct inode *inode, struct file *file,
238 if (fmr2->mute) 238 if (fmr2->mute)
239 v->flags |= VIDEO_AUDIO_MUTE; 239 v->flags |= VIDEO_AUDIO_MUTE;
240 v->mode=VIDEO_MODE_AUTO; 240 v->mode=VIDEO_MODE_AUTO;
241 down(&lock); 241 mutex_lock(&lock);
242 v->signal = fmr2_getsigstr(fmr2); 242 v->signal = fmr2_getsigstr(fmr2);
243 up(&lock); 243 mutex_unlock(&lock);
244 return 0; 244 return 0;
245 } 245 }
246 case VIDIOCSTUNER: 246 case VIDIOCSTUNER:
@@ -274,9 +274,9 @@ static int fmr2_do_ioctl(struct inode *inode, struct file *file,
274 /* set card freq (if not muted) */ 274 /* set card freq (if not muted) */
275 if (fmr2->curvol && !fmr2->mute) 275 if (fmr2->curvol && !fmr2->mute)
276 { 276 {
277 down(&lock); 277 mutex_lock(&lock);
278 fmr2_setfreq(fmr2); 278 fmr2_setfreq(fmr2);
279 up(&lock); 279 mutex_unlock(&lock);
280 } 280 }
281 return 0; 281 return 0;
282 } 282 }
@@ -318,14 +318,14 @@ static int fmr2_do_ioctl(struct inode *inode, struct file *file,
318 else 318 else
319 printk(KERN_DEBUG "mute\n"); 319 printk(KERN_DEBUG "mute\n");
320#endif 320#endif
321 down(&lock); 321 mutex_lock(&lock);
322 if (fmr2->curvol && !fmr2->mute) 322 if (fmr2->curvol && !fmr2->mute)
323 { 323 {
324 fmr2_setvolume(fmr2); 324 fmr2_setvolume(fmr2);
325 fmr2_setfreq(fmr2); 325 fmr2_setfreq(fmr2);
326 } 326 }
327 else fmr2_mute(fmr2->port); 327 else fmr2_mute(fmr2->port);
328 up(&lock); 328 mutex_unlock(&lock);
329 return 0; 329 return 0;
330 } 330 }
331 case VIDIOCGUNIT: 331 case VIDIOCGUNIT:
@@ -380,7 +380,7 @@ static int __init fmr2_init(void)
380 fmr2_unit.card_type = 0; 380 fmr2_unit.card_type = 0;
381 fmr2_radio.priv = &fmr2_unit; 381 fmr2_radio.priv = &fmr2_unit;
382 382
383 init_MUTEX(&lock); 383 mutex_init(&lock);
384 384
385 if (request_region(io, 2, "sf16fmr2")) 385 if (request_region(io, 2, "sf16fmr2"))
386 { 386 {
@@ -397,10 +397,10 @@ static int __init fmr2_init(void)
397 printk(KERN_INFO "SF16FMR2 radio card driver at 0x%x.\n", io); 397 printk(KERN_INFO "SF16FMR2 radio card driver at 0x%x.\n", io);
398 debug_print((KERN_DEBUG "Mute %d Low %d\n",VIDEO_AUDIO_MUTE,VIDEO_TUNER_LOW)); 398 debug_print((KERN_DEBUG "Mute %d Low %d\n",VIDEO_AUDIO_MUTE,VIDEO_TUNER_LOW));
399 /* mute card - prevents noisy bootups */ 399 /* mute card - prevents noisy bootups */
400 down(&lock); 400 mutex_lock(&lock);
401 fmr2_mute(io); 401 fmr2_mute(io);
402 fmr2_product_info(&fmr2_unit); 402 fmr2_product_info(&fmr2_unit);
403 up(&lock); 403 mutex_unlock(&lock);
404 debug_print((KERN_DEBUG "card_type %d\n", fmr2_unit.card_type)); 404 debug_print((KERN_DEBUG "card_type %d\n", fmr2_unit.card_type));
405 return 0; 405 return 0;
406} 406}
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
index 8ac9a8ef9094..e50955836d6b 100644
--- a/drivers/media/radio/radio-typhoon.c
+++ b/drivers/media/radio/radio-typhoon.c
@@ -59,7 +59,7 @@ struct typhoon_device {
59 int muted; 59 int muted;
60 unsigned long curfreq; 60 unsigned long curfreq;
61 unsigned long mutefreq; 61 unsigned long mutefreq;
62 struct semaphore lock; 62 struct mutex lock;
63}; 63};
64 64
65static void typhoon_setvol_generic(struct typhoon_device *dev, int vol); 65static void typhoon_setvol_generic(struct typhoon_device *dev, int vol);
@@ -77,12 +77,12 @@ static int typhoon_get_info(char *buf, char **start, off_t offset, int len);
77 77
78static void typhoon_setvol_generic(struct typhoon_device *dev, int vol) 78static void typhoon_setvol_generic(struct typhoon_device *dev, int vol)
79{ 79{
80 down(&dev->lock); 80 mutex_lock(&dev->lock);
81 vol >>= 14; /* Map 16 bit to 2 bit */ 81 vol >>= 14; /* Map 16 bit to 2 bit */
82 vol &= 3; 82 vol &= 3;
83 outb_p(vol / 2, dev->iobase); /* Set the volume, high bit. */ 83 outb_p(vol / 2, dev->iobase); /* Set the volume, high bit. */
84 outb_p(vol % 2, dev->iobase + 2); /* Set the volume, low bit. */ 84 outb_p(vol % 2, dev->iobase + 2); /* Set the volume, low bit. */
85 up(&dev->lock); 85 mutex_unlock(&dev->lock);
86} 86}
87 87
88static int typhoon_setfreq_generic(struct typhoon_device *dev, 88static int typhoon_setfreq_generic(struct typhoon_device *dev,
@@ -102,7 +102,7 @@ static int typhoon_setfreq_generic(struct typhoon_device *dev,
102 * 102 *
103 */ 103 */
104 104
105 down(&dev->lock); 105 mutex_lock(&dev->lock);
106 x = frequency / 160; 106 x = frequency / 160;
107 outval = (x * x + 2500) / 5000; 107 outval = (x * x + 2500) / 5000;
108 outval = (outval * x + 5000) / 10000; 108 outval = (outval * x + 5000) / 10000;
@@ -112,7 +112,7 @@ static int typhoon_setfreq_generic(struct typhoon_device *dev,
112 outb_p((outval >> 8) & 0x01, dev->iobase + 4); 112 outb_p((outval >> 8) & 0x01, dev->iobase + 4);
113 outb_p(outval >> 9, dev->iobase + 6); 113 outb_p(outval >> 9, dev->iobase + 6);
114 outb_p(outval & 0xff, dev->iobase + 8); 114 outb_p(outval & 0xff, dev->iobase + 8);
115 up(&dev->lock); 115 mutex_unlock(&dev->lock);
116 116
117 return 0; 117 return 0;
118} 118}
@@ -337,7 +337,7 @@ static int __init typhoon_init(void)
337#endif /* MODULE */ 337#endif /* MODULE */
338 338
339 printk(KERN_INFO BANNER); 339 printk(KERN_INFO BANNER);
340 init_MUTEX(&typhoon_unit.lock); 340 mutex_init(&typhoon_unit.lock);
341 io = typhoon_unit.iobase; 341 io = typhoon_unit.iobase;
342 if (!request_region(io, 8, "typhoon")) { 342 if (!request_region(io, 8, "typhoon")) {
343 printk(KERN_ERR "radio-typhoon: port 0x%x already in use\n", 343 printk(KERN_ERR "radio-typhoon: port 0x%x already in use\n",
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index d590e80c922e..7bf1a4264891 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -48,7 +48,7 @@ struct zol_device {
48 unsigned long curfreq; 48 unsigned long curfreq;
49 int muted; 49 int muted;
50 unsigned int stereo; 50 unsigned int stereo;
51 struct semaphore lock; 51 struct mutex lock;
52}; 52};
53 53
54static int zol_setvol(struct zol_device *dev, int vol) 54static int zol_setvol(struct zol_device *dev, int vol)
@@ -57,30 +57,30 @@ static int zol_setvol(struct zol_device *dev, int vol)
57 if (dev->muted) 57 if (dev->muted)
58 return 0; 58 return 0;
59 59
60 down(&dev->lock); 60 mutex_lock(&dev->lock);
61 if (vol == 0) { 61 if (vol == 0) {
62 outb(0, io); 62 outb(0, io);
63 outb(0, io); 63 outb(0, io);
64 inb(io + 3); /* Zoltrix needs to be read to confirm */ 64 inb(io + 3); /* Zoltrix needs to be read to confirm */
65 up(&dev->lock); 65 mutex_unlock(&dev->lock);
66 return 0; 66 return 0;
67 } 67 }
68 68
69 outb(dev->curvol-1, io); 69 outb(dev->curvol-1, io);
70 msleep(10); 70 msleep(10);
71 inb(io + 2); 71 inb(io + 2);
72 up(&dev->lock); 72 mutex_unlock(&dev->lock);
73 return 0; 73 return 0;
74} 74}
75 75
76static void zol_mute(struct zol_device *dev) 76static void zol_mute(struct zol_device *dev)
77{ 77{
78 dev->muted = 1; 78 dev->muted = 1;
79 down(&dev->lock); 79 mutex_lock(&dev->lock);
80 outb(0, io); 80 outb(0, io);
81 outb(0, io); 81 outb(0, io);
82 inb(io + 3); /* Zoltrix needs to be read to confirm */ 82 inb(io + 3); /* Zoltrix needs to be read to confirm */
83 up(&dev->lock); 83 mutex_unlock(&dev->lock);
84} 84}
85 85
86static void zol_unmute(struct zol_device *dev) 86static void zol_unmute(struct zol_device *dev)
@@ -104,7 +104,7 @@ static int zol_setfreq(struct zol_device *dev, unsigned long freq)
104 bitmask = 0xc480402c10080000ull; 104 bitmask = 0xc480402c10080000ull;
105 i = 45; 105 i = 45;
106 106
107 down(&dev->lock); 107 mutex_lock(&dev->lock);
108 108
109 outb(0, io); 109 outb(0, io);
110 outb(0, io); 110 outb(0, io);
@@ -149,7 +149,7 @@ static int zol_setfreq(struct zol_device *dev, unsigned long freq)
149 udelay(1000); 149 udelay(1000);
150 } 150 }
151 151
152 up(&dev->lock); 152 mutex_unlock(&dev->lock);
153 153
154 if(!dev->muted) 154 if(!dev->muted)
155 { 155 {
@@ -164,7 +164,7 @@ static int zol_getsigstr(struct zol_device *dev)
164{ 164{
165 int a, b; 165 int a, b;
166 166
167 down(&dev->lock); 167 mutex_lock(&dev->lock);
168 outb(0x00, io); /* This stuff I found to do nothing */ 168 outb(0x00, io); /* This stuff I found to do nothing */
169 outb(dev->curvol, io); 169 outb(dev->curvol, io);
170 msleep(20); 170 msleep(20);
@@ -173,7 +173,7 @@ static int zol_getsigstr(struct zol_device *dev)
173 msleep(10); 173 msleep(10);
174 b = inb(io); 174 b = inb(io);
175 175
176 up(&dev->lock); 176 mutex_unlock(&dev->lock);
177 177
178 if (a != b) 178 if (a != b)
179 return (0); 179 return (0);
@@ -188,7 +188,7 @@ static int zol_is_stereo (struct zol_device *dev)
188{ 188{
189 int x1, x2; 189 int x1, x2;
190 190
191 down(&dev->lock); 191 mutex_lock(&dev->lock);
192 192
193 outb(0x00, io); 193 outb(0x00, io);
194 outb(dev->curvol, io); 194 outb(dev->curvol, io);
@@ -198,7 +198,7 @@ static int zol_is_stereo (struct zol_device *dev)
198 msleep(10); 198 msleep(10);
199 x2 = inb(io); 199 x2 = inb(io);
200 200
201 up(&dev->lock); 201 mutex_unlock(&dev->lock);
202 202
203 if ((x1 == x2) && (x1 == 0xcf)) 203 if ((x1 == x2) && (x1 == 0xcf))
204 return 1; 204 return 1;
@@ -350,7 +350,7 @@ static int __init zoltrix_init(void)
350 } 350 }
351 printk(KERN_INFO "Zoltrix Radio Plus card driver.\n"); 351 printk(KERN_INFO "Zoltrix Radio Plus card driver.\n");
352 352
353 init_MUTEX(&zoltrix_unit.lock); 353 mutex_init(&zoltrix_unit.lock);
354 354
355 /* mute card - prevents noisy bootups */ 355 /* mute card - prevents noisy bootups */
356 356
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index 994b75fe165a..c586f64b6b7f 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -31,8 +31,8 @@
31#include <linux/mm.h> 31#include <linux/mm.h>
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/videodev.h> 33#include <linux/videodev.h>
34#include <linux/mutex.h>
34 35
35#include <asm/semaphore.h>
36#include <asm/uaccess.h> 36#include <asm/uaccess.h>
37#include <asm/m32r.h> 37#include <asm/m32r.h>
38#include <asm/io.h> 38#include <asm/io.h>
@@ -117,7 +117,7 @@ struct ar_device {
117 int width, height; 117 int width, height;
118 int frame_bytes, line_bytes; 118 int frame_bytes, line_bytes;
119 wait_queue_head_t wait; 119 wait_queue_head_t wait;
120 struct semaphore lock; 120 struct mutex lock;
121}; 121};
122 122
123static int video_nr = -1; /* video device number (first free) */ 123static int video_nr = -1; /* video device number (first free) */
@@ -288,7 +288,7 @@ static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos)
288 if (ar->mode == AR_MODE_NORMAL) 288 if (ar->mode == AR_MODE_NORMAL)
289 arvcr1 |= ARVCR1_NORMAL; 289 arvcr1 |= ARVCR1_NORMAL;
290 290
291 down(&ar->lock); 291 mutex_lock(&ar->lock);
292 292
293#if USE_INT 293#if USE_INT
294 local_irq_save(flags); 294 local_irq_save(flags);
@@ -392,7 +392,7 @@ static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos)
392 } 392 }
393 DEBUG(1, "ret = %d\n", ret); 393 DEBUG(1, "ret = %d\n", ret);
394out_up: 394out_up:
395 up(&ar->lock); 395 mutex_unlock(&ar->lock);
396 return ret; 396 return ret;
397} 397}
398 398
@@ -456,7 +456,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file,
456 (w->width != AR_WIDTH_QVGA || w->height != AR_HEIGHT_QVGA)) 456 (w->width != AR_WIDTH_QVGA || w->height != AR_HEIGHT_QVGA))
457 return -EINVAL; 457 return -EINVAL;
458 458
459 down(&ar->lock); 459 mutex_lock(&ar->lock);
460 ar->width = w->width; 460 ar->width = w->width;
461 ar->height = w->height; 461 ar->height = w->height;
462 if (ar->width == AR_WIDTH_VGA) { 462 if (ar->width == AR_WIDTH_VGA) {
@@ -473,7 +473,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file,
473 ar->line_bytes = AR_LINE_BYTES_QVGA; 473 ar->line_bytes = AR_LINE_BYTES_QVGA;
474 ar->mode = AR_MODE_INTERLACE; 474 ar->mode = AR_MODE_INTERLACE;
475 } 475 }
476 up(&ar->lock); 476 mutex_unlock(&ar->lock);
477 return 0; 477 return 0;
478 } 478 }
479 case VIDIOCGFBUF: 479 case VIDIOCGFBUF:
@@ -734,7 +734,7 @@ static int ar_initialize(struct video_device *dev)
734void ar_release(struct video_device *vfd) 734void ar_release(struct video_device *vfd)
735{ 735{
736 struct ar_device *ar = vfd->priv; 736 struct ar_device *ar = vfd->priv;
737 down(&ar->lock); 737 mutex_lock(&ar->lock);
738 video_device_release(vfd); 738 video_device_release(vfd);
739} 739}
740 740
@@ -824,7 +824,7 @@ static int __init ar_init(void)
824 ar->line_bytes = AR_LINE_BYTES_QVGA; 824 ar->line_bytes = AR_LINE_BYTES_QVGA;
825 ar->mode = AR_MODE_INTERLACE; 825 ar->mode = AR_MODE_INTERLACE;
826 } 826 }
827 init_MUTEX(&ar->lock); 827 mutex_init(&ar->lock);
828 init_waitqueue_head(&ar->wait); 828 init_waitqueue_head(&ar->wait);
829 829
830#if USE_INT 830#if USE_INT
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index 578b20085082..c0415d6e7fee 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -1965,7 +1965,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
1965 BUG(); 1965 BUG();
1966 } 1966 }
1967 1967
1968 down(&fh->cap.lock); 1968 mutex_lock(&fh->cap.lock);
1969 kfree(fh->ov.clips); 1969 kfree(fh->ov.clips);
1970 fh->ov.clips = clips; 1970 fh->ov.clips = clips;
1971 fh->ov.nclips = n; 1971 fh->ov.nclips = n;
@@ -1986,7 +1986,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
1986 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); 1986 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
1987 retval = bttv_switch_overlay(btv,fh,new); 1987 retval = bttv_switch_overlay(btv,fh,new);
1988 } 1988 }
1989 up(&fh->cap.lock); 1989 mutex_unlock(&fh->cap.lock);
1990 return retval; 1990 return retval;
1991} 1991}
1992 1992
@@ -2166,7 +2166,7 @@ static int bttv_s_fmt(struct bttv_fh *fh, struct bttv *btv,
2166 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 2166 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
2167 2167
2168 /* update our state informations */ 2168 /* update our state informations */
2169 down(&fh->cap.lock); 2169 mutex_lock(&fh->cap.lock);
2170 fh->fmt = fmt; 2170 fh->fmt = fmt;
2171 fh->cap.field = f->fmt.pix.field; 2171 fh->cap.field = f->fmt.pix.field;
2172 fh->cap.last = V4L2_FIELD_NONE; 2172 fh->cap.last = V4L2_FIELD_NONE;
@@ -2175,7 +2175,7 @@ static int bttv_s_fmt(struct bttv_fh *fh, struct bttv *btv,
2175 btv->init.fmt = fmt; 2175 btv->init.fmt = fmt;
2176 btv->init.width = f->fmt.pix.width; 2176 btv->init.width = f->fmt.pix.width;
2177 btv->init.height = f->fmt.pix.height; 2177 btv->init.height = f->fmt.pix.height;
2178 up(&fh->cap.lock); 2178 mutex_unlock(&fh->cap.lock);
2179 2179
2180 return 0; 2180 return 0;
2181 } 2181 }
@@ -2282,7 +2282,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2282 fmt = format_by_palette(pic->palette); 2282 fmt = format_by_palette(pic->palette);
2283 if (NULL == fmt) 2283 if (NULL == fmt)
2284 return -EINVAL; 2284 return -EINVAL;
2285 down(&fh->cap.lock); 2285 mutex_lock(&fh->cap.lock);
2286 if (fmt->depth != pic->depth) { 2286 if (fmt->depth != pic->depth) {
2287 retval = -EINVAL; 2287 retval = -EINVAL;
2288 goto fh_unlock_and_return; 2288 goto fh_unlock_and_return;
@@ -2313,7 +2313,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2313 bt848_contrast(btv,pic->contrast); 2313 bt848_contrast(btv,pic->contrast);
2314 bt848_hue(btv,pic->hue); 2314 bt848_hue(btv,pic->hue);
2315 bt848_sat(btv,pic->colour); 2315 bt848_sat(btv,pic->colour);
2316 up(&fh->cap.lock); 2316 mutex_unlock(&fh->cap.lock);
2317 return 0; 2317 return 0;
2318 } 2318 }
2319 2319
@@ -2379,7 +2379,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2379 return -EPERM; 2379 return -EPERM;
2380 end = (unsigned long)fbuf->base + 2380 end = (unsigned long)fbuf->base +
2381 fbuf->height * fbuf->bytesperline; 2381 fbuf->height * fbuf->bytesperline;
2382 down(&fh->cap.lock); 2382 mutex_lock(&fh->cap.lock);
2383 retval = -EINVAL; 2383 retval = -EINVAL;
2384 2384
2385 switch (fbuf->depth) { 2385 switch (fbuf->depth) {
@@ -2417,7 +2417,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2417 btv->fbuf.fmt.bytesperline = fbuf->bytesperline; 2417 btv->fbuf.fmt.bytesperline = fbuf->bytesperline;
2418 else 2418 else
2419 btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fbuf->depth/8; 2419 btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fbuf->depth/8;
2420 up(&fh->cap.lock); 2420 mutex_unlock(&fh->cap.lock);
2421 return 0; 2421 return 0;
2422 } 2422 }
2423 2423
@@ -2440,7 +2440,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2440 if (!check_alloc_btres(btv,fh,RESOURCE_OVERLAY)) 2440 if (!check_alloc_btres(btv,fh,RESOURCE_OVERLAY))
2441 return -EBUSY; 2441 return -EBUSY;
2442 2442
2443 down(&fh->cap.lock); 2443 mutex_lock(&fh->cap.lock);
2444 if (*on) { 2444 if (*on) {
2445 fh->ov.tvnorm = btv->tvnorm; 2445 fh->ov.tvnorm = btv->tvnorm;
2446 new = videobuf_alloc(sizeof(*new)); 2446 new = videobuf_alloc(sizeof(*new));
@@ -2451,7 +2451,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2451 2451
2452 /* switch over */ 2452 /* switch over */
2453 retval = bttv_switch_overlay(btv,fh,new); 2453 retval = bttv_switch_overlay(btv,fh,new);
2454 up(&fh->cap.lock); 2454 mutex_unlock(&fh->cap.lock);
2455 return retval; 2455 return retval;
2456 } 2456 }
2457 2457
@@ -2460,7 +2460,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2460 struct video_mbuf *mbuf = arg; 2460 struct video_mbuf *mbuf = arg;
2461 unsigned int i; 2461 unsigned int i;
2462 2462
2463 down(&fh->cap.lock); 2463 mutex_lock(&fh->cap.lock);
2464 retval = videobuf_mmap_setup(&fh->cap,gbuffers,gbufsize, 2464 retval = videobuf_mmap_setup(&fh->cap,gbuffers,gbufsize,
2465 V4L2_MEMORY_MMAP); 2465 V4L2_MEMORY_MMAP);
2466 if (retval < 0) 2466 if (retval < 0)
@@ -2470,7 +2470,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2470 mbuf->size = gbuffers * gbufsize; 2470 mbuf->size = gbuffers * gbufsize;
2471 for (i = 0; i < gbuffers; i++) 2471 for (i = 0; i < gbuffers; i++)
2472 mbuf->offsets[i] = i * gbufsize; 2472 mbuf->offsets[i] = i * gbufsize;
2473 up(&fh->cap.lock); 2473 mutex_unlock(&fh->cap.lock);
2474 return 0; 2474 return 0;
2475 } 2475 }
2476 case VIDIOCMCAPTURE: 2476 case VIDIOCMCAPTURE:
@@ -2482,7 +2482,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2482 if (vm->frame >= VIDEO_MAX_FRAME) 2482 if (vm->frame >= VIDEO_MAX_FRAME)
2483 return -EINVAL; 2483 return -EINVAL;
2484 2484
2485 down(&fh->cap.lock); 2485 mutex_lock(&fh->cap.lock);
2486 retval = -EINVAL; 2486 retval = -EINVAL;
2487 buf = (struct bttv_buffer *)fh->cap.bufs[vm->frame]; 2487 buf = (struct bttv_buffer *)fh->cap.bufs[vm->frame];
2488 if (NULL == buf) 2488 if (NULL == buf)
@@ -2504,7 +2504,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2504 spin_lock_irqsave(&btv->s_lock,flags); 2504 spin_lock_irqsave(&btv->s_lock,flags);
2505 buffer_queue(&fh->cap,&buf->vb); 2505 buffer_queue(&fh->cap,&buf->vb);
2506 spin_unlock_irqrestore(&btv->s_lock,flags); 2506 spin_unlock_irqrestore(&btv->s_lock,flags);
2507 up(&fh->cap.lock); 2507 mutex_unlock(&fh->cap.lock);
2508 return 0; 2508 return 0;
2509 } 2509 }
2510 case VIDIOCSYNC: 2510 case VIDIOCSYNC:
@@ -2515,7 +2515,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2515 if (*frame >= VIDEO_MAX_FRAME) 2515 if (*frame >= VIDEO_MAX_FRAME)
2516 return -EINVAL; 2516 return -EINVAL;
2517 2517
2518 down(&fh->cap.lock); 2518 mutex_lock(&fh->cap.lock);
2519 retval = -EINVAL; 2519 retval = -EINVAL;
2520 buf = (struct bttv_buffer *)fh->cap.bufs[*frame]; 2520 buf = (struct bttv_buffer *)fh->cap.bufs[*frame];
2521 if (NULL == buf) 2521 if (NULL == buf)
@@ -2535,7 +2535,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2535 retval = -EINVAL; 2535 retval = -EINVAL;
2536 break; 2536 break;
2537 } 2537 }
2538 up(&fh->cap.lock); 2538 mutex_unlock(&fh->cap.lock);
2539 return retval; 2539 return retval;
2540 } 2540 }
2541 2541
@@ -2719,7 +2719,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2719 if (0 == (fmt->flags & FORMAT_FLAGS_PACKED)) 2719 if (0 == (fmt->flags & FORMAT_FLAGS_PACKED))
2720 return -EINVAL; 2720 return -EINVAL;
2721 2721
2722 down(&fh->cap.lock); 2722 mutex_lock(&fh->cap.lock);
2723 retval = -EINVAL; 2723 retval = -EINVAL;
2724 if (fb->flags & V4L2_FBUF_FLAG_OVERLAY) { 2724 if (fb->flags & V4L2_FBUF_FLAG_OVERLAY) {
2725 if (fb->fmt.width > bttv_tvnorms[btv->tvnorm].swidth) 2725 if (fb->fmt.width > bttv_tvnorms[btv->tvnorm].swidth)
@@ -2759,7 +2759,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2759 retval = bttv_switch_overlay(btv,fh,new); 2759 retval = bttv_switch_overlay(btv,fh,new);
2760 } 2760 }
2761 } 2761 }
2762 up(&fh->cap.lock); 2762 mutex_unlock(&fh->cap.lock);
2763 return retval; 2763 return retval;
2764 } 2764 }
2765 2765
@@ -2890,7 +2890,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2890 return 0; 2890 return 0;
2891 2891
2892 fh_unlock_and_return: 2892 fh_unlock_and_return:
2893 up(&fh->cap.lock); 2893 mutex_unlock(&fh->cap.lock);
2894 return retval; 2894 return retval;
2895} 2895}
2896 2896
@@ -2957,16 +2957,16 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
2957 buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); 2957 buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream);
2958 } else { 2958 } else {
2959 /* read() capture */ 2959 /* read() capture */
2960 down(&fh->cap.lock); 2960 mutex_lock(&fh->cap.lock);
2961 if (NULL == fh->cap.read_buf) { 2961 if (NULL == fh->cap.read_buf) {
2962 /* need to capture a new frame */ 2962 /* need to capture a new frame */
2963 if (locked_btres(fh->btv,RESOURCE_VIDEO)) { 2963 if (locked_btres(fh->btv,RESOURCE_VIDEO)) {
2964 up(&fh->cap.lock); 2964 mutex_unlock(&fh->cap.lock);
2965 return POLLERR; 2965 return POLLERR;
2966 } 2966 }
2967 fh->cap.read_buf = videobuf_alloc(fh->cap.msize); 2967 fh->cap.read_buf = videobuf_alloc(fh->cap.msize);
2968 if (NULL == fh->cap.read_buf) { 2968 if (NULL == fh->cap.read_buf) {
2969 up(&fh->cap.lock); 2969 mutex_unlock(&fh->cap.lock);
2970 return POLLERR; 2970 return POLLERR;
2971 } 2971 }
2972 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; 2972 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
@@ -2974,13 +2974,13 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
2974 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { 2974 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
2975 kfree (fh->cap.read_buf); 2975 kfree (fh->cap.read_buf);
2976 fh->cap.read_buf = NULL; 2976 fh->cap.read_buf = NULL;
2977 up(&fh->cap.lock); 2977 mutex_unlock(&fh->cap.lock);
2978 return POLLERR; 2978 return POLLERR;
2979 } 2979 }
2980 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); 2980 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
2981 fh->cap.read_off = 0; 2981 fh->cap.read_off = 0;
2982 } 2982 }
2983 up(&fh->cap.lock); 2983 mutex_unlock(&fh->cap.lock);
2984 buf = (struct bttv_buffer*)fh->cap.read_buf; 2984 buf = (struct bttv_buffer*)fh->cap.read_buf;
2985 } 2985 }
2986 2986
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 6bad93ef969f..d97b7d8ac33d 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -73,7 +73,7 @@ OTHER DEALINGS IN THE SOFTWARE.
73#include <linux/parport.h> 73#include <linux/parport.h>
74#include <linux/sched.h> 74#include <linux/sched.h>
75#include <linux/videodev.h> 75#include <linux/videodev.h>
76#include <asm/semaphore.h> 76#include <linux/mutex.h>
77#include <asm/uaccess.h> 77#include <asm/uaccess.h>
78 78
79#include "bw-qcam.h" 79#include "bw-qcam.h"
@@ -168,7 +168,7 @@ static struct qcam_device *qcam_init(struct parport *port)
168 168
169 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template)); 169 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
170 170
171 init_MUTEX(&q->lock); 171 mutex_init(&q->lock);
172 172
173 q->port_mode = (QC_ANY | QC_NOTSET); 173 q->port_mode = (QC_ANY | QC_NOTSET);
174 q->width = 320; 174 q->width = 320;
@@ -772,9 +772,9 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
772 qcam->whitebal = p->whiteness>>8; 772 qcam->whitebal = p->whiteness>>8;
773 qcam->bpp = p->depth; 773 qcam->bpp = p->depth;
774 774
775 down(&qcam->lock); 775 mutex_lock(&qcam->lock);
776 qc_setscanmode(qcam); 776 qc_setscanmode(qcam);
777 up(&qcam->lock); 777 mutex_unlock(&qcam->lock);
778 qcam->status |= QC_PARAM_CHANGE; 778 qcam->status |= QC_PARAM_CHANGE;
779 779
780 return 0; 780 return 0;
@@ -805,9 +805,9 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
805 qcam->height = 240; 805 qcam->height = 240;
806 qcam->transfer_scale = 1; 806 qcam->transfer_scale = 1;
807 } 807 }
808 down(&qcam->lock); 808 mutex_lock(&qcam->lock);
809 qc_setscanmode(qcam); 809 qc_setscanmode(qcam);
810 up(&qcam->lock); 810 mutex_unlock(&qcam->lock);
811 811
812 /* We must update the camera before we grab. We could 812 /* We must update the camera before we grab. We could
813 just have changed the grab size */ 813 just have changed the grab size */
@@ -854,7 +854,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
854 int len; 854 int len;
855 parport_claim_or_block(qcam->pdev); 855 parport_claim_or_block(qcam->pdev);
856 856
857 down(&qcam->lock); 857 mutex_lock(&qcam->lock);
858 858
859 qc_reset(qcam); 859 qc_reset(qcam);
860 860
@@ -864,7 +864,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
864 864
865 len=qc_capture(qcam, buf,count); 865 len=qc_capture(qcam, buf,count);
866 866
867 up(&qcam->lock); 867 mutex_unlock(&qcam->lock);
868 868
869 parport_release(qcam->pdev); 869 parport_release(qcam->pdev);
870 return len; 870 return len;
diff --git a/drivers/media/video/bw-qcam.h b/drivers/media/video/bw-qcam.h
index 723e8ad9e56a..6701dafbc0da 100644
--- a/drivers/media/video/bw-qcam.h
+++ b/drivers/media/video/bw-qcam.h
@@ -55,7 +55,7 @@ struct qcam_device {
55 struct video_device vdev; 55 struct video_device vdev;
56 struct pardevice *pdev; 56 struct pardevice *pdev;
57 struct parport *pport; 57 struct parport *pport;
58 struct semaphore lock; 58 struct mutex lock;
59 int width, height; 59 int width, height;
60 int bpp; 60 int bpp;
61 int mode; 61 int mode;
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index 9976db4f6da8..8211fd8d7cbf 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -34,7 +34,8 @@
34#include <linux/parport.h> 34#include <linux/parport.h>
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/videodev.h> 36#include <linux/videodev.h>
37#include <asm/semaphore.h> 37#include <linux/mutex.h>
38
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
39 40
40struct qcam_device { 41struct qcam_device {
@@ -47,7 +48,7 @@ struct qcam_device {
47 int contrast, brightness, whitebal; 48 int contrast, brightness, whitebal;
48 int top, left; 49 int top, left;
49 unsigned int bidirectional; 50 unsigned int bidirectional;
50 struct semaphore lock; 51 struct mutex lock;
51}; 52};
52 53
53/* cameras maximum */ 54/* cameras maximum */
@@ -581,11 +582,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
581 qcam->contrast = p->contrast>>8; 582 qcam->contrast = p->contrast>>8;
582 qcam->whitebal = p->whiteness>>8; 583 qcam->whitebal = p->whiteness>>8;
583 584
584 down(&qcam->lock); 585 mutex_lock(&qcam->lock);
585 parport_claim_or_block(qcam->pdev); 586 parport_claim_or_block(qcam->pdev);
586 qc_setup(qcam); 587 qc_setup(qcam);
587 parport_release(qcam->pdev); 588 parport_release(qcam->pdev);
588 up(&qcam->lock); 589 mutex_unlock(&qcam->lock);
589 return 0; 590 return 0;
590 } 591 }
591 case VIDIOCSWIN: 592 case VIDIOCSWIN:
@@ -628,11 +629,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
628#endif 629#endif
629 /* Ok we figured out what to use from our 630 /* Ok we figured out what to use from our
630 wide choice */ 631 wide choice */
631 down(&qcam->lock); 632 mutex_lock(&qcam->lock);
632 parport_claim_or_block(qcam->pdev); 633 parport_claim_or_block(qcam->pdev);
633 qc_setup(qcam); 634 qc_setup(qcam);
634 parport_release(qcam->pdev); 635 parport_release(qcam->pdev);
635 up(&qcam->lock); 636 mutex_unlock(&qcam->lock);
636 return 0; 637 return 0;
637 } 638 }
638 case VIDIOCGWIN: 639 case VIDIOCGWIN:
@@ -672,12 +673,12 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
672 struct qcam_device *qcam=(struct qcam_device *)v; 673 struct qcam_device *qcam=(struct qcam_device *)v;
673 int len; 674 int len;
674 675
675 down(&qcam->lock); 676 mutex_lock(&qcam->lock);
676 parport_claim_or_block(qcam->pdev); 677 parport_claim_or_block(qcam->pdev);
677 /* Probably should have a semaphore against multiple users */ 678 /* Probably should have a semaphore against multiple users */
678 len = qc_capture(qcam, buf,count); 679 len = qc_capture(qcam, buf,count);
679 parport_release(qcam->pdev); 680 parport_release(qcam->pdev);
680 up(&qcam->lock); 681 mutex_unlock(&qcam->lock);
681 return len; 682 return len;
682} 683}
683 684
@@ -727,7 +728,7 @@ static struct qcam_device *qcam_init(struct parport *port)
727 728
728 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template)); 729 memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
729 730
730 init_MUTEX(&q->lock); 731 mutex_init(&q->lock);
731 q->width = q->ccd_width = 320; 732 q->width = q->ccd_width = 320;
732 q->height = q->ccd_height = 240; 733 q->height = q->ccd_height = 240;
733 q->mode = QC_MILLIONS | QC_DECIMATION_1; 734 q->mode = QC_MILLIONS | QC_DECIMATION_1;
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index 9f59541155d9..c2405029a720 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -39,7 +39,7 @@
39#include <linux/pagemap.h> 39#include <linux/pagemap.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <asm/io.h> 41#include <asm/io.h>
42#include <asm/semaphore.h> 42#include <linux/mutex.h>
43 43
44#ifdef CONFIG_KMOD 44#ifdef CONFIG_KMOD
45#include <linux/kmod.h> 45#include <linux/kmod.h>
@@ -622,7 +622,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
622 622
623 buffer = page; 623 buffer = page;
624 624
625 if (down_interruptible(&cam->param_lock)) 625 if (mutex_lock_interruptible(&cam->param_lock))
626 return -ERESTARTSYS; 626 return -ERESTARTSYS;
627 627
628 /* 628 /*
@@ -1350,7 +1350,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
1350 } else 1350 } else
1351 DBG("error: %d\n", retval); 1351 DBG("error: %d\n", retval);
1352 1352
1353 up(&cam->param_lock); 1353 mutex_unlock(&cam->param_lock);
1354 1354
1355out: 1355out:
1356 free_page((unsigned long)page); 1356 free_page((unsigned long)page);
@@ -1664,7 +1664,7 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
1664 case CPIA_COMMAND_GetColourParams: 1664 case CPIA_COMMAND_GetColourParams:
1665 case CPIA_COMMAND_GetColourBalance: 1665 case CPIA_COMMAND_GetColourBalance:
1666 case CPIA_COMMAND_GetExposure: 1666 case CPIA_COMMAND_GetExposure:
1667 down(&cam->param_lock); 1667 mutex_lock(&cam->param_lock);
1668 datasize=8; 1668 datasize=8;
1669 break; 1669 break;
1670 case CPIA_COMMAND_ReadMCPorts: 1670 case CPIA_COMMAND_ReadMCPorts:
@@ -1691,7 +1691,7 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
1691 if (command == CPIA_COMMAND_GetColourParams || 1691 if (command == CPIA_COMMAND_GetColourParams ||
1692 command == CPIA_COMMAND_GetColourBalance || 1692 command == CPIA_COMMAND_GetColourBalance ||
1693 command == CPIA_COMMAND_GetExposure) 1693 command == CPIA_COMMAND_GetExposure)
1694 up(&cam->param_lock); 1694 mutex_unlock(&cam->param_lock);
1695 } else { 1695 } else {
1696 switch(command) { 1696 switch(command) {
1697 case CPIA_COMMAND_GetCPIAVersion: 1697 case CPIA_COMMAND_GetCPIAVersion:
@@ -1726,13 +1726,13 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
1726 cam->params.colourParams.brightness = data[0]; 1726 cam->params.colourParams.brightness = data[0];
1727 cam->params.colourParams.contrast = data[1]; 1727 cam->params.colourParams.contrast = data[1];
1728 cam->params.colourParams.saturation = data[2]; 1728 cam->params.colourParams.saturation = data[2];
1729 up(&cam->param_lock); 1729 mutex_unlock(&cam->param_lock);
1730 break; 1730 break;
1731 case CPIA_COMMAND_GetColourBalance: 1731 case CPIA_COMMAND_GetColourBalance:
1732 cam->params.colourBalance.redGain = data[0]; 1732 cam->params.colourBalance.redGain = data[0];
1733 cam->params.colourBalance.greenGain = data[1]; 1733 cam->params.colourBalance.greenGain = data[1];
1734 cam->params.colourBalance.blueGain = data[2]; 1734 cam->params.colourBalance.blueGain = data[2];
1735 up(&cam->param_lock); 1735 mutex_unlock(&cam->param_lock);
1736 break; 1736 break;
1737 case CPIA_COMMAND_GetExposure: 1737 case CPIA_COMMAND_GetExposure:
1738 cam->params.exposure.gain = data[0]; 1738 cam->params.exposure.gain = data[0];
@@ -1743,7 +1743,7 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
1743 cam->params.exposure.green1Comp = data[5]; 1743 cam->params.exposure.green1Comp = data[5];
1744 cam->params.exposure.green2Comp = data[6]; 1744 cam->params.exposure.green2Comp = data[6];
1745 cam->params.exposure.blueComp = data[7]; 1745 cam->params.exposure.blueComp = data[7];
1746 up(&cam->param_lock); 1746 mutex_unlock(&cam->param_lock);
1747 break; 1747 break;
1748 1748
1749 case CPIA_COMMAND_ReadMCPorts: 1749 case CPIA_COMMAND_ReadMCPorts:
@@ -2059,7 +2059,7 @@ static int parse_picture(struct cam_data *cam, int size)
2059 int rows, cols, linesize, subsample_422; 2059 int rows, cols, linesize, subsample_422;
2060 2060
2061 /* make sure params don't change while we are decoding */ 2061 /* make sure params don't change while we are decoding */
2062 down(&cam->param_lock); 2062 mutex_lock(&cam->param_lock);
2063 2063
2064 obuf = cam->decompressed_frame.data; 2064 obuf = cam->decompressed_frame.data;
2065 end_obuf = obuf+CPIA_MAX_FRAME_SIZE; 2065 end_obuf = obuf+CPIA_MAX_FRAME_SIZE;
@@ -2069,26 +2069,26 @@ static int parse_picture(struct cam_data *cam, int size)
2069 2069
2070 if ((ibuf[0] != MAGIC_0) || (ibuf[1] != MAGIC_1)) { 2070 if ((ibuf[0] != MAGIC_0) || (ibuf[1] != MAGIC_1)) {
2071 LOG("header not found\n"); 2071 LOG("header not found\n");
2072 up(&cam->param_lock); 2072 mutex_unlock(&cam->param_lock);
2073 return -1; 2073 return -1;
2074 } 2074 }
2075 2075
2076 if ((ibuf[16] != VIDEOSIZE_QCIF) && (ibuf[16] != VIDEOSIZE_CIF)) { 2076 if ((ibuf[16] != VIDEOSIZE_QCIF) && (ibuf[16] != VIDEOSIZE_CIF)) {
2077 LOG("wrong video size\n"); 2077 LOG("wrong video size\n");
2078 up(&cam->param_lock); 2078 mutex_unlock(&cam->param_lock);
2079 return -1; 2079 return -1;
2080 } 2080 }
2081 2081
2082 if (ibuf[17] != SUBSAMPLE_420 && ibuf[17] != SUBSAMPLE_422) { 2082 if (ibuf[17] != SUBSAMPLE_420 && ibuf[17] != SUBSAMPLE_422) {
2083 LOG("illegal subtype %d\n",ibuf[17]); 2083 LOG("illegal subtype %d\n",ibuf[17]);
2084 up(&cam->param_lock); 2084 mutex_unlock(&cam->param_lock);
2085 return -1; 2085 return -1;
2086 } 2086 }
2087 subsample_422 = ibuf[17] == SUBSAMPLE_422; 2087 subsample_422 = ibuf[17] == SUBSAMPLE_422;
2088 2088
2089 if (ibuf[18] != YUVORDER_YUYV && ibuf[18] != YUVORDER_UYVY) { 2089 if (ibuf[18] != YUVORDER_YUYV && ibuf[18] != YUVORDER_UYVY) {
2090 LOG("illegal yuvorder %d\n",ibuf[18]); 2090 LOG("illegal yuvorder %d\n",ibuf[18]);
2091 up(&cam->param_lock); 2091 mutex_unlock(&cam->param_lock);
2092 return -1; 2092 return -1;
2093 } 2093 }
2094 in_uyvy = ibuf[18] == YUVORDER_UYVY; 2094 in_uyvy = ibuf[18] == YUVORDER_UYVY;
@@ -2098,7 +2098,7 @@ static int parse_picture(struct cam_data *cam, int size)
2098 (ibuf[26] != cam->params.roi.rowStart) || 2098 (ibuf[26] != cam->params.roi.rowStart) ||
2099 (ibuf[27] != cam->params.roi.rowEnd)) { 2099 (ibuf[27] != cam->params.roi.rowEnd)) {
2100 LOG("ROI mismatch\n"); 2100 LOG("ROI mismatch\n");
2101 up(&cam->param_lock); 2101 mutex_unlock(&cam->param_lock);
2102 return -1; 2102 return -1;
2103 } 2103 }
2104 cols = 8*(ibuf[25] - ibuf[24]); 2104 cols = 8*(ibuf[25] - ibuf[24]);
@@ -2107,14 +2107,14 @@ static int parse_picture(struct cam_data *cam, int size)
2107 2107
2108 if ((ibuf[28] != NOT_COMPRESSED) && (ibuf[28] != COMPRESSED)) { 2108 if ((ibuf[28] != NOT_COMPRESSED) && (ibuf[28] != COMPRESSED)) {
2109 LOG("illegal compression %d\n",ibuf[28]); 2109 LOG("illegal compression %d\n",ibuf[28]);
2110 up(&cam->param_lock); 2110 mutex_unlock(&cam->param_lock);
2111 return -1; 2111 return -1;
2112 } 2112 }
2113 compressed = (ibuf[28] == COMPRESSED); 2113 compressed = (ibuf[28] == COMPRESSED);
2114 2114
2115 if (ibuf[29] != NO_DECIMATION && ibuf[29] != DECIMATION_ENAB) { 2115 if (ibuf[29] != NO_DECIMATION && ibuf[29] != DECIMATION_ENAB) {
2116 LOG("illegal decimation %d\n",ibuf[29]); 2116 LOG("illegal decimation %d\n",ibuf[29]);
2117 up(&cam->param_lock); 2117 mutex_unlock(&cam->param_lock);
2118 return -1; 2118 return -1;
2119 } 2119 }
2120 decimation = (ibuf[29] == DECIMATION_ENAB); 2120 decimation = (ibuf[29] == DECIMATION_ENAB);
@@ -2130,7 +2130,7 @@ static int parse_picture(struct cam_data *cam, int size)
2130 cam->params.status.vpStatus = ibuf[38]; 2130 cam->params.status.vpStatus = ibuf[38];
2131 cam->params.status.errorCode = ibuf[39]; 2131 cam->params.status.errorCode = ibuf[39];
2132 cam->fps = ibuf[41]; 2132 cam->fps = ibuf[41];
2133 up(&cam->param_lock); 2133 mutex_unlock(&cam->param_lock);
2134 2134
2135 linesize = skipcount(cols, out_fmt); 2135 linesize = skipcount(cols, out_fmt);
2136 ibuf += FRAME_HEADER_SIZE; 2136 ibuf += FRAME_HEADER_SIZE;
@@ -2271,9 +2271,9 @@ static int find_over_exposure(int brightness)
2271/* update various camera modes and settings */ 2271/* update various camera modes and settings */
2272static void dispatch_commands(struct cam_data *cam) 2272static void dispatch_commands(struct cam_data *cam)
2273{ 2273{
2274 down(&cam->param_lock); 2274 mutex_lock(&cam->param_lock);
2275 if (cam->cmd_queue==COMMAND_NONE) { 2275 if (cam->cmd_queue==COMMAND_NONE) {
2276 up(&cam->param_lock); 2276 mutex_unlock(&cam->param_lock);
2277 return; 2277 return;
2278 } 2278 }
2279 DEB_BYTE(cam->cmd_queue); 2279 DEB_BYTE(cam->cmd_queue);
@@ -2415,7 +2415,7 @@ static void dispatch_commands(struct cam_data *cam)
2415 } 2415 }
2416 2416
2417 cam->cmd_queue = COMMAND_NONE; 2417 cam->cmd_queue = COMMAND_NONE;
2418 up(&cam->param_lock); 2418 mutex_unlock(&cam->param_lock);
2419 return; 2419 return;
2420} 2420}
2421 2421
@@ -2562,7 +2562,7 @@ static void monitor_exposure(struct cam_data *cam)
2562 gain = data[2]; 2562 gain = data[2];
2563 coarseL = data[3]; 2563 coarseL = data[3];
2564 2564
2565 down(&cam->param_lock); 2565 mutex_lock(&cam->param_lock);
2566 light_exp = cam->params.colourParams.brightness + 2566 light_exp = cam->params.colourParams.brightness +
2567 TC - 50 + EXP_ACC_LIGHT; 2567 TC - 50 + EXP_ACC_LIGHT;
2568 if(light_exp > 255) 2568 if(light_exp > 255)
@@ -2762,7 +2762,7 @@ static void monitor_exposure(struct cam_data *cam)
2762 LOG("Automatically increasing sensor_fps\n"); 2762 LOG("Automatically increasing sensor_fps\n");
2763 } 2763 }
2764 } 2764 }
2765 up(&cam->param_lock); 2765 mutex_unlock(&cam->param_lock);
2766} 2766}
2767 2767
2768/*-----------------------------------------------------------------*/ 2768/*-----------------------------------------------------------------*/
@@ -2778,10 +2778,10 @@ static void restart_flicker(struct cam_data *cam)
2778 int cam_exposure, old_exp; 2778 int cam_exposure, old_exp;
2779 if(!FIRMWARE_VERSION(1,2)) 2779 if(!FIRMWARE_VERSION(1,2))
2780 return; 2780 return;
2781 down(&cam->param_lock); 2781 mutex_lock(&cam->param_lock);
2782 if(cam->params.flickerControl.flickerMode == 0 || 2782 if(cam->params.flickerControl.flickerMode == 0 ||
2783 cam->raw_image[39] == 0) { 2783 cam->raw_image[39] == 0) {
2784 up(&cam->param_lock); 2784 mutex_unlock(&cam->param_lock);
2785 return; 2785 return;
2786 } 2786 }
2787 cam_exposure = cam->raw_image[39]*2; 2787 cam_exposure = cam->raw_image[39]*2;
@@ -2810,7 +2810,7 @@ static void restart_flicker(struct cam_data *cam)
2810 cam->exposure_status = EXPOSURE_NORMAL; 2810 cam->exposure_status = EXPOSURE_NORMAL;
2811 2811
2812 } 2812 }
2813 up(&cam->param_lock); 2813 mutex_unlock(&cam->param_lock);
2814} 2814}
2815#undef FIRMWARE_VERSION 2815#undef FIRMWARE_VERSION
2816 2816
@@ -3186,7 +3186,7 @@ static int cpia_open(struct inode *inode, struct file *file)
3186 if (!try_module_get(cam->ops->owner)) 3186 if (!try_module_get(cam->ops->owner))
3187 return -ENODEV; 3187 return -ENODEV;
3188 3188
3189 down(&cam->busy_lock); 3189 mutex_lock(&cam->busy_lock);
3190 err = -ENOMEM; 3190 err = -ENOMEM;
3191 if (!cam->raw_image) { 3191 if (!cam->raw_image) {
3192 cam->raw_image = rvmalloc(CPIA_MAX_IMAGE_SIZE); 3192 cam->raw_image = rvmalloc(CPIA_MAX_IMAGE_SIZE);
@@ -3227,7 +3227,7 @@ static int cpia_open(struct inode *inode, struct file *file)
3227 3227
3228 ++cam->open_count; 3228 ++cam->open_count;
3229 file->private_data = dev; 3229 file->private_data = dev;
3230 up(&cam->busy_lock); 3230 mutex_unlock(&cam->busy_lock);
3231 return 0; 3231 return 0;
3232 3232
3233 oops: 3233 oops:
@@ -3239,7 +3239,7 @@ static int cpia_open(struct inode *inode, struct file *file)
3239 rvfree(cam->raw_image, CPIA_MAX_IMAGE_SIZE); 3239 rvfree(cam->raw_image, CPIA_MAX_IMAGE_SIZE);
3240 cam->raw_image = NULL; 3240 cam->raw_image = NULL;
3241 } 3241 }
3242 up(&cam->busy_lock); 3242 mutex_unlock(&cam->busy_lock);
3243 put_cam(cam->ops); 3243 put_cam(cam->ops);
3244 return err; 3244 return err;
3245} 3245}
@@ -3303,24 +3303,24 @@ static ssize_t cpia_read(struct file *file, char __user *buf,
3303 int err; 3303 int err;
3304 3304
3305 /* make this _really_ smp and multithread-safe */ 3305 /* make this _really_ smp and multithread-safe */
3306 if (down_interruptible(&cam->busy_lock)) 3306 if (mutex_lock_interruptible(&cam->busy_lock))
3307 return -EINTR; 3307 return -EINTR;
3308 3308
3309 if (!buf) { 3309 if (!buf) {
3310 DBG("buf NULL\n"); 3310 DBG("buf NULL\n");
3311 up(&cam->busy_lock); 3311 mutex_unlock(&cam->busy_lock);
3312 return -EINVAL; 3312 return -EINVAL;
3313 } 3313 }
3314 3314
3315 if (!count) { 3315 if (!count) {
3316 DBG("count 0\n"); 3316 DBG("count 0\n");
3317 up(&cam->busy_lock); 3317 mutex_unlock(&cam->busy_lock);
3318 return 0; 3318 return 0;
3319 } 3319 }
3320 3320
3321 if (!cam->ops) { 3321 if (!cam->ops) {
3322 DBG("ops NULL\n"); 3322 DBG("ops NULL\n");
3323 up(&cam->busy_lock); 3323 mutex_unlock(&cam->busy_lock);
3324 return -ENODEV; 3324 return -ENODEV;
3325 } 3325 }
3326 3326
@@ -3329,7 +3329,7 @@ static ssize_t cpia_read(struct file *file, char __user *buf,
3329 cam->mmap_kludge=0; 3329 cam->mmap_kludge=0;
3330 if((err = fetch_frame(cam)) != 0) { 3330 if((err = fetch_frame(cam)) != 0) {
3331 DBG("ERROR from fetch_frame: %d\n", err); 3331 DBG("ERROR from fetch_frame: %d\n", err);
3332 up(&cam->busy_lock); 3332 mutex_unlock(&cam->busy_lock);
3333 return err; 3333 return err;
3334 } 3334 }
3335 cam->decompressed_frame.state = FRAME_UNUSED; 3335 cam->decompressed_frame.state = FRAME_UNUSED;
@@ -3338,17 +3338,17 @@ static ssize_t cpia_read(struct file *file, char __user *buf,
3338 if (cam->decompressed_frame.count > count) { 3338 if (cam->decompressed_frame.count > count) {
3339 DBG("count wrong: %d, %lu\n", cam->decompressed_frame.count, 3339 DBG("count wrong: %d, %lu\n", cam->decompressed_frame.count,
3340 (unsigned long) count); 3340 (unsigned long) count);
3341 up(&cam->busy_lock); 3341 mutex_unlock(&cam->busy_lock);
3342 return -EFAULT; 3342 return -EFAULT;
3343 } 3343 }
3344 if (copy_to_user(buf, cam->decompressed_frame.data, 3344 if (copy_to_user(buf, cam->decompressed_frame.data,
3345 cam->decompressed_frame.count)) { 3345 cam->decompressed_frame.count)) {
3346 DBG("copy_to_user failed\n"); 3346 DBG("copy_to_user failed\n");
3347 up(&cam->busy_lock); 3347 mutex_unlock(&cam->busy_lock);
3348 return -EFAULT; 3348 return -EFAULT;
3349 } 3349 }
3350 3350
3351 up(&cam->busy_lock); 3351 mutex_unlock(&cam->busy_lock);
3352 return cam->decompressed_frame.count; 3352 return cam->decompressed_frame.count;
3353} 3353}
3354 3354
@@ -3363,7 +3363,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3363 return -ENODEV; 3363 return -ENODEV;
3364 3364
3365 /* make this _really_ smp-safe */ 3365 /* make this _really_ smp-safe */
3366 if (down_interruptible(&cam->busy_lock)) 3366 if (mutex_lock_interruptible(&cam->busy_lock))
3367 return -EINTR; 3367 return -EINTR;
3368 3368
3369 //DBG("cpia_ioctl: %u\n", ioctlnr); 3369 //DBG("cpia_ioctl: %u\n", ioctlnr);
@@ -3439,7 +3439,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3439 break; 3439 break;
3440 } 3440 }
3441 3441
3442 down(&cam->param_lock); 3442 mutex_lock(&cam->param_lock);
3443 /* brightness, colour, contrast need no check 0-65535 */ 3443 /* brightness, colour, contrast need no check 0-65535 */
3444 cam->vp = *vp; 3444 cam->vp = *vp;
3445 /* update cam->params.colourParams */ 3445 /* update cam->params.colourParams */
@@ -3466,7 +3466,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3466 3466
3467 /* queue command to update camera */ 3467 /* queue command to update camera */
3468 cam->cmd_queue |= COMMAND_SETCOLOURPARAMS; 3468 cam->cmd_queue |= COMMAND_SETCOLOURPARAMS;
3469 up(&cam->param_lock); 3469 mutex_unlock(&cam->param_lock);
3470 DBG("VIDIOCSPICT: %d / %d // %d / %d / %d / %d\n", 3470 DBG("VIDIOCSPICT: %d / %d // %d / %d / %d / %d\n",
3471 vp->depth, vp->palette, vp->brightness, vp->hue, vp->colour, 3471 vp->depth, vp->palette, vp->brightness, vp->hue, vp->colour,
3472 vp->contrast); 3472 vp->contrast);
@@ -3501,13 +3501,13 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3501 /* we set the video window to something smaller or equal to what 3501 /* we set the video window to something smaller or equal to what
3502 * is requested by the user??? 3502 * is requested by the user???
3503 */ 3503 */
3504 down(&cam->param_lock); 3504 mutex_lock(&cam->param_lock);
3505 if (vw->width != cam->vw.width || vw->height != cam->vw.height) { 3505 if (vw->width != cam->vw.width || vw->height != cam->vw.height) {
3506 int video_size = match_videosize(vw->width, vw->height); 3506 int video_size = match_videosize(vw->width, vw->height);
3507 3507
3508 if (video_size < 0) { 3508 if (video_size < 0) {
3509 retval = -EINVAL; 3509 retval = -EINVAL;
3510 up(&cam->param_lock); 3510 mutex_unlock(&cam->param_lock);
3511 break; 3511 break;
3512 } 3512 }
3513 cam->video_size = video_size; 3513 cam->video_size = video_size;
@@ -3520,7 +3520,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3520 cam->cmd_queue |= COMMAND_SETFORMAT; 3520 cam->cmd_queue |= COMMAND_SETFORMAT;
3521 } 3521 }
3522 3522
3523 up(&cam->param_lock); 3523 mutex_unlock(&cam->param_lock);
3524 3524
3525 /* setformat ignored by camera during streaming, 3525 /* setformat ignored by camera during streaming,
3526 * so stop/dispatch/start */ 3526 * so stop/dispatch/start */
@@ -3682,7 +3682,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3682 3682
3683 DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height); 3683 DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height);
3684 3684
3685 down(&cam->param_lock); 3685 mutex_lock(&cam->param_lock);
3686 3686
3687 cam->vc.x = vc->x; 3687 cam->vc.x = vc->x;
3688 cam->vc.y = vc->y; 3688 cam->vc.y = vc->y;
@@ -3692,7 +3692,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3692 set_vw_size(cam); 3692 set_vw_size(cam);
3693 cam->cmd_queue |= COMMAND_SETFORMAT; 3693 cam->cmd_queue |= COMMAND_SETFORMAT;
3694 3694
3695 up(&cam->param_lock); 3695 mutex_unlock(&cam->param_lock);
3696 3696
3697 /* setformat ignored by camera during streaming, 3697 /* setformat ignored by camera during streaming,
3698 * so stop/dispatch/start */ 3698 * so stop/dispatch/start */
@@ -3736,7 +3736,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
3736 break; 3736 break;
3737 } 3737 }
3738 3738
3739 up(&cam->busy_lock); 3739 mutex_unlock(&cam->busy_lock);
3740 return retval; 3740 return retval;
3741} 3741}
3742 3742
@@ -3769,12 +3769,12 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
3769 return -ENODEV; 3769 return -ENODEV;
3770 3770
3771 /* make this _really_ smp-safe */ 3771 /* make this _really_ smp-safe */
3772 if (down_interruptible(&cam->busy_lock)) 3772 if (mutex_lock_interruptible(&cam->busy_lock))
3773 return -EINTR; 3773 return -EINTR;
3774 3774
3775 if (!cam->frame_buf) { /* we do lazy allocation */ 3775 if (!cam->frame_buf) { /* we do lazy allocation */
3776 if ((retval = allocate_frame_buf(cam))) { 3776 if ((retval = allocate_frame_buf(cam))) {
3777 up(&cam->busy_lock); 3777 mutex_unlock(&cam->busy_lock);
3778 return retval; 3778 return retval;
3779 } 3779 }
3780 } 3780 }
@@ -3783,7 +3783,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
3783 while (size > 0) { 3783 while (size > 0) {
3784 page = vmalloc_to_pfn((void *)pos); 3784 page = vmalloc_to_pfn((void *)pos);
3785 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { 3785 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
3786 up(&cam->busy_lock); 3786 mutex_unlock(&cam->busy_lock);
3787 return -EAGAIN; 3787 return -EAGAIN;
3788 } 3788 }
3789 start += PAGE_SIZE; 3789 start += PAGE_SIZE;
@@ -3795,7 +3795,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
3795 } 3795 }
3796 3796
3797 DBG("cpia_mmap: %ld\n", size); 3797 DBG("cpia_mmap: %ld\n", size);
3798 up(&cam->busy_lock); 3798 mutex_unlock(&cam->busy_lock);
3799 3799
3800 return 0; 3800 return 0;
3801} 3801}
@@ -3936,8 +3936,8 @@ static void init_camera_struct(struct cam_data *cam,
3936 memset(cam, 0, sizeof(struct cam_data)); 3936 memset(cam, 0, sizeof(struct cam_data));
3937 3937
3938 cam->ops = ops; 3938 cam->ops = ops;
3939 init_MUTEX(&cam->param_lock); 3939 mutex_init(&cam->param_lock);
3940 init_MUTEX(&cam->busy_lock); 3940 mutex_init(&cam->busy_lock);
3941 3941
3942 reset_camera_struct(cam); 3942 reset_camera_struct(cam);
3943 3943
diff --git a/drivers/media/video/cpia.h b/drivers/media/video/cpia.h
index f629b693ee65..de6678200a57 100644
--- a/drivers/media/video/cpia.h
+++ b/drivers/media/video/cpia.h
@@ -47,6 +47,7 @@
47#include <linux/videodev.h> 47#include <linux/videodev.h>
48#include <linux/list.h> 48#include <linux/list.h>
49#include <linux/smp_lock.h> 49#include <linux/smp_lock.h>
50#include <linux/mutex.h>
50 51
51struct cpia_camera_ops 52struct cpia_camera_ops
52{ 53{
@@ -246,7 +247,7 @@ enum v4l_camstates {
246struct cam_data { 247struct cam_data {
247 struct list_head cam_data_list; 248 struct list_head cam_data_list;
248 249
249 struct semaphore busy_lock; /* guard against SMP multithreading */ 250 struct mutex busy_lock; /* guard against SMP multithreading */
250 struct cpia_camera_ops *ops; /* lowlevel driver operations */ 251 struct cpia_camera_ops *ops; /* lowlevel driver operations */
251 void *lowlevel_data; /* private data for lowlevel driver */ 252 void *lowlevel_data; /* private data for lowlevel driver */
252 u8 *raw_image; /* buffer for raw image data */ 253 u8 *raw_image; /* buffer for raw image data */
@@ -261,7 +262,7 @@ struct cam_data {
261 u8 mainsFreq; /* for flicker control */ 262 u8 mainsFreq; /* for flicker control */
262 263
263 /* proc interface */ 264 /* proc interface */
264 struct semaphore param_lock; /* params lock for this camera */ 265 struct mutex param_lock; /* params lock for this camera */
265 struct cam_params params; /* camera settings */ 266 struct cam_params params; /* camera settings */
266 struct proc_dir_entry *proc_entry; /* /proc/cpia/videoX */ 267 struct proc_dir_entry *proc_entry; /* /proc/cpia/videoX */
267 268
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 3720f24a25cf..eda7cd8b2d4a 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -1061,7 +1061,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1061 core->pci_bus = pci->bus->number; 1061 core->pci_bus = pci->bus->number;
1062 core->pci_slot = PCI_SLOT(pci->devfn); 1062 core->pci_slot = PCI_SLOT(pci->devfn);
1063 core->pci_irqmask = 0x00fc00; 1063 core->pci_irqmask = 0x00fc00;
1064 init_MUTEX(&core->lock); 1064 mutex_init(&core->lock);
1065 1065
1066 core->nr = cx88_devcount++; 1066 core->nr = cx88_devcount++;
1067 sprintf(core->name,"cx88[%d]",core->nr); 1067 sprintf(core->name,"cx88[%d]",core->nr);
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 073494ceab0f..d15ef158ac8f 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -336,17 +336,17 @@ static int res_get(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bi
336 return 1; 336 return 1;
337 337
338 /* is it free? */ 338 /* is it free? */
339 down(&core->lock); 339 mutex_lock(&core->lock);
340 if (dev->resources & bit) { 340 if (dev->resources & bit) {
341 /* no, someone else uses it */ 341 /* no, someone else uses it */
342 up(&core->lock); 342 mutex_unlock(&core->lock);
343 return 0; 343 return 0;
344 } 344 }
345 /* it's free, grab it */ 345 /* it's free, grab it */
346 fh->resources |= bit; 346 fh->resources |= bit;
347 dev->resources |= bit; 347 dev->resources |= bit;
348 dprintk(1,"res: get %d\n",bit); 348 dprintk(1,"res: get %d\n",bit);
349 up(&core->lock); 349 mutex_unlock(&core->lock);
350 return 1; 350 return 1;
351} 351}
352 352
@@ -369,11 +369,11 @@ void res_free(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bits)
369 if ((fh->resources & bits) != bits) 369 if ((fh->resources & bits) != bits)
370 BUG(); 370 BUG();
371 371
372 down(&core->lock); 372 mutex_lock(&core->lock);
373 fh->resources &= ~bits; 373 fh->resources &= ~bits;
374 dev->resources &= ~bits; 374 dev->resources &= ~bits;
375 dprintk(1,"res: put %d\n",bits); 375 dprintk(1,"res: put %d\n",bits);
376 up(&core->lock); 376 mutex_unlock(&core->lock);
377} 377}
378 378
379/* ------------------------------------------------------------------ */ 379/* ------------------------------------------------------------------ */
@@ -1291,9 +1291,9 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
1291 if (i == ARRAY_SIZE(tvnorms)) 1291 if (i == ARRAY_SIZE(tvnorms))
1292 return -EINVAL; 1292 return -EINVAL;
1293 1293
1294 down(&core->lock); 1294 mutex_lock(&core->lock);
1295 cx88_set_tvnorm(core,&tvnorms[i]); 1295 cx88_set_tvnorm(core,&tvnorms[i]);
1296 up(&core->lock); 1296 mutex_unlock(&core->lock);
1297 return 0; 1297 return 0;
1298 } 1298 }
1299 1299
@@ -1343,10 +1343,10 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
1343 1343
1344 if (*i >= 4) 1344 if (*i >= 4)
1345 return -EINVAL; 1345 return -EINVAL;
1346 down(&core->lock); 1346 mutex_lock(&core->lock);
1347 cx88_newstation(core); 1347 cx88_newstation(core);
1348 video_mux(core,*i); 1348 video_mux(core,*i);
1349 up(&core->lock); 1349 mutex_unlock(&core->lock);
1350 return 0; 1350 return 0;
1351 } 1351 }
1352 1352
@@ -1438,7 +1438,7 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
1438 return -EINVAL; 1438 return -EINVAL;
1439 if (1 == radio && f->type != V4L2_TUNER_RADIO) 1439 if (1 == radio && f->type != V4L2_TUNER_RADIO)
1440 return -EINVAL; 1440 return -EINVAL;
1441 down(&core->lock); 1441 mutex_lock(&core->lock);
1442 core->freq = f->frequency; 1442 core->freq = f->frequency;
1443 cx88_newstation(core); 1443 cx88_newstation(core);
1444 cx88_call_i2c_clients(core,VIDIOC_S_FREQUENCY,f); 1444 cx88_call_i2c_clients(core,VIDIOC_S_FREQUENCY,f);
@@ -1447,7 +1447,7 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
1447 msleep (10); 1447 msleep (10);
1448 cx88_set_tvaudio(core); 1448 cx88_set_tvaudio(core);
1449 1449
1450 up(&core->lock); 1450 mutex_unlock(&core->lock);
1451 return 0; 1451 return 0;
1452 } 1452 }
1453 1453
@@ -1921,11 +1921,11 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1921 pci_set_drvdata(pci_dev,dev); 1921 pci_set_drvdata(pci_dev,dev);
1922 1922
1923 /* initial device configuration */ 1923 /* initial device configuration */
1924 down(&core->lock); 1924 mutex_lock(&core->lock);
1925 cx88_set_tvnorm(core,tvnorms); 1925 cx88_set_tvnorm(core,tvnorms);
1926 init_controls(core); 1926 init_controls(core);
1927 video_mux(core,0); 1927 video_mux(core,0);
1928 up(&core->lock); 1928 mutex_unlock(&core->lock);
1929 1929
1930 /* start tvaudio thread */ 1930 /* start tvaudio thread */
1931 if (core->tuner_type != TUNER_ABSENT) 1931 if (core->tuner_type != TUNER_ABSENT)
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 31a688a3fb77..a4cf2473eacf 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -35,6 +35,7 @@
35#include "cx88-reg.h" 35#include "cx88-reg.h"
36 36
37#include <linux/version.h> 37#include <linux/version.h>
38#include <linux/mutex.h>
38#define CX88_VERSION_CODE KERNEL_VERSION(0,0,5) 39#define CX88_VERSION_CODE KERNEL_VERSION(0,0,5)
39 40
40#ifndef TRUE 41#ifndef TRUE
@@ -309,8 +310,7 @@ struct cx88_core {
309 /* IR remote control state */ 310 /* IR remote control state */
310 struct cx88_IR *ir; 311 struct cx88_IR *ir;
311 312
312 struct semaphore lock; 313 struct mutex lock;
313
314 /* various v4l controls */ 314 /* various v4l controls */
315 u32 freq; 315 u32 freq;
316 316
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 1c1557d9bace..671fc52b6a88 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -362,12 +362,12 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
362 return -EBUSY; 362 return -EBUSY;
363 } 363 }
364 364
365 init_MUTEX(&dev->fileop_lock); /* to 1 == available */ 365 mutex_init(&dev->fileop_lock); /* to 1 == available */
366 spin_lock_init(&dev->queue_lock); 366 spin_lock_init(&dev->queue_lock);
367 init_waitqueue_head(&dev->wait_frame); 367 init_waitqueue_head(&dev->wait_frame);
368 init_waitqueue_head(&dev->wait_stream); 368 init_waitqueue_head(&dev->wait_stream);
369 369
370 down(&dev->lock); 370 mutex_lock(&dev->lock);
371 371
372 if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { 372 if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
373 em28xx_set_alternate(dev); 373 em28xx_set_alternate(dev);
@@ -404,8 +404,8 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
404 404
405 dev->state |= DEV_INITIALIZED; 405 dev->state |= DEV_INITIALIZED;
406 406
407 err: 407err:
408 up(&dev->lock); 408 mutex_unlock(&dev->lock);
409 up_read(&em28xx_disconnect); 409 up_read(&em28xx_disconnect);
410 return errCode; 410 return errCode;
411} 411}
@@ -447,7 +447,7 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp)
447 447
448 em28xx_videodbg("users=%d\n", dev->users); 448 em28xx_videodbg("users=%d\n", dev->users);
449 449
450 down(&dev->lock); 450 mutex_lock(&dev->lock);
451 451
452 em28xx_uninit_isoc(dev); 452 em28xx_uninit_isoc(dev);
453 453
@@ -456,7 +456,7 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp)
456 /* the device is already disconnect, free the remaining resources */ 456 /* the device is already disconnect, free the remaining resources */
457 if (dev->state & DEV_DISCONNECTED) { 457 if (dev->state & DEV_DISCONNECTED) {
458 em28xx_release_resources(dev); 458 em28xx_release_resources(dev);
459 up(&dev->lock); 459 mutex_unlock(&dev->lock);
460 kfree(dev); 460 kfree(dev);
461 return 0; 461 return 0;
462 } 462 }
@@ -472,7 +472,7 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp)
472 472
473 dev->users--; 473 dev->users--;
474 wake_up_interruptible_nr(&dev->open, 1); 474 wake_up_interruptible_nr(&dev->open, 1);
475 up(&dev->lock); 475 mutex_unlock(&dev->lock);
476 return 0; 476 return 0;
477} 477}
478 478
@@ -496,7 +496,7 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
496 em28xx_videodbg("V4L2_BUF_TYPE_VBI_CAPTURE is set\n"); 496 em28xx_videodbg("V4L2_BUF_TYPE_VBI_CAPTURE is set\n");
497 em28xx_videodbg("not supported yet! ...\n"); 497 em28xx_videodbg("not supported yet! ...\n");
498 if (copy_to_user(buf, "", 1)) { 498 if (copy_to_user(buf, "", 1)) {
499 up(&dev->fileop_lock); 499 mutex_unlock(&dev->fileop_lock);
500 return -EFAULT; 500 return -EFAULT;
501 } 501 }
502 return (1); 502 return (1);
@@ -505,38 +505,38 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
505 em28xx_videodbg("V4L2_BUF_TYPE_SLICED_VBI_CAPTURE is set\n"); 505 em28xx_videodbg("V4L2_BUF_TYPE_SLICED_VBI_CAPTURE is set\n");
506 em28xx_videodbg("not supported yet! ...\n"); 506 em28xx_videodbg("not supported yet! ...\n");
507 if (copy_to_user(buf, "", 1)) { 507 if (copy_to_user(buf, "", 1)) {
508 up(&dev->fileop_lock); 508 mutex_unlock(&dev->fileop_lock);
509 return -EFAULT; 509 return -EFAULT;
510 } 510 }
511 return (1); 511 return (1);
512 } 512 }
513 513
514 if (down_interruptible(&dev->fileop_lock)) 514 if (mutex_lock_interruptible(&dev->fileop_lock))
515 return -ERESTARTSYS; 515 return -ERESTARTSYS;
516 516
517 if (dev->state & DEV_DISCONNECTED) { 517 if (dev->state & DEV_DISCONNECTED) {
518 em28xx_videodbg("device not present\n"); 518 em28xx_videodbg("device not present\n");
519 up(&dev->fileop_lock); 519 mutex_unlock(&dev->fileop_lock);
520 return -ENODEV; 520 return -ENODEV;
521 } 521 }
522 522
523 if (dev->state & DEV_MISCONFIGURED) { 523 if (dev->state & DEV_MISCONFIGURED) {
524 em28xx_videodbg("device misconfigured; close and open it again\n"); 524 em28xx_videodbg("device misconfigured; close and open it again\n");
525 up(&dev->fileop_lock); 525 mutex_unlock(&dev->fileop_lock);
526 return -EIO; 526 return -EIO;
527 } 527 }
528 528
529 if (dev->io == IO_MMAP) { 529 if (dev->io == IO_MMAP) {
530 em28xx_videodbg ("IO method is set to mmap; close and open" 530 em28xx_videodbg ("IO method is set to mmap; close and open"
531 " the device again to choose the read method\n"); 531 " the device again to choose the read method\n");
532 up(&dev->fileop_lock); 532 mutex_unlock(&dev->fileop_lock);
533 return -EINVAL; 533 return -EINVAL;
534 } 534 }
535 535
536 if (dev->io == IO_NONE) { 536 if (dev->io == IO_NONE) {
537 if (!em28xx_request_buffers(dev, EM28XX_NUM_READ_FRAMES)) { 537 if (!em28xx_request_buffers(dev, EM28XX_NUM_READ_FRAMES)) {
538 em28xx_errdev("read failed, not enough memory\n"); 538 em28xx_errdev("read failed, not enough memory\n");
539 up(&dev->fileop_lock); 539 mutex_unlock(&dev->fileop_lock);
540 return -ENOMEM; 540 return -ENOMEM;
541 } 541 }
542 dev->io = IO_READ; 542 dev->io = IO_READ;
@@ -545,13 +545,13 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
545 } 545 }
546 546
547 if (!count) { 547 if (!count) {
548 up(&dev->fileop_lock); 548 mutex_unlock(&dev->fileop_lock);
549 return 0; 549 return 0;
550 } 550 }
551 551
552 if (list_empty(&dev->outqueue)) { 552 if (list_empty(&dev->outqueue)) {
553 if (filp->f_flags & O_NONBLOCK) { 553 if (filp->f_flags & O_NONBLOCK) {
554 up(&dev->fileop_lock); 554 mutex_unlock(&dev->fileop_lock);
555 return -EAGAIN; 555 return -EAGAIN;
556 } 556 }
557 ret = wait_event_interruptible 557 ret = wait_event_interruptible
@@ -559,11 +559,11 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
559 (!list_empty(&dev->outqueue)) || 559 (!list_empty(&dev->outqueue)) ||
560 (dev->state & DEV_DISCONNECTED)); 560 (dev->state & DEV_DISCONNECTED));
561 if (ret) { 561 if (ret) {
562 up(&dev->fileop_lock); 562 mutex_unlock(&dev->fileop_lock);
563 return ret; 563 return ret;
564 } 564 }
565 if (dev->state & DEV_DISCONNECTED) { 565 if (dev->state & DEV_DISCONNECTED) {
566 up(&dev->fileop_lock); 566 mutex_unlock(&dev->fileop_lock);
567 return -ENODEV; 567 return -ENODEV;
568 } 568 }
569 } 569 }
@@ -582,12 +582,12 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
582 count = f->buf.length; 582 count = f->buf.length;
583 583
584 if (copy_to_user(buf, f->bufmem, count)) { 584 if (copy_to_user(buf, f->bufmem, count)) {
585 up(&dev->fileop_lock); 585 mutex_unlock(&dev->fileop_lock);
586 return -EFAULT; 586 return -EFAULT;
587 } 587 }
588 *f_pos += count; 588 *f_pos += count;
589 589
590 up(&dev->fileop_lock); 590 mutex_unlock(&dev->fileop_lock);
591 591
592 return count; 592 return count;
593} 593}
@@ -601,7 +601,7 @@ static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait)
601 unsigned int mask = 0; 601 unsigned int mask = 0;
602 struct em28xx *dev = filp->private_data; 602 struct em28xx *dev = filp->private_data;
603 603
604 if (down_interruptible(&dev->fileop_lock)) 604 if (mutex_lock_interruptible(&dev->fileop_lock))
605 return POLLERR; 605 return POLLERR;
606 606
607 if (dev->state & DEV_DISCONNECTED) { 607 if (dev->state & DEV_DISCONNECTED) {
@@ -627,13 +627,13 @@ static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait)
627 if (!list_empty(&dev->outqueue)) 627 if (!list_empty(&dev->outqueue))
628 mask |= POLLIN | POLLRDNORM; 628 mask |= POLLIN | POLLRDNORM;
629 629
630 up(&dev->fileop_lock); 630 mutex_unlock(&dev->fileop_lock);
631 631
632 return mask; 632 return mask;
633 } 633 }
634 } 634 }
635 635
636 up(&dev->fileop_lock); 636 mutex_unlock(&dev->fileop_lock);
637 return POLLERR; 637 return POLLERR;
638} 638}
639 639
@@ -673,25 +673,25 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
673 673
674 struct em28xx *dev = filp->private_data; 674 struct em28xx *dev = filp->private_data;
675 675
676 if (down_interruptible(&dev->fileop_lock)) 676 if (mutex_lock_interruptible(&dev->fileop_lock))
677 return -ERESTARTSYS; 677 return -ERESTARTSYS;
678 678
679 if (dev->state & DEV_DISCONNECTED) { 679 if (dev->state & DEV_DISCONNECTED) {
680 em28xx_videodbg("mmap: device not present\n"); 680 em28xx_videodbg("mmap: device not present\n");
681 up(&dev->fileop_lock); 681 mutex_unlock(&dev->fileop_lock);
682 return -ENODEV; 682 return -ENODEV;
683 } 683 }
684 684
685 if (dev->state & DEV_MISCONFIGURED) { 685 if (dev->state & DEV_MISCONFIGURED) {
686 em28xx_videodbg ("mmap: Device is misconfigured; close and " 686 em28xx_videodbg ("mmap: Device is misconfigured; close and "
687 "open it again\n"); 687 "open it again\n");
688 up(&dev->fileop_lock); 688 mutex_unlock(&dev->fileop_lock);
689 return -EIO; 689 return -EIO;
690 } 690 }
691 691
692 if (dev->io != IO_MMAP || !(vma->vm_flags & VM_WRITE) || 692 if (dev->io != IO_MMAP || !(vma->vm_flags & VM_WRITE) ||
693 size != PAGE_ALIGN(dev->frame[0].buf.length)) { 693 size != PAGE_ALIGN(dev->frame[0].buf.length)) {
694 up(&dev->fileop_lock); 694 mutex_unlock(&dev->fileop_lock);
695 return -EINVAL; 695 return -EINVAL;
696 } 696 }
697 697
@@ -701,7 +701,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
701 } 701 }
702 if (i == dev->num_frames) { 702 if (i == dev->num_frames) {
703 em28xx_videodbg("mmap: user supplied mapping address is out of range\n"); 703 em28xx_videodbg("mmap: user supplied mapping address is out of range\n");
704 up(&dev->fileop_lock); 704 mutex_unlock(&dev->fileop_lock);
705 return -EINVAL; 705 return -EINVAL;
706 } 706 }
707 707
@@ -713,7 +713,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
713 while (size > 0) { /* size is page-aligned */ 713 while (size > 0) { /* size is page-aligned */
714 if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { 714 if (vm_insert_page(vma, start, vmalloc_to_page(pos))) {
715 em28xx_videodbg("mmap: vm_insert_page failed\n"); 715 em28xx_videodbg("mmap: vm_insert_page failed\n");
716 up(&dev->fileop_lock); 716 mutex_unlock(&dev->fileop_lock);
717 return -EAGAIN; 717 return -EAGAIN;
718 } 718 }
719 start += PAGE_SIZE; 719 start += PAGE_SIZE;
@@ -725,7 +725,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
725 vma->vm_private_data = &dev->frame[i]; 725 vma->vm_private_data = &dev->frame[i];
726 726
727 em28xx_vm_open(vma); 727 em28xx_vm_open(vma);
728 up(&dev->fileop_lock); 728 mutex_unlock(&dev->fileop_lock);
729 return 0; 729 return 0;
730} 730}
731 731
@@ -1125,7 +1125,7 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
1125 if (i == TVNORMS) 1125 if (i == TVNORMS)
1126 return -EINVAL; 1126 return -EINVAL;
1127 1127
1128 down(&dev->lock); 1128 mutex_lock(&dev->lock);
1129 dev->tvnorm = &tvnorms[i]; 1129 dev->tvnorm = &tvnorms[i];
1130 1130
1131 em28xx_set_norm(dev, dev->width, dev->height); 1131 em28xx_set_norm(dev, dev->width, dev->height);
@@ -1135,7 +1135,7 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
1135 em28xx_i2c_call_clients(dev, VIDIOC_S_STD, 1135 em28xx_i2c_call_clients(dev, VIDIOC_S_STD,
1136 &dev->tvnorm->id); 1136 &dev->tvnorm->id);
1137 1137
1138 up(&dev->lock); 1138 mutex_unlock(&dev->lock);
1139 1139
1140 return 0; 1140 return 0;
1141 } 1141 }
@@ -1189,9 +1189,9 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
1189 if (0 == INPUT(*index)->type) 1189 if (0 == INPUT(*index)->type)
1190 return -EINVAL; 1190 return -EINVAL;
1191 1191
1192 down(&dev->lock); 1192 mutex_lock(&dev->lock);
1193 video_mux(dev, *index); 1193 video_mux(dev, *index);
1194 up(&dev->lock); 1194 mutex_unlock(&dev->lock);
1195 1195
1196 return 0; 1196 return 0;
1197 } 1197 }
@@ -1338,10 +1338,10 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
1338/* t->signal = 0xffff;*/ 1338/* t->signal = 0xffff;*/
1339/* em28xx_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/ 1339/* em28xx_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/
1340 /* No way to get signal strength? */ 1340 /* No way to get signal strength? */
1341 down(&dev->lock); 1341 mutex_lock(&dev->lock);
1342 em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, 1342 em28xx_i2c_call_clients(dev, DECODER_GET_STATUS,
1343 &status); 1343 &status);
1344 up(&dev->lock); 1344 mutex_unlock(&dev->lock);
1345 t->signal = 1345 t->signal =
1346 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; 1346 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0;
1347 1347
@@ -1363,10 +1363,10 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
1363 t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */ 1363 t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */
1364/* t->signal = 0xffff; */ 1364/* t->signal = 0xffff; */
1365 /* No way to get signal strength? */ 1365 /* No way to get signal strength? */
1366 down(&dev->lock); 1366 mutex_lock(&dev->lock);
1367 em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, 1367 em28xx_i2c_call_clients(dev, DECODER_GET_STATUS,
1368 &status); 1368 &status);
1369 up(&dev->lock); 1369 mutex_unlock(&dev->lock);
1370 t->signal = 1370 t->signal =
1371 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; 1371 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0;
1372 1372
@@ -1394,10 +1394,10 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
1394 if (V4L2_TUNER_ANALOG_TV != f->type) 1394 if (V4L2_TUNER_ANALOG_TV != f->type)
1395 return -EINVAL; 1395 return -EINVAL;
1396 1396
1397 down(&dev->lock); 1397 mutex_lock(&dev->lock);
1398 dev->ctl_freq = f->frequency; 1398 dev->ctl_freq = f->frequency;
1399 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f); 1399 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f);
1400 up(&dev->lock); 1400 mutex_unlock(&dev->lock);
1401 return 0; 1401 return 0;
1402 } 1402 }
1403 case VIDIOC_CROPCAP: 1403 case VIDIOC_CROPCAP:
@@ -1660,25 +1660,25 @@ static int em28xx_v4l2_ioctl(struct inode *inode, struct file *filp,
1660 int ret = 0; 1660 int ret = 0;
1661 struct em28xx *dev = filp->private_data; 1661 struct em28xx *dev = filp->private_data;
1662 1662
1663 if (down_interruptible(&dev->fileop_lock)) 1663 if (mutex_lock_interruptible(&dev->fileop_lock))
1664 return -ERESTARTSYS; 1664 return -ERESTARTSYS;
1665 1665
1666 if (dev->state & DEV_DISCONNECTED) { 1666 if (dev->state & DEV_DISCONNECTED) {
1667 em28xx_errdev("v4l2 ioctl: device not present\n"); 1667 em28xx_errdev("v4l2 ioctl: device not present\n");
1668 up(&dev->fileop_lock); 1668 mutex_unlock(&dev->fileop_lock);
1669 return -ENODEV; 1669 return -ENODEV;
1670 } 1670 }
1671 1671
1672 if (dev->state & DEV_MISCONFIGURED) { 1672 if (dev->state & DEV_MISCONFIGURED) {
1673 em28xx_errdev 1673 em28xx_errdev
1674 ("v4l2 ioctl: device is misconfigured; close and open it again\n"); 1674 ("v4l2 ioctl: device is misconfigured; close and open it again\n");
1675 up(&dev->fileop_lock); 1675 mutex_unlock(&dev->fileop_lock);
1676 return -EIO; 1676 return -EIO;
1677 } 1677 }
1678 1678
1679 ret = video_usercopy(inode, filp, cmd, arg, em28xx_video_do_ioctl); 1679 ret = video_usercopy(inode, filp, cmd, arg, em28xx_video_do_ioctl);
1680 1680
1681 up(&dev->fileop_lock); 1681 mutex_unlock(&dev->fileop_lock);
1682 1682
1683 return ret; 1683 return ret;
1684} 1684}
@@ -1712,7 +1712,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1712 1712
1713 dev->udev = udev; 1713 dev->udev = udev;
1714 dev->model = model; 1714 dev->model = model;
1715 init_MUTEX(&dev->lock); 1715 mutex_init(&dev->lock);
1716 init_waitqueue_head(&dev->open); 1716 init_waitqueue_head(&dev->open);
1717 1717
1718 dev->em28xx_write_regs = em28xx_write_regs; 1718 dev->em28xx_write_regs = em28xx_write_regs;
@@ -1788,7 +1788,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1788 return -ENOMEM; 1788 return -ENOMEM;
1789 } 1789 }
1790 1790
1791 down(&dev->lock); 1791 mutex_lock(&dev->lock);
1792 /* register i2c bus */ 1792 /* register i2c bus */
1793 em28xx_i2c_register(dev); 1793 em28xx_i2c_register(dev);
1794 1794
@@ -1798,7 +1798,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1798 /* configure the device */ 1798 /* configure the device */
1799 em28xx_config_i2c(dev); 1799 em28xx_config_i2c(dev);
1800 1800
1801 up(&dev->lock); 1801 mutex_unlock(&dev->lock);
1802 1802
1803 errCode = em28xx_config(dev); 1803 errCode = em28xx_config(dev);
1804 1804
@@ -1849,12 +1849,12 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1849 list_add_tail(&dev->devlist,&em28xx_devlist); 1849 list_add_tail(&dev->devlist,&em28xx_devlist);
1850 1850
1851 /* register v4l2 device */ 1851 /* register v4l2 device */
1852 down(&dev->lock); 1852 mutex_lock(&dev->lock);
1853 if ((retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, 1853 if ((retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
1854 video_nr[dev->devno]))) { 1854 video_nr[dev->devno]))) {
1855 em28xx_errdev("unable to register video device (error=%i).\n", 1855 em28xx_errdev("unable to register video device (error=%i).\n",
1856 retval); 1856 retval);
1857 up(&dev->lock); 1857 mutex_unlock(&dev->lock);
1858 list_del(&dev->devlist); 1858 list_del(&dev->devlist);
1859 video_device_release(dev->vdev); 1859 video_device_release(dev->vdev);
1860 kfree(dev); 1860 kfree(dev);
@@ -1865,7 +1865,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1865 if (video_register_device(dev->vbi_dev, VFL_TYPE_VBI, 1865 if (video_register_device(dev->vbi_dev, VFL_TYPE_VBI,
1866 vbi_nr[dev->devno]) < 0) { 1866 vbi_nr[dev->devno]) < 0) {
1867 printk("unable to register vbi device\n"); 1867 printk("unable to register vbi device\n");
1868 up(&dev->lock); 1868 mutex_unlock(&dev->lock);
1869 list_del(&dev->devlist); 1869 list_del(&dev->devlist);
1870 video_device_release(dev->vbi_dev); 1870 video_device_release(dev->vbi_dev);
1871 video_device_release(dev->vdev); 1871 video_device_release(dev->vdev);
@@ -1886,7 +1886,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1886 } 1886 }
1887 video_mux(dev, 0); 1887 video_mux(dev, 0);
1888 1888
1889 up(&dev->lock); 1889 mutex_unlock(&dev->lock);
1890 1890
1891 em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n", 1891 em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n",
1892 dev->vdev->minor-MINOR_VFL_TYPE_GRABBER_MIN, 1892 dev->vdev->minor-MINOR_VFL_TYPE_GRABBER_MIN,
@@ -2035,7 +2035,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
2035 2035
2036 down_write(&em28xx_disconnect); 2036 down_write(&em28xx_disconnect);
2037 2037
2038 down(&dev->lock); 2038 mutex_lock(&dev->lock);
2039 2039
2040 em28xx_info("disconnecting %s\n", dev->vdev->name); 2040 em28xx_info("disconnecting %s\n", dev->vdev->name);
2041 2041
@@ -2057,7 +2057,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
2057 em28xx_release_resources(dev); 2057 em28xx_release_resources(dev);
2058 } 2058 }
2059 2059
2060 up(&dev->lock); 2060 mutex_unlock(&dev->lock);
2061 2061
2062 if (!dev->users) { 2062 if (!dev->users) {
2063 kfree(dev->alt_max_pkt_size); 2063 kfree(dev->alt_max_pkt_size);
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index ddf06c520e99..4e2fe62b7350 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -27,6 +27,7 @@
27 27
28#include <linux/videodev.h> 28#include <linux/videodev.h>
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/mutex.h>
30#include <media/ir-kbd-i2c.h> 31#include <media/ir-kbd-i2c.h>
31 32
32/* Boards supported by driver */ 33/* Boards supported by driver */
@@ -260,7 +261,7 @@ struct em28xx {
260 enum em28xx_stream_state stream; 261 enum em28xx_stream_state stream;
261 enum em28xx_io_method io; 262 enum em28xx_io_method io;
262 /* locks */ 263 /* locks */
263 struct semaphore lock, fileop_lock; 264 struct mutex lock, fileop_lock;
264 spinlock_t queue_lock; 265 spinlock_t queue_lock;
265 struct list_head inqueue, outqueue; 266 struct list_head inqueue, outqueue;
266 wait_queue_head_t open, wait_frame, wait_stream; 267 wait_queue_head_t open, wait_frame, wait_stream;
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index 2869464aee0d..850bee97090c 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -925,7 +925,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
925 return -EINVAL; 925 return -EINVAL;
926 if (p->palette != VIDEO_PALETTE_YUV422) 926 if (p->palette != VIDEO_PALETTE_YUV422)
927 return -EINVAL; 927 return -EINVAL;
928 down(&meye.lock); 928 mutex_lock(&meye.lock);
929 sonypi_camera_command(SONYPI_COMMAND_SETCAMERABRIGHTNESS, 929 sonypi_camera_command(SONYPI_COMMAND_SETCAMERABRIGHTNESS,
930 p->brightness >> 10); 930 p->brightness >> 10);
931 sonypi_camera_command(SONYPI_COMMAND_SETCAMERAHUE, 931 sonypi_camera_command(SONYPI_COMMAND_SETCAMERAHUE,
@@ -935,7 +935,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
935 sonypi_camera_command(SONYPI_COMMAND_SETCAMERACONTRAST, 935 sonypi_camera_command(SONYPI_COMMAND_SETCAMERACONTRAST,
936 p->contrast >> 10); 936 p->contrast >> 10);
937 meye.picture = *p; 937 meye.picture = *p;
938 up(&meye.lock); 938 mutex_unlock(&meye.lock);
939 break; 939 break;
940 } 940 }
941 941
@@ -946,21 +946,21 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
946 if (*i < 0 || *i >= gbuffers) 946 if (*i < 0 || *i >= gbuffers)
947 return -EINVAL; 947 return -EINVAL;
948 948
949 down(&meye.lock); 949 mutex_lock(&meye.lock);
950 950
951 switch (meye.grab_buffer[*i].state) { 951 switch (meye.grab_buffer[*i].state) {
952 952
953 case MEYE_BUF_UNUSED: 953 case MEYE_BUF_UNUSED:
954 up(&meye.lock); 954 mutex_unlock(&meye.lock);
955 return -EINVAL; 955 return -EINVAL;
956 case MEYE_BUF_USING: 956 case MEYE_BUF_USING:
957 if (file->f_flags & O_NONBLOCK) { 957 if (file->f_flags & O_NONBLOCK) {
958 up(&meye.lock); 958 mutex_unlock(&meye.lock);
959 return -EAGAIN; 959 return -EAGAIN;
960 } 960 }
961 if (wait_event_interruptible(meye.proc_list, 961 if (wait_event_interruptible(meye.proc_list,
962 (meye.grab_buffer[*i].state != MEYE_BUF_USING))) { 962 (meye.grab_buffer[*i].state != MEYE_BUF_USING))) {
963 up(&meye.lock); 963 mutex_unlock(&meye.lock);
964 return -EINTR; 964 return -EINTR;
965 } 965 }
966 /* fall through */ 966 /* fall through */
@@ -968,7 +968,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
968 meye.grab_buffer[*i].state = MEYE_BUF_UNUSED; 968 meye.grab_buffer[*i].state = MEYE_BUF_UNUSED;
969 kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int)); 969 kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int));
970 } 970 }
971 up(&meye.lock); 971 mutex_unlock(&meye.lock);
972 break; 972 break;
973 } 973 }
974 974
@@ -987,7 +987,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
987 if (meye.grab_buffer[vm->frame].state != MEYE_BUF_UNUSED) 987 if (meye.grab_buffer[vm->frame].state != MEYE_BUF_UNUSED)
988 return -EBUSY; 988 return -EBUSY;
989 989
990 down(&meye.lock); 990 mutex_lock(&meye.lock);
991 if (vm->width == 640 && vm->height == 480) { 991 if (vm->width == 640 && vm->height == 480) {
992 if (meye.params.subsample) { 992 if (meye.params.subsample) {
993 meye.params.subsample = 0; 993 meye.params.subsample = 0;
@@ -999,7 +999,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
999 restart = 1; 999 restart = 1;
1000 } 1000 }
1001 } else { 1001 } else {
1002 up(&meye.lock); 1002 mutex_unlock(&meye.lock);
1003 return -EINVAL; 1003 return -EINVAL;
1004 } 1004 }
1005 1005
@@ -1007,7 +1007,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1007 mchip_continuous_start(); 1007 mchip_continuous_start();
1008 meye.grab_buffer[vm->frame].state = MEYE_BUF_USING; 1008 meye.grab_buffer[vm->frame].state = MEYE_BUF_USING;
1009 kfifo_put(meye.grabq, (unsigned char *)&vm->frame, sizeof(int)); 1009 kfifo_put(meye.grabq, (unsigned char *)&vm->frame, sizeof(int));
1010 up(&meye.lock); 1010 mutex_unlock(&meye.lock);
1011 break; 1011 break;
1012 } 1012 }
1013 1013
@@ -1039,7 +1039,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1039 return -EINVAL; 1039 return -EINVAL;
1040 if (jp->framerate > 31) 1040 if (jp->framerate > 31)
1041 return -EINVAL; 1041 return -EINVAL;
1042 down(&meye.lock); 1042 mutex_lock(&meye.lock);
1043 if (meye.params.subsample != jp->subsample || 1043 if (meye.params.subsample != jp->subsample ||
1044 meye.params.quality != jp->quality) 1044 meye.params.quality != jp->quality)
1045 mchip_hic_stop(); /* need restart */ 1045 mchip_hic_stop(); /* need restart */
@@ -1050,7 +1050,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1050 meye.params.agc); 1050 meye.params.agc);
1051 sonypi_camera_command(SONYPI_COMMAND_SETCAMERAPICTURE, 1051 sonypi_camera_command(SONYPI_COMMAND_SETCAMERAPICTURE,
1052 meye.params.picture); 1052 meye.params.picture);
1053 up(&meye.lock); 1053 mutex_unlock(&meye.lock);
1054 break; 1054 break;
1055 } 1055 }
1056 1056
@@ -1068,12 +1068,12 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1068 } 1068 }
1069 if (meye.grab_buffer[*nb].state != MEYE_BUF_UNUSED) 1069 if (meye.grab_buffer[*nb].state != MEYE_BUF_UNUSED)
1070 return -EBUSY; 1070 return -EBUSY;
1071 down(&meye.lock); 1071 mutex_lock(&meye.lock);
1072 if (meye.mchip_mode != MCHIP_HIC_MODE_CONT_COMP) 1072 if (meye.mchip_mode != MCHIP_HIC_MODE_CONT_COMP)
1073 mchip_cont_compression_start(); 1073 mchip_cont_compression_start();
1074 meye.grab_buffer[*nb].state = MEYE_BUF_USING; 1074 meye.grab_buffer[*nb].state = MEYE_BUF_USING;
1075 kfifo_put(meye.grabq, (unsigned char *)nb, sizeof(int)); 1075 kfifo_put(meye.grabq, (unsigned char *)nb, sizeof(int));
1076 up(&meye.lock); 1076 mutex_unlock(&meye.lock);
1077 break; 1077 break;
1078 } 1078 }
1079 1079
@@ -1084,20 +1084,20 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1084 if (*i < 0 || *i >= gbuffers) 1084 if (*i < 0 || *i >= gbuffers)
1085 return -EINVAL; 1085 return -EINVAL;
1086 1086
1087 down(&meye.lock); 1087 mutex_lock(&meye.lock);
1088 switch (meye.grab_buffer[*i].state) { 1088 switch (meye.grab_buffer[*i].state) {
1089 1089
1090 case MEYE_BUF_UNUSED: 1090 case MEYE_BUF_UNUSED:
1091 up(&meye.lock); 1091 mutex_unlock(&meye.lock);
1092 return -EINVAL; 1092 return -EINVAL;
1093 case MEYE_BUF_USING: 1093 case MEYE_BUF_USING:
1094 if (file->f_flags & O_NONBLOCK) { 1094 if (file->f_flags & O_NONBLOCK) {
1095 up(&meye.lock); 1095 mutex_unlock(&meye.lock);
1096 return -EAGAIN; 1096 return -EAGAIN;
1097 } 1097 }
1098 if (wait_event_interruptible(meye.proc_list, 1098 if (wait_event_interruptible(meye.proc_list,
1099 (meye.grab_buffer[*i].state != MEYE_BUF_USING))) { 1099 (meye.grab_buffer[*i].state != MEYE_BUF_USING))) {
1100 up(&meye.lock); 1100 mutex_unlock(&meye.lock);
1101 return -EINTR; 1101 return -EINTR;
1102 } 1102 }
1103 /* fall through */ 1103 /* fall through */
@@ -1106,7 +1106,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1106 kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int)); 1106 kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int));
1107 } 1107 }
1108 *i = meye.grab_buffer[*i].size; 1108 *i = meye.grab_buffer[*i].size;
1109 up(&meye.lock); 1109 mutex_unlock(&meye.lock);
1110 break; 1110 break;
1111 } 1111 }
1112 1112
@@ -1116,14 +1116,14 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1116 return -EINVAL; 1116 return -EINVAL;
1117 if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED) 1117 if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED)
1118 return -EBUSY; 1118 return -EBUSY;
1119 down(&meye.lock); 1119 mutex_lock(&meye.lock);
1120 meye.grab_buffer[0].state = MEYE_BUF_USING; 1120 meye.grab_buffer[0].state = MEYE_BUF_USING;
1121 mchip_take_picture(); 1121 mchip_take_picture();
1122 mchip_get_picture( 1122 mchip_get_picture(
1123 meye.grab_fbuffer, 1123 meye.grab_fbuffer,
1124 mchip_hsize() * mchip_vsize() * 2); 1124 mchip_hsize() * mchip_vsize() * 2);
1125 meye.grab_buffer[0].state = MEYE_BUF_DONE; 1125 meye.grab_buffer[0].state = MEYE_BUF_DONE;
1126 up(&meye.lock); 1126 mutex_unlock(&meye.lock);
1127 break; 1127 break;
1128 } 1128 }
1129 1129
@@ -1134,7 +1134,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1134 return -EINVAL; 1134 return -EINVAL;
1135 if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED) 1135 if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED)
1136 return -EBUSY; 1136 return -EBUSY;
1137 down(&meye.lock); 1137 mutex_lock(&meye.lock);
1138 meye.grab_buffer[0].state = MEYE_BUF_USING; 1138 meye.grab_buffer[0].state = MEYE_BUF_USING;
1139 *len = -1; 1139 *len = -1;
1140 while (*len == -1) { 1140 while (*len == -1) {
@@ -1142,7 +1142,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1142 *len = mchip_compress_frame(meye.grab_fbuffer, gbufsize); 1142 *len = mchip_compress_frame(meye.grab_fbuffer, gbufsize);
1143 } 1143 }
1144 meye.grab_buffer[0].state = MEYE_BUF_DONE; 1144 meye.grab_buffer[0].state = MEYE_BUF_DONE;
1145 up(&meye.lock); 1145 mutex_unlock(&meye.lock);
1146 break; 1146 break;
1147 } 1147 }
1148 1148
@@ -1285,7 +1285,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1285 case VIDIOC_S_CTRL: { 1285 case VIDIOC_S_CTRL: {
1286 struct v4l2_control *c = arg; 1286 struct v4l2_control *c = arg;
1287 1287
1288 down(&meye.lock); 1288 mutex_lock(&meye.lock);
1289 switch (c->id) { 1289 switch (c->id) {
1290 case V4L2_CID_BRIGHTNESS: 1290 case V4L2_CID_BRIGHTNESS:
1291 sonypi_camera_command( 1291 sonypi_camera_command(
@@ -1329,17 +1329,17 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1329 meye.params.framerate = c->value; 1329 meye.params.framerate = c->value;
1330 break; 1330 break;
1331 default: 1331 default:
1332 up(&meye.lock); 1332 mutex_unlock(&meye.lock);
1333 return -EINVAL; 1333 return -EINVAL;
1334 } 1334 }
1335 up(&meye.lock); 1335 mutex_unlock(&meye.lock);
1336 break; 1336 break;
1337 } 1337 }
1338 1338
1339 case VIDIOC_G_CTRL: { 1339 case VIDIOC_G_CTRL: {
1340 struct v4l2_control *c = arg; 1340 struct v4l2_control *c = arg;
1341 1341
1342 down(&meye.lock); 1342 mutex_lock(&meye.lock);
1343 switch (c->id) { 1343 switch (c->id) {
1344 case V4L2_CID_BRIGHTNESS: 1344 case V4L2_CID_BRIGHTNESS:
1345 c->value = meye.picture.brightness >> 10; 1345 c->value = meye.picture.brightness >> 10;
@@ -1369,10 +1369,10 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1369 c->value = meye.params.framerate; 1369 c->value = meye.params.framerate;
1370 break; 1370 break;
1371 default: 1371 default:
1372 up(&meye.lock); 1372 mutex_unlock(&meye.lock);
1373 return -EINVAL; 1373 return -EINVAL;
1374 } 1374 }
1375 up(&meye.lock); 1375 mutex_unlock(&meye.lock);
1376 break; 1376 break;
1377 } 1377 }
1378 1378
@@ -1469,7 +1469,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1469 f->fmt.pix.field != V4L2_FIELD_NONE) 1469 f->fmt.pix.field != V4L2_FIELD_NONE)
1470 return -EINVAL; 1470 return -EINVAL;
1471 f->fmt.pix.field = V4L2_FIELD_NONE; 1471 f->fmt.pix.field = V4L2_FIELD_NONE;
1472 down(&meye.lock); 1472 mutex_lock(&meye.lock);
1473 if (f->fmt.pix.width <= 320) { 1473 if (f->fmt.pix.width <= 320) {
1474 f->fmt.pix.width = 320; 1474 f->fmt.pix.width = 320;
1475 f->fmt.pix.height = 240; 1475 f->fmt.pix.height = 240;
@@ -1487,7 +1487,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1487 meye.mchip_mode = MCHIP_HIC_MODE_CONT_COMP; 1487 meye.mchip_mode = MCHIP_HIC_MODE_CONT_COMP;
1488 break; 1488 break;
1489 } 1489 }
1490 up(&meye.lock); 1490 mutex_unlock(&meye.lock);
1491 f->fmt.pix.bytesperline = f->fmt.pix.width * 2; 1491 f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
1492 f->fmt.pix.sizeimage = f->fmt.pix.height * 1492 f->fmt.pix.sizeimage = f->fmt.pix.height *
1493 f->fmt.pix.bytesperline; 1493 f->fmt.pix.bytesperline;
@@ -1509,11 +1509,11 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1509 /* already allocated, no modifications */ 1509 /* already allocated, no modifications */
1510 break; 1510 break;
1511 } 1511 }
1512 down(&meye.lock); 1512 mutex_lock(&meye.lock);
1513 if (meye.grab_fbuffer) { 1513 if (meye.grab_fbuffer) {
1514 for (i = 0; i < gbuffers; i++) 1514 for (i = 0; i < gbuffers; i++)
1515 if (meye.vma_use_count[i]) { 1515 if (meye.vma_use_count[i]) {
1516 up(&meye.lock); 1516 mutex_unlock(&meye.lock);
1517 return -EINVAL; 1517 return -EINVAL;
1518 } 1518 }
1519 rvfree(meye.grab_fbuffer, gbuffers * gbufsize); 1519 rvfree(meye.grab_fbuffer, gbuffers * gbufsize);
@@ -1525,12 +1525,12 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1525 if (!meye.grab_fbuffer) { 1525 if (!meye.grab_fbuffer) {
1526 printk(KERN_ERR "meye: v4l framebuffer allocation" 1526 printk(KERN_ERR "meye: v4l framebuffer allocation"
1527 " failed\n"); 1527 " failed\n");
1528 up(&meye.lock); 1528 mutex_unlock(&meye.lock);
1529 return -ENOMEM; 1529 return -ENOMEM;
1530 } 1530 }
1531 for (i = 0; i < gbuffers; i++) 1531 for (i = 0; i < gbuffers; i++)
1532 meye.vma_use_count[i] = 0; 1532 meye.vma_use_count[i] = 0;
1533 up(&meye.lock); 1533 mutex_unlock(&meye.lock);
1534 break; 1534 break;
1535 } 1535 }
1536 1536
@@ -1569,12 +1569,12 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1569 return -EINVAL; 1569 return -EINVAL;
1570 if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED) 1570 if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED)
1571 return -EINVAL; 1571 return -EINVAL;
1572 down(&meye.lock); 1572 mutex_lock(&meye.lock);
1573 buf->flags |= V4L2_BUF_FLAG_QUEUED; 1573 buf->flags |= V4L2_BUF_FLAG_QUEUED;
1574 buf->flags &= ~V4L2_BUF_FLAG_DONE; 1574 buf->flags &= ~V4L2_BUF_FLAG_DONE;
1575 meye.grab_buffer[buf->index].state = MEYE_BUF_USING; 1575 meye.grab_buffer[buf->index].state = MEYE_BUF_USING;
1576 kfifo_put(meye.grabq, (unsigned char *)&buf->index, sizeof(int)); 1576 kfifo_put(meye.grabq, (unsigned char *)&buf->index, sizeof(int));
1577 up(&meye.lock); 1577 mutex_unlock(&meye.lock);
1578 break; 1578 break;
1579 } 1579 }
1580 1580
@@ -1587,23 +1587,23 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1587 if (buf->memory != V4L2_MEMORY_MMAP) 1587 if (buf->memory != V4L2_MEMORY_MMAP)
1588 return -EINVAL; 1588 return -EINVAL;
1589 1589
1590 down(&meye.lock); 1590 mutex_lock(&meye.lock);
1591 if (kfifo_len(meye.doneq) == 0 && file->f_flags & O_NONBLOCK) { 1591 if (kfifo_len(meye.doneq) == 0 && file->f_flags & O_NONBLOCK) {
1592 up(&meye.lock); 1592 mutex_unlock(&meye.lock);
1593 return -EAGAIN; 1593 return -EAGAIN;
1594 } 1594 }
1595 if (wait_event_interruptible(meye.proc_list, 1595 if (wait_event_interruptible(meye.proc_list,
1596 kfifo_len(meye.doneq) != 0) < 0) { 1596 kfifo_len(meye.doneq) != 0) < 0) {
1597 up(&meye.lock); 1597 mutex_unlock(&meye.lock);
1598 return -EINTR; 1598 return -EINTR;
1599 } 1599 }
1600 if (!kfifo_get(meye.doneq, (unsigned char *)&reqnr, 1600 if (!kfifo_get(meye.doneq, (unsigned char *)&reqnr,
1601 sizeof(int))) { 1601 sizeof(int))) {
1602 up(&meye.lock); 1602 mutex_unlock(&meye.lock);
1603 return -EBUSY; 1603 return -EBUSY;
1604 } 1604 }
1605 if (meye.grab_buffer[reqnr].state != MEYE_BUF_DONE) { 1605 if (meye.grab_buffer[reqnr].state != MEYE_BUF_DONE) {
1606 up(&meye.lock); 1606 mutex_unlock(&meye.lock);
1607 return -EINVAL; 1607 return -EINVAL;
1608 } 1608 }
1609 buf->index = reqnr; 1609 buf->index = reqnr;
@@ -1616,12 +1616,12 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1616 buf->m.offset = reqnr * gbufsize; 1616 buf->m.offset = reqnr * gbufsize;
1617 buf->length = gbufsize; 1617 buf->length = gbufsize;
1618 meye.grab_buffer[reqnr].state = MEYE_BUF_UNUSED; 1618 meye.grab_buffer[reqnr].state = MEYE_BUF_UNUSED;
1619 up(&meye.lock); 1619 mutex_unlock(&meye.lock);
1620 break; 1620 break;
1621 } 1621 }
1622 1622
1623 case VIDIOC_STREAMON: { 1623 case VIDIOC_STREAMON: {
1624 down(&meye.lock); 1624 mutex_lock(&meye.lock);
1625 switch (meye.mchip_mode) { 1625 switch (meye.mchip_mode) {
1626 case MCHIP_HIC_MODE_CONT_OUT: 1626 case MCHIP_HIC_MODE_CONT_OUT:
1627 mchip_continuous_start(); 1627 mchip_continuous_start();
@@ -1630,23 +1630,23 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
1630 mchip_cont_compression_start(); 1630 mchip_cont_compression_start();
1631 break; 1631 break;
1632 default: 1632 default:
1633 up(&meye.lock); 1633 mutex_unlock(&meye.lock);
1634 return -EINVAL; 1634 return -EINVAL;
1635 } 1635 }
1636 up(&meye.lock); 1636 mutex_unlock(&meye.lock);
1637 break; 1637 break;
1638 } 1638 }
1639 1639
1640 case VIDIOC_STREAMOFF: { 1640 case VIDIOC_STREAMOFF: {
1641 int i; 1641 int i;
1642 1642
1643 down(&meye.lock); 1643 mutex_lock(&meye.lock);
1644 mchip_hic_stop(); 1644 mchip_hic_stop();
1645 kfifo_reset(meye.grabq); 1645 kfifo_reset(meye.grabq);
1646 kfifo_reset(meye.doneq); 1646 kfifo_reset(meye.doneq);
1647 for (i = 0; i < MEYE_MAX_BUFNBRS; i++) 1647 for (i = 0; i < MEYE_MAX_BUFNBRS; i++)
1648 meye.grab_buffer[i].state = MEYE_BUF_UNUSED; 1648 meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
1649 up(&meye.lock); 1649 mutex_unlock(&meye.lock);
1650 break; 1650 break;
1651 } 1651 }
1652 1652
@@ -1672,11 +1672,11 @@ static unsigned int meye_poll(struct file *file, poll_table *wait)
1672{ 1672{
1673 unsigned int res = 0; 1673 unsigned int res = 0;
1674 1674
1675 down(&meye.lock); 1675 mutex_lock(&meye.lock);
1676 poll_wait(file, &meye.proc_list, wait); 1676 poll_wait(file, &meye.proc_list, wait);
1677 if (kfifo_len(meye.doneq)) 1677 if (kfifo_len(meye.doneq))
1678 res = POLLIN | POLLRDNORM; 1678 res = POLLIN | POLLRDNORM;
1679 up(&meye.lock); 1679 mutex_unlock(&meye.lock);
1680 return res; 1680 return res;
1681} 1681}
1682 1682
@@ -1704,9 +1704,9 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma)
1704 unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; 1704 unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
1705 unsigned long page, pos; 1705 unsigned long page, pos;
1706 1706
1707 down(&meye.lock); 1707 mutex_lock(&meye.lock);
1708 if (size > gbuffers * gbufsize) { 1708 if (size > gbuffers * gbufsize) {
1709 up(&meye.lock); 1709 mutex_unlock(&meye.lock);
1710 return -EINVAL; 1710 return -EINVAL;
1711 } 1711 }
1712 if (!meye.grab_fbuffer) { 1712 if (!meye.grab_fbuffer) {
@@ -1716,7 +1716,7 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma)
1716 meye.grab_fbuffer = rvmalloc(gbuffers*gbufsize); 1716 meye.grab_fbuffer = rvmalloc(gbuffers*gbufsize);
1717 if (!meye.grab_fbuffer) { 1717 if (!meye.grab_fbuffer) {
1718 printk(KERN_ERR "meye: v4l framebuffer allocation failed\n"); 1718 printk(KERN_ERR "meye: v4l framebuffer allocation failed\n");
1719 up(&meye.lock); 1719 mutex_unlock(&meye.lock);
1720 return -ENOMEM; 1720 return -ENOMEM;
1721 } 1721 }
1722 for (i = 0; i < gbuffers; i++) 1722 for (i = 0; i < gbuffers; i++)
@@ -1727,7 +1727,7 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma)
1727 while (size > 0) { 1727 while (size > 0) {
1728 page = vmalloc_to_pfn((void *)pos); 1728 page = vmalloc_to_pfn((void *)pos);
1729 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { 1729 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
1730 up(&meye.lock); 1730 mutex_unlock(&meye.lock);
1731 return -EAGAIN; 1731 return -EAGAIN;
1732 } 1732 }
1733 start += PAGE_SIZE; 1733 start += PAGE_SIZE;
@@ -1744,7 +1744,7 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma)
1744 vma->vm_private_data = (void *) (offset / gbufsize); 1744 vma->vm_private_data = (void *) (offset / gbufsize);
1745 meye_vm_open(vma); 1745 meye_vm_open(vma);
1746 1746
1747 up(&meye.lock); 1747 mutex_unlock(&meye.lock);
1748 return 0; 1748 return 0;
1749} 1749}
1750 1750
@@ -1913,7 +1913,7 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
1913 goto outvideoreg; 1913 goto outvideoreg;
1914 } 1914 }
1915 1915
1916 init_MUTEX(&meye.lock); 1916 mutex_init(&meye.lock);
1917 init_waitqueue_head(&meye.proc_list); 1917 init_waitqueue_head(&meye.proc_list);
1918 meye.picture.depth = 16; 1918 meye.picture.depth = 16;
1919 meye.picture.palette = VIDEO_PALETTE_YUV422; 1919 meye.picture.palette = VIDEO_PALETTE_YUV422;
diff --git a/drivers/media/video/meye.h b/drivers/media/video/meye.h
index e8cd897b0d20..0d09a0e3803c 100644
--- a/drivers/media/video/meye.h
+++ b/drivers/media/video/meye.h
@@ -260,6 +260,8 @@
260 260
261/* private API definitions */ 261/* private API definitions */
262#include <linux/meye.h> 262#include <linux/meye.h>
263#include <linux/mutex.h>
264
263 265
264/* Enable jpg software correction */ 266/* Enable jpg software correction */
265#define MEYE_JPEG_CORRECTION 1 267#define MEYE_JPEG_CORRECTION 1
@@ -301,7 +303,7 @@ struct meye {
301 /* list of buffers */ 303 /* list of buffers */
302 struct meye_grab_buffer grab_buffer[MEYE_MAX_BUFNBRS]; 304 struct meye_grab_buffer grab_buffer[MEYE_MAX_BUFNBRS];
303 int vma_use_count[MEYE_MAX_BUFNBRS]; /* mmap count */ 305 int vma_use_count[MEYE_MAX_BUFNBRS]; /* mmap count */
304 struct semaphore lock; /* semaphore for open/mmap... */ 306 struct mutex lock; /* mutex for open/mmap... */
305 struct kfifo *grabq; /* queue for buffers to be grabbed */ 307 struct kfifo *grabq; /* queue for buffers to be grabbed */
306 spinlock_t grabq_lock; /* lock protecting the queue */ 308 spinlock_t grabq_lock; /* lock protecting the queue */
307 struct kfifo *doneq; /* queue for grabbed buffers */ 309 struct kfifo *doneq; /* queue for grabbed buffers */
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 8416ceff524b..69a7eddf3a24 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -625,9 +625,9 @@ static int mxb_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
625 } 625 }
626 626
627 /* fixme: locke das setzen des inputs mit hilfe des mutexes 627 /* fixme: locke das setzen des inputs mit hilfe des mutexes
628 down(&dev->lock); 628 mutex_lock(&dev->lock);
629 video_mux(dev,*i); 629 video_mux(dev,*i);
630 up(&dev->lock); 630 mutex_unlock(&dev->lock);
631 */ 631 */
632 632
633 /* fixme: check if streaming capture 633 /* fixme: check if streaming capture
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c
index f3fc361bec97..15fd85acabda 100644
--- a/drivers/media/video/planb.c
+++ b/drivers/media/video/planb.c
@@ -48,7 +48,7 @@
48#include <asm/pgtable.h> 48#include <asm/pgtable.h>
49#include <asm/page.h> 49#include <asm/page.h>
50#include <asm/irq.h> 50#include <asm/irq.h>
51#include <asm/semaphore.h> 51#include <linux/mutex.h>
52 52
53#include "planb.h" 53#include "planb.h"
54#include "saa7196.h" 54#include "saa7196.h"
@@ -329,12 +329,12 @@ static volatile struct dbdma_cmd *cmd_geo_setup(
329 329
330static inline void planb_lock(struct planb *pb) 330static inline void planb_lock(struct planb *pb)
331{ 331{
332 down(&pb->lock); 332 mutex_lock(&pb->lock);
333} 333}
334 334
335static inline void planb_unlock(struct planb *pb) 335static inline void planb_unlock(struct planb *pb)
336{ 336{
337 up(&pb->lock); 337 mutex_unlock(&pb->lock);
338} 338}
339 339
340/***************/ 340/***************/
@@ -2067,7 +2067,7 @@ static int init_planb(struct planb *pb)
2067#endif 2067#endif
2068 pb->tab_size = PLANB_MAXLINES + 40; 2068 pb->tab_size = PLANB_MAXLINES + 40;
2069 pb->suspend = 0; 2069 pb->suspend = 0;
2070 init_MUTEX(&pb->lock); 2070 mutex_init(&pb->lock);
2071 pb->ch1_cmd = 0; 2071 pb->ch1_cmd = 0;
2072 pb->ch2_cmd = 0; 2072 pb->ch2_cmd = 0;
2073 pb->mask = 0; 2073 pb->mask = 0;
diff --git a/drivers/media/video/planb.h b/drivers/media/video/planb.h
index 8a0faad16118..79b6b561426e 100644
--- a/drivers/media/video/planb.h
+++ b/drivers/media/video/planb.h
@@ -174,7 +174,7 @@ struct planb {
174 int user; 174 int user;
175 unsigned int tab_size; 175 unsigned int tab_size;
176 int maxlines; 176 int maxlines;
177 struct semaphore lock; 177 struct mutex lock;
178 unsigned int irq; /* interrupt number */ 178 unsigned int irq; /* interrupt number */
179 volatile unsigned int intr_mask; 179 volatile unsigned int intr_mask;
180 180
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 9e6448639480..05ca55939e77 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -30,6 +30,8 @@
30#include <asm/io.h> 30#include <asm/io.h>
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/videodev.h> 32#include <linux/videodev.h>
33#include <linux/mutex.h>
34
33#include <asm/uaccess.h> 35#include <asm/uaccess.h>
34 36
35 37
@@ -44,7 +46,7 @@ struct pms_device
44 struct video_picture picture; 46 struct video_picture picture;
45 int height; 47 int height;
46 int width; 48 int width;
47 struct semaphore lock; 49 struct mutex lock;
48}; 50};
49 51
50struct i2c_info 52struct i2c_info
@@ -724,10 +726,10 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
724 struct video_channel *v = arg; 726 struct video_channel *v = arg;
725 if(v->channel<0 || v->channel>3) 727 if(v->channel<0 || v->channel>3)
726 return -EINVAL; 728 return -EINVAL;
727 down(&pd->lock); 729 mutex_lock(&pd->lock);
728 pms_videosource(v->channel&1); 730 pms_videosource(v->channel&1);
729 pms_vcrinput(v->channel>>1); 731 pms_vcrinput(v->channel>>1);
730 up(&pd->lock); 732 mutex_unlock(&pd->lock);
731 return 0; 733 return 0;
732 } 734 }
733 case VIDIOCGTUNER: 735 case VIDIOCGTUNER:
@@ -761,7 +763,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
761 struct video_tuner *v = arg; 763 struct video_tuner *v = arg;
762 if(v->tuner) 764 if(v->tuner)
763 return -EINVAL; 765 return -EINVAL;
764 down(&pd->lock); 766 mutex_lock(&pd->lock);
765 switch(v->mode) 767 switch(v->mode)
766 { 768 {
767 case VIDEO_MODE_AUTO: 769 case VIDEO_MODE_AUTO:
@@ -785,10 +787,10 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
785 pms_format(2); 787 pms_format(2);
786 break; 788 break;
787 default: 789 default:
788 up(&pd->lock); 790 mutex_unlock(&pd->lock);
789 return -EINVAL; 791 return -EINVAL;
790 } 792 }
791 up(&pd->lock); 793 mutex_unlock(&pd->lock);
792 return 0; 794 return 0;
793 } 795 }
794 case VIDIOCGPICT: 796 case VIDIOCGPICT:
@@ -809,12 +811,12 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
809 * Now load the card. 811 * Now load the card.
810 */ 812 */
811 813
812 down(&pd->lock); 814 mutex_lock(&pd->lock);
813 pms_brightness(p->brightness>>8); 815 pms_brightness(p->brightness>>8);
814 pms_hue(p->hue>>8); 816 pms_hue(p->hue>>8);
815 pms_colour(p->colour>>8); 817 pms_colour(p->colour>>8);
816 pms_contrast(p->contrast>>8); 818 pms_contrast(p->contrast>>8);
817 up(&pd->lock); 819 mutex_unlock(&pd->lock);
818 return 0; 820 return 0;
819 } 821 }
820 case VIDIOCSWIN: 822 case VIDIOCSWIN:
@@ -830,9 +832,9 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
830 return -EINVAL; 832 return -EINVAL;
831 pd->width=vw->width; 833 pd->width=vw->width;
832 pd->height=vw->height; 834 pd->height=vw->height;
833 down(&pd->lock); 835 mutex_lock(&pd->lock);
834 pms_resolution(pd->width, pd->height); 836 pms_resolution(pd->width, pd->height);
835 up(&pd->lock); /* Ok we figured out what to use from our wide choice */ 837 mutex_unlock(&pd->lock); /* Ok we figured out what to use from our wide choice */
836 return 0; 838 return 0;
837 } 839 }
838 case VIDIOCGWIN: 840 case VIDIOCGWIN:
@@ -872,9 +874,9 @@ static ssize_t pms_read(struct file *file, char __user *buf,
872 struct pms_device *pd=(struct pms_device *)v; 874 struct pms_device *pd=(struct pms_device *)v;
873 int len; 875 int len;
874 876
875 down(&pd->lock); 877 mutex_lock(&pd->lock);
876 len=pms_capture(pd, buf, (pd->picture.depth==16)?0:1,count); 878 len=pms_capture(pd, buf, (pd->picture.depth==16)?0:1,count);
877 up(&pd->lock); 879 mutex_unlock(&pd->lock);
878 return len; 880 return len;
879} 881}
880 882
@@ -1029,7 +1031,7 @@ static int __init init_pms_cards(void)
1029 return -ENODEV; 1031 return -ENODEV;
1030 } 1032 }
1031 memcpy(&pms_device, &pms_template, sizeof(pms_template)); 1033 memcpy(&pms_device, &pms_template, sizeof(pms_template));
1032 init_MUTEX(&pms_device.lock); 1034 mutex_init(&pms_device.lock);
1033 pms_device.height=240; 1035 pms_device.height=240;
1034 pms_device.width=320; 1036 pms_device.width=320;
1035 pms_swsense(75); 1037 pms_swsense(75);
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index 2ce010201308..dd830e0e5e96 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -46,6 +46,8 @@
46#include <linux/i2c.h> 46#include <linux/i2c.h>
47#include <linux/videotext.h> 47#include <linux/videotext.h>
48#include <linux/videodev.h> 48#include <linux/videodev.h>
49#include <linux/mutex.h>
50
49#include "saa5246a.h" 51#include "saa5246a.h"
50 52
51MODULE_AUTHOR("Michael Geng <linux@MichaelGeng.de>"); 53MODULE_AUTHOR("Michael Geng <linux@MichaelGeng.de>");
@@ -57,7 +59,7 @@ struct saa5246a_device
57 u8 pgbuf[NUM_DAUS][VTX_VIRTUALSIZE]; 59 u8 pgbuf[NUM_DAUS][VTX_VIRTUALSIZE];
58 int is_searching[NUM_DAUS]; 60 int is_searching[NUM_DAUS];
59 struct i2c_client *client; 61 struct i2c_client *client;
60 struct semaphore lock; 62 struct mutex lock;
61}; 63};
62 64
63static struct video_device saa_template; /* Declared near bottom */ 65static struct video_device saa_template; /* Declared near bottom */
@@ -90,7 +92,7 @@ static int saa5246a_attach(struct i2c_adapter *adap, int addr, int kind)
90 return -ENOMEM; 92 return -ENOMEM;
91 } 93 }
92 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); 94 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE);
93 init_MUTEX(&t->lock); 95 mutex_init(&t->lock);
94 96
95 /* 97 /*
96 * Now create a video4linux device 98 * Now create a video4linux device
@@ -719,9 +721,9 @@ static int saa5246a_ioctl(struct inode *inode, struct file *file,
719 int err; 721 int err;
720 722
721 cmd = vtx_fix_command(cmd); 723 cmd = vtx_fix_command(cmd);
722 down(&t->lock); 724 mutex_lock(&t->lock);
723 err = video_usercopy(inode, file, cmd, arg, do_saa5246a_ioctl); 725 err = video_usercopy(inode, file, cmd, arg, do_saa5246a_ioctl);
724 up(&t->lock); 726 mutex_unlock(&t->lock);
725 return err; 727 return err;
726} 728}
727 729
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 5694eb58c3a1..a9f3cf0b1e3c 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -56,6 +56,8 @@
56#include <linux/i2c.h> 56#include <linux/i2c.h>
57#include <linux/videotext.h> 57#include <linux/videotext.h>
58#include <linux/videodev.h> 58#include <linux/videodev.h>
59#include <linux/mutex.h>
60
59 61
60#include <asm/io.h> 62#include <asm/io.h>
61#include <asm/uaccess.h> 63#include <asm/uaccess.h>
@@ -105,7 +107,7 @@ struct saa5249_device
105 int disp_mode; 107 int disp_mode;
106 int virtual_mode; 108 int virtual_mode;
107 struct i2c_client *client; 109 struct i2c_client *client;
108 struct semaphore lock; 110 struct mutex lock;
109}; 111};
110 112
111 113
@@ -158,7 +160,7 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
158 return -ENOMEM; 160 return -ENOMEM;
159 } 161 }
160 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); 162 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE);
161 init_MUTEX(&t->lock); 163 mutex_init(&t->lock);
162 164
163 /* 165 /*
164 * Now create a video4linux device 166 * Now create a video4linux device
@@ -619,9 +621,9 @@ static int saa5249_ioctl(struct inode *inode, struct file *file,
619 int err; 621 int err;
620 622
621 cmd = vtx_fix_command(cmd); 623 cmd = vtx_fix_command(cmd);
622 down(&t->lock); 624 mutex_lock(&t->lock);
623 err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl); 625 err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl);
624 up(&t->lock); 626 mutex_unlock(&t->lock);
625 return err; 627 return err;
626} 628}
627 629
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index a7a6ab9298a9..d3c7345a5d22 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -609,12 +609,12 @@ static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream)
609 struct saa7134_dev *dev = saa7134->dev; 609 struct saa7134_dev *dev = saa7134->dev;
610 int err; 610 int err;
611 611
612 down(&dev->dmasound.lock); 612 mutex_lock(&dev->dmasound.lock);
613 613
614 dev->dmasound.read_count = 0; 614 dev->dmasound.read_count = 0;
615 dev->dmasound.read_offset = 0; 615 dev->dmasound.read_offset = 0;
616 616
617 up(&dev->dmasound.lock); 617 mutex_unlock(&dev->dmasound.lock);
618 618
619 pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); 619 pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
620 if (pcm == NULL) 620 if (pcm == NULL)
@@ -932,7 +932,7 @@ static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
932 932
933 chip->irq = dev->pci->irq; 933 chip->irq = dev->pci->irq;
934 934
935 init_MUTEX(&dev->dmasound.lock); 935 mutex_init(&dev->dmasound.lock);
936 936
937 if ((err = snd_card_saa7134_new_mixer(chip)) < 0) 937 if ((err = snd_card_saa7134_new_mixer(chip)) < 0)
938 goto __nodev; 938 goto __nodev;
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 028904bd94a2..e7c30665739e 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -613,7 +613,7 @@ static int saa7134_hwinit1(struct saa7134_dev *dev)
613 613
614 saa_writel(SAA7134_IRQ1, 0); 614 saa_writel(SAA7134_IRQ1, 0);
615 saa_writel(SAA7134_IRQ2, 0); 615 saa_writel(SAA7134_IRQ2, 0);
616 init_MUTEX(&dev->lock); 616 mutex_init(&dev->lock);
617 spin_lock_init(&dev->slock); 617 spin_lock_init(&dev->slock);
618 618
619 saa7134_track_gpio(dev,"pre-init"); 619 saa7134_track_gpio(dev,"pre-init");
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index bd4c389d4c37..1d972edb3be6 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -89,7 +89,7 @@ static int ts_open(struct inode *inode, struct file *file)
89 89
90 dprintk("open minor=%d\n",minor); 90 dprintk("open minor=%d\n",minor);
91 err = -EBUSY; 91 err = -EBUSY;
92 if (down_trylock(&dev->empress_tsq.lock)) 92 if (!mutex_trylock(&dev->empress_tsq.lock))
93 goto done; 93 goto done;
94 if (dev->empress_users) 94 if (dev->empress_users)
95 goto done_up; 95 goto done_up;
@@ -99,7 +99,7 @@ static int ts_open(struct inode *inode, struct file *file)
99 err = 0; 99 err = 0;
100 100
101done_up: 101done_up:
102 up(&dev->empress_tsq.lock); 102 mutex_unlock(&dev->empress_tsq.lock);
103done: 103done:
104 return err; 104 return err;
105} 105}
@@ -110,7 +110,7 @@ static int ts_release(struct inode *inode, struct file *file)
110 110
111 if (dev->empress_tsq.streaming) 111 if (dev->empress_tsq.streaming)
112 videobuf_streamoff(&dev->empress_tsq); 112 videobuf_streamoff(&dev->empress_tsq);
113 down(&dev->empress_tsq.lock); 113 mutex_lock(&dev->empress_tsq.lock);
114 if (dev->empress_tsq.reading) 114 if (dev->empress_tsq.reading)
115 videobuf_read_stop(&dev->empress_tsq); 115 videobuf_read_stop(&dev->empress_tsq);
116 videobuf_mmap_free(&dev->empress_tsq); 116 videobuf_mmap_free(&dev->empress_tsq);
@@ -119,7 +119,7 @@ static int ts_release(struct inode *inode, struct file *file)
119 /* stop the encoder */ 119 /* stop the encoder */
120 ts_reset_encoder(dev); 120 ts_reset_encoder(dev);
121 121
122 up(&dev->empress_tsq.lock); 122 mutex_unlock(&dev->empress_tsq.lock);
123 return 0; 123 return 0;
124} 124}
125 125
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index 7448e386a804..80e34a5fdcc5 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -254,7 +254,7 @@ static int dsp_open(struct inode *inode, struct file *file)
254 if (NULL == dev) 254 if (NULL == dev)
255 return -ENODEV; 255 return -ENODEV;
256 256
257 down(&dev->dmasound.lock); 257 mutex_lock(&dev->dmasound.lock);
258 err = -EBUSY; 258 err = -EBUSY;
259 if (dev->dmasound.users_dsp) 259 if (dev->dmasound.users_dsp)
260 goto fail1; 260 goto fail1;
@@ -270,13 +270,13 @@ static int dsp_open(struct inode *inode, struct file *file)
270 if (0 != err) 270 if (0 != err)
271 goto fail2; 271 goto fail2;
272 272
273 up(&dev->dmasound.lock); 273 mutex_unlock(&dev->dmasound.lock);
274 return 0; 274 return 0;
275 275
276 fail2: 276 fail2:
277 dev->dmasound.users_dsp--; 277 dev->dmasound.users_dsp--;
278 fail1: 278 fail1:
279 up(&dev->dmasound.lock); 279 mutex_unlock(&dev->dmasound.lock);
280 return err; 280 return err;
281} 281}
282 282
@@ -284,13 +284,13 @@ static int dsp_release(struct inode *inode, struct file *file)
284{ 284{
285 struct saa7134_dev *dev = file->private_data; 285 struct saa7134_dev *dev = file->private_data;
286 286
287 down(&dev->dmasound.lock); 287 mutex_lock(&dev->dmasound.lock);
288 if (dev->dmasound.recording_on) 288 if (dev->dmasound.recording_on)
289 dsp_rec_stop(dev); 289 dsp_rec_stop(dev);
290 dsp_buffer_free(dev); 290 dsp_buffer_free(dev);
291 dev->dmasound.users_dsp--; 291 dev->dmasound.users_dsp--;
292 file->private_data = NULL; 292 file->private_data = NULL;
293 up(&dev->dmasound.lock); 293 mutex_unlock(&dev->dmasound.lock);
294 return 0; 294 return 0;
295} 295}
296 296
@@ -304,7 +304,7 @@ static ssize_t dsp_read(struct file *file, char __user *buffer,
304 int err,ret = 0; 304 int err,ret = 0;
305 305
306 add_wait_queue(&dev->dmasound.wq, &wait); 306 add_wait_queue(&dev->dmasound.wq, &wait);
307 down(&dev->dmasound.lock); 307 mutex_lock(&dev->dmasound.lock);
308 while (count > 0) { 308 while (count > 0) {
309 /* wait for data if needed */ 309 /* wait for data if needed */
310 if (0 == dev->dmasound.read_count) { 310 if (0 == dev->dmasound.read_count) {
@@ -328,12 +328,12 @@ static ssize_t dsp_read(struct file *file, char __user *buffer,
328 ret = -EAGAIN; 328 ret = -EAGAIN;
329 break; 329 break;
330 } 330 }
331 up(&dev->dmasound.lock); 331 mutex_unlock(&dev->dmasound.lock);
332 set_current_state(TASK_INTERRUPTIBLE); 332 set_current_state(TASK_INTERRUPTIBLE);
333 if (0 == dev->dmasound.read_count) 333 if (0 == dev->dmasound.read_count)
334 schedule(); 334 schedule();
335 set_current_state(TASK_RUNNING); 335 set_current_state(TASK_RUNNING);
336 down(&dev->dmasound.lock); 336 mutex_lock(&dev->dmasound.lock);
337 if (signal_pending(current)) { 337 if (signal_pending(current)) {
338 if (0 == ret) 338 if (0 == ret)
339 ret = -EINTR; 339 ret = -EINTR;
@@ -362,7 +362,7 @@ static ssize_t dsp_read(struct file *file, char __user *buffer,
362 if (dev->dmasound.read_offset == dev->dmasound.bufsize) 362 if (dev->dmasound.read_offset == dev->dmasound.bufsize)
363 dev->dmasound.read_offset = 0; 363 dev->dmasound.read_offset = 0;
364 } 364 }
365 up(&dev->dmasound.lock); 365 mutex_unlock(&dev->dmasound.lock);
366 remove_wait_queue(&dev->dmasound.wq, &wait); 366 remove_wait_queue(&dev->dmasound.wq, &wait);
367 return ret; 367 return ret;
368} 368}
@@ -435,13 +435,13 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
435 case SNDCTL_DSP_STEREO: 435 case SNDCTL_DSP_STEREO:
436 if (get_user(val, p)) 436 if (get_user(val, p))
437 return -EFAULT; 437 return -EFAULT;
438 down(&dev->dmasound.lock); 438 mutex_lock(&dev->dmasound.lock);
439 dev->dmasound.channels = val ? 2 : 1; 439 dev->dmasound.channels = val ? 2 : 1;
440 if (dev->dmasound.recording_on) { 440 if (dev->dmasound.recording_on) {
441 dsp_rec_stop(dev); 441 dsp_rec_stop(dev);
442 dsp_rec_start(dev); 442 dsp_rec_start(dev);
443 } 443 }
444 up(&dev->dmasound.lock); 444 mutex_unlock(&dev->dmasound.lock);
445 return put_user(dev->dmasound.channels-1, p); 445 return put_user(dev->dmasound.channels-1, p);
446 446
447 case SNDCTL_DSP_CHANNELS: 447 case SNDCTL_DSP_CHANNELS:
@@ -449,13 +449,13 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
449 return -EFAULT; 449 return -EFAULT;
450 if (val != 1 && val != 2) 450 if (val != 1 && val != 2)
451 return -EINVAL; 451 return -EINVAL;
452 down(&dev->dmasound.lock); 452 mutex_lock(&dev->dmasound.lock);
453 dev->dmasound.channels = val; 453 dev->dmasound.channels = val;
454 if (dev->dmasound.recording_on) { 454 if (dev->dmasound.recording_on) {
455 dsp_rec_stop(dev); 455 dsp_rec_stop(dev);
456 dsp_rec_start(dev); 456 dsp_rec_start(dev);
457 } 457 }
458 up(&dev->dmasound.lock); 458 mutex_unlock(&dev->dmasound.lock);
459 /* fall through */ 459 /* fall through */
460 case SOUND_PCM_READ_CHANNELS: 460 case SOUND_PCM_READ_CHANNELS:
461 return put_user(dev->dmasound.channels, p); 461 return put_user(dev->dmasound.channels, p);
@@ -478,13 +478,13 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
478 case AFMT_U16_BE: 478 case AFMT_U16_BE:
479 case AFMT_S16_LE: 479 case AFMT_S16_LE:
480 case AFMT_S16_BE: 480 case AFMT_S16_BE:
481 down(&dev->dmasound.lock); 481 mutex_lock(&dev->dmasound.lock);
482 dev->dmasound.afmt = val; 482 dev->dmasound.afmt = val;
483 if (dev->dmasound.recording_on) { 483 if (dev->dmasound.recording_on) {
484 dsp_rec_stop(dev); 484 dsp_rec_stop(dev);
485 dsp_rec_start(dev); 485 dsp_rec_start(dev);
486 } 486 }
487 up(&dev->dmasound.lock); 487 mutex_unlock(&dev->dmasound.lock);
488 return put_user(dev->dmasound.afmt, p); 488 return put_user(dev->dmasound.afmt, p);
489 default: 489 default:
490 return -EINVAL; 490 return -EINVAL;
@@ -509,10 +509,10 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
509 return 0; 509 return 0;
510 510
511 case SNDCTL_DSP_RESET: 511 case SNDCTL_DSP_RESET:
512 down(&dev->dmasound.lock); 512 mutex_lock(&dev->dmasound.lock);
513 if (dev->dmasound.recording_on) 513 if (dev->dmasound.recording_on)
514 dsp_rec_stop(dev); 514 dsp_rec_stop(dev);
515 up(&dev->dmasound.lock); 515 mutex_unlock(&dev->dmasound.lock);
516 return 0; 516 return 0;
517 case SNDCTL_DSP_GETBLKSIZE: 517 case SNDCTL_DSP_GETBLKSIZE:
518 return put_user(dev->dmasound.blksize, p); 518 return put_user(dev->dmasound.blksize, p);
@@ -556,10 +556,10 @@ static unsigned int dsp_poll(struct file *file, struct poll_table_struct *wait)
556 poll_wait(file, &dev->dmasound.wq, wait); 556 poll_wait(file, &dev->dmasound.wq, wait);
557 557
558 if (0 == dev->dmasound.read_count) { 558 if (0 == dev->dmasound.read_count) {
559 down(&dev->dmasound.lock); 559 mutex_lock(&dev->dmasound.lock);
560 if (!dev->dmasound.recording_on) 560 if (!dev->dmasound.recording_on)
561 dsp_rec_start(dev); 561 dsp_rec_start(dev);
562 up(&dev->dmasound.lock); 562 mutex_unlock(&dev->dmasound.lock);
563 } else 563 } else
564 mask |= (POLLIN | POLLRDNORM); 564 mask |= (POLLIN | POLLRDNORM);
565 return mask; 565 return mask;
@@ -852,7 +852,7 @@ int saa7134_oss_init1(struct saa7134_dev *dev)
852 return -1; 852 return -1;
853 853
854 /* general */ 854 /* general */
855 init_MUTEX(&dev->dmasound.lock); 855 mutex_init(&dev->dmasound.lock);
856 init_waitqueue_head(&dev->dmasound.wq); 856 init_waitqueue_head(&dev->dmasound.wq);
857 857
858 switch (dev->pci->device) { 858 switch (dev->pci->device) {
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index e97426bc85df..72f389a51a13 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -460,17 +460,17 @@ static int res_get(struct saa7134_dev *dev, struct saa7134_fh *fh, unsigned int
460 return 1; 460 return 1;
461 461
462 /* is it free? */ 462 /* is it free? */
463 down(&dev->lock); 463 mutex_lock(&dev->lock);
464 if (dev->resources & bit) { 464 if (dev->resources & bit) {
465 /* no, someone else uses it */ 465 /* no, someone else uses it */
466 up(&dev->lock); 466 mutex_unlock(&dev->lock);
467 return 0; 467 return 0;
468 } 468 }
469 /* it's free, grab it */ 469 /* it's free, grab it */
470 fh->resources |= bit; 470 fh->resources |= bit;
471 dev->resources |= bit; 471 dev->resources |= bit;
472 dprintk("res: get %d\n",bit); 472 dprintk("res: get %d\n",bit);
473 up(&dev->lock); 473 mutex_unlock(&dev->lock);
474 return 1; 474 return 1;
475} 475}
476 476
@@ -492,11 +492,11 @@ void res_free(struct saa7134_dev *dev, struct saa7134_fh *fh, unsigned int bits)
492 if ((fh->resources & bits) != bits) 492 if ((fh->resources & bits) != bits)
493 BUG(); 493 BUG();
494 494
495 down(&dev->lock); 495 mutex_lock(&dev->lock);
496 fh->resources &= ~bits; 496 fh->resources &= ~bits;
497 dev->resources &= ~bits; 497 dev->resources &= ~bits;
498 dprintk("res: put %d\n",bits); 498 dprintk("res: put %d\n",bits);
499 up(&dev->lock); 499 mutex_unlock(&dev->lock);
500} 500}
501 501
502/* ------------------------------------------------------------------ */ 502/* ------------------------------------------------------------------ */
@@ -1340,21 +1340,21 @@ video_poll(struct file *file, struct poll_table_struct *wait)
1340 if (!list_empty(&fh->cap.stream)) 1340 if (!list_empty(&fh->cap.stream))
1341 buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream); 1341 buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream);
1342 } else { 1342 } else {
1343 down(&fh->cap.lock); 1343 mutex_lock(&fh->cap.lock);
1344 if (UNSET == fh->cap.read_off) { 1344 if (UNSET == fh->cap.read_off) {
1345 /* need to capture a new frame */ 1345 /* need to capture a new frame */
1346 if (res_locked(fh->dev,RESOURCE_VIDEO)) { 1346 if (res_locked(fh->dev,RESOURCE_VIDEO)) {
1347 up(&fh->cap.lock); 1347 mutex_unlock(&fh->cap.lock);
1348 return POLLERR; 1348 return POLLERR;
1349 } 1349 }
1350 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) { 1350 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) {
1351 up(&fh->cap.lock); 1351 mutex_unlock(&fh->cap.lock);
1352 return POLLERR; 1352 return POLLERR;
1353 } 1353 }
1354 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); 1354 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
1355 fh->cap.read_off = 0; 1355 fh->cap.read_off = 0;
1356 } 1356 }
1357 up(&fh->cap.lock); 1357 mutex_unlock(&fh->cap.lock);
1358 buf = fh->cap.read_buf; 1358 buf = fh->cap.read_buf;
1359 } 1359 }
1360 1360
@@ -1561,14 +1561,14 @@ static int saa7134_s_fmt(struct saa7134_dev *dev, struct saa7134_fh *fh,
1561 if (0 != err) 1561 if (0 != err)
1562 return err; 1562 return err;
1563 1563
1564 down(&dev->lock); 1564 mutex_lock(&dev->lock);
1565 fh->win = f->fmt.win; 1565 fh->win = f->fmt.win;
1566 fh->nclips = f->fmt.win.clipcount; 1566 fh->nclips = f->fmt.win.clipcount;
1567 if (fh->nclips > 8) 1567 if (fh->nclips > 8)
1568 fh->nclips = 8; 1568 fh->nclips = 8;
1569 if (copy_from_user(fh->clips,f->fmt.win.clips, 1569 if (copy_from_user(fh->clips,f->fmt.win.clips,
1570 sizeof(struct v4l2_clip)*fh->nclips)) { 1570 sizeof(struct v4l2_clip)*fh->nclips)) {
1571 up(&dev->lock); 1571 mutex_unlock(&dev->lock);
1572 return -EFAULT; 1572 return -EFAULT;
1573 } 1573 }
1574 1574
@@ -1578,7 +1578,7 @@ static int saa7134_s_fmt(struct saa7134_dev *dev, struct saa7134_fh *fh,
1578 start_preview(dev,fh); 1578 start_preview(dev,fh);
1579 spin_unlock_irqrestore(&dev->slock,flags); 1579 spin_unlock_irqrestore(&dev->slock,flags);
1580 } 1580 }
1581 up(&dev->lock); 1581 mutex_unlock(&dev->lock);
1582 return 0; 1582 return 0;
1583 case V4L2_BUF_TYPE_VBI_CAPTURE: 1583 case V4L2_BUF_TYPE_VBI_CAPTURE:
1584 saa7134_vbi_fmt(dev,f); 1584 saa7134_vbi_fmt(dev,f);
@@ -1612,9 +1612,9 @@ int saa7134_common_ioctl(struct saa7134_dev *dev,
1612 return get_control(dev,arg); 1612 return get_control(dev,arg);
1613 case VIDIOC_S_CTRL: 1613 case VIDIOC_S_CTRL:
1614 { 1614 {
1615 down(&dev->lock); 1615 mutex_lock(&dev->lock);
1616 err = set_control(dev,NULL,arg); 1616 err = set_control(dev,NULL,arg);
1617 up(&dev->lock); 1617 mutex_unlock(&dev->lock);
1618 return err; 1618 return err;
1619 } 1619 }
1620 /* --- input switching --------------------------------------- */ 1620 /* --- input switching --------------------------------------- */
@@ -1664,9 +1664,9 @@ int saa7134_common_ioctl(struct saa7134_dev *dev,
1664 return -EINVAL; 1664 return -EINVAL;
1665 if (NULL == card_in(dev,*i).name) 1665 if (NULL == card_in(dev,*i).name)
1666 return -EINVAL; 1666 return -EINVAL;
1667 down(&dev->lock); 1667 mutex_lock(&dev->lock);
1668 video_mux(dev,*i); 1668 video_mux(dev,*i);
1669 up(&dev->lock); 1669 mutex_unlock(&dev->lock);
1670 return 0; 1670 return 0;
1671 } 1671 }
1672 1672
@@ -1766,7 +1766,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1766 if (i == TVNORMS) 1766 if (i == TVNORMS)
1767 return -EINVAL; 1767 return -EINVAL;
1768 1768
1769 down(&dev->lock); 1769 mutex_lock(&dev->lock);
1770 if (res_check(fh, RESOURCE_OVERLAY)) { 1770 if (res_check(fh, RESOURCE_OVERLAY)) {
1771 spin_lock_irqsave(&dev->slock,flags); 1771 spin_lock_irqsave(&dev->slock,flags);
1772 stop_preview(dev,fh); 1772 stop_preview(dev,fh);
@@ -1776,7 +1776,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1776 } else 1776 } else
1777 set_tvnorm(dev,&tvnorms[i]); 1777 set_tvnorm(dev,&tvnorms[i]);
1778 saa7134_tvaudio_do_scan(dev); 1778 saa7134_tvaudio_do_scan(dev);
1779 up(&dev->lock); 1779 mutex_unlock(&dev->lock);
1780 return 0; 1780 return 0;
1781 } 1781 }
1782 1782
@@ -1909,13 +1909,13 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1909 return -EINVAL; 1909 return -EINVAL;
1910 if (1 == fh->radio && V4L2_TUNER_RADIO != f->type) 1910 if (1 == fh->radio && V4L2_TUNER_RADIO != f->type)
1911 return -EINVAL; 1911 return -EINVAL;
1912 down(&dev->lock); 1912 mutex_lock(&dev->lock);
1913 dev->ctl_freq = f->frequency; 1913 dev->ctl_freq = f->frequency;
1914 1914
1915 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,f); 1915 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,f);
1916 1916
1917 saa7134_tvaudio_do_scan(dev); 1917 saa7134_tvaudio_do_scan(dev);
1918 up(&dev->lock); 1918 mutex_unlock(&dev->lock);
1919 return 0; 1919 return 0;
1920 } 1920 }
1921 1921
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index ff39a63c7372..691c10be459d 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -29,6 +29,7 @@
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/notifier.h> 30#include <linux/notifier.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/mutex.h>
32 33
33#include <asm/io.h> 34#include <asm/io.h>
34 35
@@ -364,7 +365,7 @@ struct saa7134_fh {
364 365
365/* dmasound dsp status */ 366/* dmasound dsp status */
366struct saa7134_dmasound { 367struct saa7134_dmasound {
367 struct semaphore lock; 368 struct mutex lock;
368 int minor_mixer; 369 int minor_mixer;
369 int minor_dsp; 370 int minor_dsp;
370 unsigned int users_dsp; 371 unsigned int users_dsp;
@@ -428,7 +429,7 @@ struct saa7134_mpeg_ops {
428/* global device status */ 429/* global device status */
429struct saa7134_dev { 430struct saa7134_dev {
430 struct list_head devlist; 431 struct list_head devlist;
431 struct semaphore lock; 432 struct mutex lock;
432 spinlock_t slock; 433 spinlock_t slock;
433#ifdef VIDIOC_G_PRIORITY 434#ifdef VIDIOC_G_PRIORITY
434 struct v4l2_prio_state prio; 435 struct v4l2_prio_state prio;
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
index 0a4004a4393c..caf3e7e2f219 100644
--- a/drivers/media/video/video-buf-dvb.c
+++ b/drivers/media/video/video-buf-dvb.c
@@ -96,7 +96,7 @@ static int videobuf_dvb_start_feed(struct dvb_demux_feed *feed)
96 if (!demux->dmx.frontend) 96 if (!demux->dmx.frontend)
97 return -EINVAL; 97 return -EINVAL;
98 98
99 down(&dvb->lock); 99 mutex_lock(&dvb->lock);
100 dvb->nfeeds++; 100 dvb->nfeeds++;
101 rc = dvb->nfeeds; 101 rc = dvb->nfeeds;
102 102
@@ -110,7 +110,7 @@ static int videobuf_dvb_start_feed(struct dvb_demux_feed *feed)
110 } 110 }
111 111
112out: 112out:
113 up(&dvb->lock); 113 mutex_unlock(&dvb->lock);
114 return rc; 114 return rc;
115} 115}
116 116
@@ -120,14 +120,14 @@ static int videobuf_dvb_stop_feed(struct dvb_demux_feed *feed)
120 struct videobuf_dvb *dvb = demux->priv; 120 struct videobuf_dvb *dvb = demux->priv;
121 int err = 0; 121 int err = 0;
122 122
123 down(&dvb->lock); 123 mutex_lock(&dvb->lock);
124 dvb->nfeeds--; 124 dvb->nfeeds--;
125 if (0 == dvb->nfeeds && NULL != dvb->thread) { 125 if (0 == dvb->nfeeds && NULL != dvb->thread) {
126 // FIXME: cx8802_cancel_buffers(dev); 126 // FIXME: cx8802_cancel_buffers(dev);
127 err = kthread_stop(dvb->thread); 127 err = kthread_stop(dvb->thread);
128 dvb->thread = NULL; 128 dvb->thread = NULL;
129 } 129 }
130 up(&dvb->lock); 130 mutex_unlock(&dvb->lock);
131 return err; 131 return err;
132} 132}
133 133
@@ -139,7 +139,7 @@ int videobuf_dvb_register(struct videobuf_dvb *dvb,
139{ 139{
140 int result; 140 int result;
141 141
142 init_MUTEX(&dvb->lock); 142 mutex_init(&dvb->lock);
143 143
144 /* register adapter */ 144 /* register adapter */
145 result = dvb_register_adapter(&dvb->adapter, dvb->name, module); 145 result = dvb_register_adapter(&dvb->adapter, dvb->name, module);
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index 9ef477523d27..cb1c228e29f8 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -385,7 +385,7 @@ void videobuf_queue_init(struct videobuf_queue* q,
385 q->ops = ops; 385 q->ops = ops;
386 q->priv_data = priv; 386 q->priv_data = priv;
387 387
388 init_MUTEX(&q->lock); 388 mutex_init(&q->lock);
389 INIT_LIST_HEAD(&q->stream); 389 INIT_LIST_HEAD(&q->stream);
390} 390}
391 391
@@ -549,7 +549,7 @@ videobuf_reqbufs(struct videobuf_queue *q,
549 if (!list_empty(&q->stream)) 549 if (!list_empty(&q->stream))
550 return -EBUSY; 550 return -EBUSY;
551 551
552 down(&q->lock); 552 mutex_lock(&q->lock);
553 count = req->count; 553 count = req->count;
554 if (count > VIDEO_MAX_FRAME) 554 if (count > VIDEO_MAX_FRAME)
555 count = VIDEO_MAX_FRAME; 555 count = VIDEO_MAX_FRAME;
@@ -566,7 +566,7 @@ videobuf_reqbufs(struct videobuf_queue *q,
566 req->count = count; 566 req->count = count;
567 567
568 done: 568 done:
569 up(&q->lock); 569 mutex_unlock(&q->lock);
570 return retval; 570 return retval;
571} 571}
572 572
@@ -592,7 +592,7 @@ videobuf_qbuf(struct videobuf_queue *q,
592 unsigned long flags; 592 unsigned long flags;
593 int retval; 593 int retval;
594 594
595 down(&q->lock); 595 mutex_lock(&q->lock);
596 retval = -EBUSY; 596 retval = -EBUSY;
597 if (q->reading) 597 if (q->reading)
598 goto done; 598 goto done;
@@ -652,7 +652,7 @@ videobuf_qbuf(struct videobuf_queue *q,
652 retval = 0; 652 retval = 0;
653 653
654 done: 654 done:
655 up(&q->lock); 655 mutex_unlock(&q->lock);
656 return retval; 656 return retval;
657} 657}
658 658
@@ -663,7 +663,7 @@ videobuf_dqbuf(struct videobuf_queue *q,
663 struct videobuf_buffer *buf; 663 struct videobuf_buffer *buf;
664 int retval; 664 int retval;
665 665
666 down(&q->lock); 666 mutex_lock(&q->lock);
667 retval = -EBUSY; 667 retval = -EBUSY;
668 if (q->reading) 668 if (q->reading)
669 goto done; 669 goto done;
@@ -693,7 +693,7 @@ videobuf_dqbuf(struct videobuf_queue *q,
693 videobuf_status(b,buf,q->type); 693 videobuf_status(b,buf,q->type);
694 694
695 done: 695 done:
696 up(&q->lock); 696 mutex_unlock(&q->lock);
697 return retval; 697 return retval;
698} 698}
699 699
@@ -704,7 +704,7 @@ int videobuf_streamon(struct videobuf_queue *q)
704 unsigned long flags; 704 unsigned long flags;
705 int retval; 705 int retval;
706 706
707 down(&q->lock); 707 mutex_lock(&q->lock);
708 retval = -EBUSY; 708 retval = -EBUSY;
709 if (q->reading) 709 if (q->reading)
710 goto done; 710 goto done;
@@ -721,7 +721,7 @@ int videobuf_streamon(struct videobuf_queue *q)
721 spin_unlock_irqrestore(q->irqlock,flags); 721 spin_unlock_irqrestore(q->irqlock,flags);
722 722
723 done: 723 done:
724 up(&q->lock); 724 mutex_unlock(&q->lock);
725 return retval; 725 return retval;
726} 726}
727 727
@@ -729,7 +729,7 @@ int videobuf_streamoff(struct videobuf_queue *q)
729{ 729{
730 int retval = -EINVAL; 730 int retval = -EINVAL;
731 731
732 down(&q->lock); 732 mutex_lock(&q->lock);
733 if (!q->streaming) 733 if (!q->streaming)
734 goto done; 734 goto done;
735 videobuf_queue_cancel(q); 735 videobuf_queue_cancel(q);
@@ -737,7 +737,7 @@ int videobuf_streamoff(struct videobuf_queue *q)
737 retval = 0; 737 retval = 0;
738 738
739 done: 739 done:
740 up(&q->lock); 740 mutex_unlock(&q->lock);
741 return retval; 741 return retval;
742} 742}
743 743
@@ -792,7 +792,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
792 unsigned size, nbufs, bytes; 792 unsigned size, nbufs, bytes;
793 int retval; 793 int retval;
794 794
795 down(&q->lock); 795 mutex_lock(&q->lock);
796 796
797 nbufs = 1; size = 0; 797 nbufs = 1; size = 0;
798 q->ops->buf_setup(q,&nbufs,&size); 798 q->ops->buf_setup(q,&nbufs,&size);
@@ -860,7 +860,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
860 } 860 }
861 861
862 done: 862 done:
863 up(&q->lock); 863 mutex_unlock(&q->lock);
864 return retval; 864 return retval;
865} 865}
866 866
@@ -922,7 +922,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
922 unsigned long flags; 922 unsigned long flags;
923 923
924 dprintk(2,"%s\n",__FUNCTION__); 924 dprintk(2,"%s\n",__FUNCTION__);
925 down(&q->lock); 925 mutex_lock(&q->lock);
926 retval = -EBUSY; 926 retval = -EBUSY;
927 if (q->streaming) 927 if (q->streaming)
928 goto done; 928 goto done;
@@ -996,7 +996,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
996 } 996 }
997 997
998 done: 998 done:
999 up(&q->lock); 999 mutex_unlock(&q->lock);
1000 return retval; 1000 return retval;
1001} 1001}
1002 1002
@@ -1007,7 +1007,7 @@ unsigned int videobuf_poll_stream(struct file *file,
1007 struct videobuf_buffer *buf = NULL; 1007 struct videobuf_buffer *buf = NULL;
1008 unsigned int rc = 0; 1008 unsigned int rc = 0;
1009 1009
1010 down(&q->lock); 1010 mutex_lock(&q->lock);
1011 if (q->streaming) { 1011 if (q->streaming) {
1012 if (!list_empty(&q->stream)) 1012 if (!list_empty(&q->stream))
1013 buf = list_entry(q->stream.next, 1013 buf = list_entry(q->stream.next,
@@ -1035,7 +1035,7 @@ unsigned int videobuf_poll_stream(struct file *file,
1035 buf->state == STATE_ERROR) 1035 buf->state == STATE_ERROR)
1036 rc = POLLIN|POLLRDNORM; 1036 rc = POLLIN|POLLRDNORM;
1037 } 1037 }
1038 up(&q->lock); 1038 mutex_unlock(&q->lock);
1039 return rc; 1039 return rc;
1040} 1040}
1041 1041
@@ -1064,7 +1064,7 @@ videobuf_vm_close(struct vm_area_struct *vma)
1064 map->count--; 1064 map->count--;
1065 if (0 == map->count) { 1065 if (0 == map->count) {
1066 dprintk(1,"munmap %p q=%p\n",map,q); 1066 dprintk(1,"munmap %p q=%p\n",map,q);
1067 down(&q->lock); 1067 mutex_lock(&q->lock);
1068 for (i = 0; i < VIDEO_MAX_FRAME; i++) { 1068 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
1069 if (NULL == q->bufs[i]) 1069 if (NULL == q->bufs[i])
1070 continue; 1070 continue;
@@ -1076,7 +1076,7 @@ videobuf_vm_close(struct vm_area_struct *vma)
1076 q->bufs[i]->baddr = 0; 1076 q->bufs[i]->baddr = 0;
1077 q->ops->buf_release(q,q->bufs[i]); 1077 q->ops->buf_release(q,q->bufs[i]);
1078 } 1078 }
1079 up(&q->lock); 1079 mutex_unlock(&q->lock);
1080 kfree(map); 1080 kfree(map);
1081 } 1081 }
1082 return; 1082 return;
@@ -1170,7 +1170,7 @@ int videobuf_mmap_mapper(struct videobuf_queue *q,
1170 unsigned int first,last,size,i; 1170 unsigned int first,last,size,i;
1171 int retval; 1171 int retval;
1172 1172
1173 down(&q->lock); 1173 mutex_lock(&q->lock);
1174 retval = -EINVAL; 1174 retval = -EINVAL;
1175 if (!(vma->vm_flags & VM_WRITE)) { 1175 if (!(vma->vm_flags & VM_WRITE)) {
1176 dprintk(1,"mmap app bug: PROT_WRITE please\n"); 1176 dprintk(1,"mmap app bug: PROT_WRITE please\n");
@@ -1238,7 +1238,7 @@ int videobuf_mmap_mapper(struct videobuf_queue *q,
1238 retval = 0; 1238 retval = 0;
1239 1239
1240 done: 1240 done:
1241 up(&q->lock); 1241 mutex_unlock(&q->lock);
1242 return retval; 1242 return retval;
1243} 1243}
1244 1244
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 908fbec776ac..75e3d41382f2 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -224,13 +224,13 @@ int video_exclusive_open(struct inode *inode, struct file *file)
224 struct video_device *vfl = video_devdata(file); 224 struct video_device *vfl = video_devdata(file);
225 int retval = 0; 225 int retval = 0;
226 226
227 down(&vfl->lock); 227 mutex_lock(&vfl->lock);
228 if (vfl->users) { 228 if (vfl->users) {
229 retval = -EBUSY; 229 retval = -EBUSY;
230 } else { 230 } else {
231 vfl->users++; 231 vfl->users++;
232 } 232 }
233 up(&vfl->lock); 233 mutex_unlock(&vfl->lock);
234 return retval; 234 return retval;
235} 235}
236 236
@@ -328,7 +328,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
328 sprintf(vfd->devfs_name, "v4l/%s%d", name_base, i - base); 328 sprintf(vfd->devfs_name, "v4l/%s%d", name_base, i - base);
329 devfs_mk_cdev(MKDEV(VIDEO_MAJOR, vfd->minor), 329 devfs_mk_cdev(MKDEV(VIDEO_MAJOR, vfd->minor),
330 S_IFCHR | S_IRUSR | S_IWUSR, vfd->devfs_name); 330 S_IFCHR | S_IRUSR | S_IWUSR, vfd->devfs_name);
331 init_MUTEX(&vfd->lock); 331 mutex_init(&vfd->lock);
332 332
333 /* sysfs class */ 333 /* sysfs class */
334 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev)); 334 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index c8fd8238904d..0229819d0aac 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -42,6 +42,7 @@
42#include <linux/videodev.h> 42#include <linux/videodev.h>
43#include <linux/videodev2.h> 43#include <linux/videodev2.h>
44#include <linux/video_decoder.h> 44#include <linux/video_decoder.h>
45#include <linux/mutex.h>
45 46
46#include <asm/paccess.h> 47#include <asm/paccess.h>
47#include <asm/io.h> 48#include <asm/io.h>
@@ -245,7 +246,7 @@ struct vino_framebuffer_queue {
245 struct vino_framebuffer *buffer[VINO_FRAMEBUFFER_COUNT_MAX]; 246 struct vino_framebuffer *buffer[VINO_FRAMEBUFFER_COUNT_MAX];
246 247
247 spinlock_t queue_lock; 248 spinlock_t queue_lock;
248 struct semaphore queue_sem; 249 struct mutex queue_mutex;
249 wait_queue_head_t frame_wait_queue; 250 wait_queue_head_t frame_wait_queue;
250}; 251};
251 252
@@ -283,7 +284,7 @@ struct vino_channel_settings {
283 /* the driver is currently processing the queue */ 284 /* the driver is currently processing the queue */
284 int capturing; 285 int capturing;
285 286
286 struct semaphore sem; 287 struct mutex mutex;
287 spinlock_t capture_lock; 288 spinlock_t capture_lock;
288 289
289 unsigned int users; 290 unsigned int users;
@@ -1131,11 +1132,11 @@ static void vino_queue_free(struct vino_framebuffer_queue *q)
1131 if (q->type != VINO_MEMORY_MMAP) 1132 if (q->type != VINO_MEMORY_MMAP)
1132 return; 1133 return;
1133 1134
1134 down(&q->queue_sem); 1135 mutex_lock(&q->queue_mutex);
1135 1136
1136 vino_queue_free_with_count(q, q->length); 1137 vino_queue_free_with_count(q, q->length);
1137 1138
1138 up(&q->queue_sem); 1139 mutex_unlock(&q->queue_mutex);
1139} 1140}
1140 1141
1141static int vino_queue_init(struct vino_framebuffer_queue *q, 1142static int vino_queue_init(struct vino_framebuffer_queue *q,
@@ -1159,7 +1160,7 @@ static int vino_queue_init(struct vino_framebuffer_queue *q,
1159 if (*length < 1) 1160 if (*length < 1)
1160 return -EINVAL; 1161 return -EINVAL;
1161 1162
1162 down(&q->queue_sem); 1163 mutex_lock(&q->queue_mutex);
1163 1164
1164 if (*length > VINO_FRAMEBUFFER_COUNT_MAX) 1165 if (*length > VINO_FRAMEBUFFER_COUNT_MAX)
1165 *length = VINO_FRAMEBUFFER_COUNT_MAX; 1166 *length = VINO_FRAMEBUFFER_COUNT_MAX;
@@ -1211,7 +1212,7 @@ static int vino_queue_init(struct vino_framebuffer_queue *q,
1211 q->magic = VINO_QUEUE_MAGIC; 1212 q->magic = VINO_QUEUE_MAGIC;
1212 } 1213 }
1213 1214
1214 up(&q->queue_sem); 1215 mutex_unlock(&q->queue_mutex);
1215 1216
1216 return ret; 1217 return ret;
1217} 1218}
@@ -4045,7 +4046,7 @@ static int vino_open(struct inode *inode, struct file *file)
4045 dprintk("open(): channel = %c\n", 4046 dprintk("open(): channel = %c\n",
4046 (vcs->channel == VINO_CHANNEL_A) ? 'A' : 'B'); 4047 (vcs->channel == VINO_CHANNEL_A) ? 'A' : 'B');
4047 4048
4048 down(&vcs->sem); 4049 mutex_lock(&vcs->mutex);
4049 4050
4050 if (vcs->users) { 4051 if (vcs->users) {
4051 dprintk("open(): driver busy\n"); 4052 dprintk("open(): driver busy\n");
@@ -4062,7 +4063,7 @@ static int vino_open(struct inode *inode, struct file *file)
4062 vcs->users++; 4063 vcs->users++;
4063 4064
4064 out: 4065 out:
4065 up(&vcs->sem); 4066 mutex_unlock(&vcs->mutex);
4066 4067
4067 dprintk("open(): %s!\n", ret ? "failed" : "complete"); 4068 dprintk("open(): %s!\n", ret ? "failed" : "complete");
4068 4069
@@ -4075,7 +4076,7 @@ static int vino_close(struct inode *inode, struct file *file)
4075 struct vino_channel_settings *vcs = video_get_drvdata(dev); 4076 struct vino_channel_settings *vcs = video_get_drvdata(dev);
4076 dprintk("close():\n"); 4077 dprintk("close():\n");
4077 4078
4078 down(&vcs->sem); 4079 mutex_lock(&vcs->mutex);
4079 4080
4080 vcs->users--; 4081 vcs->users--;
4081 4082
@@ -4087,7 +4088,7 @@ static int vino_close(struct inode *inode, struct file *file)
4087 vino_queue_free(&vcs->fb_queue); 4088 vino_queue_free(&vcs->fb_queue);
4088 } 4089 }
4089 4090
4090 up(&vcs->sem); 4091 mutex_unlock(&vcs->mutex);
4091 4092
4092 return 0; 4093 return 0;
4093} 4094}
@@ -4130,7 +4131,7 @@ static int vino_mmap(struct file *file, struct vm_area_struct *vma)
4130 4131
4131 // TODO: reject mmap if already mapped 4132 // TODO: reject mmap if already mapped
4132 4133
4133 if (down_interruptible(&vcs->sem)) 4134 if (mutex_lock_interruptible(&vcs->mutex))
4134 return -EINTR; 4135 return -EINTR;
4135 4136
4136 if (vcs->reading) { 4137 if (vcs->reading) {
@@ -4214,7 +4215,7 @@ found:
4214 vma->vm_ops = &vino_vm_ops; 4215 vma->vm_ops = &vino_vm_ops;
4215 4216
4216out: 4217out:
4217 up(&vcs->sem); 4218 mutex_unlock(&vcs->mutex);
4218 4219
4219 return ret; 4220 return ret;
4220} 4221}
@@ -4374,12 +4375,12 @@ static int vino_ioctl(struct inode *inode, struct file *file,
4374 struct vino_channel_settings *vcs = video_get_drvdata(dev); 4375 struct vino_channel_settings *vcs = video_get_drvdata(dev);
4375 int ret; 4376 int ret;
4376 4377
4377 if (down_interruptible(&vcs->sem)) 4378 if (mutex_lock_interruptible(&vcs->mutex))
4378 return -EINTR; 4379 return -EINTR;
4379 4380
4380 ret = video_usercopy(inode, file, cmd, arg, vino_do_ioctl); 4381 ret = video_usercopy(inode, file, cmd, arg, vino_do_ioctl);
4381 4382
4382 up(&vcs->sem); 4383 mutex_unlock(&vcs->mutex);
4383 4384
4384 return ret; 4385 return ret;
4385} 4386}
@@ -4564,10 +4565,10 @@ static int vino_init_channel_settings(struct vino_channel_settings *vcs,
4564 4565
4565 vcs->capturing = 0; 4566 vcs->capturing = 0;
4566 4567
4567 init_MUTEX(&vcs->sem); 4568 mutex_init(&vcs->mutex);
4568 spin_lock_init(&vcs->capture_lock); 4569 spin_lock_init(&vcs->capture_lock);
4569 4570
4570 init_MUTEX(&vcs->fb_queue.queue_sem); 4571 mutex_init(&vcs->fb_queue.queue_mutex);
4571 spin_lock_init(&vcs->fb_queue.queue_lock); 4572 spin_lock_init(&vcs->fb_queue.queue_lock);
4572 init_waitqueue_head(&vcs->fb_queue.frame_wait_queue); 4573 init_waitqueue_head(&vcs->fb_queue.frame_wait_queue);
4573 4574