From patchwork Fri Nov 21 22:17:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 413201 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 5DA48140186 for ; Sat, 22 Nov 2014 09:19:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752720AbaKUWSi (ORCPT ); Fri, 21 Nov 2014 17:18:38 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:34050 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752502AbaKUWSD (ORCPT ); Fri, 21 Nov 2014 17:18:03 -0500 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id sALMHu0S004384 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Nov 2014 22:17:57 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id sALMHutM005673 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 21 Nov 2014 22:17:56 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id sALMHtad020292; Fri, 21 Nov 2014 22:17:55 GMT Received: from laptop.dumpdata.com (/50.195.21.189) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 21 Nov 2014 14:17:55 -0800 Received: by laptop.dumpdata.com (Postfix, from userid 1000) id 7F8A9118BF9; Fri, 21 Nov 2014 17:17:52 -0500 (EST) From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, bhelgaas@google.com, linux@eikelenboom.it Cc: Konrad Rzeszutek Wilk Subject: [PATCH v4 2/7] driver core: Provide an wrapper around the mutex to do lockdep warnings Date: Fri, 21 Nov 2014 17:17:46 -0500 Message-Id: <1416608271-18931-3-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1416608271-18931-1-git-send-email-konrad.wilk@oracle.com> References: <1416608271-18931-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Instead of open-coding it in drivers that want to double check that their functions are indeed holding the device lock. Signed-off-by: Konrad Rzeszutek Wilk Suggested-by: David Vrabel Acked-by: Greg Kroah-Hartman --- drivers/xen/xen-pciback/pci_stub.c | 2 +- include/linux/device.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c index 9cbe1a3..8b77089 100644 --- a/drivers/xen/xen-pciback/pci_stub.c +++ b/drivers/xen/xen-pciback/pci_stub.c @@ -278,7 +278,7 @@ void pcistub_put_pci_dev(struct pci_dev *dev) /* Cleanup our device * (so it's ready for the next domain) */ - lockdep_assert_held(&dev->dev.mutex); + device_lock_assert(&dev->dev); __pci_reset_function_locked(dev); pci_restore_state(dev); diff --git a/include/linux/device.h b/include/linux/device.h index ce1f2160..41d6a75 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -911,6 +911,11 @@ static inline void device_unlock(struct device *dev) mutex_unlock(&dev->mutex); } +static inline void device_lock_assert(struct device *dev) +{ + lockdep_assert_held(&dev->mutex); +} + void driver_init(void); /*