mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
From: jbrunet@baylibre.com (Jerome Brunet)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH 1/9] clk: meson: check pll rate param table before using it
Date: Thu, 18 Jan 2018 19:45:24 +0100	[thread overview]
Message-ID: <20180118184532.6856-2-jbrunet@baylibre.com> (raw)
In-Reply-To: <20180118184532.6856-1-jbrunet@baylibre.com>

Make sure the rate param table is available before using it.
Some read-only pll don't provide it, which is ok because the
table is not used by read-only clock. R/W clock are supposed
to provide it, but it does not hurt check it.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 drivers/clk/meson/clk-pll.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
index 01341553f50b..2614341fc4ad 100644
--- a/drivers/clk/meson/clk-pll.c
+++ b/drivers/clk/meson/clk-pll.c
@@ -94,6 +94,13 @@ static long meson_clk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
 	const struct pll_rate_table *rate_table = pll->rate_table;
 	int i;
 
+	/*
+	 * if the table is missing, just return the current rate
+	 * since we don't have the other available frequencies
+	 */
+	if (!rate_table)
+		return meson_clk_pll_recalc_rate(hw, *parent_rate);
+
 	for (i = 0; i < pll->rate_count; i++) {
 		if (rate <= rate_table[i].rate)
 			return rate_table[i].rate;
@@ -109,6 +116,9 @@ static const struct pll_rate_table *meson_clk_get_pll_settings(struct meson_clk_
 	const struct pll_rate_table *rate_table = pll->rate_table;
 	int i;
 
+	if (!rate_table)
+		return NULL;
+
 	for (i = 0; i < pll->rate_count; i++) {
 		if (rate == rate_table[i].rate)
 			return &rate_table[i];
-- 
2.14.3

  reply	other threads:[~2018-01-18 18:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-18 18:45 [PATCH 0/9] clk: meson: pll fixes Jerome Brunet
2018-01-18 18:45 ` Jerome Brunet [this message]
2018-01-18 18:45 ` [PATCH 2/9] clk: meson: remove useless pll rate param tables Jerome Brunet
2018-01-18 18:45 ` [PATCH 3/9] clk: meson: remove unnecessary rounding in the pll clock Jerome Brunet
2018-01-19  2:06   ` Yixun Lan
2018-01-18 18:45 ` [PATCH 4/9] clk: meson: use frac parameter width instead of a constant Jerome Brunet
2018-01-18 18:45 ` [PATCH 5/9] clk: meson: add od3 to the pll driver Jerome Brunet
2018-01-18 18:45 ` [PATCH 6/9] clk: meson: add gxl hdmi pll Jerome Brunet
2018-01-18 18:45 ` [PATCH 7/9] clk: meson: fix pll with fractional part calculation Jerome Brunet
2018-01-18 18:45 ` [PATCH 8/9] clk: meson: gxbb: add the fractional part of the fixed_pll Jerome Brunet
2018-01-18 18:45 ` [PATCH 9/9] clk: meson: axg: " Jerome Brunet

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=20180118184532.6856-2-jbrunet@baylibre.com \
    --to=jbrunet@baylibre.com \
    --cc=linus-amlogic@lists.infradead.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

all inboxes | Powered by JetHome®