All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Clark <robdclark@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] dm: core: don't fail to iterate if first one fails to probe
Date: Tue, 20 Jun 2017 17:49:23 -0400	[thread overview]
Message-ID: <20170620214923.8564-1-robdclark@gmail.com> (raw)

efi_disk_register() would try to iterate all the blk devices.  But if
the first one in the list failed to probe, uclass_first_device() would
return NULL and no attempt would be made to register the remaining
devices.  Also uclass_next_device() needs the same fix.

Signed-off-by: Rob Clark <robdclark@gmail.com>
---
 drivers/core/uclass.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 21dc696..c47ff56 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -458,14 +458,23 @@ int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent,
 
 int uclass_first_device(enum uclass_id id, struct udevice **devp)
 {
-	struct udevice *dev;
+	struct udevice *dev = NULL;
 	int ret;
 
 	*devp = NULL;
 	ret = uclass_find_first_device(id, &dev);
 	if (!dev)
 		return 0;
-	return uclass_get_device_tail(dev, ret, devp);
+	ret = uclass_get_device_tail(dev, ret, devp);
+	if (ret && dev) {
+		/* we have a device, but it failed to probe, move on and
+		 * try the next one.
+		 */
+		ret = uclass_next_device(&dev);
+		if (!ret)
+			*devp = dev;
+	}
+	return ret;
 }
 
 int uclass_first_device_err(enum uclass_id id, struct udevice **devp)
@@ -490,7 +499,16 @@ int uclass_next_device(struct udevice **devp)
 	ret = uclass_find_next_device(&dev);
 	if (!dev)
 		return 0;
-	return uclass_get_device_tail(dev, ret, devp);
+	ret = uclass_get_device_tail(dev, ret, devp);
+	if (ret && (dev != *devp)) {
+		/* we have a device, but it failed to probe, move on and
+		 * try the next one.
+		 */
+		ret = uclass_next_device(&dev);
+		if (!ret)
+			*devp = dev;
+	}
+	return ret;
 }
 
 int uclass_bind_device(struct udevice *dev)
-- 
2.9.4

             reply	other threads:[~2017-06-20 21:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20 21:49 Rob Clark [this message]
2017-06-21 10:23 ` [U-Boot] [PATCH] dm: core: don't fail to iterate if first one fails to probe Peter Robinson
2017-06-21 10:52   ` Rob Clark
2017-07-13 19:10     ` Simon Glass
2017-07-19 16:53       ` Rob Clark
2017-08-03 15:24         ` Simon Glass
2017-08-03 15:37           ` Rob Clark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170620214923.8564-1-robdclark@gmail.com \
    --to=robdclark@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.