Commit 88ca3619 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] technisat-usb2: use DMA buffers for I2C transfers

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.

On this driver, most of the transfers are OK, but the I2C
one was using stack.
Reviewed-by: default avatarPatrick Boettcher <patrick.boettcher@posteo.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 5dfd2c8f
...@@ -89,9 +89,13 @@ struct technisat_usb2_state { ...@@ -89,9 +89,13 @@ struct technisat_usb2_state {
static int technisat_usb2_i2c_access(struct usb_device *udev, static int technisat_usb2_i2c_access(struct usb_device *udev,
u8 device_addr, u8 *tx, u8 txlen, u8 *rx, u8 rxlen) u8 device_addr, u8 *tx, u8 txlen, u8 *rx, u8 rxlen)
{ {
u8 b[64]; u8 *b;
int ret, actual_length; int ret, actual_length;
b = kmalloc(64, GFP_KERNEL);
if (!b)
return -ENOMEM;
deb_i2c("i2c-access: %02x, tx: ", device_addr); deb_i2c("i2c-access: %02x, tx: ", device_addr);
debug_dump(tx, txlen, deb_i2c); debug_dump(tx, txlen, deb_i2c);
deb_i2c(" "); deb_i2c(" ");
...@@ -123,7 +127,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev, ...@@ -123,7 +127,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
if (ret < 0) { if (ret < 0) {
err("i2c-error: out failed %02x = %d", device_addr, ret); err("i2c-error: out failed %02x = %d", device_addr, ret);
return -ENODEV; goto err;
} }
ret = usb_bulk_msg(udev, ret = usb_bulk_msg(udev,
...@@ -131,7 +135,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev, ...@@ -131,7 +135,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
b, 64, &actual_length, 1000); b, 64, &actual_length, 1000);
if (ret < 0) { if (ret < 0) {
err("i2c-error: in failed %02x = %d", device_addr, ret); err("i2c-error: in failed %02x = %d", device_addr, ret);
return -ENODEV; goto err;
} }
if (b[0] != I2C_STATUS_OK) { if (b[0] != I2C_STATUS_OK) {
...@@ -140,7 +144,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev, ...@@ -140,7 +144,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
if (!(b[0] == I2C_STATUS_NAK && if (!(b[0] == I2C_STATUS_NAK &&
device_addr == 0x60 device_addr == 0x60
/* && device_is_technisat_usb2 */)) /* && device_is_technisat_usb2 */))
return -ENODEV; goto err;
} }
deb_i2c("status: %d, ", b[0]); deb_i2c("status: %d, ", b[0]);
...@@ -154,7 +158,9 @@ static int technisat_usb2_i2c_access(struct usb_device *udev, ...@@ -154,7 +158,9 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
deb_i2c("\n"); deb_i2c("\n");
return 0; err:
kfree(b);
return ret;
} }
static int technisat_usb2_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, static int technisat_usb2_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
......
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