Commit d3411f65 authored by Malcolm Priestley's avatar Malcolm Priestley Committed by Mauro Carvalho Chehab

media: lmedm04: use dvb_usbv2_generic_rw_locked

Use dvb-usb-v2 generic usb function for bulk transfers and simplify logic.
Signed-off-by: default avatarMalcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 8824e501
...@@ -147,50 +147,30 @@ struct lme2510_state { ...@@ -147,50 +147,30 @@ struct lme2510_state {
u8 dvb_usb_lme2510_firmware; u8 dvb_usb_lme2510_firmware;
}; };
static int lme2510_bulk_write(struct usb_device *dev,
u8 *snd, int len, u8 pipe)
{
int actual_l;
return usb_bulk_msg(dev, usb_sndbulkpipe(dev, pipe),
snd, len, &actual_l, 100);
}
static int lme2510_bulk_read(struct usb_device *dev,
u8 *rev, int len, u8 pipe)
{
int actual_l;
return usb_bulk_msg(dev, usb_rcvbulkpipe(dev, pipe),
rev, len, &actual_l, 200);
}
static int lme2510_usb_talk(struct dvb_usb_device *d, static int lme2510_usb_talk(struct dvb_usb_device *d,
u8 *wbuf, int wlen, u8 *rbuf, int rlen) u8 *wbuf, int wlen, u8 *rbuf, int rlen)
{ {
struct lme2510_state *st = d->priv; struct lme2510_state *st = d->priv;
u8 *buff = st->usb_buffer;
int ret = 0; int ret = 0;
ret = mutex_lock_interruptible(&d->usb_mutex); if (max(wlen, rlen) > sizeof(st->usb_buffer))
return -EINVAL;
ret = mutex_lock_interruptible(&d->usb_mutex);
if (ret < 0) if (ret < 0)
return -EAGAIN; return -EAGAIN;
/* the read/write capped at 64 */ memcpy(st->usb_buffer, wbuf, wlen);
memcpy(buff, wbuf, (wlen < 64) ? wlen : 64);
ret |= lme2510_bulk_write(d->udev, buff, wlen , 0x01); ret = dvb_usbv2_generic_rw_locked(d, st->usb_buffer, wlen,
st->usb_buffer, rlen);
ret |= lme2510_bulk_read(d->udev, buff, (rlen < 64) ? if (rlen)
rlen : 64 , 0x01); memcpy(rbuf, st->usb_buffer, rlen);
if (rlen > 0)
memcpy(rbuf, buff, rlen);
mutex_unlock(&d->usb_mutex); mutex_unlock(&d->usb_mutex);
return (ret < 0) ? -ENODEV : 0; return ret;
} }
static int lme2510_stream_restart(struct dvb_usb_device *d) static int lme2510_stream_restart(struct dvb_usb_device *d)
...@@ -1259,6 +1239,8 @@ static struct dvb_usb_device_properties lme2510_props = { ...@@ -1259,6 +1239,8 @@ static struct dvb_usb_device_properties lme2510_props = {
.bInterfaceNumber = 0, .bInterfaceNumber = 0,
.adapter_nr = adapter_nr, .adapter_nr = adapter_nr,
.size_of_priv = sizeof(struct lme2510_state), .size_of_priv = sizeof(struct lme2510_state),
.generic_bulk_ctrl_endpoint = 0x01,
.generic_bulk_ctrl_endpoint_response = 0x01,
.download_firmware = lme2510_download_firmware, .download_firmware = lme2510_download_firmware,
......
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