From fc4eab2cbae547fb278c2583b77ee0ff7f5832d3 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Thu, 4 Aug 2011 04:14:10 -0300 Subject: [PATCH] [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 Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/tm6000/tm6000-cards.c | 1 + drivers/staging/tm6000/tm6000-core.c | 4 +++- drivers/staging/tm6000/tm6000.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c index bac4309a3868..f247e7e685f9 100644 --- a/drivers/staging/tm6000/tm6000-cards.c +++ b/drivers/staging/tm6000/tm6000-cards.c @@ -1168,6 +1168,7 @@ static int tm6000_usb_probe(struct usb_interface *interface, return -ENOMEM; } spin_lock_init(&dev->slock); + mutex_init(&dev->usb_lock); /* Increment usage count */ tm6000_devused |= 1<usb_lock); + if (len) 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); - msleep(5); + mutex_unlock(&dev->usb_lock); return ret; } diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h index 4323fc2c1487..cf57e1e3aa62 100644 --- a/drivers/staging/tm6000/tm6000.h +++ b/drivers/staging/tm6000/tm6000.h @@ -245,6 +245,7 @@ struct tm6000_core { /* locks */ struct mutex lock; + struct mutex usb_lock; /* usb transfer */ struct usb_device *udev; /* the usb device */ -- 2.20.1