spi: ti-qspi: revise ti_qspi_probe() failure flow
authorPrahlad V <prahlad.eee@gmail.com>
Thu, 16 Feb 2017 20:33:35 +0000 (02:03 +0530)
committerMark Brown <broonie@kernel.org>
Fri, 17 Feb 2017 11:24:51 +0000 (11:24 +0000)
call spi_master_put() in case of failures after spi_alloc_master().
call pm_runtime_disable() in case of failures after pm_runtime_enable().

Signed-off-by: Prahlad V <prahlad.eee@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-ti-qspi.c

index ec6fb09e2e1711f7adfbe079559a89f1a9cd343d..e784d0f64dc1dc426a3eebe4e2f7ab9964f2a8ed 100644 (file)
@@ -652,7 +652,8 @@ static int ti_qspi_probe(struct platform_device *pdev)
                r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
                if (r == NULL) {
                        dev_err(&pdev->dev, "missing platform data\n");
-                       return -ENODEV;
+                       ret = -ENODEV;
+                       goto free_master;
                }
        }
 
@@ -669,7 +670,8 @@ static int ti_qspi_probe(struct platform_device *pdev)
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
                dev_err(&pdev->dev, "no irq resource?\n");
-               return irq;
+               ret = irq;
+               goto free_master;
        }
 
        mutex_init(&qspi->list_lock);
@@ -685,15 +687,17 @@ static int ti_qspi_probe(struct platform_device *pdev)
                qspi->ctrl_base =
                syscon_regmap_lookup_by_phandle(np,
                                                "syscon-chipselects");
-               if (IS_ERR(qspi->ctrl_base))
-                       return PTR_ERR(qspi->ctrl_base);
+               if (IS_ERR(qspi->ctrl_base)) {
+                       ret = PTR_ERR(qspi->ctrl_base);
+                       goto free_master;
+               }
                ret = of_property_read_u32_index(np,
                                                 "syscon-chipselects",
                                                 1, &qspi->ctrl_reg);
                if (ret) {
                        dev_err(&pdev->dev,
                                "couldn't get ctrl_mod reg index\n");
-                       return ret;
+                       goto free_master;
                }
        }
 
@@ -742,6 +746,7 @@ no_dma:
        if (!ret)
                return 0;
 
+       pm_runtime_disable(&pdev->dev);
 free_master:
        spi_master_put(master);
        return ret;