]> www.infradead.org Git - users/hch/misc.git/commitdiff
scsi: switch scsi_bios_ptable() and scsi_partsize() to gendisk
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 22 May 2024 03:08:31 +0000 (23:08 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 13 Aug 2025 06:59:28 +0000 (02:59 -0400)
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>
Documentation/scsi/scsi_mid_low_api.rst
drivers/scsi/BusLogic.c
drivers/scsi/aacraid/linit.c
drivers/scsi/aic7xxx/aic79xx_osm.c
drivers/scsi/aic7xxx/aic7xxx_osm.c
drivers/scsi/arcmsr/arcmsr_hba.c
drivers/scsi/fdomain.c
drivers/scsi/megaraid.c
drivers/scsi/scsicam.c
include/scsi/scsicam.h

index 3ac4c7fafb55c8bf004411e324be16362a956539..96c8230d638e67c02c6449f0e6d3c66e64f89a3e 100644 (file)
@@ -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)
 
 
     /**
index 1f100270cd385eeec8b057c47071444a05508d40..743be2ef6d1a7928259edc5ecbb988dd9c2bbf9e 100644 (file)
@@ -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;
        /*
index 4b12e6dd8f07f7d63886aea0f1a487c8c4d653cb..2264a97d91a0f81f7af1f167c66988d36ddbb0a6 100644 (file)
@@ -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)) {
index 17dfc3c72110c504862c392abbb2ca1b3eed9bd4..2cff19e95fec48a57463ead01a82449e1ca31d27 100644 (file)
@@ -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;
index cebf8c5d0caf806b0144f677709716eb690e9a73..05bdb73d115702f309b7603f37fbd0d90e86a9eb 100644 (file)
@@ -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;
index fb57343a97bd502540c038278598148fef37b5bf..6968da9fb67c16e9128905b1f951089c2feb142c 100644 (file)
@@ -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;
index 504c4e0c5d17a6c95b1ef57998d2341f3891713e..4a3716dc644cb643b5065890d08ee0bca4639cf4 100644 (file)
@@ -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 */
index 2006094af41897b3c314a6ea11ed76937e03cbda..c7581c7829af2147c101101a94864f97a933e9dc 100644 (file)
@@ -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,
index 19e6c3852d50482d30c515b17888b3ee5eecda73..3ff2cf51d5b0fd43bae90489c3e2cd2e73e7863b 100644 (file)
@@ -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)) {
index 08edd603e521433e4a7a466eaeb0346f2c85a7ba..67f4e8835bc8870396d397896c0b57825b98f9a3 100644 (file)
@@ -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 */