Commit 77b1e2fb authored by Andreas Oberritter's avatar Andreas Oberritter Committed by Mauro Carvalho Chehab

[media] DVB: dvb_frontend: update locking in dvb_frontend_{add, get_event}

  - fepriv->parameters_out isn't protected by events->mtx, so
    move the call to fe->ops.get_frontend out of the locked area.
  - move the assignment of e->status into the locked area.

  - use direct assignment instead of memcpy.

  - use mutex_lock instead of mutex_lock_interruptible, because
    all code paths protected by this mutex won't block.
Signed-off-by: default avatarAndreas Oberritter <obi@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 20640bea
...@@ -149,30 +149,25 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) ...@@ -149,30 +149,25 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
dprintk ("%s\n", __func__); dprintk ("%s\n", __func__);
if (mutex_lock_interruptible (&events->mtx)) if ((status & FE_HAS_LOCK) && fe->ops.get_frontend)
return; fe->ops.get_frontend(fe, &fepriv->parameters_out);
wp = (events->eventw + 1) % MAX_EVENT; mutex_lock(&events->mtx);
wp = (events->eventw + 1) % MAX_EVENT;
if (wp == events->eventr) { if (wp == events->eventr) {
events->overflow = 1; events->overflow = 1;
events->eventr = (events->eventr + 1) % MAX_EVENT; events->eventr = (events->eventr + 1) % MAX_EVENT;
} }
e = &events->events[events->eventw]; e = &events->events[events->eventw];
e->status = status;
if (status & FE_HAS_LOCK)
if (fe->ops.get_frontend)
fe->ops.get_frontend(fe, &fepriv->parameters_out);
e->parameters = fepriv->parameters_out; e->parameters = fepriv->parameters_out;
events->eventw = wp; events->eventw = wp;
mutex_unlock(&events->mtx); mutex_unlock(&events->mtx);
e->status = status;
wake_up_interruptible (&events->wait_queue); wake_up_interruptible (&events->wait_queue);
} }
...@@ -207,14 +202,9 @@ static int dvb_frontend_get_event(struct dvb_frontend *fe, ...@@ -207,14 +202,9 @@ static int dvb_frontend_get_event(struct dvb_frontend *fe,
return ret; return ret;
} }
if (mutex_lock_interruptible (&events->mtx)) mutex_lock(&events->mtx);
return -ERESTARTSYS; *event = events->events[events->eventr];
memcpy (event, &events->events[events->eventr],
sizeof(struct dvb_frontend_event));
events->eventr = (events->eventr + 1) % MAX_EVENT; events->eventr = (events->eventr + 1) % MAX_EVENT;
mutex_unlock(&events->mtx); mutex_unlock(&events->mtx);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment