From patchwork Thu Jul 2 08:02:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 240592 List-Id: U-Boot discussion From: faiz_abbas at ti.com (Faiz Abbas) Date: Thu, 2 Jul 2020 13:32:22 +0530 Subject: [PATCH 02/13] spl: usb: Only init usb once In-Reply-To: <20200702080233.27582-1-faiz_abbas@ti.com> References: <20200702080233.27582-1-faiz_abbas@ti.com> Message-ID: <20200702080233.27582-3-faiz_abbas@ti.com> usb_init() may be called multiple times for fetching multiple images from SPL. Skip reinitializing USB if its already been done Signed-off-by: Faiz Abbas --- common/spl/spl_usb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c index 92ae96f66e..3648de3492 100644 --- a/common/spl/spl_usb.c +++ b/common/spl/spl_usb.c @@ -22,11 +22,16 @@ int spl_usb_load(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, int partition, const char *filename) { - int err; + int err = 0; struct blk_desc *stor_dev; + static bool usb_init_pending = true; + + if (usb_init_pending) { + usb_stop(); + err = usb_init(); + usb_init_pending = false; + } - usb_stop(); - err = usb_init(); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("%s: usb init failed: err - %d\n", __func__, err);