Commit e63105df authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent f17c21c1
...@@ -35,19 +35,17 @@ static int setsize(unsigned long capacity, unsigned int *cyls, unsigned int *hds ...@@ -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 *scsi_bios_ptable(struct block_device *dev)
{ {
unsigned char *res = kmalloc(66, GFP_KERNEL); struct address_space *mapping = dev->bd_contains->bd_inode->i_mapping;
if (res) { unsigned char *res = NULL;
struct block_device *bdev = dev->bd_contains; struct page *page;
Sector sect;
void *data = read_dev_sector(bdev, 0, &sect); page = read_mapping_page(mapping, 0, NULL);
if (data) { if (IS_ERR(page))
memcpy(res, data + 0x1be, 66); return NULL;
put_dev_sector(sect);
} else { if (!PageError(page))
kfree(res); res = kmemdup(page_address(page) + 0x1be, 66, GFP_KERNEL);
res = NULL; put_page(page);
}
}
return res; return res;
} }
EXPORT_SYMBOL(scsi_bios_ptable); EXPORT_SYMBOL(scsi_bios_ptable);
......
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