diff options
author | Florian Mickler <florian@mickler.org> | 2011-03-21 06:19:08 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-05-20 08:28:05 -0400 |
commit | 1c6410f317c3e78409f0179283089034c77a6ad5 (patch) | |
tree | 281a8ff04d5e6af29030572f78cb14a4447441b6 /drivers/media/dvb/dvb-usb | |
parent | 36f773e8e3f207136a6b903b71754593e0e1819c (diff) |
[media] vp702x: preallocate memory on device probe
This sets up a buffer and a mutex protecting that buffer in
the struct vp702x_device_state.
The definition of struct vp702x_device_state is moved into the header
in order to use the buffer also in the frontend.
Signed-off-by: Florian Mickler <florian@mickler.org>
Cc: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r-- | drivers/media/dvb/dvb-usb/vp702x.c | 41 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/vp702x.h | 8 |
2 files changed, 42 insertions, 7 deletions
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c index 25536f98c4d1..569c93fbb86c 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.c +++ b/drivers/media/dvb/dvb-usb/vp702x.c | |||
@@ -15,6 +15,7 @@ | |||
15 | * see Documentation/dvb/README.dvb-usb for more information | 15 | * see Documentation/dvb/README.dvb-usb for more information |
16 | */ | 16 | */ |
17 | #include "vp702x.h" | 17 | #include "vp702x.h" |
18 | #include <linux/mutex.h> | ||
18 | 19 | ||
19 | /* debug */ | 20 | /* debug */ |
20 | int dvb_usb_vp702x_debug; | 21 | int dvb_usb_vp702x_debug; |
@@ -29,10 +30,6 @@ struct vp702x_adapter_state { | |||
29 | u8 pid_filter_state; | 30 | u8 pid_filter_state; |
30 | }; | 31 | }; |
31 | 32 | ||
32 | struct vp702x_device_state { | ||
33 | u8 power_state; | ||
34 | }; | ||
35 | |||
36 | /* check for mutex FIXME */ | 33 | /* check for mutex FIXME */ |
37 | int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) | 34 | int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) |
38 | { | 35 | { |
@@ -241,8 +238,38 @@ static struct dvb_usb_device_properties vp702x_properties; | |||
241 | static int vp702x_usb_probe(struct usb_interface *intf, | 238 | static int vp702x_usb_probe(struct usb_interface *intf, |
242 | const struct usb_device_id *id) | 239 | const struct usb_device_id *id) |
243 | { | 240 | { |
244 | return dvb_usb_device_init(intf, &vp702x_properties, | 241 | struct dvb_usb_device *d; |
245 | THIS_MODULE, NULL, adapter_nr); | 242 | struct vp702x_device_state *st; |
243 | int ret; | ||
244 | |||
245 | ret = dvb_usb_device_init(intf, &vp702x_properties, | ||
246 | THIS_MODULE, &d, adapter_nr); | ||
247 | if (ret) | ||
248 | goto out; | ||
249 | |||
250 | st = d->priv; | ||
251 | st->buf_len = 16; | ||
252 | st->buf = kmalloc(st->buf_len, GFP_KERNEL); | ||
253 | if (!st->buf) { | ||
254 | ret = -ENOMEM; | ||
255 | dvb_usb_device_exit(intf); | ||
256 | goto out; | ||
257 | } | ||
258 | mutex_init(&st->buf_mutex); | ||
259 | |||
260 | out: | ||
261 | return ret; | ||
262 | |||
263 | } | ||
264 | |||
265 | static void vp702x_usb_disconnect(struct usb_interface *intf) | ||
266 | { | ||
267 | struct dvb_usb_device *d = usb_get_intfdata(intf); | ||
268 | struct vp702x_device_state *st = d->priv; | ||
269 | mutex_lock(&st->buf_mutex); | ||
270 | kfree(st->buf); | ||
271 | mutex_unlock(&st->buf_mutex); | ||
272 | dvb_usb_device_exit(intf); | ||
246 | } | 273 | } |
247 | 274 | ||
248 | static struct usb_device_id vp702x_usb_table [] = { | 275 | static struct usb_device_id vp702x_usb_table [] = { |
@@ -309,7 +336,7 @@ static struct dvb_usb_device_properties vp702x_properties = { | |||
309 | static struct usb_driver vp702x_usb_driver = { | 336 | static struct usb_driver vp702x_usb_driver = { |
310 | .name = "dvb_usb_vp702x", | 337 | .name = "dvb_usb_vp702x", |
311 | .probe = vp702x_usb_probe, | 338 | .probe = vp702x_usb_probe, |
312 | .disconnect = dvb_usb_device_exit, | 339 | .disconnect = vp702x_usb_disconnect, |
313 | .id_table = vp702x_usb_table, | 340 | .id_table = vp702x_usb_table, |
314 | }; | 341 | }; |
315 | 342 | ||
diff --git a/drivers/media/dvb/dvb-usb/vp702x.h b/drivers/media/dvb/dvb-usb/vp702x.h index c2f97f96c21f..86960c657522 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.h +++ b/drivers/media/dvb/dvb-usb/vp702x.h | |||
@@ -98,6 +98,14 @@ extern int dvb_usb_vp702x_debug; | |||
98 | #define RESET_TUNER 0xBE | 98 | #define RESET_TUNER 0xBE |
99 | /* IN i: 0, v: 0, no extra buffer */ | 99 | /* IN i: 0, v: 0, no extra buffer */ |
100 | 100 | ||
101 | struct vp702x_device_state { | ||
102 | u8 power_state; | ||
103 | struct mutex buf_mutex; | ||
104 | int buf_len; | ||
105 | u8 *buf; | ||
106 | }; | ||
107 | |||
108 | |||
101 | extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d); | 109 | extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d); |
102 | 110 | ||
103 | extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec); | 111 | extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec); |