From patchwork Mon Aug 23 07:33:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 1519559 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=d6yuODs7; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=khgBdt3e; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GtPFr553Vz9sWS for ; Mon, 23 Aug 2021 17:37:04 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w89YGrcX7byjL0ih7W3ouxH+9o9R6Pe3aRXWgkyhcyw=; b=d6yuODs7wXCI0i BLd4nfW9o4mfYxht31uMVVZaHvdj45Agnzhd5EXZqVOyyFGirRd5hIEWCCEqSWyu/TirvRSMHb53G o4mtxhYrhgjXEu66KsZyzKoCzy2pbP2sQGpwY4h7ssj7Z/iK7a7nZrzBzaVUjsyisBA5ajGnHJNzT pFDwfpMOg7FysYGgLF+yKWLPXbAjaPm3MkPTszWImch5b9wEgcJXFBpsiTfX0+ZklrIPKfKBjxA5s MdUfDfSnkeNqXkCKc4rWpV02G15GLJ7xkOW/jhKn7yrLHsONl8HzawxFC1MJ0euWMvRQX47I+6sng aLnB+Ry/fvrOK9Sx8V6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mI4VQ-00FkmA-13; Mon, 23 Aug 2021 07:36:28 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mI4VN-00FklJ-MO for linux-mtd@bombadil.infradead.org; Mon, 23 Aug 2021 07:36:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=b9Uclk6xpoiqnKRmUY/NkslucqoYr3q7peRqvLgdZC0=; b=khgBdt3e+C/I60lCMW3e21PVF8 ZcxCbOobT2+edSAS9yR0ytdZJXhig5OPGRrqV6BIzcYbWLdMTX+k52DCorgSVlc8KddifcrOKPPFQ cBkEh0HFu0Sl3fANZFx4zDbKKuY8CKDjmJU0mRqnOSz+Bcdts/8UnknoOKLjo1PjCEME8eDmHWD0D aNP3+ygMzfok/UtMrsr2Fva56da06KSC94M6f04v8/OlNN35308o2E47c2w00FFNfbNg176t+IYe1 NkmbUsNomYkCPVv+DictHDhmUZYZ/VAPgniEbhIrC8FrasZ2vAyNHY58DLv/gJCrHFKF1ttEo5/q/ z9NA8QbA==; Received: from [2001:4bb8:193:fd10:c6e8:3c08:6f8b:cbf0] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mI4UH-009QjV-Sk; Mon, 23 Aug 2021 07:35:48 +0000 From: Christoph Hellwig To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: Guenter Roeck , linux-mtd@lists.infradead.org Subject: [PATCH 2/8] mtd_blkdevs: use lockdep_assert_held Date: Mon, 23 Aug 2021 09:33:53 +0200 Message-Id: <20210823073359.705281-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210823073359.705281-1-hch@lst.de> References: <20210823073359.705281-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use lockdep_assert_held to ensure mtd_table_mutex is held instead of mutex_trylock games. Signed-off-by: Christoph Hellwig --- drivers/mtd/mtd_blkdevs.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 6b81a1c9ccbe..81f0ce2a0b5a 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -310,10 +310,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) struct gendisk *gd; int ret; - if (mutex_trylock(&mtd_table_mutex)) { - mutex_unlock(&mtd_table_mutex); - BUG(); - } + lockdep_assert_held(&mtd_table_mutex); mutex_lock(&blktrans_ref_mutex); list_for_each_entry(d, &tr->devs, list) { @@ -444,10 +441,7 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old) { unsigned long flags; - if (mutex_trylock(&mtd_table_mutex)) { - mutex_unlock(&mtd_table_mutex); - BUG(); - } + lockdep_assert_held(&mtd_table_mutex); if (old->disk_attributes) sysfs_remove_group(&disk_to_dev(old->disk)->kobj,