Skip to content

Commit 3d0316c

Browse files
knaerzchemmind
authored andcommitted
clk: rockchip: rk3128: Drop CLK_NR_CLKS usage
In order to get rid of CLK_NR_CLKS and be able to drop it from the bindings, use rockchip_clk_find_max_clk_id helper to find the highest clock id. Signed-off-by: Alex Bee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Heiko Stuebner <[email protected]>
1 parent e745698 commit 3d0316c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

drivers/clk/rockchip/clk-rk3128.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,18 +569,22 @@ static const char *const rk3128_critical_clocks[] __initconst = {
569569
"sclk_timer5",
570570
};
571571

572-
static struct rockchip_clk_provider *__init rk3128_common_clk_init(struct device_node *np)
572+
static struct rockchip_clk_provider *__init rk3128_common_clk_init(struct device_node *np,
573+
unsigned long soc_nr_clks)
573574
{
574575
struct rockchip_clk_provider *ctx;
576+
unsigned long common_nr_clks;
575577
void __iomem *reg_base;
576578

579+
common_nr_clks = rockchip_clk_find_max_clk_id(common_clk_branches,
580+
ARRAY_SIZE(common_clk_branches)) + 1;
577581
reg_base = of_iomap(np, 0);
578582
if (!reg_base) {
579583
pr_err("%s: could not map cru region\n", __func__);
580584
return ERR_PTR(-ENOMEM);
581585
}
582586

583-
ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
587+
ctx = rockchip_clk_init(np, reg_base, max(common_nr_clks, soc_nr_clks));
584588
if (IS_ERR(ctx)) {
585589
pr_err("%s: rockchip clk init failed\n", __func__);
586590
iounmap(reg_base);
@@ -609,8 +613,12 @@ static struct rockchip_clk_provider *__init rk3128_common_clk_init(struct device
609613
static void __init rk3126_clk_init(struct device_node *np)
610614
{
611615
struct rockchip_clk_provider *ctx;
616+
unsigned long soc_nr_clks;
612617

613-
ctx = rk3128_common_clk_init(np);
618+
soc_nr_clks = rockchip_clk_find_max_clk_id(rk3126_clk_branches,
619+
ARRAY_SIZE(rk3126_clk_branches)) + 1;
620+
621+
ctx = rk3128_common_clk_init(np, soc_nr_clks);
614622
if (IS_ERR(ctx))
615623
return;
616624

@@ -627,8 +635,12 @@ CLK_OF_DECLARE(rk3126_cru, "rockchip,rk3126-cru", rk3126_clk_init);
627635
static void __init rk3128_clk_init(struct device_node *np)
628636
{
629637
struct rockchip_clk_provider *ctx;
638+
unsigned long soc_nr_clks;
639+
640+
soc_nr_clks = rockchip_clk_find_max_clk_id(rk3128_clk_branches,
641+
ARRAY_SIZE(rk3128_clk_branches)) + 1;
630642

631-
ctx = rk3128_common_clk_init(np);
643+
ctx = rk3128_common_clk_init(np, soc_nr_clks);
632644
if (IS_ERR(ctx))
633645
return;
634646

0 commit comments

Comments
 (0)