Skip to content

Commit

Permalink
clk: mediatek: clk-gate: Shrink by adding clockgating bit check helper
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
AngeloGioacchino Del Regno authored and Stephen Boyd committed Jan 7, 2022
1 parent fa55b7d commit 4233463
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions drivers/clk/mediatek/clk-gate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4233463

Please sign in to comment.