Commit 4f7309e2 authored by Marton Nemeth's avatar Marton Nemeth Committed by Mauro Carvalho Chehab

V4L/DVB (13324): gspca - pac7302/pac7311: Handle return value of usb_control_msg().

The function usb_control_msg() can return error any time so at least
warn the user if an error happens. No message is printed in case of
normal operation.
Signed-off-by: default avatarMarton Nemeth <nm127@freemail.hu>
Signed-off-by: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 56205cc0
...@@ -335,14 +335,20 @@ static void reg_w_buf(struct gspca_dev *gspca_dev, ...@@ -335,14 +335,20 @@ static void reg_w_buf(struct gspca_dev *gspca_dev,
__u8 index, __u8 index,
const char *buffer, int len) const char *buffer, int len)
{ {
int ret;
memcpy(gspca_dev->usb_buf, buffer, len); memcpy(gspca_dev->usb_buf, buffer, len);
usb_control_msg(gspca_dev->dev, ret = usb_control_msg(gspca_dev->dev,
usb_sndctrlpipe(gspca_dev->dev, 0), usb_sndctrlpipe(gspca_dev->dev, 0),
1, /* request */ 1, /* request */
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, /* value */ 0, /* value */
index, gspca_dev->usb_buf, len, index, gspca_dev->usb_buf, len,
500); 500);
if (ret < 0)
PDEBUG(D_ERR, "reg_w_buf(): "
"Failed to write registers to index 0x%x, error %i",
index, ret);
} }
...@@ -350,13 +356,19 @@ static void reg_w(struct gspca_dev *gspca_dev, ...@@ -350,13 +356,19 @@ static void reg_w(struct gspca_dev *gspca_dev,
__u8 index, __u8 index,
__u8 value) __u8 value)
{ {
int ret;
gspca_dev->usb_buf[0] = value; gspca_dev->usb_buf[0] = value;
usb_control_msg(gspca_dev->dev, ret = usb_control_msg(gspca_dev->dev,
usb_sndctrlpipe(gspca_dev->dev, 0), usb_sndctrlpipe(gspca_dev->dev, 0),
0, /* request */ 0, /* request */
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, index, gspca_dev->usb_buf, 1, 0, index, gspca_dev->usb_buf, 1,
500); 500);
if (ret < 0)
PDEBUG(D_ERR, "reg_w(): "
"Failed to write register to index 0x%x, value 0x%x, error %i",
index, value, ret);
} }
static void reg_w_seq(struct gspca_dev *gspca_dev, static void reg_w_seq(struct gspca_dev *gspca_dev,
...@@ -373,17 +385,23 @@ static void reg_w_page(struct gspca_dev *gspca_dev, ...@@ -373,17 +385,23 @@ static void reg_w_page(struct gspca_dev *gspca_dev,
const __u8 *page, int len) const __u8 *page, int len)
{ {
int index; int index;
int ret;
for (index = 0; index < len; index++) { for (index = 0; index < len; index++) {
if (page[index] == SKIP) /* skip this index */ if (page[index] == SKIP) /* skip this index */
continue; continue;
gspca_dev->usb_buf[0] = page[index]; gspca_dev->usb_buf[0] = page[index];
usb_control_msg(gspca_dev->dev, ret = usb_control_msg(gspca_dev->dev,
usb_sndctrlpipe(gspca_dev->dev, 0), usb_sndctrlpipe(gspca_dev->dev, 0),
0, /* request */ 0, /* request */
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, index, gspca_dev->usb_buf, 1, 0, index, gspca_dev->usb_buf, 1,
500); 500);
if (ret < 0)
PDEBUG(D_ERR, "reg_w_page(): "
"Failed to write register to index 0x%x, "
"value 0x%x, error %i",
index, page[index], ret);
} }
} }
......
...@@ -263,14 +263,20 @@ static void reg_w_buf(struct gspca_dev *gspca_dev, ...@@ -263,14 +263,20 @@ static void reg_w_buf(struct gspca_dev *gspca_dev,
__u8 index, __u8 index,
const char *buffer, int len) const char *buffer, int len)
{ {
int ret;
memcpy(gspca_dev->usb_buf, buffer, len); memcpy(gspca_dev->usb_buf, buffer, len);
usb_control_msg(gspca_dev->dev, ret = usb_control_msg(gspca_dev->dev,
usb_sndctrlpipe(gspca_dev->dev, 0), usb_sndctrlpipe(gspca_dev->dev, 0),
1, /* request */ 1, /* request */
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, /* value */ 0, /* value */
index, gspca_dev->usb_buf, len, index, gspca_dev->usb_buf, len,
500); 500);
if (ret < 0)
PDEBUG(D_ERR, "reg_w_buf(): "
"Failed to write registers to index 0x%x, error %i",
index, ret);
} }
...@@ -278,13 +284,19 @@ static void reg_w(struct gspca_dev *gspca_dev, ...@@ -278,13 +284,19 @@ static void reg_w(struct gspca_dev *gspca_dev,
__u8 index, __u8 index,
__u8 value) __u8 value)
{ {
int ret;
gspca_dev->usb_buf[0] = value; gspca_dev->usb_buf[0] = value;
usb_control_msg(gspca_dev->dev, ret = usb_control_msg(gspca_dev->dev,
usb_sndctrlpipe(gspca_dev->dev, 0), usb_sndctrlpipe(gspca_dev->dev, 0),
0, /* request */ 0, /* request */
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, index, gspca_dev->usb_buf, 1, 0, index, gspca_dev->usb_buf, 1,
500); 500);
if (ret < 0)
PDEBUG(D_ERR, "reg_w(): "
"Failed to write register to index 0x%x, value 0x%x, error %i",
index, value, ret);
} }
static void reg_w_seq(struct gspca_dev *gspca_dev, static void reg_w_seq(struct gspca_dev *gspca_dev,
...@@ -301,17 +313,23 @@ static void reg_w_page(struct gspca_dev *gspca_dev, ...@@ -301,17 +313,23 @@ static void reg_w_page(struct gspca_dev *gspca_dev,
const __u8 *page, int len) const __u8 *page, int len)
{ {
int index; int index;
int ret;
for (index = 0; index < len; index++) { for (index = 0; index < len; index++) {
if (page[index] == SKIP) /* skip this index */ if (page[index] == SKIP) /* skip this index */
continue; continue;
gspca_dev->usb_buf[0] = page[index]; gspca_dev->usb_buf[0] = page[index];
usb_control_msg(gspca_dev->dev, ret = usb_control_msg(gspca_dev->dev,
usb_sndctrlpipe(gspca_dev->dev, 0), usb_sndctrlpipe(gspca_dev->dev, 0),
0, /* request */ 0, /* request */
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, index, gspca_dev->usb_buf, 1, 0, index, gspca_dev->usb_buf, 1,
500); 500);
if (ret < 0)
PDEBUG(D_ERR, "reg_w_page(): "
"Failed to write register to index 0x%x, "
"value 0x%x, error %i",
index, page[index], ret);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment