clk: rockchip: simplify rockchip_clk_add_lookup
authorSebastian Reichel <sebastian.reichel@collabora.com>
Tue, 18 Oct 2022 15:14:05 +0000 (17:14 +0200)
committerHeiko Stuebner <heiko@sntech.de>
Mon, 14 Nov 2022 14:35:07 +0000 (15:35 +0100)
rockchip_clk_add_lookup is only called from within the file,
so it can be made static. The additional checks are removed
with the following reasoning:

1. The data structure is initialized by rockchip_clk_init(),
   which is called by all rockchip platforms before the clocks
   are registered. Not doing so would result in an incomplete
   clock tree at the moment, which is a fatal error. In other
   parts of the kernel these kind of checks are usually
   omitted, so this was done here. The alternative is adding
   a pr_err to inform the kernel programmer adding a new platform
   about his incorrect code. Apart from that we are also not
   checking if the clock id is within the array boundings.

2. While not used so far by any rockchip platform, 0 is a valid
   clock identifier. To align rockchip closer to other ARM
   platforms we will start using it with rk3588.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20221018151407.63395-8-sebastian.reichel@collabora.com
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
drivers/clk/rockchip/clk.c
drivers/clk/rockchip/clk.h

index e63d4f20b479d2d70a8148cac716dce2abbfdf73..1aed6f254ccd858a4fbd35a466a3036ff78b0d57 100644 (file)
@@ -198,6 +198,12 @@ static void rockchip_fractional_approximation(struct clk_hw *hw,
        clk_fractional_divider_general_approximation(hw, rate, parent_rate, m, n);
 }
 
+static void rockchip_clk_add_lookup(struct rockchip_clk_provider *ctx,
+                                   struct clk *clk, unsigned int id)
+{
+       ctx->clk_data.clks[id] = clk;
+}
+
 static struct clk *rockchip_clk_register_frac_branch(
                struct rockchip_clk_provider *ctx, const char *name,
                const char *const *parent_names, u8 num_parents,
@@ -401,14 +407,6 @@ void rockchip_clk_of_add_provider(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(rockchip_clk_of_add_provider);
 
-void rockchip_clk_add_lookup(struct rockchip_clk_provider *ctx,
-                            struct clk *clk, unsigned int id)
-{
-       if (ctx->clk_data.clks && id)
-               ctx->clk_data.clks[id] = clk;
-}
-EXPORT_SYMBOL_GPL(rockchip_clk_add_lookup);
-
 void rockchip_clk_register_plls(struct rockchip_clk_provider *ctx,
                                struct rockchip_pll_clock *list,
                                unsigned int nr_pll, int grf_lock_offset)
index 24d3e56d3f7148c5a116781d8db6a9bdf136d61c..6e84ab85b372fd688b9341866095e76058b42ad5 100644 (file)
@@ -928,8 +928,6 @@ struct rockchip_clk_provider *rockchip_clk_init(struct device_node *np,
                        void __iomem *base, unsigned long nr_clks);
 void rockchip_clk_of_add_provider(struct device_node *np,
                                struct rockchip_clk_provider *ctx);
-void rockchip_clk_add_lookup(struct rockchip_clk_provider *ctx,
-                            struct clk *clk, unsigned int id);
 void rockchip_clk_register_branches(struct rockchip_clk_provider *ctx,
                                    struct rockchip_clk_branch *list,
                                    unsigned int nr_clk);