Skip to content

Commit 69ac2ac

Browse files
bijudasgeertu
authored andcommitted
clk: renesas: rzv2h: Adjust for CPG_BUS_m_MSTOP starting from m = 1
Avoid using the "- 1" for finding mstop_index in all functions accessing priv->mstop_count, by adjusting its pointer in rzv2h_cpg_probe(). While at it, drop the intermediate local variable index. Reported-by: Geert Uytterhoeven <geert+renesas@glider.be> Closes: https://lore.kernel.org/all/CAMuHMdX1gPNCFddg_DyK7Bv0BeFLOLi=5eteT_HhMH=Ph2wVvA@mail.gmail.com/ Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/20250222142009.41324-1-biju.das.jz@bp.renesas.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
1 parent 5288fe0 commit 69ac2ac

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/clk/renesas/rzv2h-cpg.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,7 @@ static void rzv2h_mod_clock_mstop_enable(struct rzv2h_cpg_priv *priv,
447447
{
448448
unsigned long mstop_mask = FIELD_GET(BUS_MSTOP_BITS_MASK, mstop_data);
449449
u16 mstop_index = FIELD_GET(BUS_MSTOP_IDX_MASK, mstop_data);
450-
unsigned int index = (mstop_index - 1) * 16;
451-
atomic_t *mstop = &priv->mstop_count[index];
450+
atomic_t *mstop = &priv->mstop_count[mstop_index * 16];
452451
unsigned long flags;
453452
unsigned int i;
454453
u32 val = 0;
@@ -469,8 +468,7 @@ static void rzv2h_mod_clock_mstop_disable(struct rzv2h_cpg_priv *priv,
469468
{
470469
unsigned long mstop_mask = FIELD_GET(BUS_MSTOP_BITS_MASK, mstop_data);
471470
u16 mstop_index = FIELD_GET(BUS_MSTOP_IDX_MASK, mstop_data);
472-
unsigned int index = (mstop_index - 1) * 16;
473-
atomic_t *mstop = &priv->mstop_count[index];
471+
atomic_t *mstop = &priv->mstop_count[mstop_index * 16];
474472
unsigned long flags;
475473
unsigned int i;
476474
u32 val = 0;
@@ -630,8 +628,7 @@ rzv2h_cpg_register_mod_clk(const struct rzv2h_mod_clk *mod,
630628
} else if (clock->mstop_data != BUS_MSTOP_NONE && mod->critical) {
631629
unsigned long mstop_mask = FIELD_GET(BUS_MSTOP_BITS_MASK, clock->mstop_data);
632630
u16 mstop_index = FIELD_GET(BUS_MSTOP_IDX_MASK, clock->mstop_data);
633-
unsigned int index = (mstop_index - 1) * 16;
634-
atomic_t *mstop = &priv->mstop_count[index];
631+
atomic_t *mstop = &priv->mstop_count[mstop_index * 16];
635632
unsigned long flags;
636633
unsigned int i;
637634
u32 val = 0;
@@ -926,6 +923,9 @@ static int __init rzv2h_cpg_probe(struct platform_device *pdev)
926923
if (!priv->mstop_count)
927924
return -ENOMEM;
928925

926+
/* Adjust for CPG_BUS_m_MSTOP starting from m = 1 */
927+
priv->mstop_count -= 16;
928+
929929
priv->resets = devm_kmemdup(dev, info->resets, sizeof(*info->resets) *
930930
info->num_resets, GFP_KERNEL);
931931
if (!priv->resets)

0 commit comments

Comments
 (0)