Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: mediatek: clk-gate: Shrink by adding clockgating bit check helper

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 <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220103143712.46675-1-angelogioacchino.delregno@collabora.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

AngeloGioacchino Del Regno and committed by
Stephen Boyd
42334638 fa55b7dc

+7 -11
+7 -11
drivers/clk/mediatek/clk-gate.c
··· 16 16 #include "clk-mtk.h" 17 17 #include "clk-gate.h" 18 18 19 - static int mtk_cg_bit_is_cleared(struct clk_hw *hw) 19 + static u32 mtk_get_clockgating(struct clk_hw *hw) 20 20 { 21 21 struct mtk_clk_gate *cg = to_mtk_clk_gate(hw); 22 22 u32 val; 23 23 24 24 regmap_read(cg->regmap, cg->sta_ofs, &val); 25 25 26 - val &= BIT(cg->bit); 26 + return val & BIT(cg->bit); 27 + } 27 28 28 - return val == 0; 29 + static int mtk_cg_bit_is_cleared(struct clk_hw *hw) 30 + { 31 + return mtk_get_clockgating(hw) == 0; 29 32 } 30 33 31 34 static int mtk_cg_bit_is_set(struct clk_hw *hw) 32 35 { 33 - struct mtk_clk_gate *cg = to_mtk_clk_gate(hw); 34 - u32 val; 35 - 36 - regmap_read(cg->regmap, cg->sta_ofs, &val); 37 - 38 - val &= BIT(cg->bit); 39 - 40 - return val != 0; 36 + return mtk_get_clockgating(hw) != 0; 41 37 } 42 38 43 39 static void mtk_cg_set_bit(struct clk_hw *hw)