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;
(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 */
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;