USB: ice40-hcd: Add retry for loading firmware
Add 3 retry for loading firmware so that if firmware load fails for first
time it will not fail loading of module. If loading of firmware fails for
3 time consecutively then this exits returning error code.
Change-Id: I8fc25383daf72917dc286b30121fbddc2282920c
Signed-off-by: Tarun Gupta <tarung@codeaurora.org>
diff --git a/drivers/usb/host/ice40-hcd.c b/drivers/usb/host/ice40-hcd.c
index 750876a..7b0a789 100644
--- a/drivers/usb/host/ice40-hcd.c
+++ b/drivers/usb/host/ice40-hcd.c
@@ -1225,7 +1225,7 @@
{
struct ice40_hcd *ihcd = hcd_to_ihcd(hcd);
u8 ctrl0;
- int ret;
+ int ret, i;
pm_stay_awake(&ihcd->spi->dev);
trace_ice40_bus_resume(0); /* start */
@@ -1234,7 +1234,18 @@
* Re-program the previous settings. For now we need to
* update the device address only.
*/
- ice40_spi_load_fw(ihcd);
+
+ for (i = 0; i < 3; i++) {
+ ret = ice40_spi_load_fw(ihcd);
+ if (!ret)
+ break;
+ }
+
+ if (ret) {
+ pr_err("Load firmware failed with ret: %d\n", ret);
+ return ret;
+ }
+
ice40_spi_reg_write(ihcd, ihcd->devnum, FADDR_REG);
ihcd->wblen0 = ~0;