Skip to contentSkip to conversation

blk: Use macros for block device vendor/product/rev string size

PATCH Superseded Bin Meng 3 participants 12 messages Sep 4, 2017 – Sep 5, 2017 Block layer

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH v2 1/4 blk: Use macros for block device vendor/product/rev string size

So far these are using magic numbers. Replace them with macros.

---

Changes in v2: None

 include/blk.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
include/blk.h +7 -3
index a106f9c..fced138 100644
@@ -36,6 +36,10 @@ enum if_type {
 	IF_TYPE_COUNT,			/* Number of interface types */
 };
 
+#define BLK_VEN_SIZE		41
+#define BLK_PRD_SIZE		21
+#define BLK_REV_SIZE		9
+
 /*
  * With driver model (CONFIG_BLK) this is uclass platform data, accessible
  * with dev_get_uclass_platdata(dev)
@@ -60,9 +64,9 @@ struct blk_desc {
 	lbaint_t	lba;		/* number of blocks */
 	unsigned long	blksz;		/* block size */
 	int		log2blksz;	/* for convenience: log2(blksz) */
-	char		vendor[40+1];	/* IDE model, SCSI Vendor */
-	char		product[20+1];	/* IDE Serial no, SCSI product */
-	char		revision[8+1];	/* firmware revision */
+	char		vendor[BLK_VEN_SIZE];	/* device vendor string */
+	char		product[BLK_PRD_SIZE];	/* device product number */
+	char		revision[BLK_REV_SIZE];	/* firmware revision */
 #if CONFIG_IS_ENABLED(BLK)
 	/*
 	 * For now we have a few functions which take struct blk_desc as a
Signature · 1 line
2.9.2
author
#1 lore raw

PATCH v2 2/4 block: ide: Fix block read/write with driver model

This converts the IDE driver to driver model so that block read and write are fully functional.

Fixes b7c6baef ("x86: Convert MMC to driver model")

---

Changes in v2:
- Fixed 'fatls ide 0' issue

 drivers/block/blk-uclass.c |  2 +-
 drivers/block/ide.c        | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h     |  1 +
 3 files changed, 70 insertions(+), 1 deletion(-)
drivers/block/blk-uclass.c +1 -1
index e5f00dc..8e58580 100644
@@ -26,7 +26,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
 };
 
 static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
-	[IF_TYPE_IDE]		= UCLASS_INVALID,
+	[IF_TYPE_IDE]		= UCLASS_IDE,
 	[IF_TYPE_SCSI]		= UCLASS_SCSI,
 	[IF_TYPE_ATAPI]		= UCLASS_INVALID,
 	[IF_TYPE_USB]		= UCLASS_MASS_STORAGE,
drivers/block/ide.c +68 -0

92 lines not on this page · raw message

include/dm/uclass-id.h +1 -0
index 1a50199..3fc2083 100644
@@ -41,6 +41,7 @@ enum uclass_id {
 	UCLASS_I2C_EEPROM,	/* I2C EEPROM device */
 	UCLASS_I2C_GENERIC,	/* Generic I2C device */
 	UCLASS_I2C_MUX,		/* I2C multiplexer */
+	UCLASS_IDE,		/* IDE device */
 	UCLASS_IRQ,		/* Interrupt controller */
 	UCLASS_KEYBOARD,	/* Keyboard input device */
 	UCLASS_LED,		/* Light-emitting diode (LED) */
Signature · 1 line
2.9.2
#2 lore raw

PATCH v2 2/4 block: ide: Fix block read/write with driver model

Quoted 4 lines · Bin Meng

This converts the IDE driver to driver model so that block read and write are fully functional.

Fixes b7c6baef ("x86: Convert MMC to driver model")

Now I am able to load a file from the IDE disk and execute it with bootefi. Thanks a lot for fixing this.

I think this is release critical and should be merged into 2017.09.

Quoted 138 lines

---

Changes in v2:
- Fixed 'fatls ide 0' issue

 drivers/block/blk-uclass.c |  2 +-
 drivers/block/ide.c        | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h     |  1 +
 3 files changed, 70 insertions(+), 1 deletion(-)
drivers/block/blk-uclass.c +1 -1
index e5f00dc..8e58580 100644
@@ -26,7 +26,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
 };
 
 static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
