836364e5deb3aaabc8b61cd6305551033fcc95be
[openwrt/staging/mans0n.git] /
1 From 08ccbb8e0667e90e5c7334057965c6205a3855fb Mon Sep 17 00:00:00 2001
2 From: Andrei Koshkosh <andreykosh000@mail.ru>
3 Date: Sun, 29 Sep 2019 05:04:05 -0300
4 Subject: [PATCH] media: dvbsky: use a single mutex and state buffers
5 for all R/W ops
6
7 commit cecf0bbbcb6f035a5ca2197f3e11ec2b7fb3da83 upstream.
8
9 Re-use usb_mutex from dvb_usb_device for this.
10
11 See: https://github.com/raspberrypi/linux/issues/3809
12
13 Tested-by: Jan Pieter van Woerkom <jp@jpvw.nl>
14 Signed-off-by: Andrei Koshkosh <andreykosh000@mail.ru>
15 Signed-off-by: Sean Young <sean@mess.org>
16 Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
17 ---
18 drivers/media/usb/dvb-usb-v2/dvbsky.c | 16 ++++++++--------
19 1 file changed, 8 insertions(+), 8 deletions(-)
20
21 --- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
22 +++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
23 @@ -22,7 +22,6 @@ MODULE_PARM_DESC(disable_rc, "Disable in
24 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
25
26 struct dvbsky_state {
27 - struct mutex stream_mutex;
28 u8 ibuf[DVBSKY_BUF_LEN];
29 u8 obuf[DVBSKY_BUF_LEN];
30 u8 last_lock;
31 @@ -60,17 +59,19 @@ static int dvbsky_usb_generic_rw(struct
32 static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
33 {
34 struct dvbsky_state *state = d_to_priv(d);
35 + static const u8 obuf_pre[3] = { 0x37, 0, 0 };
36 + static const u8 obuf_post[3] = { 0x36, 3, 0 };
37 int ret;
38 - u8 obuf_pre[3] = { 0x37, 0, 0 };
39 - u8 obuf_post[3] = { 0x36, 3, 0 };
40
41 - mutex_lock(&state->stream_mutex);
42 - ret = dvbsky_usb_generic_rw(d, obuf_pre, 3, NULL, 0);
43 + mutex_lock(&d->usb_mutex);
44 + memcpy(state->obuf, obuf_pre, 3);
45 + ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
46 if (!ret && onoff) {
47 msleep(20);
48 - ret = dvbsky_usb_generic_rw(d, obuf_post, 3, NULL, 0);
49 + memcpy(state->obuf, obuf_post, 3);
50 + ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
51 }
52 - mutex_unlock(&state->stream_mutex);
53 + mutex_unlock(&d->usb_mutex);
54 return ret;
55 }
56
57 @@ -598,7 +599,6 @@ static int dvbsky_init(struct dvb_usb_de
58 if (ret)
59 return ret;
60 */
61 - mutex_init(&state->stream_mutex);
62
63 state->last_lock = 0;
64