diff options
author | Florian Mickler <florian@mickler.org> | 2011-03-21 14:33:42 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-05-20 08:27:55 -0400 |
commit | ab22cbda6651db25d03052aa9ee9452b5eaa3edd (patch) | |
tree | 0c2a81048cfa165c7493b37cf51bd187d306e71d /drivers/media/dvb | |
parent | 54f4e11ae3051ff7a921494be5106788db19dcf7 (diff) |
[media] vp7045: get rid of on-stack dma buffers
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/dvb-usb/vp7045.c | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index ab0ab3c35e80..3db89e3cb0bb 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c | |||
@@ -28,9 +28,9 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | |||
28 | int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, int inlen, int msec) | 28 | int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, int inlen, int msec) |
29 | { | 29 | { |
30 | int ret = 0; | 30 | int ret = 0; |
31 | u8 inbuf[12] = { 0 }, outbuf[20] = { 0 }; | 31 | u8 *buf = d->priv; |
32 | 32 | ||
33 | outbuf[0] = cmd; | 33 | buf[0] = cmd; |
34 | 34 | ||
35 | if (outlen > 19) | 35 | if (outlen > 19) |
36 | outlen = 19; | 36 | outlen = 19; |
@@ -38,19 +38,21 @@ int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, | |||
38 | if (inlen > 11) | 38 | if (inlen > 11) |
39 | inlen = 11; | 39 | inlen = 11; |
40 | 40 | ||
41 | ret = mutex_lock_interruptible(&d->usb_mutex); | ||
42 | if (ret) | ||
43 | return ret; | ||
44 | |||
41 | if (out != NULL && outlen > 0) | 45 | if (out != NULL && outlen > 0) |
42 | memcpy(&outbuf[1], out, outlen); | 46 | memcpy(&buf[1], out, outlen); |
43 | 47 | ||
44 | deb_xfer("out buffer: "); | 48 | deb_xfer("out buffer: "); |
45 | debug_dump(outbuf,outlen+1,deb_xfer); | 49 | debug_dump(buf, outlen+1, deb_xfer); |
46 | 50 | ||
47 | if ((ret = mutex_lock_interruptible(&d->usb_mutex))) | ||
48 | return ret; | ||
49 | 51 | ||
50 | if (usb_control_msg(d->udev, | 52 | if (usb_control_msg(d->udev, |
51 | usb_sndctrlpipe(d->udev,0), | 53 | usb_sndctrlpipe(d->udev,0), |
52 | TH_COMMAND_OUT, USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, | 54 | TH_COMMAND_OUT, USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, |
53 | outbuf, 20, 2000) != 20) { | 55 | buf, 20, 2000) != 20) { |
54 | err("USB control message 'out' went wrong."); | 56 | err("USB control message 'out' went wrong."); |
55 | ret = -EIO; | 57 | ret = -EIO; |
56 | goto unlock; | 58 | goto unlock; |
@@ -61,17 +63,17 @@ int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, | |||
61 | if (usb_control_msg(d->udev, | 63 | if (usb_control_msg(d->udev, |
62 | usb_rcvctrlpipe(d->udev,0), | 64 | usb_rcvctrlpipe(d->udev,0), |
63 | TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, | 65 | TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, |
64 | inbuf, 12, 2000) != 12) { | 66 | buf, 12, 2000) != 12) { |
65 | err("USB control message 'in' went wrong."); | 67 | err("USB control message 'in' went wrong."); |
66 | ret = -EIO; | 68 | ret = -EIO; |
67 | goto unlock; | 69 | goto unlock; |
68 | } | 70 | } |
69 | 71 | ||
70 | deb_xfer("in buffer: "); | 72 | deb_xfer("in buffer: "); |
71 | debug_dump(inbuf,12,deb_xfer); | 73 | debug_dump(buf, 12, deb_xfer); |
72 | 74 | ||
73 | if (in != NULL && inlen > 0) | 75 | if (in != NULL && inlen > 0) |
74 | memcpy(in,&inbuf[1],inlen); | 76 | memcpy(in, &buf[1], inlen); |
75 | 77 | ||
76 | unlock: | 78 | unlock: |
77 | mutex_unlock(&d->usb_mutex); | 79 | mutex_unlock(&d->usb_mutex); |
@@ -222,8 +224,26 @@ static struct dvb_usb_device_properties vp7045_properties; | |||
222 | static int vp7045_usb_probe(struct usb_interface *intf, | 224 | static int vp7045_usb_probe(struct usb_interface *intf, |
223 | const struct usb_device_id *id) | 225 | const struct usb_device_id *id) |
224 | { | 226 | { |
225 | return dvb_usb_device_init(intf, &vp7045_properties, | 227 | struct dvb_usb_device *d; |
226 | THIS_MODULE, NULL, adapter_nr); | 228 | int ret = dvb_usb_device_init(intf, &vp7045_properties, |
229 | THIS_MODULE, &d, adapter_nr); | ||
230 | if (ret) | ||
231 | return ret; | ||
232 | |||
233 | d->priv = kmalloc(20, GFP_KERNEL); | ||
234 | if (!d->priv) { | ||
235 | dvb_usb_device_exit(intf); | ||
236 | return -ENOMEM; | ||
237 | } | ||
238 | |||
239 | return ret; | ||
240 | } | ||
241 | |||
242 | static void vp7045_usb_disconnect(struct usb_interface *intf) | ||
243 | { | ||
244 | struct dvb_usb_device *d = usb_get_intfdata(intf); | ||
245 | kfree(d->priv); | ||
246 | dvb_usb_device_exit(intf); | ||
227 | } | 247 | } |
228 | 248 | ||
229 | static struct usb_device_id vp7045_usb_table [] = { | 249 | static struct usb_device_id vp7045_usb_table [] = { |
@@ -238,6 +258,7 @@ MODULE_DEVICE_TABLE(usb, vp7045_usb_table); | |||
238 | static struct dvb_usb_device_properties vp7045_properties = { | 258 | static struct dvb_usb_device_properties vp7045_properties = { |
239 | .usb_ctrl = CYPRESS_FX2, | 259 | .usb_ctrl = CYPRESS_FX2, |
240 | .firmware = "dvb-usb-vp7045-01.fw", | 260 | .firmware = "dvb-usb-vp7045-01.fw", |
261 | .size_of_priv = sizeof(u8 *), | ||
241 | 262 | ||
242 | .num_adapters = 1, | 263 | .num_adapters = 1, |
243 | .adapter = { | 264 | .adapter = { |
@@ -284,7 +305,7 @@ static struct dvb_usb_device_properties vp7045_properties = { | |||
284 | static struct usb_driver vp7045_usb_driver = { | 305 | static struct usb_driver vp7045_usb_driver = { |
285 | .name = "dvb_usb_vp7045", | 306 | .name = "dvb_usb_vp7045", |
286 | .probe = vp7045_usb_probe, | 307 | .probe = vp7045_usb_probe, |
287 | .disconnect = dvb_usb_device_exit, | 308 | .disconnect = vp7045_usb_disconnect, |
288 | .id_table = vp7045_usb_table, | 309 | .id_table = vp7045_usb_table, |
289 | }; | 310 | }; |
290 | 311 | ||