diff mbox series

[U-Boot,v4,3/4] block: ide: Don't bother to create BLK device if no CDROM inserted

Message ID 1505045573-11552-3-git-send-email-bmeng.cn@gmail.com
State Accepted
Delegated to: Tom Rini
Headers show
Series [U-Boot,v4,1/4] blk: Use macros for block device vendor/product/rev string size | expand

Commit Message

Bin Meng Sept. 10, 2017, 12:12 p.m. UTC
When there is no CDROM inserted, the block size is zero hence there
is no need to create a BLK device for it.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

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

Comments

Tom Rini Sept. 10, 2017, 10:02 p.m. UTC | #1
On Sun, Sep 10, 2017 at 05:12:52AM -0700, Bin Meng wrote:

> When there is no CDROM inserted, the block size is zero hence there
> is no need to create a BLK device for it.
> 
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index ed3b27e..9ab01a9 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -1202,6 +1202,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);