From patchwork Mon Jan 3 14:37:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 12702563 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12E90C433EF for ; Mon, 3 Jan 2022 14:39:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=LYuADEK5YPrVdMBvL/E/DWycEqPglF1wSPtGViiEZm4=; b=vPZ7k9agxZ7koC ySmnzs1jA8bMc2cKlvV91V1I9GD07JS3yxkcqi7OoTowCHq+Be+WFM7zt0CSgYPCKsMJWnhhLJwH1 JShYUQ8QQShLTi7yCvrEHGROQ3F5WvvD+wM/v5C74xVwcUDkz6PnWFBX632UtrMVun40LbbqpVf7r C/2PilpMV0JeuTfdY1Wz0U9HhMkuIB3/vwuguXJrAb1hfDbQnQcDXqrUM+t0Jrt4J//XcuxwV8p9G zSdlktIr+J+OjTFgG1YQGbZClujTx7Li8khP0ZK8G7Qgy5TNN2ZS/Qhf3PuhxOAg5XbXEOj7Y+9R5 UJbkQsDvkvgk8wsRV46Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4OSm-009Ct5-Dw; Mon, 03 Jan 2022 14:37:28 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4OSi-009Cru-0k; Mon, 03 Jan 2022 14:37:25 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id F2CF71F41FC7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1641220641; bh=qSvITlSu/EuyG+NjQRmV2sMPNmQCjRo2UzY7HOf2Nho=; h=From:To:Cc:Subject:Date:From; b=f/uhrvzMZjOrwsczlBf18PrfUJE/YL1OYGyZTyvSisSGMvRgJDPZJ+jnilDvi+vGG b59GQfaZ6JKukfLnVudHm0Vw27rDee2Jy4JzP7ywCDXovQNUkkVTJBccjBiHAp+DEE CaziJL8QXJcnqKd+au8Dx9HklGAe5rS6d82IQWjoSU3xcIiD0yhHSVts6vpvmBsoFi GZMtEsK7f6qisXmc+cyBwhJE6LVTJiHH54tDYNObW2o7w3L6XidoufnrP27X4KSRpc Q/c3OuxBOJmSYNZu91PYCI2/7OGaWfh1cUgWt3Y+kk3l7p9crtBvruF7UwtXiX8ywZ pH34lc3lUc7oQ== From: AngeloGioacchino Del Regno To: mturquette@baylibre.com Cc: sboyd@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, miles.chen@mediatek.com, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com Subject: [PATCH 1/2] clk: mediatek: clk-gate: Shrink by adding clockgating bit check helper Date: Mon, 3 Jan 2022 15:37:11 +0100 Message-Id: <20220103143712.46675-1-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220103_063724_264254_AF44A81A X-CRM114-Status: UNSURE ( 9.09 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a clockgating bit check helper and use it in functions mtk_cg_bit_is_cleared(), mtk_cg_bit_is_set() to shrink the file size. Signed-off-by: AngeloGioacchino Del Regno --- drivers/clk/mediatek/clk-gate.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gate.c index b02d2f74dd0d..957fa1d68f07 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -16,28 +16,24 @@ #include "clk-mtk.h" #include "clk-gate.h" -static int mtk_cg_bit_is_cleared(struct clk_hw *hw) +static u32 mtk_get_clockgating(struct clk_hw *hw) { struct mtk_clk_gate *cg = to_mtk_clk_gate(hw); u32 val; regmap_read(cg->regmap, cg->sta_ofs, &val); - val &= BIT(cg->bit); + return val & BIT(cg->bit); +} - return val == 0; +static int mtk_cg_bit_is_cleared(struct clk_hw *hw) +{ + return mtk_get_clockgating(hw) == 0; } static int mtk_cg_bit_is_set(struct clk_hw *hw) { - struct mtk_clk_gate *cg = to_mtk_clk_gate(hw); - u32 val; - - regmap_read(cg->regmap, cg->sta_ofs, &val); - - val &= BIT(cg->bit); - - return val != 0; + return mtk_get_clockgating(hw) != 0; } static void mtk_cg_set_bit(struct clk_hw *hw) From patchwork Mon Jan 3 14:37:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 12702562 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E4FAC4332F for ; Mon, 3 Jan 2022 14:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f9CTVPkfYzLXHr5FkP+9jEEaMJ4gonAUhrFl3KBtBU4=; b=ETbZVUlS+1SAe4 yeyv2HsDqrwlj0qySqCka5fl9yxwjzHoKODLNHMDEQ+zZGf0yjCX2Cg8vOJpQfpW+ZDM14hVdCRpz obpvu8NzfbOgtuEuhf2eNk5kmELSzKPShaWXlFkFTB53H8uJstkUXqAuCcgOvActRDhJyHILSHAss QZGGBO2wdFsba/W1ih1bPi60TVoN10iLty0t1My2cCZ5toOchx/AjeZDhBaRnPAjd0uGY3e01ZqvL ZVzKKUSnMVbvbAztOXImsqt6IHwm9iPlLs/Emzh60TMdoBxb3E18CYR2x7mr9yIpcIdTufGyUmZTQ WpNaw409A3AQ8r7o+N9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4OSv-009CuE-89; Mon, 03 Jan 2022 14:37:37 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4OSi-009Cry-0k; Mon, 03 Jan 2022 14:37:25 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: kholk11) with ESMTPSA id 947C31F424E2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1641220642; bh=QIrc2bb8Mrasiom9iIiy7g+f0RYvDaspbjMj2QcgCbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fDXnfUhNavlAFHDED0sqUIs8UUE3luAUemyeH9Z3+Qt4JASAwIr8giPgfx+fZbeOp JyG2wHkUolD88qUv8kbRdFx7evoxtIJFtGYcmhHOr2wqAB1brS0ESiDUVZl6kDg4MB Flxk/dbcOX0sLIq2Gz03y44y4Bd35JvvKd+jan7ldXalJMA+/ydxrWmnAfBuPXk0sP C4Q0DCunCHhmxFaxulbwB3xxEgDYf8smUwzauFzaNemcluEPjb7PD1Fd5JM1MGulKy JxduP95Z4Y8+3FKA8cXoYFewbAsBcHJuuguHRNP8LfhHH1cX+NK3jhlnBEezQAc0Pi i++DXtBaXm9Aw== From: AngeloGioacchino Del Regno To: mturquette@baylibre.com Cc: sboyd@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, miles.chen@mediatek.com, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com Subject: [PATCH 2/2] clk: mediatek: clk-gate: Use regmap_{set/clear}_bits helpers Date: Mon, 3 Jan 2022 15:37:12 +0100 Message-Id: <20220103143712.46675-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220103143712.46675-1-angelogioacchino.delregno@collabora.com> References: <20220103143712.46675-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220103_063724_264489_8A1514FF X-CRM114-Status: UNSURE ( 8.26 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Appropriately change calls to regmap_update_bits() with regmap_set_bits() and regmap_clear_bits() for improved readability. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-gate.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gate.c index 957fa1d68f07..5d88b428565b 100644 --- a/drivers/clk/mediatek/clk-gate.c +++ b/drivers/clk/mediatek/clk-gate.c @@ -53,17 +53,15 @@ static void mtk_cg_clr_bit(struct clk_hw *hw) static void mtk_cg_set_bit_no_setclr(struct clk_hw *hw) { struct mtk_clk_gate *cg = to_mtk_clk_gate(hw); - u32 cgbit = BIT(cg->bit); - regmap_update_bits(cg->regmap, cg->sta_ofs, cgbit, cgbit); + regmap_set_bits(cg->regmap, cg->sta_ofs, BIT(cg->bit)); } static void mtk_cg_clr_bit_no_setclr(struct clk_hw *hw) { struct mtk_clk_gate *cg = to_mtk_clk_gate(hw); - u32 cgbit = BIT(cg->bit); - regmap_update_bits(cg->regmap, cg->sta_ofs, cgbit, 0); + regmap_clear_bits(cg->regmap, cg->sta_ofs, BIT(cg->bit)); } static int mtk_cg_enable(struct clk_hw *hw)