diff options
author | Antti Palosaari <crope@iki.fi> | 2012-06-21 03:27:42 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-04 14:56:37 +0400 |
commit | 1162c7b383a62431d5800e3697423fbcf9133ad7 (patch) | |
tree | 5fb34ee3cb08844eacd6ca153a55c38b75646e0a /drivers/media/dvb/dvb-usb | |
parent | 831511bdeee8b956fc9399f61fc9b25bd808429f (diff) | |
download | linux-1162c7b383a62431d5800e3697423fbcf9133ad7.tar.xz |
[media] dvb_usb_v2: refactor dvb_usbv2_generic_rw()
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r-- | drivers/media/dvb/dvb-usb/af9015.c | 2 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/af9035.c | 2 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/anysee.c | 2 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb_usb.h | 4 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb_usb_urb.c | 47 |
5 files changed, 26 insertions, 31 deletions
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c index 6cecd755f1d9..e48cb586f4cf 100644 --- a/drivers/media/dvb/dvb-usb/af9015.c +++ b/drivers/media/dvb/dvb-usb/af9015.c @@ -100,7 +100,7 @@ static int af9015_ctrl_msg(struct dvb_usb_device *d, struct req_t *req) if (req->cmd == DOWNLOAD_FIRMWARE || req->cmd == RECONNECT_USB) rlen = 0; - ret = dvb_usbv2_generic_rw(d, buf, wlen, buf, rlen, 0); + ret = dvb_usbv2_generic_rw(d, buf, wlen, buf, rlen); if (ret) goto error; diff --git a/drivers/media/dvb/dvb-usb/af9035.c b/drivers/media/dvb/dvb-usb/af9035.c index b030055d14a3..82b1ac716c2f 100644 --- a/drivers/media/dvb/dvb-usb/af9035.c +++ b/drivers/media/dvb/dvb-usb/af9035.c @@ -77,7 +77,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct usb_req *req) if (req->cmd == CMD_FW_DL) rlen = 0; - ret = dvb_usbv2_generic_rw(d, buf, wlen, buf, rlen, 0); + ret = dvb_usbv2_generic_rw(d, buf, wlen, buf, rlen); if (ret) goto err; diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c index 9de0004c06d3..87c978b0373e 100644 --- a/drivers/media/dvb/dvb-usb/anysee.c +++ b/drivers/media/dvb/dvb-usb/anysee.c @@ -69,7 +69,7 @@ static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen, /* We need receive one message more after dvb_usb_generic_rw due to weird transaction flow, which is 1 x send + 2 x receive. */ - ret = dvb_usbv2_generic_rw(d, buf, sizeof(buf), buf, sizeof(buf), 0); + ret = dvb_usbv2_generic_rw(d, buf, sizeof(buf), buf, sizeof(buf)); if (ret) goto error_unlock; diff --git a/drivers/media/dvb/dvb-usb/dvb_usb.h b/drivers/media/dvb/dvb-usb/dvb_usb.h index 56bf3a7f085b..d771e1c72737 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb.h +++ b/drivers/media/dvb/dvb-usb/dvb_usb.h @@ -197,6 +197,7 @@ struct dvb_usb_device_properties { unsigned int size_of_priv; u8 generic_bulk_ctrl_endpoint; u8 generic_bulk_ctrl_endpoint_response; + unsigned int generic_bulk_ctrl_delay; #define WARM 0 #define COLD 1 @@ -371,8 +372,7 @@ extern int dvb_usbv2_suspend(struct usb_interface *, pm_message_t); extern int dvb_usbv2_resume(struct usb_interface *); /* the generic read/write method for device control */ -extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16, - int); +extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16); extern int dvb_usbv2_generic_write(struct dvb_usb_device *, u8 *, u16); #endif diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_urb.c b/drivers/media/dvb/dvb-usb/dvb_usb_urb.c index e886362ccf7e..11e284b371be 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_urb.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_urb.c @@ -10,55 +10,50 @@ #undef DVB_USB_XFER_DEBUG int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, - u16 rlen, int delay_ms) + u16 rlen) { - int actlen, ret = -ENOMEM; + int ret, actual_length; - if (!d || wbuf == NULL || wlen == 0) - return -EINVAL; - - if (d->props->generic_bulk_ctrl_endpoint == 0) { - pr_err("%s: endpoint for generic control not specified\n", - KBUILD_MODNAME); + if (!d || !wbuf || !wlen || !d->props->generic_bulk_ctrl_endpoint || + !d->props->generic_bulk_ctrl_endpoint_response) { + pr_debug("%s: failed=%d\n", __func__, -EINVAL); return -EINVAL; } ret = mutex_lock_interruptible(&d->usb_mutex); - if (ret) + if (ret < 0) return ret; #ifdef DVB_USB_XFER_DEBUG print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": >>> ", DUMP_PREFIX_NONE, 32, 1, wbuf, wlen, 0); #endif - ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev, d->props->generic_bulk_ctrl_endpoint), wbuf, wlen, - &actlen, 2000); - - if (ret) - pr_err("%s: bulk message failed: %d (%d/%d)\n", KBUILD_MODNAME, - ret, wlen, actlen); + &actual_length, 2000); + if (ret < 0) + pr_err("%s: usb_bulk_msg() failed=%d\n", KBUILD_MODNAME, ret); else - ret = actlen != wlen ? -1 : 0; + ret = actual_length != wlen ? -EIO : 0; /* an answer is expected, and no error before */ if (!ret && rbuf && rlen) { - if (delay_ms) - msleep(delay_ms); + if (d->props->generic_bulk_ctrl_delay) + usleep_range(d->props->generic_bulk_ctrl_delay, + d->props->generic_bulk_ctrl_delay + + 20000); ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, - d->props->generic_bulk_ctrl_endpoint_response ? - d->props->generic_bulk_ctrl_endpoint_response : - d->props->generic_bulk_ctrl_endpoint), - rbuf, rlen, &actlen, 2000); - + d->props->generic_bulk_ctrl_endpoint_response), + rbuf, rlen, &actual_length, 2000); if (ret) - pr_err("%s: recv bulk message failed: %d\n", + pr_err("%s: 2nd usb_bulk_msg() failed=%d\n", KBUILD_MODNAME, ret); + #ifdef DVB_USB_XFER_DEBUG print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": <<< ", - DUMP_PREFIX_NONE, 32, 1, rbuf, actlen, 0); + DUMP_PREFIX_NONE, 32, 1, rbuf, actual_length, + 0); #endif } @@ -69,6 +64,6 @@ EXPORT_SYMBOL(dvb_usbv2_generic_rw); int dvb_usbv2_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len) { - return dvb_usbv2_generic_rw(d, buf, len, NULL, 0, 0); + return dvb_usbv2_generic_rw(d, buf, len, NULL, 0); } EXPORT_SYMBOL(dvb_usbv2_generic_write); |