-	[IF_TYPE_IDE]		= UCLASS_INVALID,
+	[IF_TYPE_IDE]		= UCLASS_IDE,
 	[IF_TYPE_SCSI]		= UCLASS_SCSI,
 	[IF_TYPE_ATAPI]		= UCLASS_INVALID,
 	[IF_TYPE_USB]		= UCLASS_MASS_STORAGE,
drivers/block/ide.c +68 -0
index ce51153..58b295e 100644
@@ -827,12 +827,20 @@ void ide_init(void)
 		ide_ident(&ide_dev_desc[i]);
 		dev_print(&ide_dev_desc[i]);
 
+#ifndef CONFIG_BLK
 		if ((ide_dev_desc[i].lba > 0) && (ide_dev_desc[i].blksz > 0)) {
 			/* initialize partition type */
 			part_init(&ide_dev_desc[i]);
 		}
+#endif
 	}
 	WATCHDOG_RESET();
+
+#ifdef CONFIG_BLK
+	struct udevice *dev;
+
+	uclass_first_device(UCLASS_IDE, &dev);
+#endif
 }
 
 /* We only need to swap data if we are running on a big endian cpu. */
@@ -1147,6 +1155,21 @@ int ide_device_present(int dev)
 #endif
 
 #ifdef CONFIG_BLK
+static int ide_blk_probe(struct udevice *udev)
+{
+	struct blk_desc *desc = dev_get_uclass_platdata(udev);
+	int devnum = desc->devnum;
+
+	/* fill in device vendor/product/rev strings */
+	strncpy(desc->vendor, ide_dev_desc[devnum].vendor, BLK_VEN_SIZE);
+	strncpy(desc->product, ide_dev_desc[devnum].product, BLK_PRD_SIZE);
+	strncpy(desc->revision, ide_dev_desc[devnum].revision, BLK_REV_SIZE);
+
+	part_init(desc);
+
+	return 0;
+}
+
 static const struct blk_ops ide_blk_ops = {
 	.read	= ide_read,
 	.write	= ide_write,
@@ -1156,6 +1179,51 @@ U_BOOT_DRIVER(ide_blk) = {
 	.name		= "ide_blk",
 	.id		= UCLASS_BLK,
 	.ops		= &ide_blk_ops,
+	.probe		= ide_blk_probe,
+};
+
+static int ide_probe(struct udevice *udev)
+{
+	struct udevice *blk_dev;
+	char name[20];
+	int blksz;
+	lbaint_t size;
+	int i;
+	int ret;
+
+	for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) {
+		if (ide_dev_desc[i].type != DEV_TYPE_UNKNOWN) {
+			sprintf(name, "blk#%d", i);
+
+			blksz = ide_dev_desc[i].blksz;
+			size = blksz * ide_dev_desc[i].lba;
+			ret = blk_create_devicef(udev, "ide_blk", name,
+						 IF_TYPE_IDE, i,
+						 blksz, size, &blk_dev);
+			if (ret)
+				return ret;
+		}
+	}
+
+	return 0;
+}
+
+U_BOOT_DRIVER(ide) = {
+	.name		= "ide",
+	.id		= UCLASS_IDE,
+	.probe		= ide_probe,
+};
+
+struct pci_device_id ide_supported[] = {
+	{ PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE << 8, 0xffff00) },
+	{ }
+};
+
+U_BOOT_PCI_DEVICE(ide, ide_supported);
+
+UCLASS_DRIVER(ide) = {
+	.name		= "ide",
+	.id		= UCLASS_IDE,
 };
 #else
 U_BOOT_LEGACY_BLK(ide) = {
include/dm/uclass-id.h +1 -0
index 1a50199..3fc2083 100644
@@ -41,6 +41,7 @@ enum uclass_id {
 	UCLASS_I2C_EEPROM,	/* I2C EEPROM device */
 	UCLASS_I2C_GENERIC,	/* Generic I2C device */
 	UCLASS_I2C_MUX,		/* I2C multiplexer */
+	UCLASS_IDE,		/* IDE device */
 	UCLASS_IRQ,		/* Interrupt controller */
 	UCLASS_KEYBOARD,	/* Keyboard input device */
 	UCLASS_LED,		/* Light-emitting diode (LED) */
#3 lore raw

PATCH v2 2/4 block: ide: Fix block read/write with driver model

In reply to Bin Meng
Quoted 135 lines · Bin Meng

This converts the IDE driver to driver model so that block read and write are fully functional.

Fixes b7c6baef ("x86: Convert MMC to driver model")

---

Changes in v2:
- Fixed 'fatls ide 0' issue

 drivers/block/blk-uclass.c |  2 +-
 drivers/block/ide.c        | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h     |  1 +
 3 files changed, 70 insertions(+), 1 deletion(-)
drivers/block/blk-uclass.c +1 -1
index e5f00dc..8e58580 100644
@@ -26,7 +26,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
 };
 
 static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
-	[IF_TYPE_IDE]		= UCLASS_INVALID,
+	[IF_TYPE_IDE]		= UCLASS_IDE,
 	[IF_TYPE_SCSI]		= UCLASS_SCSI,
 	[IF_TYPE_ATAPI]		= UCLASS_INVALID,
 	[IF_TYPE_USB]		= UCLASS_MASS_STORAGE,
drivers/block/ide.c +68 -0
index ce51153..58b295e 100644
@@ -827,12 +827,20 @@ void ide_init(void)
 		ide_ident(&ide_dev_desc[i]);
 		dev_print(&ide_dev_desc[i]);
 
+#ifndef CONFIG_BLK
 		if ((ide_dev_desc[i].lba > 0) && (ide_dev_desc[i].blksz > 0)) {
 			/* initialize partition type */
 			part_init(&ide_dev_desc[i]);
 		}
+#endif
 	}
 	WATCHDOG_RESET();
