[media] dtv5100: don't do DMA on stack
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 7 Oct 2016 11:51:23 +0000 (08:51 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 14 Oct 2016 15:44:03 +0000 (12:44 -0300)
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: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/usb/dvb-usb/dtv5100.c

index 3d11df41cac0300c00a5d635412b233d232d338f..c60fb54f445f582357ca949b3e4f6775e0822e12 100644 (file)
@@ -31,9 +31,14 @@ module_param_named(debug, dvb_usb_dtv5100_debug, int, 0644);
 MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
+struct dtv5100_state {
+       unsigned char data[80];
+};
+
 static int dtv5100_i2c_msg(struct dvb_usb_device *d, u8 addr,
                           u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
 {
+       struct dtv5100_state *st = d->priv;
        u8 request;
        u8 type;
        u16 value;
@@ -60,9 +65,10 @@ static int dtv5100_i2c_msg(struct dvb_usb_device *d, u8 addr,
        }
        index = (addr << 8) + wbuf[0];
 
+       memcpy(st->data, rbuf, rlen);
        msleep(1); /* avoid I2C errors */
        return usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), request,
-                              type, value, index, rbuf, rlen,
+                              type, value, index, st->data, rlen,
                               DTV5100_USB_TIMEOUT);
 }
 
@@ -176,7 +182,7 @@ static struct dvb_usb_device_properties dtv5100_properties = {
        .caps = DVB_USB_IS_AN_I2C_ADAPTER,
        .usb_ctrl = DEVICE_SPECIFIC,
 
-       .size_of_priv = 0,
+       .size_of_priv = sizeof(struct dtv5100_state),
 
        .num_adapters = 1,
        .adapter = {{