Add changes from the Linux-2.6 tree.
[linux-2.6.git] / drivers / scsi / scsicam.c
index cedefa2..cd68a66 100644 (file)
@@ -57,17 +57,9 @@ EXPORT_SYMBOL(scsi_bios_ptable);
 int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip)
 {
        unsigned char *p;
+       u64 capacity64 = capacity;      /* Suppress gcc warning */
        int ret;
 
-       /* Are we above the max. allowed for cylinder/sector/head? */
-       if (capacity > 65535*63*255) {
-               ip[0] = 255;
-               ip[1] = 63;
-               ip[2] = 65535;
-
-               return 0;
-       }
-
        p = scsi_bios_ptable(bdev);
        if (!p)
                return -1;
@@ -77,7 +69,7 @@ int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip)
                               (unsigned int *)ip + 0, (unsigned int *)ip + 1);
        kfree(p);
 
-       if (ret == -1) {
+       if (ret == -1 && capacity64 < (1ULL << 32)) {
                /* pick some standard mapping with at most 1024 cylinders,
                   and at most 62 sectors per track - this works up to
                   7905 MB */
@@ -95,7 +87,11 @@ int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip)
                        ip[0] = 64;
                        ip[1] = 32;
                }
-               ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
+
+               if (capacity > 65535*63*255)
+                       ip[2] = 65535;
+               else
+                       ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
        }
 
        return 0;