+
+#ifdef CONFIG_BLK
+	struct udevice *dev;
+
+	uclass_first_device(UCLASS_IDE, &dev);
+#endif
 }
 
 /* We only need to swap data if we are running on a big endian cpu. */
@@ -1147,6 +1155,21 @@ int ide_device_present(int dev)
 #endif
 
 #ifdef CONFIG_BLK
+static int ide_blk_probe(struct udevice *udev)
+{
+	struct blk_desc *desc = dev_get_uclass_platdata(udev);
+	int devnum = desc->devnum;
+
+	/* fill in device vendor/product/rev strings */
+	strncpy(desc->vendor, ide_dev_desc[devnum].vendor, BLK_VEN_SIZE);
+	strncpy(desc->product, ide_dev_desc[devnum].product, BLK_PRD_SIZE);
+	strncpy(desc->revision, ide_dev_desc[devnum].revision, BLK_REV_SIZE);
+
+	part_init(desc);
+
+	return 0;
+}
+
 static const struct blk_ops ide_blk_ops = {
 	.read	= ide_read,
 	.write	= ide_write,
@@ -1156,6 +1179,51 @@ U_BOOT_DRIVER(ide_blk) = {
 	.name		= "ide_blk",
 	.id		= UCLASS_BLK,
 	.ops		= &ide_blk_ops,
+	.probe		= ide_blk_probe,
+};
+
+static int ide_probe(struct udevice *udev)
+{
+	struct udevice *blk_dev;
+	char name[20];
+	int blksz;
+	lbaint_t size;
+	int i;
+	int ret;
+
+	for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) {
+		if (ide_dev_desc[i].type != DEV_TYPE_UNKNOWN) {
+			sprintf(name, "blk#%d", i);
+
+			blksz = ide_dev_desc[i].blksz;
+			size = blksz * ide_dev_desc[i].lba;
+			ret = blk_create_devicef(udev, "ide_blk", name,
+						 IF_TYPE_IDE, i,
+						 blksz, size, &blk_dev);
+			if (ret)
+				return ret;
+		}
+	}
+
+	return 0;
+}
+
+U_BOOT_DRIVER(ide) = {
+	.name		= "ide",
+	.id		= UCLASS_IDE,
+	.probe		= ide_probe,
+};
+
+struct pci_device_id ide_supported[] = {
+	{ PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE << 8, 0xffff00) },
+	{ }
+};
+
+U_BOOT_PCI_DEVICE(ide, ide_supported);
+
+UCLASS_DRIVER(ide) = {
+	.name		= "ide",
+	.id		= UCLASS_IDE,
 };
 #else
 U_BOOT_LEGACY_BLK(ide) = {
include/dm/uclass-id.h +0 -0
index 1a50199..3fc2083 100644

include/dm/uclass-id.h enum uclass_id { · line 47

Quoted 7 lines
include/dm/uclass-id.h +1 -0
@@ -41,6 +41,7 @@ enum uclass_id {
 	UCLASS_I2C_EEPROM,	/* I2C EEPROM device */
 	UCLASS_I2C_GENERIC,	/* Generic I2C device */
 	UCLASS_I2C_MUX,		/* I2C multiplexer */
+	UCLASS_IDE,		/* IDE device */
 	UCLASS_IRQ,		/* Interrupt controller */
 	UCLASS_KEYBOARD,	/* Keyboard input device */
 	UCLASS_LED,		/* Light-emitting diode (LED) */

Hello Bin,

I assume the same sort of changes as in ide.c is needed in drivers/ata/sata.c too.

When booting I see these error messages:
** Bad device scsi 0 **
Error: Invalid Boot Flag (found 0x0000, expected 0xaa55)

qemu-system-x86_64 -m 1G -bios denx/u-boot.rom -nographic \
-netdev \
user,id=eth0,tftp=tftp,net=192.168.76.0/24,dhcpstart=192.168.76.9 \
-device e1000,netdev=eth0 -machine pc-i440fx-2.8 \
-drive file=img,if=scsi,bus=0,unit=6

Best regards

Heinrich

author
#4 lore raw

PATCH v2 2/4 block: ide: Fix block read/write with driver model

Hi Heinrich,

Quoted 157 lines · Heinrich Schuchardt
Quoted 135 lines · Bin Meng

This converts the IDE driver to driver model so that block read and write are fully functional.

Fixes b7c6baef ("x86: Convert MMC to driver model")

---

Changes in v2:
- Fixed 'fatls ide 0' issue

 drivers/block/blk-uclass.c |  2 +-
 drivers/block/ide.c        | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h     |  1 +
 3 files changed, 70 insertions(+), 1 deletion(-)
drivers/block/blk-uclass.c +1 -1
index e5f00dc..8e58580 100644
@@ -26,7 +26,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
 };
 
 static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
-     [IF_TYPE_IDE]           = UCLASS_INVALID,
+     [IF_TYPE_IDE]           = UCLASS_IDE,
      [IF_TYPE_SCSI]          = UCLASS_SCSI,
      [IF_TYPE_ATAPI]         = UCLASS_INVALID,
      [IF_TYPE_USB]           = UCLASS_MASS_STORAGE,
drivers/block/ide.c +68 -0
index ce51153..58b295e 100644
@@ -827,12 +827,20 @@ void ide_init(void)
              ide_ident(&ide_dev_desc[i]);
              dev_print(&ide_dev_desc[i]);
 
+#ifndef CONFIG_BLK
              if ((ide_dev_desc[i].lba > 0) && (ide_dev_desc[i].blksz > 0)) {
                      /* initialize partition type */
                      part_init(&ide_dev_desc[i]);
              }
+#endif
      }
      WATCHDOG_RESET();
+
+#ifdef CONFIG_BLK
+     struct udevice *dev;
+
+     uclass_first_device(UCLASS_IDE, &dev);
+#endif
 }
 
 /* We only need to swap data if we are running on a big endian cpu. */
