Unverified Commit 4f12ee0a authored by Mark Brown's avatar Mark Brown
Browse files

spi: cadence-quadspi: Probe and unbind fixes

Several fixes from Johan for probe failure and unbind issues in the
cadence-quadspi driver.
parents 8d0189c1 5e8bb0cc
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -1860,14 +1860,10 @@ static int cqspi_probe(struct platform_device *pdev)
	if (irq < 0)
		return -ENXIO;

	ret = pm_runtime_set_active(dev);
	if (ret)
		return ret;

	ret = clk_bulk_prepare_enable(CLK_QSPI_NUM, cqspi->clks);
	if (ret) {
		dev_err(dev, "Cannot enable QSPI clocks.\n");
		goto disable_rpm;
		return ret;
	}

	/* Obtain QSPI reset control */
@@ -1962,10 +1958,11 @@ static int cqspi_probe(struct platform_device *pdev)
	cqspi->sclk = 0;

	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
		pm_runtime_enable(dev);
		pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT);
		pm_runtime_use_autosuspend(dev);
		pm_runtime_get_noresume(dev);
		pm_runtime_set_active(dev);
		pm_runtime_enable(dev);
	}

	host->num_chipselect = cqspi->num_chipselect;
@@ -1977,7 +1974,7 @@ static int cqspi_probe(struct platform_device *pdev)
		ret = cqspi_request_mmap_dma(cqspi);
		if (ret == -EPROBE_DEFER) {
			dev_err_probe(&pdev->dev, ret, "Failed to request mmap DMA\n");
			goto disable_controller;
			goto disable_rpm;
		}
	}

@@ -1995,14 +1992,16 @@ static int cqspi_probe(struct platform_device *pdev)
release_dma_chan:
	if (cqspi->rx_chan)
		dma_release_channel(cqspi->rx_chan);
disable_controller:
disable_rpm:
	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
		pm_runtime_disable(dev);
		pm_runtime_set_suspended(dev);
		pm_runtime_put_noidle(dev);
		pm_runtime_dont_use_autosuspend(dev);
	}
	cqspi_controller_enable(cqspi, 0);
disable_clks:
	if (pm_runtime_get_sync(&pdev->dev) >= 0)
	clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
disable_rpm:
	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
		pm_runtime_disable(dev);

	return ret;
}
@@ -2026,18 +2025,19 @@ static void cqspi_remove(struct platform_device *pdev)
	if (cqspi->rx_chan)
		dma_release_channel(cqspi->rx_chan);

	cqspi_controller_enable(cqspi, 0);


	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
		ret = pm_runtime_get_sync(&pdev->dev);

	if (ret >= 0)
	if (ret >= 0) {
		cqspi_controller_enable(cqspi, 0);
		clk_bulk_disable_unprepare(CLK_QSPI_NUM, cqspi->clks);
	}

	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
		pm_runtime_put_sync(&pdev->dev);
		pm_runtime_disable(&pdev->dev);
		pm_runtime_set_suspended(&pdev->dev);
		pm_runtime_put_noidle(&pdev->dev);
		pm_runtime_dont_use_autosuspend(&pdev->dev);
	}
}