aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean-François Moine <moinejf@free.fr>2010-10-16 13:10:59 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-21 05:55:53 -0400
commitd4015493139ed1a6ec7b576ce7e4a3b11cc9561d (patch)
tree96a643a125b54f635529519f1925188e62d677a3 /drivers
parente3b4d2c6ae5d15f9f9ae36cfc5335b3a0861644f (diff)
[media] gspca - mars: Propagate USB errors to higher level
Signed-off-by: Jean-François Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/mars.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c
index cd0d69277b02..adec5be646a7 100644
--- a/drivers/media/video/gspca/mars.c
+++ b/drivers/media/video/gspca/mars.c
@@ -133,21 +133,25 @@ static const __u8 mi_data[0x20] = {
133}; 133};
134 134
135/* write <len> bytes from gspca_dev->usb_buf */ 135/* write <len> bytes from gspca_dev->usb_buf */
136static int reg_w(struct gspca_dev *gspca_dev, 136static void reg_w(struct gspca_dev *gspca_dev,
137 int len) 137 int len)
138{ 138{
139 int alen, ret; 139 int alen, ret;
140 140
141 if (gspca_dev->usb_err < 0)
142 return;
143
141 ret = usb_bulk_msg(gspca_dev->dev, 144 ret = usb_bulk_msg(gspca_dev->dev,
142 usb_sndbulkpipe(gspca_dev->dev, 4), 145 usb_sndbulkpipe(gspca_dev->dev, 4),
143 gspca_dev->usb_buf, 146 gspca_dev->usb_buf,
144 len, 147 len,
145 &alen, 148 &alen,
146 500); /* timeout in milliseconds */ 149 500); /* timeout in milliseconds */
147 if (ret < 0) 150 if (ret < 0) {
148 err("reg write [%02x] error %d", 151 err("reg write [%02x] error %d",
149 gspca_dev->usb_buf[0], ret); 152 gspca_dev->usb_buf[0], ret);
150 return ret; 153 gspca_dev->usb_err = ret;
154 }
151} 155}
152 156
153static void mi_w(struct gspca_dev *gspca_dev, 157static void mi_w(struct gspca_dev *gspca_dev,
@@ -226,7 +230,6 @@ static int sd_init(struct gspca_dev *gspca_dev)
226static int sd_start(struct gspca_dev *gspca_dev) 230static int sd_start(struct gspca_dev *gspca_dev)
227{ 231{
228 struct sd *sd = (struct sd *) gspca_dev; 232 struct sd *sd = (struct sd *) gspca_dev;
229 int err_code;
230 u8 *data; 233 u8 *data;
231 int i; 234 int i;
232 235
@@ -239,9 +242,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
239 242
240 data[0] = 0x01; /* address */ 243 data[0] = 0x01; /* address */
241 data[1] = 0x01; 244 data[1] = 0x01;
242 err_code = reg_w(gspca_dev, 2); 245 reg_w(gspca_dev, 2);
243 if (err_code < 0)
244 return err_code;
245 246
246 /* 247 /*
247 Initialize the MR97113 chip register 248 Initialize the MR97113 chip register
@@ -263,16 +264,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
263/*jfm: from win trace*/ 264/*jfm: from win trace*/
264 data[10] = 0x18; 265 data[10] = 0x18;
265 266
266 err_code = reg_w(gspca_dev, 11); 267 reg_w(gspca_dev, 11);
267 if (err_code < 0)
268 return err_code;
269 268
270 data[0] = 0x23; /* address */ 269 data[0] = 0x23; /* address */
271 data[1] = 0x09; /* reg 35, append frame header */ 270 data[1] = 0x09; /* reg 35, append frame header */
272 271
273 err_code = reg_w(gspca_dev, 2); 272 reg_w(gspca_dev, 2);
274 if (err_code < 0)
275 return err_code;
276 273
277 data[0] = 0x3c; /* address */ 274 data[0] = 0x3c; /* address */
278/* if (gspca_dev->width == 1280) */ 275/* if (gspca_dev->width == 1280) */
@@ -281,9 +278,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
281/* else */ 278/* else */
282 data[1] = 50; /* 50 reg 60, pc-cam frame size 279 data[1] = 50; /* 50 reg 60, pc-cam frame size
283 * (unit: 4KB) 200KB */ 280 * (unit: 4KB) 200KB */
284 err_code = reg_w(gspca_dev, 2); 281 reg_w(gspca_dev, 2);
285 if (err_code < 0)
286 return err_code;
287 282
288 /* auto dark-gain */ 283 /* auto dark-gain */
289 data[0] = 0x5e; /* address */ 284 data[0] = 0x5e; /* address */
@@ -297,32 +292,24 @@ static int sd_start(struct gspca_dev *gspca_dev)
297 data[4] = sd->ctrls[BRIGHTNESS].val; /* reg 0x61 = brightness */ 292 data[4] = sd->ctrls[BRIGHTNESS].val; /* reg 0x61 = brightness */
298 data[5] = 0x00; 293 data[5] = 0x00;
299 294
300 err_code = reg_w(gspca_dev, 6); 295 reg_w(gspca_dev, 6);
301 if (err_code < 0)
302 return err_code;
303 296
304 data[0] = 0x67; 297 data[0] = 0x67;
305/*jfm: from win trace*/ 298/*jfm: from win trace*/
306 data[1] = sd->ctrls[SHARPNESS].val * 4 + 3; 299 data[1] = sd->ctrls[SHARPNESS].val * 4 + 3;
307 data[2] = 0x14; 300 data[2] = 0x14;
308 err_code = reg_w(gspca_dev, 3); 301 reg_w(gspca_dev, 3);
309 if (err_code < 0)
310 return err_code;
311 302
312 data[0] = 0x69; 303 data[0] = 0x69;
313 data[1] = 0x2f; 304 data[1] = 0x2f;
314 data[2] = 0x28; 305 data[2] = 0x28;
315 data[3] = 0x42; 306 data[3] = 0x42;
316 err_code = reg_w(gspca_dev, 4); 307 reg_w(gspca_dev, 4);
317 if (err_code < 0)
318 return err_code;
319 308
320 data[0] = 0x63; 309 data[0] = 0x63;
321 data[1] = 0x07; 310 data[1] = 0x07;
322 err_code = reg_w(gspca_dev, 2); 311 reg_w(gspca_dev, 2);
323/*jfm: win trace - many writes here to reg 0x64*/ 312/*jfm: win trace - many writes here to reg 0x64*/
324 if (err_code < 0)
325 return err_code;
326 313
327 /* initialize the MI sensor */ 314 /* initialize the MI sensor */
328 for (i = 0; i < sizeof mi_data; i++) 315 for (i = 0; i < sizeof mi_data; i++)
@@ -331,18 +318,15 @@ static int sd_start(struct gspca_dev *gspca_dev)
331 data[0] = 0x00; 318 data[0] = 0x00;
332 data[1] = 0x4d; /* ISOC transfering enable... */ 319 data[1] = 0x4d; /* ISOC transfering enable... */
333 reg_w(gspca_dev, 2); 320 reg_w(gspca_dev, 2);
334 return 0; 321
322 return gspca_dev->usb_err;
335} 323}
336 324
337static void sd_stopN(struct gspca_dev *gspca_dev) 325static void sd_stopN(struct gspca_dev *gspca_dev)
338{ 326{
339 int result;
340
341 gspca_dev->usb_buf[0] = 1; 327 gspca_dev->usb_buf[0] = 1;
342 gspca_dev->usb_buf[1] = 0; 328 gspca_dev->usb_buf[1] = 0;
343 result = reg_w(gspca_dev, 2); 329 reg_w(gspca_dev, 2);
344 if (result < 0)
345 PDEBUG(D_ERR, "Camera Stop failed");
346} 330}
347 331
348static void sd_pkt_scan(struct gspca_dev *gspca_dev, 332static void sd_pkt_scan(struct gspca_dev *gspca_dev,