From: Florian Mickler Date: Mon, 21 Mar 2011 10:19:11 +0000 (-0300) Subject: [media] vp702x: fix locking of usb operations X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9a187c4183edb6e705245c0fb2439aa3e8dce1fe;p=linux-beck.git [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 Cc: Patrick Boettcher Signed-off-by: Mauro Carvalho Chehab --- 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 { u8 pid_filter_state; }; -/* check for mutex FIXME */ -int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) +static int vp702x_usb_in_op_unlocked(struct dvb_usb_device *d, u8 req, + u16 value, u16 index, u8 *b, int blen) { int ret; @@ -55,8 +55,20 @@ int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 return ret; } -static int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, - u16 index, u8 *b, int blen) +int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, + u16 index, u8 *b, int blen) +{ + int ret; + + mutex_lock(&d->usb_mutex); + ret = vp702x_usb_in_op_unlocked(d, req, value, index, b, blen); + mutex_unlock(&d->usb_mutex); + + return ret; +} + +int vp702x_usb_out_op_unlocked(struct dvb_usb_device *d, u8 req, u16 value, + u16 index, u8 *b, int blen) { int ret; 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, return 0; } +int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, + u16 index, u8 *b, int blen) +{ + int ret; + + mutex_lock(&d->usb_mutex); + ret = vp702x_usb_out_op_unlocked(d, req, value, index, b, blen); + mutex_unlock(&d->usb_mutex); + + return ret; +} + int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec) { int ret; @@ -81,12 +105,11 @@ int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int il if ((ret = mutex_lock_interruptible(&d->usb_mutex))) return ret; - ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen); + ret = vp702x_usb_out_op_unlocked(d, REQUEST_OUT, 0, 0, o, olen); msleep(msec); - ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen); + ret = vp702x_usb_in_op_unlocked(d, REQUEST_IN, 0, 0, i, ilen); mutex_unlock(&d->usb_mutex); - return ret; }