Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06a3206b authored by Tarun Gupta's avatar Tarun Gupta
Browse files

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: default avatarTarun Gupta <tarung@codeaurora.org>
parent 636d7495
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -1229,7 +1229,7 @@ static int ice40_bus_resume(struct usb_hcd *hcd)
{
	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 */
@@ -1238,7 +1238,18 @@ static int ice40_bus_resume(struct usb_hcd *hcd)
	 * 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;