From: Christoph Hellwig <hch@lst.de>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>
Cc: Guenter Roeck <linux@roeck-us.net>, linux-mtd@lists.infradead.org
Subject: [PATCH 5/8] mtd_blkdevs: simplify blktrans_dev_get
Date: Mon, 23 Aug 2021 09:33:56 +0200 [thread overview]
Message-ID: <20210823073359.705281-6-hch@lst.de> (raw)
In-Reply-To: <20210823073359.705281-1-hch@lst.de>
->private_data is set before the disk is added and never cleared, so don't
bother trying to handle a NULL pointer there.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/mtd/mtd_blkdevs.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 81f0ce2a0b5a..f5e13b919614 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -39,16 +39,12 @@ static void blktrans_dev_release(struct kref *kref)
static struct mtd_blktrans_dev *blktrans_dev_get(struct gendisk *disk)
{
- struct mtd_blktrans_dev *dev;
+ struct mtd_blktrans_dev *dev = disk->private_data;
mutex_lock(&blktrans_ref_mutex);
- dev = disk->private_data;
-
- if (!dev)
- goto unlock;
kref_get(&dev->ref);
-unlock:
mutex_unlock(&blktrans_ref_mutex);
+
return dev;
}
@@ -204,9 +200,6 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
struct mtd_blktrans_dev *dev = blktrans_dev_get(bdev->bd_disk);
int ret = 0;
- if (!dev)
- return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/
-
mutex_lock(&dev->lock);
if (dev->open)
@@ -250,9 +243,6 @@ static void blktrans_release(struct gendisk *disk, fmode_t mode)
{
struct mtd_blktrans_dev *dev = blktrans_dev_get(disk);
- if (!dev)
- return;
-
mutex_lock(&dev->lock);
if (--dev->open)
@@ -276,9 +266,6 @@ static int blktrans_getgeo(struct block_device *bdev, struct hd_geometry *geo)
struct mtd_blktrans_dev *dev = blktrans_dev_get(bdev->bd_disk);
int ret = -ENXIO;
- if (!dev)
- return ret;
-
mutex_lock(&dev->lock);
if (!dev->mtd)
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2021-08-23 7:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-23 7:33 mtd locking fix and cleanups Christoph Hellwig
2021-08-23 7:33 ` [PATCH 1/8] mtd_blkdevs: don't hold del_mtd_blktrans_dev in blktrans_{open, release} Christoph Hellwig
2021-08-23 8:33 ` Miquel Raynal
2021-08-23 7:33 ` [PATCH 2/8] mtd_blkdevs: use lockdep_assert_held Christoph Hellwig
2021-08-23 8:33 ` Miquel Raynal
2021-08-23 7:33 ` [PATCH 3/8] mtd/ftl: don't cast away the type when calling add_mtd_blktrans_dev Christoph Hellwig
2021-08-23 8:33 ` Miquel Raynal
2021-08-23 7:33 ` [PATCH 4/8] mtd/rfd_ftl: " Christoph Hellwig
2021-08-23 8:33 ` Miquel Raynal
2021-08-23 7:33 ` Christoph Hellwig [this message]
2021-08-23 8:33 ` [PATCH 5/8] mtd_blkdevs: simplify blktrans_dev_get Miquel Raynal
2021-08-23 7:33 ` [PATCH 6/8] mtd_blkdevs: remove blktrans_ref_mutex Christoph Hellwig
2021-08-23 8:33 ` Miquel Raynal
2021-08-23 7:33 ` [PATCH 7/8] mtd_blkdevs: simplify blktrans_getgeo Christoph Hellwig
2021-08-23 8:33 ` Miquel Raynal
2021-08-23 7:33 ` [PATCH 8/8] mtd_blkdevs: simplify the refcounting in blktrans_{open, release} Christoph Hellwig
2021-08-23 8:33 ` Miquel Raynal
2021-08-23 8:30 ` mtd locking fix and cleanups Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210823073359.705281-6-hch@lst.de \
--to=hch@lst.de \
--cc=linux-mtd@lists.infradead.org \
--cc=linux@roeck-us.net \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox