From patchwork Thu Jan 18 18:45:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10173881 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 6011C601E7 for ; Thu, 18 Jan 2018 18:46:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F96128437 for ; Thu, 18 Jan 2018 18:46:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 432BB2844E; Thu, 18 Jan 2018 18:46: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 94D1F28449 for ; Thu, 18 Jan 2018 18:46: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=ASXyWYpIDIkTjQd3+YkiDdToNL1uU/bu1uc6kYB7keA=; b=PpGz4EbcgrGob7vwzJ1AvhbkOl DzVs4x5k0Zr7bynneL9jikWMlmmX5on8DrMuUogBfRcOT8Y4kWS3HI0ydyUcUHPtc7GH3KvsFTL2M maxBR1qas5pGzEM78ol80mu0yBHA21VkCuCI4C6L6sBq0L+7XrCUa7oY9MvFEblfa/zT8xAImN5xD DRLS/bzF2g1YXEwfE8gQHeoQO9xllpGJ36o614vPhA+SKXQDA8qE2N0CFMrFkbIqWCiWmxYp/Fh0E RrENxJg4ERKHEqh3zA9aXiZxeK4bd9/nvTReXmc9x4LtEN5iplYs6EFhIoOky+zlUpgJaLVCotE2G Hv5yfRyA==; 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 1ecFCG-0003ff-96; Thu, 18 Jan 2018 18:45:56 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ecFC8-0003at-Ay for linux-amlogic@lists.infradead.org; Thu, 18 Jan 2018 18:45:51 +0000 Received: by mail-wr0-x241.google.com with SMTP id 100so23615519wrb.7 for ; Thu, 18 Jan 2018 10:45:37 -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=RItXkslxKZcjuxPXqK8QX2m70p44JFKu6G7KWp9RBIE=; b=lIzXOeAxpVl/CRATU+8FpCYZllldGrKvj1oVWNsiFvxVa/5r1Olo8aCydD/9fz40Ex UdwzhnOzqQru3WfZdZS0OuVgnRB7HiBs4nONXPiZ4Zvu1ITf+h1iggyVyWFma1WP/njB Q0v9/zN5RpBzvWlp/ljXV9bxQ9XQ9uuAvHYPGd99EDLRAVY3PtlWrZKoEYAWfh2eGVG6 oa7/+LjyNenSV8pbk6QtwoxExtNNxL7vug5d5UsG7zxVxOmUr8Kd+zZEmQ/Ksv/QKR2k gr2dCzf++PkJgxCOfsgx5lHkA5tYZRa3ifXEDJk/VTbTig44GvE5pJf0dq17Ta6Yqvj1 3pfg== 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=RItXkslxKZcjuxPXqK8QX2m70p44JFKu6G7KWp9RBIE=; b=bVyAhL9cFwUoQvx4BcRDfH/+1hbMpUX6tOWYene2BCNOQhBq1LguJlnLrCnDiJ6htM FtKh15UEbVSNHvp9IYfKTrNv7jzR3zhJcQMgBdsxt8aYcosdRVcghP25Nqe6VIyW7dNM Og5rIrJBKp5JT4j3r2DmdAJK6WX8VILsD3SUk8wGVvZKevSFWUfPLc6UHrGSxHOvPX/U enhZII4RK3l3r0iTIG/TqVU2sNOMhuXQ3XmZAyduetdF6cstOBz+5yzygXAWjHVA9yLe v9XCO606lAuHk3YBLopQpIj5w7+mS9QnudTKeuOv+iWrWhu1BbzgZKBHswiYk/Ddf+h4 tq1Q== X-Gm-Message-State: AKwxyteXjLhs8mO1i4pFvHkPh6gF/85LRrhPXOlrPuTd1qW/TwPG3Uvp JYQrzEOv/4GggwEAeYRHscC/oA== X-Google-Smtp-Source: ACJfBosF5GmYQb00m/DE1ffDkQbha1Xj6eRPfTvNS4+4WPJZXH9ykmzPgud55Gze29WwzWt3/Y4A2w== X-Received: by 10.223.158.131 with SMTP id a3mr7496997wrf.83.1516301136235; Thu, 18 Jan 2018 10:45:36 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id y62sm6240236wrb.48.2018.01.18.10.45.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jan 2018 10:45:35 -0800 (PST) From: Jerome Brunet To: Neil Armstrong Subject: [PATCH 1/9] clk: meson: check pll rate param table before using it Date: Thu, 18 Jan 2018 19:45:24 +0100 Message-Id: <20180118184532.6856-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180118184532.6856-1-jbrunet@baylibre.com> References: <20180118184532.6856-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 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 --- 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];