Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>,
Minchan Kim <minchan@kernel.org>,
Stefan Haberland <sth@linux.ibm.com>,
Jan Hoeppner <hoeppner@linux.ibm.com>,
Joseph Qi <joseph.qi@linux.alibaba.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Pavel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, nbd@other.debian.org,
linux-ide@vger.kernel.org, linux-s390@vger.kernel.org,
linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com,
linux-pm@vger.kernel.org, linux-mm@kvack.org,
linux-block@vger.kernel.org
Subject: [PATCH 05/14] pktcdvd: use blkdev_get_by_dev instead of open coding it
Date: Mon, 21 Sep 2020 09:19:49 +0200 [thread overview]
Message-ID: <20200921071958.307589-6-hch@lst.de> (raw)
In-Reply-To: <20200921071958.307589-1-hch@lst.de>
Replace bdget + blkdev_get by blkdev_get_by_dev.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/block/pktcdvd.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index bc870a5f15f77b..467dbd06b7cdb1 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2110,16 +2110,18 @@ static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
int ret;
long lba;
struct request_queue *q;
+ struct block_device *bdev;
/*
* We need to re-open the cdrom device without O_NONBLOCK to be able
* to read/write from/to it. It is already opened in O_NONBLOCK mode
- * so bdget() can't fail.
+ * so open should not fail.
*/
- bdget(pd->bdev->bd_dev);
- ret = blkdev_get(pd->bdev, FMODE_READ | FMODE_EXCL, pd);
- if (ret)
+ bdev = blkdev_get_by_dev(pd->bdev->bd_dev, FMODE_READ | FMODE_EXCL, pd);
+ if (IS_ERR(bdev)) {
+ ret = PTR_ERR(bdev);
goto out;
+ }
ret = pkt_get_last_written(pd, &lba);
if (ret) {
@@ -2163,7 +2165,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
return 0;
out_putdev:
- blkdev_put(pd->bdev, FMODE_READ | FMODE_EXCL);
+ blkdev_put(bdev, FMODE_READ | FMODE_EXCL);
out:
return ret;
}
@@ -2500,7 +2502,6 @@ static int pkt_seq_show(struct seq_file *m, void *p)
static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
{
int i;
- int ret = 0;
char b[BDEVNAME_SIZE];
struct block_device *bdev;
@@ -2523,12 +2524,9 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
}
}
- bdev = bdget(dev);
- if (!bdev)
- return -ENOMEM;
- ret = blkdev_get(bdev, FMODE_READ | FMODE_NDELAY, NULL);
- if (ret)
- return ret;
+ bdev = blkdev_get_by_dev(dev, FMODE_READ | FMODE_NDELAY, NULL);
+ if (IS_ERR(bdev))
+ return PTR_ERR(bdev);
if (!blk_queue_scsi_passthrough(bdev_get_queue(bdev))) {
blkdev_put(bdev, FMODE_READ | FMODE_NDELAY);
return -EINVAL;
@@ -2546,7 +2544,6 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->name);
if (IS_ERR(pd->cdrw.thread)) {
pkt_err(pd, "can't start kernel thread\n");
- ret = -ENOMEM;
goto out_mem;
}
@@ -2558,7 +2555,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
blkdev_put(bdev, FMODE_READ | FMODE_NDELAY);
/* This is safe: open() is still holding a reference. */
module_put(THIS_MODULE);
- return ret;
+ return -ENOMEM;
}
static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
--
2.28.0
next prev parent reply other threads:[~2020-09-21 7:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-21 7:19 remove blkdev_get as a public API v2 Christoph Hellwig
2020-09-21 7:19 ` [PATCH 01/14] block: move the NEED_PART_SCAN flag to struct gendisk Christoph Hellwig
2020-09-21 7:19 ` [PATCH 02/14] block: cleanup partition scanning in register_disk Christoph Hellwig
2020-09-21 7:19 ` [PATCH 03/14] block: cleanup blkdev_bszset Christoph Hellwig
2020-09-21 7:19 ` [PATCH 04/14] pktcdvd: remove the if 0'ed pkt_start_recovery function Christoph Hellwig
2020-09-21 7:19 ` Christoph Hellwig [this message]
2020-09-21 7:19 ` [PATCH 06/14] zram: cleanup backing_dev_store Christoph Hellwig
2020-09-21 7:19 ` [PATCH 07/14] raw: don't keep unopened block device around Christoph Hellwig
2020-09-21 7:19 ` [PATCH 08/14] dasd: cleanup dasd_scan_partitions Christoph Hellwig
2020-09-21 8:45 ` Sergei Shtylyov
2020-09-22 15:18 ` Stefan Haberland
2020-09-21 7:19 ` [PATCH 09/14] ocfs2: cleanup o2hb_region_dev_store Christoph Hellwig
2020-09-21 7:19 ` [PATCH 10/14] mm: cleanup claim_swapfile Christoph Hellwig
2020-09-21 7:19 ` [PATCH 11/14] PM: rewrite is_hibernate_resume_dev to not require an inode Christoph Hellwig
2020-09-21 21:46 ` Pavel Machek
2020-09-21 7:19 ` [PATCH 12/14] mm: split swap_type_of Christoph Hellwig
2020-09-21 7:19 ` [PATCH 13/14] PM: mm: cleanup swsusp_swap_check Christoph Hellwig
2020-09-21 7:19 ` [PATCH 14/14] block: mark blkdev_get static Christoph Hellwig
2020-09-23 16:43 ` remove blkdev_get as a public API v2 Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2020-09-17 16:57 remove blkdev_get as a public API Christoph Hellwig
2020-09-17 16:57 ` [PATCH 05/14] pktcdvd: use blkdev_get_by_dev instead of open coding it Christoph Hellwig
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=20200921071958.307589-6-hch@lst.de \
--to=hch@lst.de \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=hoeppner@linux.ibm.com \
--cc=josef@toxicpanda.com \
--cc=joseph.qi@linux.alibaba.com \
--cc=len.brown@intel.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=nbd@other.debian.org \
--cc=ocfs2-devel@oss.oracle.com \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
--cc=sth@linux.ibm.com \
--subject='Re: [PATCH 05/14] pktcdvd: use blkdev_get_by_dev instead of open coding it' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).