Skip to contentSkip to conversation

usb: Add missing guard around env_get() in usb_hub

PATCH In review Marek Vasut 2 participants 2 messages Sep 19, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: Add missing guard around env_get() in usb_hub

The env_get() might be undefined in case ENV_SUPPORT is disabled, which may happen e.g. in SPL. Add missing ifdef guard around the env_get() to prevent build failure.

---
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>

---
 common/usb_hub.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
common/usb_hub.c +3 -1
index d73638950b9..95f1449b5cb 100644
@@ -168,7 +168,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
 	int i;
 	struct usb_device *dev;
 	unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2;
-	const char *env;
+	const char __maybe_unused *env;
 
 	dev = hub->pusb_dev;
 
@@ -193,10 +193,12 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
 	 * but allow this time to be increased via env variable as some
 	 * devices break the spec and require longer warm-up times
 	 */
+#if CONFIG_IS_ENABLED(ENV_SUPPORT)
 	env = env_get("usb_pgood_delay");
 	if (env)
 		pgood_delay = max(pgood_delay,
 			          (unsigned)simple_strtol(env, NULL, 0));
+#endif
 	debug("pgood_delay=%dms\n", pgood_delay);
 
 	/*
Signature · 1 line
2.35.1
Tested-by on v1 1/1
#1 lore raw

Hi Marek,

Quoted 4 lines · Marek Vasut

The env_get() might be undefined in case ENV_SUPPORT is disabled, which may happen e.g. in SPL. Add missing ifdef guard around the env_get() to prevent build failure.

Yes, this fixes a build failure when adding imx8mm-evk SDP SPL support, thanks: