public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Dinh Nguyen <dinguyen@kernel.org>
To: linux-clk@vger.kernel.org
Cc: dinguyen@kernel.org, sboyd@kernel.org, mturquette@baylibre.com,
	stable@vger.kernel.org
Subject: [PATCHv3 4/4] clk: agilex/stratix10/n5x: fix how the bypass_reg is handled
Date: Thu, 10 Jun 2021 21:52:01 -0500	[thread overview]
Message-ID: <20210611025201.118799-4-dinguyen@kernel.org> (raw)
In-Reply-To: <20210611025201.118799-1-dinguyen@kernel.org>

If the bypass_reg is set, then we can return the bypass parent, however,
if there is not a bypass_reg, we need to figure what the correct parent
mux is.

The previous code never handled the parent mux if there was a
bypass_reg.

Fixes: 80c6b7a0894f ("clk: socfpga: agilex: add clock driver for the Agilex platform")
Cc: stable@vger.kernel.org
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
---
v3: fix smatch warning by initializing parent to 0
v2: add linux-stable to cc
---
 drivers/clk/socfpga/clk-periph-s10.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/socfpga/clk-periph-s10.c b/drivers/clk/socfpga/clk-periph-s10.c
index e5a5fef76df7..cbabde2b476b 100644
--- a/drivers/clk/socfpga/clk-periph-s10.c
+++ b/drivers/clk/socfpga/clk-periph-s10.c
@@ -64,16 +64,21 @@ static u8 clk_periclk_get_parent(struct clk_hw *hwclk)
 {
 	struct socfpga_periph_clk *socfpgaclk = to_periph_clk(hwclk);
 	u32 clk_src, mask;
-	u8 parent;
+	u8 parent = 0;
 
+	/* handle the bypass first */
 	if (socfpgaclk->bypass_reg) {
 		mask = (0x1 << socfpgaclk->bypass_shift);
 		parent = ((readl(socfpgaclk->bypass_reg) & mask) >>
 			   socfpgaclk->bypass_shift);
-	} else {
+		if (parent)
+			return parent;
+	}
+
+	if (socfpgaclk->hw.reg) {
 		clk_src = readl(socfpgaclk->hw.reg);
 		parent = (clk_src >> CLK_MGR_FREE_SHIFT) &
-			CLK_MGR_FREE_MASK;
+			  CLK_MGR_FREE_MASK;
 	}
 	return parent;
 }
-- 
2.25.1


  parent reply	other threads:[~2021-06-11  2:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-11  2:51 [PATCHv3 1/4] clk: agilex/stratix10: remove noc_clk Dinh Nguyen
2021-06-11  2:51 ` [PATCHv3 2/4] clk: agilex/stratix10: fix bypass representation Dinh Nguyen
2021-06-27 23:41   ` Stephen Boyd
2021-06-11  2:52 ` [PATCHv3 3/4] clk: agilex/stratix10: add support for the 2nd bypass Dinh Nguyen
2021-06-27 23:41   ` Stephen Boyd
2021-06-11  2:52 ` Dinh Nguyen [this message]
2021-06-27 23:41   ` [PATCHv3 4/4] clk: agilex/stratix10/n5x: fix how the bypass_reg is handled Stephen Boyd
2021-06-24 15:45 ` [PATCHv3 1/4] clk: agilex/stratix10: remove noc_clk Dinh Nguyen
2021-06-27 23:41 ` Stephen Boyd

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=20210611025201.118799-4-dinguyen@kernel.org \
    --to=dinguyen@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    --cc=stable@vger.kernel.org \
    /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