diff options
author | Christoph Hellwig <hch@lst.de> | 2021-08-23 09:33:56 +0200 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2021-08-23 10:01:09 +0200 |
commit | 89843828399ec825f8ec3e614634a428a951a2b3 (patch) | |
tree | 8da3a7a6f6304f8b0679bdba57572e71e48fe914 /drivers/mtd/mtd_blkdevs.c | |
parent | a0faf5fdfb9967b33eda5eafcb55470180216af3 (diff) |
mtd_blkdevs: simplify blktrans_dev_get
->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>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210823073359.705281-6-hch@lst.de
Diffstat (limited to 'drivers/mtd/mtd_blkdevs.c')
-rw-r--r-- | drivers/mtd/mtd_blkdevs.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 5981fd026c87..eb15a84cb650 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) |