diff options
author | Christoph Hellwig <hch@lst.de> | 2020-03-24 08:25:15 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-03-24 07:57:07 -0600 |
commit | e63105df8fa1c87bdec4fb82ca7b121f139da221 (patch) | |
tree | c8e137cfdd577261d702117f32a6e613998b08b0 /drivers/scsi | |
parent | f17c21c1ecb80e957bafa07d6454836854be7cf2 (diff) |
scsi: simplify scsi_bios_ptable
Use read_mapping_page and kmemdup instead of the odd read_dev_sector and
put_dev_sector helpers from the partitioning code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/scsicam.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/scsi/scsicam.c b/drivers/scsi/scsicam.c index e969138051c7..91a9530a4dcb 100644 --- a/drivers/scsi/scsicam.c +++ b/drivers/scsi/scsicam.c @@ -35,19 +35,17 @@ static int setsize(unsigned long capacity, unsigned int *cyls, unsigned int *hds */ unsigned char *scsi_bios_ptable(struct block_device *dev) { - unsigned char *res = kmalloc(66, GFP_KERNEL); - if (res) { - struct block_device *bdev = dev->bd_contains; - Sector sect; - void *data = read_dev_sector(bdev, 0, §); - if (data) { - memcpy(res, data + 0x1be, 66); - put_dev_sector(sect); - } else { - kfree(res); - res = NULL; - } - } + struct address_space *mapping = dev->bd_contains->bd_inode->i_mapping; + unsigned char *res = NULL; + struct page *page; + + page = read_mapping_page(mapping, 0, NULL); + if (IS_ERR(page)) + return NULL; + + if (!PageError(page)) + res = kmemdup(page_address(page) + 0x1be, 66, GFP_KERNEL); + put_page(page); return res; } EXPORT_SYMBOL(scsi_bios_ptable); |