aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-02-07 03:49:14 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-02-07 03:49:14 -0500
commit3593cab5d62c4c7abced1076710f9bc2d8847433 (patch)
treedd5dc21961f6b4aef6900b0c2eb63ce7c70aecd5 /drivers/media/dvb
parent538f9630afbbe429ecbcdcf92536200293a8e4b3 (diff)
V4L/DVB (3318b): sem2mutex: drivers/media/, #2
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb')
-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
31 files changed, 262 insertions, 251 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-common.h b/drivers/media/dvb/b2c2/flexcop-common.h
index 7d7e1613c5a..b3dd0603cd9 100644
--- a/drivers/media/dvb/b2c2/flexcop-common.h
+++ b/drivers/media/dvb/b2c2/flexcop-common.h
@@ -10,6 +10,7 @@
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 56495cb6cd0..e0bd2d8f0f0 100644
--- a/drivers/media/dvb/b2c2/flexcop-i2c.c
+++ b/drivers/media/dvb/b2c2/flexcop-i2c.c
@@ -135,7 +135,7 @@ static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs
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 34c3189a1a3..d276ce6b366 100644
--- a/drivers/media/dvb/bt8xx/bt878.c
+++ b/drivers/media/dvb/bt8xx/bt878.c
@@ -344,7 +344,7 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *
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 9faf93770d0..f685bc12960 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 3a2ff1cc24b..d800df1212c 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -910,7 +910,7 @@ static int dst_get_device_id(struct dst_state *state)
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 c650b4bf7f5..f6b49a801eb 100644
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -81,7 +81,7 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8
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 81557f38fe3..51d4e043716 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 ea27b15007e..1649846f9ce 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -76,13 +76,13 @@ static int dvb_bt8xx_start_feed(struct dvb_demux_feed *dvbdmxfeed)
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 cf035a80361..00dd9fa54c8 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 c4b4c5b6b7c..29b7be5271d 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 7b8373ad121..ead5343d770 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -175,12 +175,12 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
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 fd72920c219..ec2a7a4da5e 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 b4c899b1595..83ec5e06c48 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -589,18 +589,18 @@ static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type,
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 0cc888339d5..2c5f915329c 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.h
+++ b/drivers/media/dvb/dvb-core/dvb_demux.h
@@ -26,7 +26,7 @@
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 771f32d889e..22e96cf8497 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -37,7 +37,6 @@
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 6711eb6a058..2f0f35811bf 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -62,6 +62,7 @@
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 f327fac1688..e62a293c7e5 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -77,7 +77,7 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
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 269d899da48..2d52b76671d 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -128,7 +128,7 @@ static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
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 caa1346e306..91136c00ce9 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -48,7 +48,7 @@ static int digitv_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
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 716f8bf528c..4258a995dce 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -42,8 +42,8 @@ static int dvb_usb_init(struct dvb_usb_device *d)
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 ee821974dc6..9002f35aa95 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
@@ -21,7 +21,7 @@ int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
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 5e5d21ad93c..d2be37cc43b 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -12,6 +12,7 @@
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 4a95eca81c5..b2f098a2d5f 100644
--- a/drivers/media/dvb/dvb-usb/vp702x.c
+++ b/drivers/media/dvb/dvb-usb/vp702x.c
@@ -75,7 +75,7 @@ int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int il
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 028204956bb..7fa656b108c 100644
--- a/drivers/media/dvb/dvb-usb/vp7045.c
+++ b/drivers/media/dvb/dvb-usb/vp7045.c
@@ -38,7 +38,7 @@ int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in,
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 caaee893ca7..1708a1d4893 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 d36369e9e88..1aa61bf29ad 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 fafd25fab83..3e2e12124ba 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 b2e63e9fc05..3c5366d15a8 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.c
+++ b/drivers/media/dvb/ttpci/av7110_hw.c
@@ -324,10 +324,10 @@ int av7110_wait_msgstate(struct av7110 *av7110, u16 flags)
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 c7bb63c4d98..4ac0f4d0802 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 5a13c4744f6..ecb15d4ecf8 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -19,7 +19,7 @@
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 df831171e03..44dea321184 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -20,7 +20,8 @@
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);