From nobody Fri Dec 19 16:59:27 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D536CECAAA1 for ; Mon, 24 Oct 2022 12:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229835AbiJXMBP (ORCPT ); Mon, 24 Oct 2022 08:01:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232482AbiJXL7D (ORCPT ); Mon, 24 Oct 2022 07:59:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8CF87AC2D; Mon, 24 Oct 2022 04:48:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1677E61252; Mon, 24 Oct 2022 11:38:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29F42C433D6; Mon, 24 Oct 2022 11:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611529; bh=YU3dLBhpv5jU/r+f4gU/MZ21d1RTiVhkqAKzdEe6idg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WVIfcYxCuyH/UKukWZzo4dyadvSa5lLxfzwDegwu3CSRj3cYgPd28BZNKCiup6fEv G7HT2xVL+dU4KV9CafPg40xTFLgEnHa1qKschrSOMypG1K6uLyKIu45rAnzIWrdWPj sSFwjs7MBr/Kwu77t1NBOeI3eh71kKgJZVZ/Oi/E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lori Hikichi , Stephen Boyd , Sasha Levin Subject: [PATCH 4.9 014/159] clk: iproc: Minor tidy up of iproc pll data structures Date: Mon, 24 Oct 2022 13:29:28 +0200 Message-Id: <20221024112949.878116041@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Lori Hikichi [ Upstream commit b33db49783763e1b2a63b12fbe0e91fb7147a987 ] There were a few fields in the iproc pll data structures that were holding information that was not true state information. Using stack variables is sufficient and simplifies the structure. There are not any functional changes in this commit. Signed-off-by: Lori Hikichi Signed-off-by: Stephen Boyd Stable-dep-of: 1b24a132eba7 ("clk: iproc: Do not rely on node name for corr= ect PLL setup") Signed-off-by: Sasha Levin --- drivers/clk/bcm/clk-iproc-pll.c | 83 ++++++++++++++------------------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/drivers/clk/bcm/clk-iproc-pll.c b/drivers/clk/bcm/clk-iproc-pl= l.c index e04634c46395..53006f4305f8 100644 --- a/drivers/clk/bcm/clk-iproc-pll.c +++ b/drivers/clk/bcm/clk-iproc-pll.c @@ -69,16 +69,6 @@ enum vco_freq_range { VCO_MAX =3D 4000000000U, }; =20 -struct iproc_pll; - -struct iproc_clk { - struct clk_hw hw; - const char *name; - struct iproc_pll *pll; - unsigned long rate; - const struct iproc_clk_ctrl *ctrl; -}; - struct iproc_pll { void __iomem *status_base; void __iomem *control_base; @@ -88,9 +78,12 @@ struct iproc_pll { const struct iproc_pll_ctrl *ctrl; const struct iproc_pll_vco_param *vco_param; unsigned int num_vco_entries; +}; =20 - struct clk_hw_onecell_data *clk_data; - struct iproc_clk *clks; +struct iproc_clk { + struct clk_hw hw; + struct iproc_pll *pll; + const struct iproc_clk_ctrl *ctrl; }; =20 #define to_iproc_clk(hw) container_of(hw, struct iproc_clk, hw) @@ -263,6 +256,7 @@ static int pll_set_rate(struct iproc_clk *clk, unsigned= int rate_index, u32 val; enum kp_band kp_index; unsigned long ref_freq; + const char *clk_name =3D clk_hw_get_name(&clk->hw); =20 /* * reference frequency =3D parent frequency / PDIV @@ -285,19 +279,19 @@ static int pll_set_rate(struct iproc_clk *clk, unsign= ed int rate_index, kp_index =3D KP_BAND_HIGH_HIGH; } else { pr_err("%s: pll: %s has invalid rate: %lu\n", __func__, - clk->name, rate); + clk_name, rate); return -EINVAL; } =20 kp =3D get_kp(ref_freq, kp_index); if (kp < 0) { - pr_err("%s: pll: %s has invalid kp\n", __func__, clk->name); + pr_err("%s: pll: %s has invalid kp\n", __func__, clk_name); return kp; } =20 ret =3D __pll_enable(pll); if (ret) { - pr_err("%s: pll: %s fails to enable\n", __func__, clk->name); + pr_err("%s: pll: %s fails to enable\n", __func__, clk_name); return ret; } =20 @@ -354,7 +348,7 @@ static int pll_set_rate(struct iproc_clk *clk, unsigned= int rate_index, =20 ret =3D pll_wait_for_lock(pll); if (ret < 0) { - pr_err("%s: pll: %s failed to lock\n", __func__, clk->name); + pr_err("%s: pll: %s failed to lock\n", __func__, clk_name); return ret; } =20 @@ -390,16 +384,15 @@ static unsigned long iproc_pll_recalc_rate(struct clk= _hw *hw, u32 val; u64 ndiv, ndiv_int, ndiv_frac; unsigned int pdiv; + unsigned long rate; =20 if (parent_rate =3D=3D 0) return 0; =20 /* PLL needs to be locked */ val =3D readl(pll->status_base + ctrl->status.offset); - if ((val & (1 << ctrl->status.shift)) =3D=3D 0) { - clk->rate =3D 0; + if ((val & (1 << ctrl->status.shift)) =3D=3D 0) return 0; - } =20 /* * PLL output frequency =3D @@ -421,14 +414,14 @@ static unsigned long iproc_pll_recalc_rate(struct clk= _hw *hw, val =3D readl(pll->control_base + ctrl->pdiv.offset); pdiv =3D (val >> ctrl->pdiv.shift) & bit_mask(ctrl->pdiv.width); =20 - clk->rate =3D (ndiv * parent_rate) >> 20; + rate =3D (ndiv * parent_rate) >> 20; =20 if (pdiv =3D=3D 0) - clk->rate *=3D 2; + rate *=3D 2; else - clk->rate /=3D pdiv; + rate /=3D pdiv; =20 - return clk->rate; + return rate; } =20 static long iproc_pll_round_rate(struct clk_hw *hw, unsigned long rate, @@ -518,6 +511,7 @@ static unsigned long iproc_clk_recalc_rate(struct clk_h= w *hw, struct iproc_pll *pll =3D clk->pll; u32 val; unsigned int mdiv; + unsigned long rate; =20 if (parent_rate =3D=3D 0) return 0; @@ -528,11 +522,11 @@ static unsigned long iproc_clk_recalc_rate(struct clk= _hw *hw, mdiv =3D 256; =20 if (ctrl->flags & IPROC_CLK_MCLK_DIV_BY_2) - clk->rate =3D parent_rate / (mdiv * 2); + rate =3D parent_rate / (mdiv * 2); else - clk->rate =3D parent_rate / mdiv; + rate =3D parent_rate / mdiv; =20 - return clk->rate; + return rate; } =20 static long iproc_clk_round_rate(struct clk_hw *hw, unsigned long rate, @@ -583,10 +577,6 @@ static int iproc_clk_set_rate(struct clk_hw *hw, unsig= ned long rate, val |=3D div << ctrl->mdiv.shift; } iproc_pll_write(pll, pll->control_base, ctrl->mdiv.offset, val); - if (ctrl->flags & IPROC_CLK_MCLK_DIV_BY_2) - clk->rate =3D parent_rate / (div * 2); - else - clk->rate =3D parent_rate / div; =20 return 0; } @@ -629,6 +619,8 @@ void __init iproc_pll_clk_setup(struct device_node *nod= e, struct iproc_clk *iclk; struct clk_init_data init; const char *parent_name; + struct iproc_clk *iclk_array; + struct clk_hw_onecell_data *clk_data; =20 if (WARN_ON(!pll_ctrl) || WARN_ON(!clk_ctrl)) return; @@ -637,14 +629,14 @@ void __init iproc_pll_clk_setup(struct device_node *n= ode, if (WARN_ON(!pll)) return; =20 - pll->clk_data =3D kzalloc(sizeof(*pll->clk_data->hws) * num_clks + - sizeof(*pll->clk_data), GFP_KERNEL); - if (WARN_ON(!pll->clk_data)) + clk_data =3D kzalloc(sizeof(*clk_data->hws) * num_clks + + sizeof(*clk_data), GFP_KERNEL); + if (WARN_ON(!clk_data)) goto err_clk_data; - pll->clk_data->num =3D num_clks; + clk_data->num =3D num_clks; =20 - pll->clks =3D kcalloc(num_clks, sizeof(*pll->clks), GFP_KERNEL); - if (WARN_ON(!pll->clks)) + iclk_array =3D kcalloc(num_clks, sizeof(struct iproc_clk), GFP_KERNEL); + if (WARN_ON(!iclk_array)) goto err_clks; =20 pll->control_base =3D of_iomap(node, 0); @@ -674,9 +666,8 @@ void __init iproc_pll_clk_setup(struct device_node *nod= e, /* initialize and register the PLL itself */ pll->ctrl =3D pll_ctrl; =20 - iclk =3D &pll->clks[0]; + iclk =3D &iclk_array[0]; iclk->pll =3D pll; - iclk->name =3D node->name; =20 init.name =3D node->name; init.ops =3D &iproc_pll_ops; @@ -697,7 +688,7 @@ void __init iproc_pll_clk_setup(struct device_node *nod= e, if (WARN_ON(ret)) goto err_pll_register; =20 - pll->clk_data->hws[0] =3D &iclk->hw; + clk_data->hws[0] =3D &iclk->hw; =20 /* now initialize and register all leaf clocks */ for (i =3D 1; i < num_clks; i++) { @@ -711,8 +702,7 @@ void __init iproc_pll_clk_setup(struct device_node *nod= e, if (WARN_ON(ret)) goto err_clk_register; =20 - iclk =3D &pll->clks[i]; - iclk->name =3D clk_name; + iclk =3D &iclk_array[i]; iclk->pll =3D pll; iclk->ctrl =3D &clk_ctrl[i]; =20 @@ -727,11 +717,10 @@ void __init iproc_pll_clk_setup(struct device_node *n= ode, if (WARN_ON(ret)) goto err_clk_register; =20 - pll->clk_data->hws[i] =3D &iclk->hw; + clk_data->hws[i] =3D &iclk->hw; } =20 - ret =3D of_clk_add_hw_provider(node, of_clk_hw_onecell_get, - pll->clk_data); + ret =3D of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); if (WARN_ON(ret)) goto err_clk_register; =20 @@ -739,7 +728,7 @@ void __init iproc_pll_clk_setup(struct device_node *nod= e, =20 err_clk_register: while (--i >=3D 0) - clk_hw_unregister(pll->clk_data->hws[i]); + clk_hw_unregister(clk_data->hws[i]); =20 err_pll_register: if (pll->status_base !=3D pll->control_base) @@ -756,10 +745,10 @@ void __init iproc_pll_clk_setup(struct device_node *n= ode, iounmap(pll->control_base); =20 err_pll_iomap: - kfree(pll->clks); + kfree(iclk_array); =20 err_clks: - kfree(pll->clk_data); + kfree(clk_data); =20 err_clk_data: kfree(pll); --=20 2.35.1