History

spi: axiado: spi: axiado: fix runtime pm imbalance on probe failure

Johan Hovold <johan@kernel.org> says: The series fixes some runtime PM related issues in the axiado driver. Included is also a couple of related cleanups.

Mark Brown committed 6 months ago

Commit ad50f7b2 parents 8370f1b 2b20e671 file · +19 −12Browse files

Unified · Split

drivers/spi/spi-axiado.c+19−12
@@ -751,9 +751,9 @@ static const struct spi_controller_mem_ops ax_spi_mem_ops = { · 750 unmodified lines
751751 */
752752 static int ax_spi_probe(struct platform_device *pdev)
753753 {
754− int ret = 0, irq;
755754 struct spi_controller *ctlr;
756755 struct ax_spi *xspi;
756+ int ret, irq;
757757 u32 num_cs;
758758
759759 ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*xspi));
@@ -785,7 +785,7 @@ static int ax_spi_probe(struct platform_device *pdev) · 25 unmodified lines
785785 ret = clk_prepare_enable(xspi->ref_clk);
786786 if (ret) {
787787 dev_err(&pdev->dev, "Unable to enable device clock.\n");
788− goto clk_dis_apb;
788+ goto err_disable_apb;
789789 }
790790
791791 pm_runtime_use_autosuspend(&pdev->dev);
@@ -815,7 +815,7 @@ static int ax_spi_probe(struct platform_device *pdev) · 23 unmodified lines
815815 irq = platform_get_irq(pdev, 0);
816816 if (irq <= 0) {
817817 ret = -ENXIO;
818− goto clk_dis_all;
818+ goto err_disable_rpm;
819819 }
820820
821821 ret = devm_request_irq(&pdev->dev, irq, ax_spi_irq,
@@ -823,7 +823,7 @@ static int ax_spi_probe(struct platform_device *pdev) · 1 unmodified line
823823 if (ret != 0) {
824824 ret = -ENXIO;
825825 dev_err(&pdev->dev, "request_irq failed\n");
826− goto clk_dis_all;
826+ goto err_disable_rpm;
827827 }
828828
829829 ctlr->use_gpio_descriptors = true;
@@ -842,23 +842,26 @@ static int ax_spi_probe(struct platform_device *pdev) · 12 unmodified lines
842842
843843 ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
844844
845− pm_runtime_put_autosuspend(&pdev->dev);
846−
847845 ctlr->mem_ops = &ax_spi_mem_ops;
848846
849847 ret = spi_register_controller(ctlr);
850848 if (ret) {
851849 dev_err(&pdev->dev, "spi_register_controller failed\n");
852− goto clk_dis_all;
850+ goto err_disable_rpm;
853851 }
854852
855− return ret;
853+ pm_runtime_put_autosuspend(&pdev->dev);
856854
857−clk_dis_all:
858− pm_runtime_set_suspended(&pdev->dev);
855+ return 0;
856+
857+err_disable_rpm:
859858 pm_runtime_disable(&pdev->dev);
859+ pm_runtime_put_noidle(&pdev->dev);
860+ pm_runtime_set_suspended(&pdev->dev);
861+ pm_runtime_dont_use_autosuspend(&pdev->dev);
862+
860863 clk_disable_unprepare(xspi->ref_clk);
861−clk_dis_apb:
864+err_disable_apb:
862865 clk_disable_unprepare(xspi->pclk);
863866
864867 return ret;
@@ -877,10 +880,14 @@ static void ax_spi_remove(struct platform_device *pdev) · 12 unmodified lines
877880 struct spi_controller *ctlr = platform_get_drvdata(pdev);
878881 struct ax_spi *xspi = spi_controller_get_devdata(ctlr);
879882
883+ pm_runtime_get_sync(&pdev->dev);
884+
880885 spi_unregister_controller(ctlr);
881886
882− pm_runtime_set_suspended(&pdev->dev);
883887 pm_runtime_disable(&pdev->dev);
888+ pm_runtime_put_noidle(&pdev->dev);
889+ pm_runtime_set_suspended(&pdev->dev);
890+ pm_runtime_dont_use_autosuspend(&pdev->dev);
884891
885892 clk_disable_unprepare(xspi->ref_clk);
886893 clk_disable_unprepare(xspi->pclk);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t