diff mbox

[U-Boot] api: storage: Avoid enumeration for non-configured subsystem

Message ID 20161019151947.5191-1-manu@bidouilliste.com
State Accepted
Commit 5d81c6df320e40c741f474a54cc6df451e830143
Delegated to: Tom Rini
Headers show

Commit Message

Emmanuel Vadot Oct. 19, 2016, 3:19 p.m. UTC
If a subsystem wasn't configured, avoid enumeration.

Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>
---
 api/api_storage.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Tom Rini Oct. 24, 2016, 3:24 p.m. UTC | #1
On Wed, Oct 19, 2016 at 05:19:47PM +0200, Emmanuel Vadot wrote:

> If a subsystem wasn't configured, avoid enumeration.
> 
> Signed-off-by: Emmanuel Vadot <manu@bidouilliste.com>

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

Patch

diff --git a/api/api_storage.c b/api/api_storage.c
index d425a9a..b5aaba1 100644
--- a/api/api_storage.c
+++ b/api/api_storage.c
@@ -41,7 +41,7 @@  struct stor_spec {
 	char		*name;
 };
 
-static struct stor_spec specs[ENUM_MAX] = { { 0, 0, 0, 0, "" }, };
+static struct stor_spec specs[ENUM_MAX] = { { 0, 0, 0, 0, NULL }, };
 
 
 void dev_stor_init(void)
@@ -105,6 +105,10 @@  static int dev_stor_get(int type, int first, int *more, struct device_info *di)
 
 	struct blk_desc *dd;
 
+	/* Wasn't configured for this type, return 0 directly */
+	if (specs[type].name == NULL)
+		return 0;
+
 	if (first) {
 		di->cookie = (void *)blk_get_dev(specs[type].name, 0);
 		if (di->cookie == NULL)