[git:v4l-dvb/v2.6.36] V4L/DVB: gspca - zc3xx: Check the USB exchanges

2010-09-27 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/media-tree.git tree:

Subject: V4L/DVB: gspca - zc3xx: Check the USB exchanges
Author:  Jean-François Moine moin...@free.fr
Date:Wed Aug 4 05:44:13 2010 -0300

Signed-off-by: Jean-François Moine moin...@free.fr
Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com

 drivers/media/video/gspca/zc3xx.c |  329 +++--
 1 files changed, 171 insertions(+), 158 deletions(-)

---

http://git.linuxtv.org/media-tree.git?a=commitdiff;h=6d31450544c75d99e1f4dbb21d5db6b2ca6ada4d

diff --git a/drivers/media/video/gspca/zc3xx.c 
b/drivers/media/video/gspca/zc3xx.c
index e184eb3..a9af568 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -5841,13 +5841,22 @@ static const struct usb_action 
tas5130c_vf0250_NoFliker[] = {
 static u8 reg_r_i(struct gspca_dev *gspca_dev,
u16 index)
 {
-   usb_control_msg(gspca_dev-dev,
+   int ret;
+
+   if (gspca_dev-usb_err  0)
+   return 0;
+   ret = usb_control_msg(gspca_dev-dev,
usb_rcvctrlpipe(gspca_dev-dev, 0),
0xa1,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x01,   /* value */
index, gspca_dev-usb_buf, 1,
500);
+   if (ret  0) {
+   PDEBUG(D_ERR, reg_r_i err %d, ret);
+   gspca_dev-usb_err = ret;
+   return 0;
+   }
return gspca_dev-usb_buf[0];
 }
 
@@ -5861,24 +5870,32 @@ static u8 reg_r(struct gspca_dev *gspca_dev,
return ret;
 }
 
-static void reg_w_i(struct usb_device *dev,
+static void reg_w_i(struct gspca_dev *gspca_dev,
u8 value,
u16 index)
 {
-   usb_control_msg(dev,
-   usb_sndctrlpipe(dev, 0),
+   int ret;
+
+   if (gspca_dev-usb_err  0)
+   return;
+   ret = usb_control_msg(gspca_dev-dev,
+   usb_sndctrlpipe(gspca_dev-dev, 0),
0xa0,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index, NULL, 0,
500);
+   if (ret  0) {
+   PDEBUG(D_ERR, reg_w_i err %d, ret);
+   gspca_dev-usb_err = ret;
+   }
 }
 
-static void reg_w(struct usb_device *dev,
+static void reg_w(struct gspca_dev *gspca_dev,
u8 value,
u16 index)
 {
PDEBUG(D_USBO, reg w [%04x] = %02x, index, value);
-   reg_w_i(dev, value, index);
+   reg_w_i(gspca_dev, value, index);
 }
 
 static u16 i2c_read(struct gspca_dev *gspca_dev,
@@ -5887,8 +5904,10 @@ static u16 i2c_read(struct gspca_dev *gspca_dev,
u8 retbyte;
u16 retval;
 
-   reg_w_i(gspca_dev-dev, reg, 0x0092);
-   reg_w_i(gspca_dev-dev, 0x02, 0x0090);  /* - read command */
+   if (gspca_dev-usb_err  0)
+   return 0;
+   reg_w_i(gspca_dev, reg, 0x0092);
+   reg_w_i(gspca_dev, 0x02, 0x0090);   /* - read command */
msleep(20);
retbyte = reg_r_i(gspca_dev, 0x0091);   /* read status */
if (retbyte != 0x00)
@@ -5907,10 +5926,12 @@ static u8 i2c_write(struct gspca_dev *gspca_dev,
 {
u8 retbyte;
 
-   reg_w_i(gspca_dev-dev, reg, 0x92);
-   reg_w_i(gspca_dev-dev, valL, 0x93);
-   reg_w_i(gspca_dev-dev, valH, 0x94);
-   reg_w_i(gspca_dev-dev, 0x01, 0x90);/* - write command */
+   if (gspca_dev-usb_err  0)
+   return 0;
+   reg_w_i(gspca_dev, reg, 0x92);
+   reg_w_i(gspca_dev, valL, 0x93);
+   reg_w_i(gspca_dev, valH, 0x94);
+   reg_w_i(gspca_dev, 0x01, 0x90); /* - write command */
msleep(1);
retbyte = reg_r_i(gspca_dev, 0x0091);   /* read status */
if (retbyte != 0x00)
@@ -5926,7 +5947,7 @@ static void usb_exchange(struct gspca_dev *gspca_dev,
while (action-req) {
switch (action-req) {
case 0xa0:  /* write register */
-   reg_w(gspca_dev-dev, action-val, action-idx);
+   reg_w(gspca_dev, action-val, action-idx);
break;
case 0xa1:  /* read status */
reg_r(gspca_dev, action-idx);
@@ -6000,13 +6021,12 @@ static void setmatrix(struct gspca_dev *gspca_dev)
if (matrix == NULL)
return; /* matrix already loaded */
for (i = 0; i  ARRAY_SIZE(ov7620_matrix); i++)
-   reg_w(gspca_dev-dev, matrix[i], 0x010a + i);
+   reg_w(gspca_dev, matrix[i], 0x010a + i);
 }
 
 static void setsharpness(struct gspca_dev *gspca_dev)
 {
struct sd *sd = (struct sd *) gspca_dev;
-   struct usb_device *dev = 

[git:v4l-dvb/v2.6.36] V4L/DVB: gspca - zc3xx: Check the USB exchanges

2010-08-06 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/media-tree.git tree:

Subject: V4L/DVB: gspca - zc3xx: Check the USB exchanges
Author:  Jean-François Moine moin...@free.fr
Date:Wed Aug 4 05:44:13 2010 -0300

Signed-off-by: Jean-François Moine moin...@free.fr
Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com

 drivers/media/video/gspca/zc3xx.c |  329 +++--
 1 files changed, 171 insertions(+), 158 deletions(-)

---

http://git.linuxtv.org/media-tree.git?a=commitdiff;h=fbe970764bc5bf8121798edf7df9afb9cabc2e1f

diff --git a/drivers/media/video/gspca/zc3xx.c 
b/drivers/media/video/gspca/zc3xx.c
index e184eb3..a9af568 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -5841,13 +5841,22 @@ static const struct usb_action 
tas5130c_vf0250_NoFliker[] = {
 static u8 reg_r_i(struct gspca_dev *gspca_dev,
u16 index)
 {
-   usb_control_msg(gspca_dev-dev,
+   int ret;
+
+   if (gspca_dev-usb_err  0)
+   return 0;
+   ret = usb_control_msg(gspca_dev-dev,
usb_rcvctrlpipe(gspca_dev-dev, 0),
0xa1,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x01,   /* value */
index, gspca_dev-usb_buf, 1,
500);
+   if (ret  0) {
+   PDEBUG(D_ERR, reg_r_i err %d, ret);
+   gspca_dev-usb_err = ret;
+   return 0;
+   }
return gspca_dev-usb_buf[0];
 }
 
@@ -5861,24 +5870,32 @@ static u8 reg_r(struct gspca_dev *gspca_dev,
return ret;
 }
 
-static void reg_w_i(struct usb_device *dev,
+static void reg_w_i(struct gspca_dev *gspca_dev,
u8 value,
u16 index)
 {
-   usb_control_msg(dev,
-   usb_sndctrlpipe(dev, 0),
+   int ret;
+
+   if (gspca_dev-usb_err  0)
+   return;
+   ret = usb_control_msg(gspca_dev-dev,
+   usb_sndctrlpipe(gspca_dev-dev, 0),
0xa0,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index, NULL, 0,
500);
+   if (ret  0) {
+   PDEBUG(D_ERR, reg_w_i err %d, ret);
+   gspca_dev-usb_err = ret;
+   }
 }
 
-static void reg_w(struct usb_device *dev,
+static void reg_w(struct gspca_dev *gspca_dev,
u8 value,
u16 index)
 {
PDEBUG(D_USBO, reg w [%04x] = %02x, index, value);
-   reg_w_i(dev, value, index);
+   reg_w_i(gspca_dev, value, index);
 }
 
 static u16 i2c_read(struct gspca_dev *gspca_dev,
@@ -5887,8 +5904,10 @@ static u16 i2c_read(struct gspca_dev *gspca_dev,
u8 retbyte;
u16 retval;
 
-   reg_w_i(gspca_dev-dev, reg, 0x0092);
-   reg_w_i(gspca_dev-dev, 0x02, 0x0090);  /* - read command */
+   if (gspca_dev-usb_err  0)
+   return 0;
+   reg_w_i(gspca_dev, reg, 0x0092);
+   reg_w_i(gspca_dev, 0x02, 0x0090);   /* - read command */
msleep(20);
retbyte = reg_r_i(gspca_dev, 0x0091);   /* read status */
if (retbyte != 0x00)
@@ -5907,10 +5926,12 @@ static u8 i2c_write(struct gspca_dev *gspca_dev,
 {
u8 retbyte;
 
-   reg_w_i(gspca_dev-dev, reg, 0x92);
-   reg_w_i(gspca_dev-dev, valL, 0x93);
-   reg_w_i(gspca_dev-dev, valH, 0x94);
-   reg_w_i(gspca_dev-dev, 0x01, 0x90);/* - write command */
+   if (gspca_dev-usb_err  0)
+   return 0;
+   reg_w_i(gspca_dev, reg, 0x92);
+   reg_w_i(gspca_dev, valL, 0x93);
+   reg_w_i(gspca_dev, valH, 0x94);
+   reg_w_i(gspca_dev, 0x01, 0x90); /* - write command */
msleep(1);
retbyte = reg_r_i(gspca_dev, 0x0091);   /* read status */
if (retbyte != 0x00)
@@ -5926,7 +5947,7 @@ static void usb_exchange(struct gspca_dev *gspca_dev,
while (action-req) {
switch (action-req) {
case 0xa0:  /* write register */
-   reg_w(gspca_dev-dev, action-val, action-idx);
+   reg_w(gspca_dev, action-val, action-idx);
break;
case 0xa1:  /* read status */
reg_r(gspca_dev, action-idx);
@@ -6000,13 +6021,12 @@ static void setmatrix(struct gspca_dev *gspca_dev)
if (matrix == NULL)
return; /* matrix already loaded */
for (i = 0; i  ARRAY_SIZE(ov7620_matrix); i++)
-   reg_w(gspca_dev-dev, matrix[i], 0x010a + i);
+   reg_w(gspca_dev, matrix[i], 0x010a + i);
 }
 
 static void setsharpness(struct gspca_dev *gspca_dev)
 {
struct sd *sd = (struct sd *) gspca_dev;
-   struct usb_device *dev =