Skip to content

Commit 8c0f9cd

Browse files
committed
spi: cadence: Probe and unbind fixes
Several fixes from Johan for issues with unbind and error handling in probe.
2 parents 4f12ee0 + ecea4f0 commit 8c0f9cd

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

drivers/spi/spi-cadence.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ static int cdns_spi_probe(struct platform_device *pdev)
741741
/* Set to default valid value */
742742
ctlr->max_speed_hz = xspi->clk_rate / 4;
743743
xspi->speed_hz = ctlr->max_speed_hz;
744-
pm_runtime_put_autosuspend(&pdev->dev);
745744
} else {
746745
ctlr->mode_bits |= SPI_NO_CS;
747746
ctlr->target_abort = cdns_target_abort;
@@ -752,12 +751,17 @@ static int cdns_spi_probe(struct platform_device *pdev)
752751
goto clk_dis_all;
753752
}
754753

754+
if (!spi_controller_is_target(ctlr))
755+
pm_runtime_put_autosuspend(&pdev->dev);
756+
755757
return ret;
756758

757759
clk_dis_all:
758760
if (!spi_controller_is_target(ctlr)) {
759761
pm_runtime_disable(&pdev->dev);
760762
pm_runtime_set_suspended(&pdev->dev);
763+
pm_runtime_put_noidle(&pdev->dev);
764+
pm_runtime_dont_use_autosuspend(&pdev->dev);
761765
}
762766
remove_ctlr:
763767
spi_controller_put(ctlr);
@@ -776,16 +780,23 @@ static void cdns_spi_remove(struct platform_device *pdev)
776780
{
777781
struct spi_controller *ctlr = platform_get_drvdata(pdev);
778782
struct cdns_spi *xspi = spi_controller_get_devdata(ctlr);
783+
int ret = 0;
784+
785+
if (!spi_controller_is_target(ctlr))
786+
ret = pm_runtime_get_sync(&pdev->dev);
779787

780788
spi_controller_get(ctlr);
781789

782790
spi_unregister_controller(ctlr);
783791

784-
cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE);
792+
if (ret >= 0)
793+
cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE);
785794

786795
if (!spi_controller_is_target(ctlr)) {
787796
pm_runtime_disable(&pdev->dev);
788797
pm_runtime_set_suspended(&pdev->dev);
798+
pm_runtime_put_noidle(&pdev->dev);
799+
pm_runtime_dont_use_autosuspend(&pdev->dev);
789800
}
790801

791802
spi_controller_put(ctlr);

0 commit comments

Comments
 (0)