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
751 */751 */
752static int ax_spi_probe(struct platform_device *pdev)752static int ax_spi_probe(struct platform_device *pdev)
753{753{
754 int ret = 0, irq;
755 struct spi_controller *ctlr;754 struct spi_controller *ctlr;
756 struct ax_spi *xspi;755 struct ax_spi *xspi;
756 int ret, irq;
757 u32 num_cs;757 u32 num_cs;
758 758
759 ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*xspi));759 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
785 ret = clk_prepare_enable(xspi->ref_clk);785 ret = clk_prepare_enable(xspi->ref_clk);
786 if (ret) {786 if (ret) {
787 dev_err(&pdev->dev, "Unable to enable device clock.\n");787 dev_err(&pdev->dev, "Unable to enable device clock.\n");
788 goto clk_dis_apb;788 goto err_disable_apb;
789 }789 }
790 790
791 pm_runtime_use_autosuspend(&pdev->dev);791 pm_runtime_use_autosuspend(&pdev->dev);
@@ -815,7 +815,7 @@ static int ax_spi_probe(struct platform_device *pdev) · 23 unmodified lines
815 irq = platform_get_irq(pdev, 0);815 irq = platform_get_irq(pdev, 0);
816 if (irq <= 0) {816 if (irq <= 0) {
817 ret = -ENXIO;817 ret = -ENXIO;
818 goto clk_dis_all;818 goto err_disable_rpm;
819 }819 }
820 820
821 ret = devm_request_irq(&pdev->dev, irq, ax_spi_irq,821 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
823 if (ret != 0) {823 if (ret != 0) {
824 ret = -ENXIO;824 ret = -ENXIO;
825 dev_err(&pdev->dev, "request_irq failed\n");825 dev_err(&pdev->dev, "request_irq failed\n");
826 goto clk_dis_all;826 goto err_disable_rpm;
827 }827 }
828 828
829 ctlr->use_gpio_descriptors = true;829 ctlr->use_gpio_descriptors = true;
@@ -842,23 +842,26 @@ static int ax_spi_probe(struct platform_device *pdev) · 12 unmodified lines
842 842
843 ctlr->bits_per_word_mask = SPI_BPW_MASK(8);843 ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
844 844
845 pm_runtime_put_autosuspend(&pdev->dev);
846
847 ctlr->mem_ops = &ax_spi_mem_ops;845 ctlr->mem_ops = &ax_spi_mem_ops;
848 846
849 ret = spi_register_controller(ctlr);847 ret = spi_register_controller(ctlr);
850 if (ret) {848 if (ret) {
851 dev_err(&pdev->dev, "spi_register_controller failed\n");849 dev_err(&pdev->dev, "spi_register_controller failed\n");
852 goto clk_dis_all;850 goto err_disable_rpm;
853 }851 }
854 852
855 return ret;853 pm_runtime_put_autosuspend(&pdev->dev);
856 854
857clk_dis_all:855 return 0;
858 pm_runtime_set_suspended(&pdev->dev);856
857err_disable_rpm:
859 pm_runtime_disable(&pdev->dev);858 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
860 clk_disable_unprepare(xspi->ref_clk);863 clk_disable_unprepare(xspi->ref_clk);
861clk_dis_apb:864err_disable_apb:
862 clk_disable_unprepare(xspi->pclk);865 clk_disable_unprepare(xspi->pclk);
863 866
864 return ret;867 return ret;
@@ -877,10 +880,14 @@ static void ax_spi_remove(struct platform_device *pdev) · 12 unmodified lines
877 struct spi_controller *ctlr = platform_get_drvdata(pdev);880 struct spi_controller *ctlr = platform_get_drvdata(pdev);
878 struct ax_spi *xspi = spi_controller_get_devdata(ctlr);881 struct ax_spi *xspi = spi_controller_get_devdata(ctlr);
879 882
883 pm_runtime_get_sync(&pdev->dev);
884
880 spi_unregister_controller(ctlr);885 spi_unregister_controller(ctlr);
881 886
882 pm_runtime_set_suspended(&pdev->dev);
883 pm_runtime_disable(&pdev->dev);887 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);
884 891
885 clk_disable_unprepare(xspi->ref_clk);892 clk_disable_unprepare(xspi->ref_clk);
886 clk_disable_unprepare(xspi->pclk);893 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