linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-raid@vger.kernel.org,
	linux-scsi@vger.kernel.org, reiserfs-devel@vger.kernel.org
Subject: [PATCH 09/21] block: unexport read_dev_sector and put_dev_sector
Date: Tue, 24 Mar 2020 08:25:18 +0100	[thread overview]
Message-ID: <20200324072530.544483-10-hch@lst.de> (raw)
In-Reply-To: <20200324072530.544483-1-hch@lst.de>

read_dev_sector and put_dev_sector are now only used by the partition
parsing code.  Remove the export for read_dev_sector and merge it into
the only caller.  Clean the mess up a bit by using goto labels and
the SECTOR_SHIFT constant.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/partition-generic.c | 31 +++++++++++++++++++------------
 block/partitions/check.h  | 14 +++++++-------
 include/linux/blkdev.h    |  9 ---------
 3 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/block/partition-generic.c b/block/partition-generic.c
index f2004f3bd6f7..fef6bacb2bbb 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -484,22 +484,29 @@ int blk_add_partitions(struct gendisk *disk, struct block_device *bdev)
 	return ret;
 }
 
-unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p)
+void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p)
 {
-	struct address_space *mapping = bdev->bd_inode->i_mapping;
+	struct address_space *mapping = state->bdev->bd_inode->i_mapping;
 	struct page *page;
 
-	page = read_mapping_page(mapping, (pgoff_t)(n >> (PAGE_SHIFT-9)), NULL);
-	if (!IS_ERR(page)) {
-		if (PageError(page))
-			goto fail;
-		p->v = page;
-		return (unsigned char *)page_address(page) +  ((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << 9);
-fail:
-		put_page(page);
+	if (n >= get_capacity(state->bdev->bd_disk)) {
+		state->access_beyond_eod = true;
+		return NULL;
 	}
+
+	page = read_mapping_page(mapping,
+			(pgoff_t)(n >> (PAGE_SHIFT - 9)), NULL);
+	if (IS_ERR(page))
+		goto out;
+	if (PageError(page))
+		goto out_put_page;
+
+	p->v = page;
+	return (unsigned char *)page_address(page) +
+			((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << SECTOR_SHIFT);
+out_put_page:
+	put_page(page);
+out:
 	p->v = NULL;
 	return NULL;
 }
-
-EXPORT_SYMBOL(read_dev_sector);
diff --git a/block/partitions/check.h b/block/partitions/check.h
index 6042f769471a..0fcf80117887 100644
--- a/block/partitions/check.h
+++ b/block/partitions/check.h
@@ -28,14 +28,14 @@ void free_partitions(struct parsed_partitions *state);
 struct parsed_partitions *
 check_partition(struct gendisk *, struct block_device *);
 
-static inline void *read_part_sector(struct parsed_partitions *state,
-				     sector_t n, Sector *p)
+typedef struct {
+	struct page *v;
+} Sector;
+
+void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p);
+static inline void put_dev_sector(Sector p)
 {
-	if (n >= get_capacity(state->bdev->bd_disk)) {
-		state->access_beyond_eod = true;
-		return NULL;
-	}
-	return read_dev_sector(state->bdev, n, p);
+	put_page(p.v);
 }
 
 static inline void
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f629d40c645c..53a1325efbc3 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1484,15 +1484,6 @@ static inline unsigned int block_size(struct block_device *bdev)
 	return bdev->bd_block_size;
 }
 
-typedef struct {struct page *v;} Sector;
-
-unsigned char *read_dev_sector(struct block_device *, sector_t, Sector *);
-
-static inline void put_dev_sector(Sector p)
-{
-	put_page(p.v);
-}
-
 int kblockd_schedule_work(struct work_struct *work);
 int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay);
 
-- 
2.25.1


  parent reply	other threads:[~2020-03-24  7:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24  7:25 cleanup the partitioning code v2 Christoph Hellwig
2020-03-24  7:25 ` [PATCH 01/21] block: remove the blk_lookup_devt export Christoph Hellwig
2020-03-24  7:25 ` [PATCH 02/21] block: remove __bdevname Christoph Hellwig
2020-03-24  7:25 ` [PATCH 03/21] block: move disk_name and related helpers out of partition-generic.c Christoph Hellwig
2020-03-24  7:25 ` [PATCH 04/21] block: move sysfs methods shared by disks and partitions to genhd.c Christoph Hellwig
2020-03-24  7:25 ` [PATCH 05/21] block: remove alloc_part_info and free_part_info Christoph Hellwig
2020-03-24  7:25 ` [PATCH 06/21] scsi: simplify scsi_bios_ptable Christoph Hellwig
2020-03-24  7:25 ` [PATCH 07/21] scsi: move scsicam_bios_param to the end of scsicam.c Christoph Hellwig
2020-03-24  7:25 ` [PATCH 08/21] scsi: simplify scsi_partsize Christoph Hellwig
2020-03-24  7:25 ` Christoph Hellwig [this message]
2020-03-24  7:25 ` [PATCH 10/21] block: cleanup how md_autodetect_dev is called Christoph Hellwig
2020-03-24  7:25 ` [PATCH 11/21] block: remove warn_no_part Christoph Hellwig
2020-03-24  7:25 ` [PATCH 12/21] block: declare all partition detection routines in check.h Christoph Hellwig
2020-03-24  7:25 ` [PATCH 13/21] block: remove block/partitions/karma.h Christoph Hellwig
2020-03-24  7:25 ` [PATCH 14/21] block: remove block/partitions/osf.h Christoph Hellwig
2020-03-24  7:25 ` [PATCH 15/21] block: remove block/partitions/sgi.h Christoph Hellwig
2020-03-24  7:25 ` [PATCH 16/21] block: remove block/partitions/sun.h Christoph Hellwig
2020-03-24  7:25 ` [PATCH 17/21] block: move struct partition out of genhd.h Christoph Hellwig
2020-03-24  7:25 ` [PATCH 18/21] block: move the *_PARTITION enum " Christoph Hellwig
2020-03-24  7:25 ` [PATCH 19/21] partitions/msdos: remove LINUX_SWAP_PARTITION Christoph Hellwig
2020-03-24  7:25 ` [PATCH 20/21] block: move the various x86 Unix label formats out of genhd.h Christoph Hellwig
2020-03-24  7:25 ` [PATCH 21/21] block: merge partition-generic.c and check.c Christoph Hellwig
2020-03-24 13:58 ` cleanup the partitioning code v2 Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2020-03-12 15:19 cleanup the partitioning code Christoph Hellwig
2020-03-12 15:19 ` [PATCH 09/21] block: unexport read_dev_sector and put_dev_sector 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=20200324072530.544483-10-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=reiserfs-devel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).