Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media: dvbsky: use a single mutex and state buffers for all R/W ops #689

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions drivers/media/usb/dvb-usb-v2/dvbsky.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MODULE_PARM_DESC(disable_rc, "Disable inbuilt IR receiver.");
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);

struct dvbsky_state {
struct mutex stream_mutex;
//struct mutex stream_mutex;
u8 ibuf[DVBSKY_BUF_LEN];
u8 obuf[DVBSKY_BUF_LEN];
u8 last_lock;
Expand Down Expand Up @@ -61,16 +61,18 @@ static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
{
struct dvbsky_state *state = d_to_priv(d);
int ret;
u8 obuf_pre[3] = { 0x37, 0, 0 };
u8 obuf_post[3] = { 0x36, 3, 0 };
static u8 obuf_pre[3] = { 0x37, 0, 0 };
static 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;
}

Expand Down Expand Up @@ -599,7 +601,7 @@ static int dvbsky_init(struct dvb_usb_device *d)
if (ret)
return ret;
*/
mutex_init(&state->stream_mutex);
//mutex_init(&state->stream_mutex);

state->last_lock = 0;

Expand Down