lkml.org 
[lkml]   [1999]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectIDE fix... ("obviously correct").
Date
From

Hi,

It is so obvious I couldn't believe my eyes, and had to ask a second
opinion in this matter, and I therfore didn't provide a patch first
time around.

It looks as if noone with a 64 bit machine has gotten bitten by this
yet, but the IDE/64bit architecture combination is getting more and
more common.

lba_sects is defined as a long, which is 64 bits on 64-bit
architectures like Alpha.

Supposed it has the value 0x12345678, and the original code is used:

lba_sects = (lba_sects << 16) | (lba_sects >> 16);

then, we assign

lba_sects = 0x123456780000 | 0x1234
= 0x123456781234

which is not the intention: we wanted 0x56781234.

I therefore propose the following patch:

diff -ur linux-2.2.9.clean/drivers/block/ide-disk.c linux/drivers/block/ide-disk.c
--- linux-2.2.9.clean/drivers/block/ide-disk.c Wed Apr 7 17:03:50 1999
+++ linux/drivers/block/ide-disk.c Mon May 17 07:53:48 1999
@@ -106,7 +106,8 @@
return 1; /* lba_capacity is good */
}
/* some drives have the word order reversed */
- lba_sects = (lba_sects << 16) | (lba_sects >> 16);
+ lba_sects = ((lba_sects & 0xffff) << 16) |
+ ((lba_sects >> 16) & 0xffff);
if ((lba_sects - chs_sects) < _10_percent) {
id->lba_capacity = lba_sects; /* fix it */
return 1; /* lba_capacity is (now) good */

Roger.

--
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
------ Microsoft SELLS you Windows, Linux GIVES you the whole house ------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.033 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site