3/8 Backport recent 2.6 IDE updates to 2.4.x
PATCH 1/1 3/8 Backport recent 2.6 IDE updates to 2.4.x
This patch fixes all cases where ide-disk displays MB to use consistant logic, and properly use the do_div() macro rather than strange non-obvious numerical sequences doing a similar task,
-Erik
--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
drivers/ide/ide-disk.c renamed from drivers/ide/ide-disk.c.orig +27 -10
@@ -69,6 +69,7 @@#include <asm/irq.h> #include <asm/uaccess.h> #include <asm/io.h> +#include <asm/div64.h> /* FIXME: some day we shouldnt need to look in here! */
@@ -1131,6 +1132,13 @@#endif /* CONFIG_IDEDISK_STROKE */ +static unsigned long long sectors_to_MB (unsigned long long n) +{ + n <<=9 ;/* make it bytes */ +do_div (n,1000000 );/* make it MB */ +return n; +} +/* * Tests if the drive supports Host Protected Area feature. * Returns true if supported, false otherwise.
@@ -1231,7 +1239,7 @@ } } -static unsigned long idedisk_capacity (ide_drive_t *drive) +static u64 idedisk_capacity (ide_drive_t *drive) {if (drive->id->cfs_enable_2 &0x0400 )return (drive->capacity48 - drive->sect0);
@@ -1616,7 +1624,7 @@int i;struct hd_driveid *id = drive->id; -unsigned long capacity; +unsigned long long capacity;idedisk_add_settings (drive);
@@ -1683,14 +1691,23 @@* by correcting bios_cyls: */ capacity =idedisk_capacity (drive); -if ((capacity >= (drive->bios_cyl * drive->bios_sect * drive->bios_head)) && - (!drive->forced_geom) && drive->bios_sect && drive->bios_head) - drive->bios_cyl = (capacity / drive->bios_sect) / drive->bios_head; -printk (KERN_INFO "%s: %ld sectors" , drive->name, capacity); - -/* Give size in megabytes (MB), not mebibytes (MiB). */ -/* We compute the exact rounded value, avoiding overflow. */ -printk (" (%ld MB)" , (capacity - capacity/625 +974 )/1950 ); +if (!drive->forced_geom && drive->bios_sect && drive->bios_head) { +unsigned int cap0 = capacity;/* truncate to 32 bits */ +unsigned int cylsz, cyl; + +if (cap0 != capacity) + drive->bios_cyl =65535 ; +else { + cylsz = drive->bios_sect * drive->bios_head; + cyl = cap0 / cylsz; +if (cyl >65535 ) + cyl =65535 ; +if (cyl > drive->bios_cyl) + drive->bios_cyl = cyl; + } + } +printk (KERN_INFO "%s: %llu sectors (%llu MB)" , + drive->name, capacity,sectors_to_MB (capacity));/* Only print cache size when it was specified */ if (id->buf_size)