LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Stefan Potyra <Stefan.Potyra@elektrobit.com>
To: Mark Brown <broonie@kernel.org>
Cc: Florian Fainelli <florian.fainelli@broadcom.com>,
Florian Fainelli <f.fainelli@gmail.com>,
<bcm-kernel-feedback-list@broadcom.com>,
<linux-spi@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
Jonas Gorski <jonas.gorski@gmail.com>,
<ldv-project@linuxtesting.org>, <sil2review@lists.osadl.org>
Subject: [PATCH v4] spi/bcm63xx-hspi: Enable the clock before calling clk_get_rate().
Date: Wed, 25 Apr 2018 18:49:06 +0200 [thread overview]
Message-ID: <20180425164904.GA30349@er01809n.ebgroup.elektrobit.com> (raw)
In-Reply-To: <20180425155028.GF24769@sirena.org.uk>
[-- Attachment #1: Type: text/plain, Size: 1502 bytes --]
Enable the clock prior to calling clk_get_rate(), because clk_get_rate()
should only be called if the clock is enabled.
Additionally, prepare/enable the pll_clk before calling clk_get_rate()
for the same reason.
Found by Linux Driver Verification project (linuxtesting.org).
Fixes: 142168eba9dc ("spi: bcm63xx-hsspi: add bcm63xx HSSPI driver")
Signed-off-by: Stefan Potyra <Stefan.Potyra@elektrobit.com>
---
drivers/spi/spi-bcm63xx-hsspi.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hsspi.c
index cbcba614b253..8475703543e5 100644
--- a/drivers/spi/spi-bcm63xx-hsspi.c
+++ b/drivers/spi/spi-bcm63xx-hsspi.c
@@ -352,22 +352,27 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
if (IS_ERR(clk))
return PTR_ERR(clk);
+ ret = clk_prepare_enable(clk);
+ if (ret)
+ return ret;
+
rate = clk_get_rate(clk);
if (!rate) {
struct clk *pll_clk = devm_clk_get(dev, "pll");
- if (IS_ERR(pll_clk))
- return PTR_ERR(pll_clk);
+ if (IS_ERR(pll_clk)) {
+ ret = PTR_ERR(pll_clk);
+ goto out_disable_clk;
+ }
+
rate = clk_get_rate(pll_clk);
- if (!rate)
- return -EINVAL;
+ if (!rate) {
+ ret = -EINVAL;
+ goto out_disable_clk;
+ }
}
- ret = clk_prepare_enable(clk);
- if (ret)
- return ret;
-
master = spi_alloc_master(&pdev->dev, sizeof(*bs));
if (!master) {
ret = -ENOMEM;
--
2.17.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-04-25 16:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-19 13:03 [PATCH] " Stefan Potyra
2018-04-21 23:10 ` Florian Fainelli
2018-04-24 16:16 ` [PATCH v2] spi/bcm63xx-hspi: " Stefan Potyra
2018-04-24 17:32 ` Mark Brown
2018-04-25 13:47 ` [PATCH v3] spi/bcm63xx-hspi: Enable the clock before calling Stefan Potyra
2018-04-25 15:50 ` Mark Brown
2018-04-25 16:49 ` Stefan Potyra [this message]
2018-04-25 17:28 ` [PATCH v4] spi/bcm63xx-hspi: Enable the clock before calling clk_get_rate() Mark Brown
2018-04-26 7:28 ` [PATCH v5] " Stefan Potyra
2018-04-26 11:53 ` Applied "spi/bcm63xx-hspi: Enable the clock before calling clk_get_rate()." to the spi tree 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=20180425164904.GA30349@er01809n.ebgroup.elektrobit.com \
--to=stefan.potyra@elektrobit.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=broonie@kernel.org \
--cc=f.fainelli@gmail.com \
--cc=florian.fainelli@broadcom.com \
--cc=jonas.gorski@gmail.com \
--cc=ldv-project@linuxtesting.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=sil2review@lists.osadl.org \
--subject='Re: [PATCH v4] spi/bcm63xx-hspi: Enable the clock before calling clk_get_rate().' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).