Commit ba26d89f authored by Doug Ledford's avatar Doug Ledford

aic7xxx_old: fix up the biosparam function to do 64bit math safely

parent dceeb5a9
...@@ -10974,7 +10974,8 @@ int ...@@ -10974,7 +10974,8 @@ int
aic7xxx_biosparam(struct scsi_device *sdev, struct block_device *bdev, aic7xxx_biosparam(struct scsi_device *sdev, struct block_device *bdev,
sector_t capacity, int geom[]) sector_t capacity, int geom[])
{ {
int heads, sectors, cylinders, ret; sector_t heads, sectors, cylinders;
int ret;
struct aic7xxx_host *p; struct aic7xxx_host *p;
unsigned char *buf; unsigned char *buf;
...@@ -10991,18 +10992,26 @@ aic7xxx_biosparam(struct scsi_device *sdev, struct block_device *bdev, ...@@ -10991,18 +10992,26 @@ aic7xxx_biosparam(struct scsi_device *sdev, struct block_device *bdev,
heads = 64; heads = 64;
sectors = 32; sectors = 32;
cylinders = (unsigned long)capacity / (heads * sectors); cylinders = capacity >> 11;
if ((p->flags & AHC_EXTEND_TRANS_A) && (cylinders > 1024)) if ((p->flags & AHC_EXTEND_TRANS_A) && (cylinders > 1024))
{ {
heads = 255; heads = 255;
sectors = 63; sectors = 63;
cylinders = (unsigned long)capacity / (heads * sectors); /* pull this crap because 64bit math in the kernel is a no-no as far
} * as division is concerned, but 64bit multiplication can be done */
/* This shift approximates capacity / (heads * sectors) */
geom[0] = heads; cylinders = capacity >> 14;
geom[1] = sectors; /* Now we brute force upping cylinders until we go over by 1 */
geom[2] = cylinders; while( capacity >= (cylinders * sectors * heads))
cylinders++;
/* Then back it back down by one */
cylinders--;
}
geom[0] = (int)heads;
geom[1] = (int)sectors;
geom[2] = (int)cylinders;
return (0); return (0);
} }
......
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