[OpenBIOS] r489 - trunk/openbios-devel/drivers

svn at openbios.org svn at openbios.org
Sun May 17 20:59:32 CEST 2009


Author: laurent
Date: 2009-05-17 20:59:32 +0200 (Sun, 17 May 2009)
New Revision: 489

Modified:
   trunk/openbios-devel/drivers/ide.c
   trunk/openbios-devel/drivers/ide.h
Log:
Author: Pavel Roskin <proski at gnu.org>

struct ata_sector was meant to facilitate taking upper and lower byte of
the sector.  However, the implementation is incorrect, as "struct" and
"union" are swapped in the definition.  What's worse, it's an overkill
for that simple task.  The code should be transparent without knowing
how struct ata_sector is defined.

[laurent: Original patch modified to remove useless "& 0xff"]


Modified: trunk/openbios-devel/drivers/ide.c
===================================================================
--- trunk/openbios-devel/drivers/ide.c	2009-05-17 17:14:01 UTC (rev 488)
+++ trunk/openbios-devel/drivers/ide.c	2009-05-17 18:59:32 UTC (rev 489)
@@ -764,7 +764,6 @@
 	unsigned int sect = (block % drive->sect) + 1;
 	unsigned int head = (track % drive->head);
 	unsigned int cyl = (track / drive->head);
-	struct ata_sector ata_sector;
 
 	/*
 	 * fill in chs command to read from disk at given location
@@ -772,8 +771,7 @@
 	cmd->buffer = buf;
 	cmd->buflen = sectors * 512;
 
-	ata_sector.all = sectors;
-	cmd->nsector = ata_sector.low;
+	cmd->nsector = sectors & 0xff;
 	cmd->sector = sect;
 	cmd->lcyl = cyl;
 	cmd->hcyl = cyl >> 8;
@@ -815,19 +813,17 @@
                       unsigned char *buf, unsigned int sectors)
 {
 	struct ata_command *cmd = &drive->channel->ata_cmd;
-	struct ata_sector ata_sector;
 
 	memset(cmd, 0, sizeof(*cmd));
 
 	cmd->buffer = buf;
 	cmd->buflen = sectors * 512;
-	ata_sector.all = sectors;
 
 	/*
 	 * we are using tasklet addressing here
 	 */
-	cmd->task[2] = ata_sector.low;
-	cmd->task[3] = ata_sector.high;
+	cmd->task[2] = sectors;
+	cmd->task[3] = sectors >> 8;
 	cmd->task[4] = block;
 	cmd->task[5] = block >>  8;
 	cmd->task[6] = block >> 16;

Modified: trunk/openbios-devel/drivers/ide.h
===================================================================
--- trunk/openbios-devel/drivers/ide.h	2009-05-17 17:14:01 UTC (rev 488)
+++ trunk/openbios-devel/drivers/ide.h	2009-05-17 18:59:32 UTC (rev 489)
@@ -208,20 +208,6 @@
 	atapi_ddir_write,
 };
 
-struct ata_sector {
-	u16 all;
-	union {
-#ifdef CONFIG_BIG_ENDIAN
-		u8 high;
-		u8 low;
-#endif
-#ifdef CONFIG_LITTLE_ENDIAN
-		u8 low;
-		u8 high;
-#endif
-	};
-};
-
 static int ob_ide_atapi_request_sense(struct ide_drive *drive);
 
 #endif




More information about the OpenBIOS mailing list