aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
diff options
context:
space:
mode:
authorJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-03-21 14:05:45 -0500
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-03-21 14:05:45 -0500
commitd04cdb64212eb5ae6a98026a97dda626e40e8e9a (patch)
treeb6a7dbb21ccfceb915844e9a330b3d3dfcaf3c5b /drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
parent2f8600dff2b140096a7df781884e918a16aa90e0 (diff)
parentec1248e70edc5cf7b485efcc7b41e44e10f422e5 (diff)
Merge ../linux-2.6
Diffstat (limited to 'drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c')
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 5a13c4744f61..248fdc7accfb 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
@@ -689,8 +688,7 @@ static void ttusb_process_frame(struct ttusb *ttusb, u8 * data, int len)
689 memcpy(ttusb->muxpack + ttusb->muxpack_ptr, 688 memcpy(ttusb->muxpack + ttusb->muxpack_ptr,
690 data, avail); 689 data, avail);
691 ttusb->muxpack_ptr += avail; 690 ttusb->muxpack_ptr += avail;
692 if (ttusb->muxpack_ptr > 264) 691 BUG_ON(ttusb->muxpack_ptr > 264);
693 BUG();
694 data += avail; 692 data += avail;
695 len -= avail; 693 len -= avail;
696 /* determine length */ 694 /* determine length */
@@ -1495,8 +1493,11 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1495 ttusb->dev = udev; 1493 ttusb->dev = udev;
1496 ttusb->c = 0; 1494 ttusb->c = 0;
1497 ttusb->mux_state = 0; 1495 ttusb->mux_state = 0;
1498 sema_init(&ttusb->semi2c, 0); 1496 mutex_init(&ttusb->semi2c);
1499 sema_init(&ttusb->semusb, 1); 1497
1498 mutex_lock(&ttusb->semi2c);
1499
1500 mutex_init(&ttusb->semusb);
1500 1501
1501 ttusb_setup_interfaces(ttusb); 1502 ttusb_setup_interfaces(ttusb);
1502 1503
@@ -1504,7 +1505,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1504 if (ttusb_init_controller(ttusb)) 1505 if (ttusb_init_controller(ttusb))
1505 printk("ttusb_init_controller: error\n"); 1506 printk("ttusb_init_controller: error\n");
1506 1507
1507 up(&ttusb->semi2c); 1508 mutex_unlock(&ttusb->semi2c);
1508 1509
1509 dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE); 1510 dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE);
1510 ttusb->adapter.priv = ttusb; 1511 ttusb->adapter.priv = ttusb;