Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi: cadence-qspi: Fix probe error path and remove

The probe has been modified by many different users, it is hard to track
history, but for sure its current state is partially broken. One easy
rule to follow is to drop/free/release the resources in the opposite
order they have been queried.

Fix the labels, the order for freeing the resources, and add the
missing DMA channel step. Replicate these changes in the remove path as
well.

Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Miquel Raynal (Schneider Electric) <miquel.raynal@bootlin.com>
Tested-by: Santhosh Kumar K <s-k6@ti.com>
Link: https://patch.msgid.link/20260122-schneider-6-19-rc1-qspi-v4-8-f9c21419a3e6@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Miquel Raynal (Schneider Electric) and committed by
Mark Brown
f18c8cfa bee08547

+25 -19
+25 -19
drivers/spi/spi-cadence-quadspi.c
··· 1889 1889 ret = clk_prepare_enable(cqspi->clk); 1890 1890 if (ret) { 1891 1891 dev_err(dev, "Cannot enable QSPI clock.\n"); 1892 - goto probe_clk_failed; 1892 + goto disable_rpm; 1893 1893 } 1894 1894 1895 1895 /* Obtain QSPI reset control */ ··· 1897 1897 if (IS_ERR(rstc)) { 1898 1898 ret = PTR_ERR(rstc); 1899 1899 dev_err(dev, "Cannot get QSPI reset.\n"); 1900 - goto probe_reset_failed; 1900 + goto disable_clk; 1901 1901 } 1902 1902 1903 1903 rstc_ocp = devm_reset_control_get_optional_exclusive(dev, "qspi-ocp"); 1904 1904 if (IS_ERR(rstc_ocp)) { 1905 1905 ret = PTR_ERR(rstc_ocp); 1906 1906 dev_err(dev, "Cannot get QSPI OCP reset.\n"); 1907 - goto probe_reset_failed; 1907 + goto disable_clk; 1908 1908 } 1909 1909 1910 1910 if (of_device_is_compatible(pdev->dev.of_node, "starfive,jh7110-qspi")) { ··· 1912 1912 if (IS_ERR(rstc_ref)) { 1913 1913 ret = PTR_ERR(rstc_ref); 1914 1914 dev_err(dev, "Cannot get QSPI REF reset.\n"); 1915 - goto probe_reset_failed; 1915 + goto disable_clk; 1916 1916 } 1917 1917 reset_control_assert(rstc_ref); 1918 1918 reset_control_deassert(rstc_ref); ··· 1954 1954 if (ddata->jh7110_clk_init) { 1955 1955 ret = cqspi_jh7110_clk_init(pdev, cqspi); 1956 1956 if (ret) 1957 - goto probe_reset_failed; 1957 + goto disable_clk; 1958 1958 } 1959 1959 if (ddata->quirks & CQSPI_DISABLE_STIG_MODE) 1960 1960 cqspi->disable_stig_mode = true; ··· 1962 1962 if (ddata->quirks & CQSPI_DMA_SET_MASK) { 1963 1963 ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); 1964 1964 if (ret) 1965 - goto probe_reset_failed; 1965 + goto disable_clks; 1966 1966 } 1967 1967 } 1968 1968 ··· 1973 1973 pdev->name, cqspi); 1974 1974 if (ret) { 1975 1975 dev_err(dev, "Cannot request IRQ.\n"); 1976 - goto probe_reset_failed; 1976 + goto disable_clks; 1977 1977 } 1978 1978 1979 1979 cqspi_wait_idle(cqspi); ··· 2000 2000 ret = cqspi_request_mmap_dma(cqspi); 2001 2001 if (ret == -EPROBE_DEFER) { 2002 2002 dev_err_probe(&pdev->dev, ret, "Failed to request mmap DMA\n"); 2003 - goto probe_setup_failed; 2003 + goto disable_controller; 2004 2004 } 2005 2005 } 2006 2006 2007 2007 ret = spi_register_controller(host); 2008 2008 if (ret) { 2009 2009 dev_err(&pdev->dev, "failed to register SPI ctlr %d\n", ret); 2010 - goto probe_setup_failed; 2010 + goto release_dma_chan; 2011 2011 } 2012 2012 2013 2013 if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) 2014 2014 pm_runtime_put_autosuspend(dev); 2015 2015 2016 2016 return 0; 2017 - probe_setup_failed: 2018 - if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) 2019 - pm_runtime_disable(dev); 2017 + 2018 + release_dma_chan: 2019 + if (cqspi->rx_chan) 2020 + dma_release_channel(cqspi->rx_chan); 2021 + disable_controller: 2020 2022 cqspi_controller_enable(cqspi, 0); 2021 - probe_reset_failed: 2023 + disable_clks: 2022 2024 if (cqspi->is_jh7110) 2023 2025 cqspi_jh7110_disable_clk(pdev, cqspi); 2024 - 2026 + disable_clk: 2025 2027 if (pm_runtime_get_sync(&pdev->dev) >= 0) 2026 2028 clk_disable_unprepare(cqspi->clk); 2027 - probe_clk_failed: 2029 + disable_rpm: 2030 + if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) 2031 + pm_runtime_disable(dev); 2032 + 2028 2033 return ret; 2029 2034 } 2030 2035 ··· 2047 2042 cqspi_wait_idle(cqspi); 2048 2043 2049 2044 spi_unregister_controller(cqspi->host); 2050 - cqspi_controller_enable(cqspi, 0); 2051 2045 2052 2046 if (cqspi->rx_chan) 2053 2047 dma_release_channel(cqspi->rx_chan); 2054 2048 2055 - if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) 2056 - if (pm_runtime_get_sync(&pdev->dev) >= 0) 2057 - clk_disable(cqspi->clk); 2049 + cqspi_controller_enable(cqspi, 0); 2058 2050 2059 2051 if (cqspi->is_jh7110) 2060 2052 cqspi_jh7110_disable_clk(pdev, cqspi); 2053 + 2054 + if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) 2055 + if (pm_runtime_get_sync(&pdev->dev) >= 0) 2056 + clk_disable(cqspi->clk); 2061 2057 2062 2058 if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) { 2063 2059 pm_runtime_put_sync(&pdev->dev);