From patchwork Thu Aug 4 07:14:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 1034082 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p747Eiw2002457 for ; Thu, 4 Aug 2011 07:14:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752129Ab1HDHOm (ORCPT ); Thu, 4 Aug 2011 03:14:42 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:64522 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751955Ab1HDHO1 (ORCPT ); Thu, 4 Aug 2011 03:14:27 -0400 Received: from localhost (p548E06E4.dip0.t-ipconnect.de [84.142.6.228]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0M8pEi-1Qf0mc2iZI-00Cu0B; Thu, 04 Aug 2011 09:14:26 +0200 From: Thierry Reding To: linux-media@vger.kernel.org Subject: [PATCH 12/21] [staging] tm6000: Add locking for USB transfers. Date: Thu, 4 Aug 2011 09:14:10 +0200 Message-Id: <1312442059-23935-13-git-send-email-thierry.reding@avionic-design.de> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1312442059-23935-1-git-send-email-thierry.reding@avionic-design.de> References: <1312442059-23935-1-git-send-email-thierry.reding@avionic-design.de> X-Provags-ID: V02:K0:p8KXr6BWIj6cIFe0zX15qczWGzz2iqBuUDuxb4gZ8Oe uojPH5GrJbzkDd5M6I4q23v9kAWrGQ1YaKO2/5PIgYgHGnF8/E PGK4yVQ1iii2QJR64NBd2lPLIEhQIC1aKCbUEmgvjXftBliu0l 6Wzn4fOOcmAAU2WInjFyVr1alhmhaCe7wTIu3VKhLQzlPaXtnD mb7usKoJDd9yw1iLtqlG9xYN/ZJjHK9luuNAUCvcuhpC/xM6vm 5ECIuO55vSibi Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 04 Aug 2011 07:14:45 +0000 (UTC) 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. --- drivers/staging/tm6000/tm6000-cards.c | 1 + drivers/staging/tm6000/tm6000-core.c | 3 +++ drivers/staging/tm6000/tm6000.h | 1 + 3 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c index a5d2a71..68f7c7a 100644 --- a/drivers/staging/tm6000/tm6000-cards.c +++ b/drivers/staging/tm6000/tm6000-cards.c @@ -1174,6 +1174,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,6 +88,7 @@ int tm6000_read_write_usb(struct tm6000_core *dev, u8 req_type, u8 req, } kfree(data); + mutex_unlock(&dev->usb_lock); return ret; } diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h index 4323fc2..cf57e1e 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 */