OSDN Git Service

spi: spi-fsl-lpspi: Fix runtime PM imbalance on error
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Sat, 23 May 2020 13:38:59 +0000 (21:38 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 26 May 2020 16:44:55 +0000 (17:44 +0100)
pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Link: https://lore.kernel.org/r/20200523133859.5625-1-dinghao.liu@zju.edu.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-fsl-lpspi.c

index 511211b..1552b28 100644 (file)
@@ -940,7 +940,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
        ret = pm_runtime_get_sync(fsl_lpspi->dev);
        if (ret < 0) {
                dev_err(fsl_lpspi->dev, "failed to enable clock\n");
-               goto out_controller_put;
+               goto out_pm_get;
        }
 
        temp = readl(fsl_lpspi->base + IMX7ULP_PARAM);
@@ -949,13 +949,15 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
 
        ret = fsl_lpspi_dma_init(&pdev->dev, fsl_lpspi, controller);
        if (ret == -EPROBE_DEFER)
-               goto out_controller_put;
+               goto out_pm_get;
 
        if (ret < 0)
                dev_err(&pdev->dev, "dma setup error %d, use pio\n", ret);
 
        return 0;
 
+out_pm_get:
+       pm_runtime_put_noidle(fsl_lpspi->dev);
 out_controller_put:
        spi_controller_put(controller);