summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-07 11:04:38 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-14 11:47:35 -0400
commit88ca3619001380a3147246a22cb356f6065ad713 (patch)
tree1b405c686d021f505b22f0675dd57f60e517fc87
parent5dfd2c8f263dfcaf614d24734f0af8c1c18a9ca8 (diff)
[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: Patrick Boettcher <patrick.boettcher@posteo.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/usb/dvb-usb/technisat-usb2.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
index d9f3262bf071..4706628a3ed5 100644
--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
@@ -89,9 +89,13 @@ struct technisat_usb2_state {
89static int technisat_usb2_i2c_access(struct usb_device *udev, 89static int technisat_usb2_i2c_access(struct usb_device *udev,
90 u8 device_addr, u8 *tx, u8 txlen, u8 *rx, u8 rxlen) 90 u8 device_addr, u8 *tx, u8 txlen, u8 *rx, u8 rxlen)
91{ 91{
92 u8 b[64]; 92 u8 *b;
93 int ret, actual_length; 93 int ret, actual_length;
94 94
95 b = kmalloc(64, GFP_KERNEL);
96 if (!b)
97 return -ENOMEM;
98
95 deb_i2c("i2c-access: %02x, tx: ", device_addr); 99 deb_i2c("i2c-access: %02x, tx: ", device_addr);
96 debug_dump(tx, txlen, deb_i2c); 100 debug_dump(tx, txlen, deb_i2c);
97 deb_i2c(" "); 101 deb_i2c(" ");
@@ -123,7 +127,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
123 127
124 if (ret < 0) { 128 if (ret < 0) {
125 err("i2c-error: out failed %02x = %d", device_addr, ret); 129 err("i2c-error: out failed %02x = %d", device_addr, ret);
126 return -ENODEV; 130 goto err;
127 } 131 }
128 132
129 ret = usb_bulk_msg(udev, 133 ret = usb_bulk_msg(udev,
@@ -131,7 +135,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
131 b, 64, &actual_length, 1000); 135 b, 64, &actual_length, 1000);
132 if (ret < 0) { 136 if (ret < 0) {
133 err("i2c-error: in failed %02x = %d", device_addr, ret); 137 err("i2c-error: in failed %02x = %d", device_addr, ret);
134 return -ENODEV; 138 goto err;
135 } 139 }
136 140
137 if (b[0] != I2C_STATUS_OK) { 141 if (b[0] != I2C_STATUS_OK) {
@@ -140,7 +144,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
140 if (!(b[0] == I2C_STATUS_NAK && 144 if (!(b[0] == I2C_STATUS_NAK &&
141 device_addr == 0x60 145 device_addr == 0x60
142 /* && device_is_technisat_usb2 */)) 146 /* && device_is_technisat_usb2 */))
143 return -ENODEV; 147 goto err;
144 } 148 }
145 149
146 deb_i2c("status: %d, ", b[0]); 150 deb_i2c("status: %d, ", b[0]);
@@ -154,7 +158,9 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
154 158
155 deb_i2c("\n"); 159 deb_i2c("\n");
156 160
157 return 0; 161err:
162 kfree(b);
163 return ret;
158} 164}
159 165
160static int technisat_usb2_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, 166static int technisat_usb2_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,