[U-Boot] [PATCH] cmd_ide: Fix detection problem with missing devices

Stefan Roese sr at denx.de
Thu May 14 07:24:47 CEST 2009


Currently only IDE busses are probed and all possible available devices
are listed in the IDE bootup log. Even when devices on the bus are not
available. This leads to the following output on the CPCI750:

IDE:   Bus 0: OK Bus 1: OK
  Device 0: Model: HITACHI_DK23FA-20J Firm: 00M7A0A0 Ser#: 42D182
            Type: Hard Disk
            Capacity: 19077.1 MB = 18.6 GB (39070080 x 512)
  Device 1: Model:  Firm:  Ser#:
            Type: # 1F #
            Capacity: not available
  Device 2: Model: SanDisk SDCFB-128 Firm: vde 1.10 Ser#: gmo5i311404
            Type: Removable Hard Disk
            Capacity: 122.5 MB = 0.1 GB (250880 x 512)
  Device 3: Model:  Firm:  Ser#:
            Type: # 1F #
            Capacity: not available

Here devices 1 + 3 are listed which are not availble.

This patch now fixes this problem by skipping the device output for
non-available devices. This is the resulting log:

IDE:   Bus 0: OK Bus 1: OK
  Device 0: Model: HITACHI_DK23FA-20J Firm: 00M7A0A0 Ser#: 42D182
            Type: Hard Disk
            Capacity: 19077.1 MB = 18.6 GB (39070080 x 512)
  Device 1: not available
  Device 2: Model: SanDisk SDCFB-128 Firm: vde 1.10 Ser#: gmo5i311404
            Type: Removable Hard Disk
            Capacity: 122.5 MB = 0.1 GB (250880 x 512)
  Device 3: not available

Signed-off-by: Stefan Roese <sr at denx.de>
---
 common/cmd_ide.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 71db933..7f9217d 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -154,7 +154,7 @@ static void ide_reset(void);
 #define ide_reset()		/* dummy */
 #endif
 
-static void ide_ident(block_dev_desc_t *dev_desc);
+static int ide_ident(block_dev_desc_t *dev_desc);
 static uchar ide_wait(int dev, ulong t);
 
 #define IDE_TIME_OUT	2000	/* 2 sec timeout */
@@ -714,6 +714,7 @@ skip_bus:
 
 	curr_device = -1;
 	for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) {
+		int ret;
 #ifdef CONFIG_IDE_LED
 		int led = (IDE_BUS(i) == 0) ? LED_IDE1 : LED_IDE2;
 #endif
@@ -727,8 +728,12 @@ skip_bus:
 		if (!ide_bus_ok[IDE_BUS(i)])
 			continue;
 		ide_led(led, 1);	/* LED on       */
-		ide_ident(&ide_dev_desc[i]);
+		ret = ide_ident(&ide_dev_desc[i]);
 		ide_led(led, 0);	/* LED off      */
+		if (ret < 0) {
+			puts("not available\n");
+			continue;
+		}
 		dev_print(&ide_dev_desc[i]);
 		if ((ide_dev_desc[i].lba > 0) && (ide_dev_desc[i].blksz > 0)) {
 			init_part(&ide_dev_desc[i]);	/* initialize partition type */
@@ -987,7 +992,7 @@ static void input_data(int dev, ulong *sect_buf, int words)
 
 /* -------------------------------------------------------------------------
  */
-static void ide_ident(block_dev_desc_t *dev_desc)
+static int ide_ident(block_dev_desc_t *dev_desc)
 {
 	ulong iobuf[ATA_SECTORWORDS];
 	unsigned char c;
@@ -1018,7 +1023,7 @@ static void ide_ident(block_dev_desc_t *dev_desc)
 		max_bus_scan = CONFIG_SYS_IDE_MAXBUS;
 	if (device >= max_bus_scan * 2) {
 		dev_desc->type = DEV_TYPE_UNKNOWN;
-		return;
+		return -1;
 	}
 #endif
 
@@ -1087,7 +1092,7 @@ static void ide_ident(block_dev_desc_t *dev_desc)
 				 ATA_LBA | ATA_DEVICE(device));
 			retries++;
 #else
-			return;
+			return -1;
 #endif
 		}
 #ifdef CONFIG_ATAPI
@@ -1096,7 +1101,7 @@ static void ide_ident(block_dev_desc_t *dev_desc)
 	}			/* see above - ugly to read */
 
 	if (retries == 2)	/* Not found */
-		return;
+		return -1;
 #endif
 
 	input_swap_data(device, iobuf, ATA_SECTORWORDS);
@@ -1161,7 +1166,7 @@ static void ide_ident(block_dev_desc_t *dev_desc)
 #ifdef CONFIG_ATAPI
 	if (dev_desc->if_type == IF_TYPE_ATAPI) {
 		atapi_inquiry(dev_desc);
-		return;
+		return 0;
 	}
 #endif /* CONFIG_ATAPI */
 
@@ -1193,6 +1198,8 @@ static void ide_ident(block_dev_desc_t *dev_desc)
 	dev_desc->type = DEV_TYPE_HARDDISK;
 	dev_desc->blksz = ATA_BLOCKSIZE;
 	dev_desc->lun = 0;	/* just to fill something in... */
+
+	return 0;
 }
 
 /* ------------------------------------------------------------------------- */
-- 
1.6.2.5



More information about the U-Boot mailing list