Commit 1a9fba3a authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: unexport read_dev_sector and put_dev_sector

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent a10183d7
...@@ -484,22 +484,29 @@ int blk_add_partitions(struct gendisk *disk, struct block_device *bdev) ...@@ -484,22 +484,29 @@ int blk_add_partitions(struct gendisk *disk, struct block_device *bdev)
return ret; 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; struct page *page;
page = read_mapping_page(mapping, (pgoff_t)(n >> (PAGE_SHIFT-9)), NULL); if (n >= get_capacity(state->bdev->bd_disk)) {
if (!IS_ERR(page)) { 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)) if (PageError(page))
goto fail; goto out_put_page;
p->v = page; p->v = page;
return (unsigned char *)page_address(page) + ((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << 9); return (unsigned char *)page_address(page) +
fail: ((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << SECTOR_SHIFT);
out_put_page:
put_page(page); put_page(page);
} out:
p->v = NULL; p->v = NULL;
return NULL; return NULL;
} }
EXPORT_SYMBOL(read_dev_sector);
...@@ -28,14 +28,14 @@ void free_partitions(struct parsed_partitions *state); ...@@ -28,14 +28,14 @@ void free_partitions(struct parsed_partitions *state);
struct parsed_partitions * struct parsed_partitions *
check_partition(struct gendisk *, struct block_device *); check_partition(struct gendisk *, struct block_device *);
static inline void *read_part_sector(struct parsed_partitions *state, typedef struct {
sector_t n, Sector *p) 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)) { put_page(p.v);
state->access_beyond_eod = true;
return NULL;
}
return read_dev_sector(state->bdev, n, p);
} }
static inline void static inline void
......
...@@ -1484,15 +1484,6 @@ static inline unsigned int block_size(struct block_device *bdev) ...@@ -1484,15 +1484,6 @@ static inline unsigned int block_size(struct block_device *bdev)
return bdev->bd_block_size; 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_schedule_work(struct work_struct *work);
int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay); int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment