@@ -1889,30 +1889,30 @@ static int cqspi_probe(struct platform_device *pdev)
18891889 ret = clk_prepare_enable (cqspi -> clk );
18901890 if (ret ) {
18911891 dev_err (dev , "Cannot enable QSPI clock.\n" );
1892- goto probe_clk_failed ;
1892+ goto disable_rpm ;
18931893 }
18941894
18951895 /* Obtain QSPI reset control */
18961896 rstc = devm_reset_control_get_optional_exclusive (dev , "qspi" );
18971897 if (IS_ERR (rstc )) {
18981898 ret = PTR_ERR (rstc );
18991899 dev_err (dev , "Cannot get QSPI reset.\n" );
1900- goto probe_reset_failed ;
1900+ goto disable_clk ;
19011901 }
19021902
19031903 rstc_ocp = devm_reset_control_get_optional_exclusive (dev , "qspi-ocp" );
19041904 if (IS_ERR (rstc_ocp )) {
19051905 ret = PTR_ERR (rstc_ocp );
19061906 dev_err (dev , "Cannot get QSPI OCP reset.\n" );
1907- goto probe_reset_failed ;
1907+ goto disable_clk ;
19081908 }
19091909
19101910 if (of_device_is_compatible (pdev -> dev .of_node , "starfive,jh7110-qspi" )) {
19111911 rstc_ref = devm_reset_control_get_optional_exclusive (dev , "rstc_ref" );
19121912 if (IS_ERR (rstc_ref )) {
19131913 ret = PTR_ERR (rstc_ref );
19141914 dev_err (dev , "Cannot get QSPI REF reset.\n" );
1915- goto probe_reset_failed ;
1915+ goto disable_clk ;
19161916 }
19171917 reset_control_assert (rstc_ref );
19181918 reset_control_deassert (rstc_ref );
@@ -1954,15 +1954,15 @@ static int cqspi_probe(struct platform_device *pdev)
19541954 if (ddata -> jh7110_clk_init ) {
19551955 ret = cqspi_jh7110_clk_init (pdev , cqspi );
19561956 if (ret )
1957- goto probe_reset_failed ;
1957+ goto disable_clk ;
19581958 }
19591959 if (ddata -> quirks & CQSPI_DISABLE_STIG_MODE )
19601960 cqspi -> disable_stig_mode = true;
19611961
19621962 if (ddata -> quirks & CQSPI_DMA_SET_MASK ) {
19631963 ret = dma_set_mask (& pdev -> dev , DMA_BIT_MASK (64 ));
19641964 if (ret )
1965- goto probe_reset_failed ;
1965+ goto disable_clks ;
19661966 }
19671967 }
19681968
@@ -1973,7 +1973,7 @@ static int cqspi_probe(struct platform_device *pdev)
19731973 pdev -> name , cqspi );
19741974 if (ret ) {
19751975 dev_err (dev , "Cannot request IRQ.\n" );
1976- goto probe_reset_failed ;
1976+ goto disable_clks ;
19771977 }
19781978
19791979 cqspi_wait_idle (cqspi );
@@ -2000,31 +2000,36 @@ static int cqspi_probe(struct platform_device *pdev)
20002000 ret = cqspi_request_mmap_dma (cqspi );
20012001 if (ret == - EPROBE_DEFER ) {
20022002 dev_err_probe (& pdev -> dev , ret , "Failed to request mmap DMA\n" );
2003- goto probe_setup_failed ;
2003+ goto disable_controller ;
20042004 }
20052005 }
20062006
20072007 ret = spi_register_controller (host );
20082008 if (ret ) {
20092009 dev_err (& pdev -> dev , "failed to register SPI ctlr %d\n" , ret );
2010- goto probe_setup_failed ;
2010+ goto release_dma_chan ;
20112011 }
20122012
20132013 if (!(ddata && (ddata -> quirks & CQSPI_DISABLE_RUNTIME_PM )))
20142014 pm_runtime_put_autosuspend (dev );
20152015
20162016 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 :
20202022 cqspi_controller_enable (cqspi , 0 );
2021- probe_reset_failed :
2023+ disable_clks :
20222024 if (cqspi -> is_jh7110 )
20232025 cqspi_jh7110_disable_clk (pdev , cqspi );
2024-
2026+ disable_clk :
20252027 if (pm_runtime_get_sync (& pdev -> dev ) >= 0 )
20262028 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+
20282033 return ret ;
20292034}
20302035
@@ -2042,18 +2047,19 @@ static void cqspi_remove(struct platform_device *pdev)
20422047 cqspi_wait_idle (cqspi );
20432048
20442049 spi_unregister_controller (cqspi -> host );
2045- cqspi_controller_enable (cqspi , 0 );
20462050
20472051 if (cqspi -> rx_chan )
20482052 dma_release_channel (cqspi -> rx_chan );
20492053
2050- if (!(ddata && (ddata -> quirks & CQSPI_DISABLE_RUNTIME_PM )))
2051- if (pm_runtime_get_sync (& pdev -> dev ) >= 0 )
2052- clk_disable (cqspi -> clk );
2054+ cqspi_controller_enable (cqspi , 0 );
20532055
20542056 if (cqspi -> is_jh7110 )
20552057 cqspi_jh7110_disable_clk (pdev , cqspi );
20562058
2059+ if (!(ddata && (ddata -> quirks & CQSPI_DISABLE_RUNTIME_PM )))
2060+ if (pm_runtime_get_sync (& pdev -> dev ) >= 0 )
2061+ clk_disable (cqspi -> clk );
2062+
20572063 if (!(ddata && (ddata -> quirks & CQSPI_DISABLE_RUNTIME_PM ))) {
20582064 pm_runtime_put_sync (& pdev -> dev );
20592065 pm_runtime_disable (& pdev -> dev );
0 commit comments