Commit 12fe2a61 authored by Florian Mickler's avatar Florian Mickler Committed by Mauro Carvalho Chehab

[media] opera1: get rid of on-stack dma buffer

usb_control_msg initiates (and waits for completion of) a dma transfer using
the supplied buffer. That buffer thus has to be seperately allocated on
the heap.

In lib/dma_debug.c the function check_for_stack even warns about it:
	WARNING: at lib/dma-debug.c:866 check_for_stack

Note: This change is tested to compile only, as I don't have the hardware.
Signed-off-by: default avatarFlorian Mickler <florian@mickler.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 513ea35f
...@@ -53,27 +53,36 @@ static int opera1_xilinx_rw(struct usb_device *dev, u8 request, u16 value, ...@@ -53,27 +53,36 @@ static int opera1_xilinx_rw(struct usb_device *dev, u8 request, u16 value,
u8 * data, u16 len, int flags) u8 * data, u16 len, int flags)
{ {
int ret; int ret;
u8 r; u8 tmp;
u8 u8buf[len]; u8 *buf;
unsigned int pipe = (flags == OPERA_READ_MSG) ? unsigned int pipe = (flags == OPERA_READ_MSG) ?
usb_rcvctrlpipe(dev,0) : usb_sndctrlpipe(dev, 0); usb_rcvctrlpipe(dev,0) : usb_sndctrlpipe(dev, 0);
u8 request_type = (flags == OPERA_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT; u8 request_type = (flags == OPERA_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
buf = kmalloc(len, GFP_KERNEL);
if (!buf)
return -ENOMEM;
if (flags == OPERA_WRITE_MSG) if (flags == OPERA_WRITE_MSG)
memcpy(u8buf, data, len); memcpy(buf, data, len);
ret = ret = usb_control_msg(dev, pipe, request,
usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, request_type | USB_TYPE_VENDOR, value, 0x0,
value, 0x0, u8buf, len, 2000); buf, len, 2000);
if (request == OPERA_TUNER_REQ) { if (request == OPERA_TUNER_REQ) {
tmp = buf[0];
if (usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), if (usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
OPERA_TUNER_REQ, USB_DIR_IN | USB_TYPE_VENDOR, OPERA_TUNER_REQ, USB_DIR_IN | USB_TYPE_VENDOR,
0x01, 0x0, &r, 1, 2000)<1 || r!=0x08) 0x01, 0x0, buf, 1, 2000) < 1 || buf[0] != 0x08) {
return 0; ret = 0;
goto out;
}
buf[0] = tmp;
} }
if (flags == OPERA_READ_MSG) if (flags == OPERA_READ_MSG)
memcpy(data, u8buf, len); memcpy(data, buf, len);
out:
kfree(buf);
return ret; return 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