]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
spi: omap2-mcspi: Fix the IS_ERR() bug for devm_clk_get_optional_enabled()
authorPurushothama Siddaiah <psiddaiah@mvista.com>
Thu, 5 Dec 2024 07:04:26 +0000 (12:34 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Jan 2025 09:34:20 +0000 (10:34 +0100)
[ Upstream commit 4c6ac5446d060f0bf435ccc8bc3aa7b7b5f718ad ]

The devm_clk_get_optional_enabled() function returns error
pointers(PTR_ERR()). So use IS_ERR() to check it.

Verified on K3-J7200 EVM board, without clock node mentioned
in the device tree.

Signed-off-by: Purushothama Siddaiah <psiddaiah@mvista.com>
Reviewed-by: Corey Minyard <cminyard@mvista.com>
Link: https://patch.msgid.link/20241205070426.1861048-1-psiddaiah@mvista.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi-omap2-mcspi.c

index 2c043817c66a88ff556710362a9e596ba54a143d..4a2f84c4d22e5fb6fbf89ad37b34ee70db29651e 100644 (file)
@@ -1561,10 +1561,10 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
        }
 
        mcspi->ref_clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
-       if (mcspi->ref_clk)
-               mcspi->ref_clk_hz = clk_get_rate(mcspi->ref_clk);
-       else
+       if (IS_ERR(mcspi->ref_clk))
                mcspi->ref_clk_hz = OMAP2_MCSPI_MAX_FREQ;
+       else
+               mcspi->ref_clk_hz = clk_get_rate(mcspi->ref_clk);
        ctlr->max_speed_hz = mcspi->ref_clk_hz;
        ctlr->min_speed_hz = mcspi->ref_clk_hz >> 15;