diff options
author | Florian Mickler <florian@mickler.org> | 2011-03-21 06:19:11 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-05-20 08:28:10 -0400 |
commit | 9a187c4183edb6e705245c0fb2439aa3e8dce1fe (patch) | |
tree | ecd256ce60fedebe92bbc0610826cc8da1d1285a /drivers/media/dvb/dvb-usb | |
parent | 57873c720caddf19eef2d5fe734575f7175abb48 (diff) |
[media] vp702x: fix locking of usb operations
Otherwise it is not obvious that vp702x_usb_in_op or vp702x_usb_out_op
will not interfere with any vp702x_usb_inout_op.
Note: This change is tested to compile only, as I don't have the
hardware.
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 | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c index 35fe778993c1..c82cb6b3a27d 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.c +++ b/drivers/media/dvb/dvb-usb/vp702x.c | |||
@@ -30,8 +30,8 @@ struct vp702x_adapter_state { | |||
30 | u8 pid_filter_state; | 30 | u8 pid_filter_state; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | /* check for mutex FIXME */ | 33 | static int vp702x_usb_in_op_unlocked(struct dvb_usb_device *d, u8 req, |
34 | int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) | 34 | u16 value, u16 index, u8 *b, int blen) |
35 | { | 35 | { |
36 | int ret; | 36 | int ret; |
37 | 37 | ||
@@ -55,8 +55,20 @@ int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 | |||
55 | return ret; | 55 | return ret; |
56 | } | 56 | } |
57 | 57 | ||
58 | static int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, | 58 | int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, |
59 | u16 index, u8 *b, int blen) | 59 | u16 index, u8 *b, int blen) |
60 | { | ||
61 | int ret; | ||
62 | |||
63 | mutex_lock(&d->usb_mutex); | ||
64 | ret = vp702x_usb_in_op_unlocked(d, req, value, index, b, blen); | ||
65 | mutex_unlock(&d->usb_mutex); | ||
66 | |||
67 | return ret; | ||
68 | } | ||
69 | |||
70 | int vp702x_usb_out_op_unlocked(struct dvb_usb_device *d, u8 req, u16 value, | ||
71 | u16 index, u8 *b, int blen) | ||
60 | { | 72 | { |
61 | int ret; | 73 | int ret; |
62 | deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index); | 74 | deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index); |
@@ -74,6 +86,18 @@ static int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, | |||
74 | return 0; | 86 | return 0; |
75 | } | 87 | } |
76 | 88 | ||
89 | int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, | ||
90 | u16 index, u8 *b, int blen) | ||
91 | { | ||
92 | int ret; | ||
93 | |||
94 | mutex_lock(&d->usb_mutex); | ||
95 | ret = vp702x_usb_out_op_unlocked(d, req, value, index, b, blen); | ||
96 | mutex_unlock(&d->usb_mutex); | ||
97 | |||
98 | return ret; | ||
99 | } | ||
100 | |||
77 | int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec) | 101 | int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec) |
78 | { | 102 | { |
79 | int ret; | 103 | int ret; |
@@ -81,12 +105,11 @@ int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int il | |||
81 | if ((ret = mutex_lock_interruptible(&d->usb_mutex))) | 105 | if ((ret = mutex_lock_interruptible(&d->usb_mutex))) |
82 | return ret; | 106 | return ret; |
83 | 107 | ||
84 | ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen); | 108 | ret = vp702x_usb_out_op_unlocked(d, REQUEST_OUT, 0, 0, o, olen); |
85 | msleep(msec); | 109 | msleep(msec); |
86 | ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen); | 110 | ret = vp702x_usb_in_op_unlocked(d, REQUEST_IN, 0, 0, i, ilen); |
87 | 111 | ||
88 | mutex_unlock(&d->usb_mutex); | 112 | mutex_unlock(&d->usb_mutex); |
89 | |||
90 | return ret; | 113 | return ret; |
91 | } | 114 | } |
92 | 115 | ||