From patchwork Fri Jan 19 15:55:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10175673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7711860392 for ; Fri, 19 Jan 2018 15:56:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59B8B2859F for ; Fri, 19 Jan 2018 15:56:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E074286B5; Fri, 19 Jan 2018 15:56:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E73442859F for ; Fri, 19 Jan 2018 15:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=h6oEsulis6ijBNIuqgXlm6PPd+q4oEYZOiZeNctcTio=; b=QViaz8H2QGZk49tJld8En3K+0f K156SrwR2u5mEBbX3XATJmnQF1lyi3Ua6haZulP+4xLT5pghNvtA/chGc8BUSCfyqYblYbWFOBFkm OfmqtmYT7Gc1+w++7VAsVjXVt0HpagKFhWEBSn/i+woeGVWZyGGvmvZptg31u8HYoYcPzbP1cFNGC 8W2cdXJvvI/8dX3BtoSrnrh7E65OfJ/nCAHav1sSrlXIivRnqGM5KlgbUHWqcv1m+zBSp5/vgxgVx 095LhBHAAkwI7cilZiGIcVKW1A3mFZBLK1BHUHmC8p8vHun16P/fE5yt+XJSdwpwbpi54XUMCWtIR +eLCKLpA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ecZ1E-0005pJ-Mr; Fri, 19 Jan 2018 15:55:52 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ecZ17-0005Uw-3V for linux-amlogic@lists.infradead.org; Fri, 19 Jan 2018 15:55:48 +0000 Received: by mail-wr0-x244.google.com with SMTP id e41so1975317wre.9 for ; Fri, 19 Jan 2018 07:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+CYyxrVVxNH+8Ei+RzyXZs/ZSdycdi/I3Lbu7pw+1BE=; b=qmN4jeNg2RMqC2pSggEZNpo8MF4cqQp0h3wKCX8LuQ2MROFG7PTuJ7afWUyVx0sael M7/5lJqJi4YO0IpHqiA5KUKJ0sB7hwCERu92gyqKJU4HyTLn3kzCp0PYE54/Lcw5K1bk uc/3cpg0qfgC4pucI2DeTIjKMdN98vVxFnTiCnvS3proY0VFtYtw4Q6NPNJW3RCZOnks S/0V71hrVL2WfRzVB0fnRk4b7Pvp7f0RldBlAEEXq1NiPE8MwaQIHtlU4pEmGvgYQPG9 y3vKgFOVpmZd69NGbmyesi0q/bY8/PQQslGKH7NPT0ZgEiZRZTzIPdPb8YnqYWnL0wBT aTRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+CYyxrVVxNH+8Ei+RzyXZs/ZSdycdi/I3Lbu7pw+1BE=; b=KhLjP5sRBL84AtnSj4EZrmyPYs/3ljiV9BbMXKVnHsX9Tf+u3m5MwTsaqW0Nqwhjkc ent8mSdo9rao/qE/Y7blaon3vUYXRSuYbpLY9UlsbCt1nx5HKkgVueiAqhgpwr7bb8d9 42KeNMp1QON1e56okYac3YE8D3QH27Ff7HUZmV+JdejjnJB+J/EnqEkGNKd/9uMHTwZh A2ljeaJwBd1JLJAR+GcQHpgHBZUwPSSmCF2aoxdLJsOzaeamSy6kNtoQCUjG8a13/4qv LODhQw0BszXy/UQteQ22mY2ZtHJ0daX0Gx9js5SrowKqxlfI/OWjrbFJHtQNM0yuNF8T UIdQ== X-Gm-Message-State: AKwxyteD8nfcUD98j4+d9TonHanBb+GYuXgiBQwy9owOqpFUXmw9P5xW Ys1OrqR5n17RfT701Z/qNo9f1g== X-Google-Smtp-Source: ACJfBosGppKeqhUs7bRPtz7lncPhb19WCXhKVmIBFM4eTC4omUfwY5g5J3S0/IANMNwoaE+8/82aqQ== X-Received: by 10.223.134.227 with SMTP id 32mr10601104wry.176.1516377333534; Fri, 19 Jan 2018 07:55:33 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id w73sm25883027wrb.34.2018.01.19.07.55.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jan 2018 07:55:32 -0800 (PST) From: Jerome Brunet To: Neil Armstrong Subject: [PATCH v2 1/9] clk: meson: check pll rate param table before using it Date: Fri, 19 Jan 2018 16:55:21 +0100 Message-Id: <20180119155529.11532-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180119155529.11532-1-jbrunet@baylibre.com> References: <20180119155529.11532-1-jbrunet@baylibre.com> X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Hilman , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, Carlo Caione , linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure the rate param table is available before using it. Some read-only plls don't provide it, which is ok since the table is not used by read-only clocks. R/W clocks are supposed to provide it, but it does not hurt check it. Signed-off-by: Jerome Brunet --- 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];