Commit acb0549a authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] dvb_usb_v2: locked versions of USB bulk IO functions

Implement:
dvb_usbv2_generic_rw_locked()
dvb_usbv2_generic_write_locked()
Caller must hold device lock when locked versions are called.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 972b072a
...@@ -400,5 +400,9 @@ extern int dvb_usbv2_reset_resume(struct usb_interface *); ...@@ -400,5 +400,9 @@ extern int dvb_usbv2_reset_resume(struct usb_interface *);
/* the generic read/write method for device control */ /* the generic read/write method for device control */
extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16); 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); extern int dvb_usbv2_generic_write(struct dvb_usb_device *, u8 *, u16);
/* caller must hold lock when locked versions are called */
extern int dvb_usbv2_generic_rw_locked(struct dvb_usb_device *,
u8 *, u16, u8 *, u16);
extern int dvb_usbv2_generic_write_locked(struct dvb_usb_device *, u8 *, u16);
#endif #endif
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include "dvb_usb_common.h" #include "dvb_usb_common.h"
int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, int dvb_usb_v2_generic_io(struct dvb_usb_device *d,
u16 rlen) u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
{ {
int ret, actual_length; int ret, actual_length;
...@@ -32,8 +32,6 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, ...@@ -32,8 +32,6 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
return -EINVAL; return -EINVAL;
} }
mutex_lock(&d->usb_mutex);
dev_dbg(&d->udev->dev, "%s: >>> %*ph\n", __func__, wlen, wbuf); dev_dbg(&d->udev->dev, "%s: >>> %*ph\n", __func__, wlen, wbuf);
ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev, ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev,
...@@ -63,13 +61,43 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, ...@@ -63,13 +61,43 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
actual_length, rbuf); actual_length, rbuf);
} }
return ret;
}
int dvb_usbv2_generic_rw(struct dvb_usb_device *d,
u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
{
int ret;
mutex_lock(&d->usb_mutex);
ret = dvb_usb_v2_generic_io(d, wbuf, wlen, rbuf, rlen);
mutex_unlock(&d->usb_mutex); mutex_unlock(&d->usb_mutex);
return ret; return ret;
} }
EXPORT_SYMBOL(dvb_usbv2_generic_rw); EXPORT_SYMBOL(dvb_usbv2_generic_rw);
int dvb_usbv2_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len) int dvb_usbv2_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len)
{ {
return dvb_usbv2_generic_rw(d, buf, len, NULL, 0); int ret;
mutex_lock(&d->usb_mutex);
ret = dvb_usb_v2_generic_io(d, buf, len, NULL, 0);
mutex_unlock(&d->usb_mutex);
return ret;
} }
EXPORT_SYMBOL(dvb_usbv2_generic_write); EXPORT_SYMBOL(dvb_usbv2_generic_write);
int dvb_usbv2_generic_rw_locked(struct dvb_usb_device *d,
u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
{
return dvb_usb_v2_generic_io(d, wbuf, wlen, rbuf, rlen);
}
EXPORT_SYMBOL(dvb_usbv2_generic_rw_locked);
int dvb_usbv2_generic_write_locked(struct dvb_usb_device *d, u8 *buf, u16 len)
{
return dvb_usb_v2_generic_io(d, buf, len, NULL, 0);
}
EXPORT_SYMBOL(dvb_usbv2_generic_write_locked);
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