@@ -1147,6 +1155,21 @@ int ide_device_present(int dev)
 #endif
 
 #ifdef CONFIG_BLK
+static int ide_blk_probe(struct udevice *udev)
+{
+     struct blk_desc *desc = dev_get_uclass_platdata(udev);
+     int devnum = desc->devnum;
+
+     /* fill in device vendor/product/rev strings */
+     strncpy(desc->vendor, ide_dev_desc[devnum].vendor, BLK_VEN_SIZE);
+     strncpy(desc->product, ide_dev_desc[devnum].product, BLK_PRD_SIZE);
+     strncpy(desc->revision, ide_dev_desc[devnum].revision, BLK_REV_SIZE);
+
+     part_init(desc);
+
+     return 0;
+}
+
 static const struct blk_ops ide_blk_ops = {
      .read   = ide_read,
      .write  = ide_write,
@@ -1156,6 +1179,51 @@ U_BOOT_DRIVER(ide_blk) = {
      .name           = "ide_blk",
      .id             = UCLASS_BLK,
      .ops            = &ide_blk_ops,
+     .probe          = ide_blk_probe,
+};
+
+static int ide_probe(struct udevice *udev)
+{
+     struct udevice *blk_dev;
+     char name[20];
+     int blksz;
+     lbaint_t size;
+     int i;
+     int ret;
+
+     for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) {
+             if (ide_dev_desc[i].type != DEV_TYPE_UNKNOWN) {
+                     sprintf(name, "blk#%d", i);
+
+                     blksz = ide_dev_desc[i].blksz;
+                     size = blksz * ide_dev_desc[i].lba;
+                     ret = blk_create_devicef(udev, "ide_blk", name,
+                                              IF_TYPE_IDE, i,
+                                              blksz, size, &blk_dev);
+                     if (ret)
+                             return ret;
+             }
+     }
+
+     return 0;
+}
+
+U_BOOT_DRIVER(ide) = {
+     .name           = "ide",
+     .id             = UCLASS_IDE,
+     .probe          = ide_probe,
+};
+
+struct pci_device_id ide_supported[] = {
+     { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE << 8, 0xffff00) },
+     { }
+};
+
+U_BOOT_PCI_DEVICE(ide, ide_supported);
+
+UCLASS_DRIVER(ide) = {
+     .name           = "ide",
+     .id             = UCLASS_IDE,
 };
 #else
 U_BOOT_LEGACY_BLK(ide) = {
include/dm/uclass-id.h +0 -0
index 1a50199..3fc2083 100644

include/dm/uclass-id.h enum uclass_id { · line 47

Quoted 7 lines
include/dm/uclass-id.h +1 -0
@@ -41,6 +41,7 @@ enum uclass_id {
      UCLASS_I2C_EEPROM,      /* I2C EEPROM device */
      UCLASS_I2C_GENERIC,     /* Generic I2C device */
      UCLASS_I2C_MUX,         /* I2C multiplexer */
+     UCLASS_IDE,             /* IDE device */
      UCLASS_IRQ,             /* Interrupt controller */
      UCLASS_KEYBOARD,        /* Keyboard input device */
      UCLASS_LED,             /* Light-emitting diode (LED) */

Hello Bin,

I assume the same sort of changes as in ide.c is needed in drivers/ata/sata.c too.

When booting I see these error messages:
** Bad device scsi 0 **
Error: Invalid Boot Flag (found 0x0000, expected 0xaa55)

qemu-system-x86_64 -m 1G -bios denx/u-boot.rom -nographic \
-netdev \
user,id=eth0,tftp=tftp,net=192.168.76.0/24,dhcpstart=192.168.76.9 \

Review

Quoted 2 lines
(quoted diff) +0 -2
-device e1000,netdev=eth0 -machine pc-i440fx-2.8 \
-drive file=img,if=scsi,bus=0,unit=6

I never used QEMU to enable any SCSI device. Looks this should be a SCSI device, but you referred to drivers/ata/sata.c. Is that the correct driver for this device? Does the U-Boot driver work before (without the commit: b7c6baef "x86: Convert MMC to driver model")?

Regards,
Bin

#5 lore raw

PATCH v2 2/4 block: ide: Fix block read/write with driver model

In reply to Bin Meng
Quoted 9 lines · Bin Meng

This converts the IDE driver to driver model so that block read and write are fully functional.

Fixes b7c6baef ("x86: Convert MMC to driver model")

---

Quoted 8 lines

Changes in v2:
- Fixed 'fatls ide 0' issue

 drivers/block/blk-uclass.c |  2 +-
 drivers/block/ide.c        | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h     |  1 +
 3 files changed, 70 insertions(+), 1 deletion(-)
author
#6 lore raw

PATCH v2 3/4 block: ide: Don't bother to create BLK device if no CDROM inserted

In reply to Bin Meng

When there is no CDROM inserted, the block size is zero hence there is no need to create a BLK device for it.

---

Changes in v2: None

 drivers/block/ide.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/block/ide.c +7 -0
index 58b295e..8125ff8 100644
@@ -1197,6 +1197,13 @@ static int ide_probe(struct udevice *udev)
 
 			blksz = ide_dev_desc[i].blksz;
 			size = blksz * ide_dev_desc[i].lba;
+
+			/*
+			 * With CDROM, if there is no CD inserted, blksz will
+			 * be zero, don't bother to create IDE block device.
+			 */
+			if (!blksz)
+				continue;
 			ret = blk_create_devicef(udev, "ide_blk", name,
 						 IF_TYPE_IDE, i,
 						 blksz, size, &blk_dev);
Signature · 1 line
2.9.2
#7 lore raw

PATCH v2 3/4 block: ide: Don't bother to create BLK device if no CDROM inserted

Quoted 11 lines · Bin Meng

When there is no CDROM inserted, the block size is zero hence there is no need to create a BLK device for it.

---

Changes in v2: None

 drivers/block/ide.c | 7 +++++++
 1 file changed, 7 insertions(+)

drivers/block/ide.c static int ide_probe(struct udevice *udev) · line 1204

Quoted 13 lines
drivers/block/ide.c +5 -0
index 58b295e..8125ff8 100644
@@ -1197,6 +1197,13 @@ static int ide_probe(struct udevice *udev)
 
                        blksz = ide_dev_desc[i].blksz;
                        size = blksz * ide_dev_desc[i].lba;
+
+                       /*
+                        * With CDROM, if there is no CD inserted, blksz will
+                        * be zero, don't bother to create IDE block device.
+                        */

I suppose that if you insert one, you then need to rerun the ide scan to find it?

Quoted 8 lines
drivers/block/ide.c +2 -1
+                       if (!blksz)
+                               continue;
                        ret = blk_create_devicef(udev, "ide_blk", name,
                                                 IF_TYPE_IDE, i,
                                                 blksz, size, &blk_dev);
--

2.9.2

author
#8 lore raw

PATCH v2 3/4 block: ide: Don't bother to create BLK device if no CDROM inserted

Hi Simon,

Quoted 22 lines · Simon Glass
Quoted 11 lines · Bin Meng

When there is no CDROM inserted, the block size is zero hence there is no need to create a BLK device for it.

---

Changes in v2: None

 drivers/block/ide.c | 7 +++++++
 1 file changed, 7 insertions(+)
Quoted 6 lines
drivers/block/ide.c +0 -0
index 58b295e..8125ff8 100644
@@ -1197,6 +1197,13 @@ static int ide_probe(struct udevice *udev)
 
Quoted 11 lines

drivers/block/ide.c static int ide_probe(struct udevice *udev) · line 1204

Quoted 7 lines
drivers/block/ide.c +5 -0
                        blksz = ide_dev_desc[i].blksz;
                        size = blksz * ide_dev_desc[i].lba;
+
+                       /*
+                        * With CDROM, if there is no CD inserted, blksz will
+                        * be zero, don't bother to create IDE block device.
+                        */

I suppose that if you insert one, you then need to rerun the ide scan to find it?

Yes, we need call "ide reset" from the U-Boot shell, like we do for USB.

Quoted 6 lines

drivers/block/ide.c static int ide_probe(struct udevice *udev)

Quoted 6 lines
drivers/block/ide.c +2 -1
+                       if (!blksz)
+                               continue;
                        ret = blk_create_devicef(udev, "ide_blk", name,
                                                 IF_TYPE_IDE, i,
                                                 blksz, size, &blk_dev);
--

Regards,
Bin

author
#9 lore raw

PATCH v2 4/4 cmd: ide: Make the first device the default one

In reply to Bin Meng

At present the IDE device number is initialized to -1, which means we cannot type "ide read" command before setting the device number via "ide device #".

For convenience, let's set the first device as the default one.

---

Changes in v2: None

 cmd/ide.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/ide.c +1 -1
index e3c3242..bdb5980 100644
@@ -30,7 +30,7 @@
 #endif
 
 /* Current I/O Device	*/
-static int curr_device = -1;
+static int curr_device;
 
 int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
Signature · 1 line
2.9.2
#10 lore raw

PATCH v2 4/4 cmd: ide: Make the first device the default one

Quoted 6 lines · Bin Meng

At present the IDE device number is initialized to -1, which means we cannot type "ide read" command before setting the device number via "ide device #".

For convenience, let's set the first device as the default one.

Quoted 9 lines

---

Changes in v2: None

 cmd/ide.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)