From: Mark Brown <broonie@kernel.org>
To: Purushothama Siddaiah <psiddaiah@mvista.com>,
Corey Minyard <cminyard@mvista.com>,
Lars Pedersen <lapeddk@gmail.com>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
Mark Brown <broonie@kernel.org>
Subject: [PATCH] spi: omap2-mcspi: Correctly handle devm_clk_get_optional() errors
Date: Fri, 17 Jan 2025 16:16:03 +0000 [thread overview]
Message-ID: <20250117-spi-fix-omap2-optional-v1-1-e77d4ac6db6e@kernel.org> (raw)
devm_clk_get_optional() returns NULL for missing clocks and a PTR_ERR()
if there is a clock but we fail to get it, but currently we only handle
the latter case and do so as though the clock was missing. If we get an
error back we should handle that as an error since the clock exists but
we failed to get it, if we get NULL then the clock doesn't exist and we
should handle that.
Fixes: 4c6ac5446d06 ("spi: omap2-mcspi: Fix the IS_ERR() bug for devm_clk_get_optional_enabled()")
Reported-by: Lars Pedersen <lapeddk@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
drivers/spi/spi-omap2-mcspi.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index add6247d348190452918900b145c3c5a00e409b3..29c616e2c408cf26b150a853f789128d003db1f0 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1561,10 +1561,15 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
}
mcspi->ref_clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
- if (IS_ERR(mcspi->ref_clk))
- mcspi->ref_clk_hz = OMAP2_MCSPI_MAX_FREQ;
- else
+ if (IS_ERR(mcspi->ref_clk)) {
+ status = PTR_ERR(mcspi->ref_clk);
+ dev_err_probe(&pdev->dev, status, "Failed to get ref_clk");
+ goto free_ctlr;
+ }
+ if (mcspi->ref_clk)
mcspi->ref_clk_hz = clk_get_rate(mcspi->ref_clk);
+ else
+ mcspi->ref_clk_hz = OMAP2_MCSPI_MAX_FREQ;
ctlr->max_speed_hz = mcspi->ref_clk_hz;
ctlr->min_speed_hz = mcspi->ref_clk_hz >> 15;
---
base-commit: 9d89551994a430b50c4fffcb1e617a057fa76e20
change-id: 20250116-spi-fix-omap2-optional-84aa541869e6
Best regards,
--
Mark Brown <broonie@kernel.org>
next reply other threads:[~2025-01-17 16:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-17 16:16 Mark Brown [this message]
2025-01-21 12:00 ` Lars Pedersen
2025-01-21 15:05 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250117-spi-fix-omap2-optional-v1-1-e77d4ac6db6e@kernel.org \
--to=broonie@kernel.org \
--cc=cminyard@mvista.com \
--cc=lapeddk@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=psiddaiah@mvista.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®