[PATCH] clk: milbeaut: Register M10V clocks on the early controller mapping
Guangshuo Li
liguangshuo at mail.sdu.edu.cn
Sun Nov 29 08:27:46 PST 2026
The M10V muxes and dividers use a platform-managed mapping, but are
published on the permanent timer clock provider. Unbinding the platform
driver unmaps registers that the clock operations still access.
Register all clocks from the existing early controller initializer. They
use the same register block and only require the parent clock name. The
provider and the mapping then share the lifetime of the timer clock.
This issue was found by our static analysis tool under development.
Fixes: 6a6ba5b55a72 ("clock: milbeaut: Add Milbeaut M10V clock controller")
Signed-off-by: Guangshuo Li <liguangshuo at mail.sdu.edu.cn>
---
drivers/clk/clk-milbeaut.c | 81 +++++++++++---------------------------
1 file changed, 22 insertions(+), 59 deletions(-)
diff --git a/drivers/clk/clk-milbeaut.c b/drivers/clk/clk-milbeaut.c
index 29c1e5f68c7a..0f0fb3b7ae87 100644
--- a/drivers/clk/clk-milbeaut.c
+++ b/drivers/clk/clk-milbeaut.c
@@ -9,7 +9,6 @@
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/of_address.h>
-#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
@@ -62,8 +61,6 @@
#define to_m10v_div(_hw) container_of(_hw, struct m10v_clk_divider, hw)
-static struct clk_hw_onecell_data *m10v_clk_data;
-
static DEFINE_SPINLOCK(m10v_crglock);
struct m10v_clk_div_factors {
@@ -558,56 +555,9 @@ static void m10v_reg_mux_pre(const struct m10v_clk_mux_factors *factors,
clk_data->hws[factors->onecell_idx] = hw;
}
-static int m10v_clk_probe(struct platform_device *pdev)
-{
- int id;
- struct device *dev = &pdev->dev;
- struct device_node *np = dev->of_node;
- void __iomem *base;
- const char *parent_name;
-
- base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
- if (IS_ERR(base))
- return PTR_ERR(base);
-
- parent_name = of_clk_get_parent_name(np, 0);
-
- for (id = 0; id < ARRAY_SIZE(m10v_div_factor_data); ++id)
- m10v_reg_div_pre(&m10v_div_factor_data[id],
- m10v_clk_data, base);
-
- for (id = 0; id < ARRAY_SIZE(m10v_div_fixed_data); ++id)
- m10v_reg_fixed_pre(&m10v_div_fixed_data[id],
- m10v_clk_data, parent_name);
-
- for (id = 0; id < ARRAY_SIZE(m10v_mux_factor_data); ++id)
- m10v_reg_mux_pre(&m10v_mux_factor_data[id],
- m10v_clk_data, base);
-
- for (id = 0; id < M10V_NUM_CLKS; id++) {
- if (IS_ERR(m10v_clk_data->hws[id]))
- return PTR_ERR(m10v_clk_data->hws[id]);
- }
-
- return 0;
-}
-
-static const struct of_device_id m10v_clk_dt_ids[] = {
- { .compatible = "socionext,milbeaut-m10v-ccu", },
- { }
-};
-
-static struct platform_driver m10v_clk_driver = {
- .probe = m10v_clk_probe,
- .driver = {
- .name = "m10v-ccu",
- .of_match_table = m10v_clk_dt_ids,
- },
-};
-builtin_platform_driver(m10v_clk_driver);
-
static void __init m10v_cc_init(struct device_node *np)
{
+ struct clk_hw_onecell_data *m10v_clk_data;
int id;
void __iomem *base;
const char *parent_name;
@@ -632,13 +582,6 @@ static void __init m10v_cc_init(struct device_node *np)
return;
}
- /*
- * This way all clocks fetched before the platform device probes,
- * except those we assign here for early use, will be deferred.
- */
- for (id = 0; id < M10V_NUM_CLKS; id++)
- m10v_clk_data->hws[id] = ERR_PTR(-EPROBE_DEFER);
-
/*
* PLLs are set by bootloader so this driver registers them as the
* fixed factor.
@@ -654,6 +597,26 @@ static void __init m10v_cc_init(struct device_node *np)
base + CLKSEL(1), 0, 3, 0, rclk_table,
&m10v_crglock, NULL);
m10v_clk_data->hws[M10V_RCLK_ID] = hw;
+
+ for (id = 0; id < ARRAY_SIZE(m10v_div_factor_data); ++id)
+ m10v_reg_div_pre(&m10v_div_factor_data[id],
+ m10v_clk_data, base);
+
+ for (id = 0; id < ARRAY_SIZE(m10v_div_fixed_data); ++id)
+ m10v_reg_fixed_pre(&m10v_div_fixed_data[id],
+ m10v_clk_data, parent_name);
+
+ for (id = 0; id < ARRAY_SIZE(m10v_mux_factor_data); ++id)
+ m10v_reg_mux_pre(&m10v_mux_factor_data[id],
+ m10v_clk_data, base);
+
+ for (id = 0; id < M10V_NUM_CLKS; id++) {
+ if (IS_ERR(m10v_clk_data->hws[id]))
+ pr_err("%pOF: failed to register clock %d: %pe\n",
+ np, id, m10v_clk_data->hws[id]);
+ }
+
of_clk_add_hw_provider(np, of_clk_hw_onecell_get, m10v_clk_data);
}
-CLK_OF_DECLARE_DRIVER(m10v_cc, "socionext,milbeaut-m10v-ccu", m10v_cc_init);
+
+CLK_OF_DECLARE(m10v_cc, "socionext,milbeaut-m10v-ccu", m10v_cc_init);
base-commit: d8f05ec001e838cdb94fc14efa7c411e676f9ab9
--
2.43.0
More information about the linux-arm-kernel
mailing list