Commit fa86c9a1 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] gp8psk: don't do DMA on stack

The USB control messages require DMA to work. We cannot pass
a stack-allocated buffer, as it is not warranted that the
stack would be into a DMA enabled area.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 8f306145
...@@ -24,6 +24,10 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DV ...@@ -24,6 +24,10 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DV
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
struct gp8psk_state {
unsigned char data[80];
};
static int gp8psk_get_fw_version(struct dvb_usb_device *d, u8 *fw_vers) static int gp8psk_get_fw_version(struct dvb_usb_device *d, u8 *fw_vers)
{ {
return (gp8psk_usb_in_op(d, GET_FW_VERS, 0, 0, fw_vers, 6)); return (gp8psk_usb_in_op(d, GET_FW_VERS, 0, 0, fw_vers, 6));
...@@ -53,17 +57,19 @@ static void gp8psk_info(struct dvb_usb_device *d) ...@@ -53,17 +57,19 @@ static void gp8psk_info(struct dvb_usb_device *d)
int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen)
{ {
struct gp8psk_state *st = d->priv;
int ret = 0,try = 0; int ret = 0,try = 0;
if ((ret = mutex_lock_interruptible(&d->usb_mutex))) if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
return ret; return ret;
while (ret >= 0 && ret != blen && try < 3) { while (ret >= 0 && ret != blen && try < 3) {
memcpy(st->data, b, blen);
ret = usb_control_msg(d->udev, ret = usb_control_msg(d->udev,
usb_rcvctrlpipe(d->udev,0), usb_rcvctrlpipe(d->udev,0),
req, req,
USB_TYPE_VENDOR | USB_DIR_IN, USB_TYPE_VENDOR | USB_DIR_IN,
value,index,b,blen, value, index, st->data, blen,
2000); 2000);
deb_info("reading number %d (ret: %d)\n",try,ret); deb_info("reading number %d (ret: %d)\n",try,ret);
try++; try++;
...@@ -86,6 +92,7 @@ int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 ...@@ -86,6 +92,7 @@ int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8
int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
u16 index, u8 *b, int blen) u16 index, u8 *b, int blen)
{ {
struct gp8psk_state *st = d->priv;
int ret; int ret;
deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index); deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index);
...@@ -94,11 +101,12 @@ int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, ...@@ -94,11 +101,12 @@ int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
if ((ret = mutex_lock_interruptible(&d->usb_mutex))) if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
return ret; return ret;
memcpy(st->data, b, blen);
if (usb_control_msg(d->udev, if (usb_control_msg(d->udev,
usb_sndctrlpipe(d->udev,0), usb_sndctrlpipe(d->udev,0),
req, req,
USB_TYPE_VENDOR | USB_DIR_OUT, USB_TYPE_VENDOR | USB_DIR_OUT,
value,index,b,blen, value, index, st->data, blen,
2000) != blen) { 2000) != blen) {
warn("usb out operation failed."); warn("usb out operation failed.");
ret = -EIO; ret = -EIO;
...@@ -265,6 +273,8 @@ static struct dvb_usb_device_properties gp8psk_properties = { ...@@ -265,6 +273,8 @@ static struct dvb_usb_device_properties gp8psk_properties = {
.usb_ctrl = CYPRESS_FX2, .usb_ctrl = CYPRESS_FX2,
.firmware = "dvb-usb-gp8psk-01.fw", .firmware = "dvb-usb-gp8psk-01.fw",
.size_of_priv = sizeof(struct gp8psk_state),
.num_adapters = 1, .num_adapters = 1,
.adapter = { .adapter = {
{ {
......
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