Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3205892rwl; Sun, 2 Apr 2023 02:44:26 -0700 (PDT) X-Google-Smtp-Source: AKy350aiQP0onAQurn6kHX1OjeJkFr0MFLHC+0JqWMBiUHatX0/RuUSfeFe3LdUBWX2wLtBIKaVM X-Received: by 2002:a17:906:184d:b0:8b1:e791:faef with SMTP id w13-20020a170906184d00b008b1e791faefmr31029455eje.67.1680428666257; Sun, 02 Apr 2023 02:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680428666; cv=none; d=google.com; s=arc-20160816; b=NjoV1/Z1fN+zB7H62yC9xmrWb9+asATYA/JCCQfV+LLbuNEYE3sAgiWT9RYUAXickU JBSiAPkoeK2SmKFWGlQ+XF0Ex8zM4XuhLf1L0F8cNjqf2BQqGJQHcC2CfqPF7RgyR+nv vDju6/qFigYV/4SG+dHd7HyneI6vCchsj+Mgl4OfBEsvsGKTvvnVkbp5sHEpCT4DS39R oD1bdWAFUlIeixP5hsqUHYLV7aEL+Q384iJ7wiyL293bbZHECluGfx80d+1AesBfCszW R++rSjwCB8LPopfaPI2BlVnEjCeWAyNAvVmWv29lFnDPH70Ik++8e0EW0tgY5rXQX8AZ Rw+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QT5yFmgCNPj9GQvMRvz/D/b7eOq3lrYP2uQVDtDaTlE=; b=Lcp6sMZeKVPLdpUAo5RGV6katV6U7Lcrxrui1hRYC2iHrlAInQFw6zxkerdGwnMH3c sRCUjL2ieCuOIgGRU9ao71hzZSumwVuki8R084n+dwS3tznwD+AJ1fb73EShwKV7VxVF ijXov4p9RT1GXKgxc1gkmwlyz3/75b8Ko3XCmz8G7822mwKN/LzXodnFC6vkGgqdFOAR Pl2IeFKiaZGNuUgURc2AHs3uMJbkWStkHkPxhRdJm3/D0gzt/iBTRyuXb2tziiMnrBJQ xrJELZmj6XcVVlOuvtNUWMU38KDrCZxw8KWujs5pI4WD7HvtLnV+uo08nwke/+SiAWeK VzkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot12-20020a170906cccc00b009485b4b4e7csi1004953ejb.856.2023.04.02.02.44.01; Sun, 02 Apr 2023 02:44:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230256AbjDBJm1 (ORCPT + 99 others); Sun, 2 Apr 2023 05:42:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbjDBJm0 (ORCPT ); Sun, 2 Apr 2023 05:42:26 -0400 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FC3A1BF7B for ; Sun, 2 Apr 2023 02:42:24 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id iuDzpwm4hwFKBiuEApeDi6; Sun, 02 Apr 2023 11:42:23 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 02 Apr 2023 11:42:23 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: mturquette@baylibre.com, sboyd@kernel.org, abelvesa@kernel.org, peng.fan@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, heiko@sntech.de Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2 1/4] clk: Compute masks for fractional_divider clk when needed. Date: Sun, 2 Apr 2023 11:42:04 +0200 Message-Id: <0fd6357242c974259c9e034c6e28a0391c480bf0.1680423909.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no real need to pre-compute mmask and nmask when handling fractional_divider clk. They can be computed when needed. Signed-off-by: Christophe JAILLET --- drivers/clk/clk-fractional-divider.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c index 6affe3565025..479297763e70 100644 --- a/drivers/clk/clk-fractional-divider.c +++ b/drivers/clk/clk-fractional-divider.c @@ -71,6 +71,7 @@ static void clk_fd_get_div(struct clk_hw *hw, struct u32_fract *fract) struct clk_fractional_divider *fd = to_clk_fd(hw); unsigned long flags = 0; unsigned long m, n; + u32 mmask, nmask; u32 val; if (fd->lock) @@ -85,8 +86,11 @@ static void clk_fd_get_div(struct clk_hw *hw, struct u32_fract *fract) else __release(fd->lock); - m = (val & fd->mmask) >> fd->mshift; - n = (val & fd->nmask) >> fd->nshift; + mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift; + nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift; + + m = (val & mmask) >> fd->mshift; + n = (val & nmask) >> fd->nshift; if (fd->flags & CLK_FRAC_DIVIDER_ZERO_BASED) { m++; @@ -166,6 +170,7 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate, struct clk_fractional_divider *fd = to_clk_fd(hw); unsigned long flags = 0; unsigned long m, n; + u32 mmask, nmask; u32 val; rational_best_approximation(rate, parent_rate, @@ -182,8 +187,11 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate, else __acquire(fd->lock); + mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift; + nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift; + val = clk_fd_readl(fd); - val &= ~(fd->mmask | fd->nmask); + val &= ~(mmask | nmask); val |= (m << fd->mshift) | (n << fd->nshift); clk_fd_writel(fd, val); @@ -260,10 +268,8 @@ struct clk_hw *clk_hw_register_fractional_divider(struct device *dev, fd->reg = reg; fd->mshift = mshift; fd->mwidth = mwidth; - fd->mmask = GENMASK(mwidth - 1, 0) << mshift; fd->nshift = nshift; fd->nwidth = nwidth; - fd->nmask = GENMASK(nwidth - 1, 0) << nshift; fd->flags = clk_divider_flags; fd->lock = lock; fd->hw.init = &init; -- 2.34.1