scsi: switch scsi_bios_ptable() and scsi_partsize() to gendisk
Both helpers are reading the partition table of the disk specified by block_device of some partition on it; result depends only upon the disk in question, so we might as well pass the struct gendisk instead. Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
8f5ae30d69
commit
1fd143c24f
|
|
@ -380,7 +380,7 @@ Details::
|
|||
|
||||
/**
|
||||
* scsi_bios_ptable - return copy of block device's partition table
|
||||
* @dev: pointer to block device
|
||||
* @dev: pointer to gendisk
|
||||
*
|
||||
* Returns pointer to partition table, or NULL for failure
|
||||
*
|
||||
|
|
@ -390,7 +390,7 @@ Details::
|
|||
*
|
||||
* Defined in: drivers/scsi/scsicam.c
|
||||
**/
|
||||
unsigned char *scsi_bios_ptable(struct block_device *dev)
|
||||
unsigned char *scsi_bios_ptable(struct gendisk *dev)
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3261,7 +3261,7 @@ static int blogic_diskparam(struct scsi_device *sdev, struct block_device *dev,
|
|||
diskparam->sectors = 32;
|
||||
}
|
||||
diskparam->cylinders = (unsigned long) capacity / (diskparam->heads * diskparam->sectors);
|
||||
buf = scsi_bios_ptable(dev);
|
||||
buf = scsi_bios_ptable(dev->bd_disk);
|
||||
if (buf == NULL)
|
||||
return 0;
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev,
|
|||
* entry whose end_head matches one of the standard geometry
|
||||
* translations ( 64/32, 128/32, 255/63 ).
|
||||
*/
|
||||
buf = scsi_bios_ptable(bdev);
|
||||
buf = scsi_bios_ptable(bdev->bd_disk);
|
||||
if (!buf)
|
||||
return 0;
|
||||
if (*(__le16 *)(buf + 0x40) == cpu_to_le16(MSDOS_LABEL_MAGIC)) {
|
||||
|
|
|
|||
|
|
@ -731,7 +731,7 @@ ahd_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev,
|
|||
|
||||
ahd = *((struct ahd_softc **)sdev->host->hostdata);
|
||||
|
||||
if (scsi_partsize(bdev, capacity, geom))
|
||||
if (scsi_partsize(bdev->bd_disk, capacity, geom))
|
||||
return 0;
|
||||
|
||||
heads = 64;
|
||||
|
|
|
|||
|
|
@ -696,7 +696,7 @@ ahc_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev,
|
|||
ahc = *((struct ahc_softc **)sdev->host->hostdata);
|
||||
channel = sdev_channel(sdev);
|
||||
|
||||
if (scsi_partsize(bdev, capacity, geom))
|
||||
if (scsi_partsize(bdev->bd_disk, capacity, geom))
|
||||
return 0;
|
||||
|
||||
heads = 64;
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ static int arcmsr_bios_param(struct scsi_device *sdev,
|
|||
{
|
||||
int heads, sectors, cylinders, total_capacity;
|
||||
|
||||
if (scsi_partsize(bdev, capacity, geom))
|
||||
if (scsi_partsize(bdev->bd_disk, capacity, geom))
|
||||
return 0;
|
||||
|
||||
total_capacity = capacity;
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ static int fdomain_biosparam(struct scsi_device *sdev,
|
|||
struct block_device *bdev, sector_t capacity,
|
||||
int geom[])
|
||||
{
|
||||
unsigned char *p = scsi_bios_ptable(bdev);
|
||||
unsigned char *p = scsi_bios_ptable(bdev->bd_disk);
|
||||
|
||||
if (p && p[65] == 0xaa && p[64] == 0x55 /* Partition table valid */
|
||||
&& p[4]) { /* Partition type */
|
||||
|
|
|
|||
|
|
@ -2813,7 +2813,7 @@ megaraid_biosparam(struct scsi_device *sdev, struct block_device *bdev,
|
|||
geom[2] = cylinders;
|
||||
}
|
||||
else {
|
||||
if (scsi_partsize(bdev, capacity, geom))
|
||||
if (scsi_partsize(bdev->bd_disk, capacity, geom))
|
||||
return 0;
|
||||
|
||||
dev_info(&adapter->dev->dev,
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@
|
|||
* starting at offset %0x1be.
|
||||
* Returns: partition table in kmalloc(GFP_KERNEL) memory, or NULL on error.
|
||||
*/
|
||||
unsigned char *scsi_bios_ptable(struct block_device *dev)
|
||||
unsigned char *scsi_bios_ptable(struct gendisk *dev)
|
||||
{
|
||||
struct address_space *mapping = bdev_whole(dev)->bd_mapping;
|
||||
struct address_space *mapping = dev->part0->bd_mapping;
|
||||
unsigned char *res = NULL;
|
||||
struct folio *folio;
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ EXPORT_SYMBOL(scsi_bios_ptable);
|
|||
|
||||
/**
|
||||
* scsi_partsize - Parse cylinders/heads/sectors from PC partition table
|
||||
* @bdev: block device to parse
|
||||
* @disk: gendisk of the disk to parse
|
||||
* @capacity: size of the disk in sectors
|
||||
* @geom: output in form of [hds, cylinders, sectors]
|
||||
*
|
||||
|
|
@ -57,7 +57,7 @@ EXPORT_SYMBOL(scsi_bios_ptable);
|
|||
*
|
||||
* Returns: %false on failure, %true on success.
|
||||
*/
|
||||
bool scsi_partsize(struct block_device *bdev, sector_t capacity, int geom[3])
|
||||
bool scsi_partsize(struct gendisk *disk, sector_t capacity, int geom[3])
|
||||
{
|
||||
int cyl, ext_cyl, end_head, end_cyl, end_sector;
|
||||
unsigned int logical_end, physical_end, ext_physical_end;
|
||||
|
|
@ -65,7 +65,7 @@ bool scsi_partsize(struct block_device *bdev, sector_t capacity, int geom[3])
|
|||
void *buf;
|
||||
int ret = false;
|
||||
|
||||
buf = scsi_bios_ptable(bdev);
|
||||
buf = scsi_bios_ptable(disk);
|
||||
if (!buf)
|
||||
return false;
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip)
|
|||
int ret = 0;
|
||||
|
||||
/* try to infer mapping from partition table */
|
||||
if (scsi_partsize(bdev, capacity, ip))
|
||||
if (scsi_partsize(bdev->bd_disk, capacity, ip))
|
||||
return 0;
|
||||
|
||||
if (capacity64 < (1ULL << 32)) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
#ifndef SCSICAM_H
|
||||
#define SCSICAM_H
|
||||
struct gendisk;
|
||||
int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip);
|
||||
bool scsi_partsize(struct block_device *bdev, sector_t capacity, int geom[3]);
|
||||
unsigned char *scsi_bios_ptable(struct block_device *bdev);
|
||||
bool scsi_partsize(struct gendisk *disk, sector_t capacity, int geom[3]);
|
||||
unsigned char *scsi_bios_ptable(struct gendisk *disk);
|
||||
#endif /* def SCSICAM_H */
|
||||
|
|
|
|||
Loading…
Reference in New Issue