forked from Minki/linux
media: dvbsky: use a single mutex and state buffers for all R/W ops
Re-use usb_mutex from dvb_usb_device for this. Tested-by: Jan Pieter van Woerkom <jp@jpvw.nl> Signed-off-by: Andrei Koshkosh <andreykosh000@mail.ru> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
767f22ac54
commit
cecf0bbbcb
@ -22,7 +22,6 @@ MODULE_PARM_DESC(disable_rc, "Disable inbuilt IR receiver.");
|
||||
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
|
||||
|
||||
struct dvbsky_state {
|
||||
struct mutex stream_mutex;
|
||||
u8 ibuf[DVBSKY_BUF_LEN];
|
||||
u8 obuf[DVBSKY_BUF_LEN];
|
||||
u8 last_lock;
|
||||
@ -60,17 +59,19 @@ static int dvbsky_usb_generic_rw(struct dvb_usb_device *d,
|
||||
static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
|
||||
{
|
||||
struct dvbsky_state *state = d_to_priv(d);
|
||||
static const u8 obuf_pre[3] = { 0x37, 0, 0 };
|
||||
static const u8 obuf_post[3] = { 0x36, 3, 0 };
|
||||
int ret;
|
||||
u8 obuf_pre[3] = { 0x37, 0, 0 };
|
||||
u8 obuf_post[3] = { 0x36, 3, 0 };
|
||||
|
||||
mutex_lock(&state->stream_mutex);
|
||||
ret = dvbsky_usb_generic_rw(d, obuf_pre, 3, NULL, 0);
|
||||
mutex_lock(&d->usb_mutex);
|
||||
memcpy(state->obuf, obuf_pre, 3);
|
||||
ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
|
||||
if (!ret && onoff) {
|
||||
msleep(20);
|
||||
ret = dvbsky_usb_generic_rw(d, obuf_post, 3, NULL, 0);
|
||||
memcpy(state->obuf, obuf_post, 3);
|
||||
ret = dvb_usbv2_generic_write_locked(d, state->obuf, 3);
|
||||
}
|
||||
mutex_unlock(&state->stream_mutex);
|
||||
mutex_unlock(&d->usb_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -598,7 +599,6 @@ static int dvbsky_init(struct dvb_usb_device *d)
|
||||
if (ret)
|
||||
return ret;
|
||||
*/
|
||||
mutex_init(&state->stream_mutex);
|
||||
|
||||
state->last_lock = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user