[media] tm6000: Add locking for USB transfers

This commit introduces the usb_lock mutex to ensure that a USB request
always gets the proper response. While this is currently not really
necessary it will become important as there are more users.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Thierry Reding 2011-08-04 04:14:10 -03:00 committed by Mauro Carvalho Chehab
parent c0fa65ff9e
commit fc4eab2cba
3 changed files with 5 additions and 1 deletions

View File

@ -1168,6 +1168,7 @@ static int tm6000_usb_probe(struct usb_interface *interface,
return -ENOMEM; return -ENOMEM;
} }
spin_lock_init(&dev->slock); spin_lock_init(&dev->slock);
mutex_init(&dev->usb_lock);
/* Increment usage count */ /* Increment usage count */
tm6000_devused |= 1<<nr; tm6000_devused |= 1<<nr;

View File

@ -39,6 +39,8 @@ int tm6000_read_write_usb(struct tm6000_core *dev, u8 req_type, u8 req,
unsigned int pipe; unsigned int pipe;
u8 *data = NULL; u8 *data = NULL;
mutex_lock(&dev->usb_lock);
if (len) if (len)
data = kzalloc(len, GFP_KERNEL); data = kzalloc(len, GFP_KERNEL);
@ -86,9 +88,9 @@ int tm6000_read_write_usb(struct tm6000_core *dev, u8 req_type, u8 req,
} }
kfree(data); kfree(data);
msleep(5); msleep(5);
mutex_unlock(&dev->usb_lock);
return ret; return ret;
} }

View File

@ -245,6 +245,7 @@ struct tm6000_core {
/* locks */ /* locks */
struct mutex lock; struct mutex lock;
struct mutex usb_lock;
/* usb transfer */ /* usb transfer */
struct usb_device *udev; /* the usb device */ struct usb_device *udev; /* the usb device */