Skip to content

Commit 7f294d1

Browse files
alpernebbibebarino
authored andcommitted
clk: mediatek: mt8173-infracfg: Handle unallocated infracfg when module
The MT8173 infracfg clock driver does initialization in two steps, via a CLK_OF_DECLARE_DRIVER declaration. However its early init function doesn't get to run when it's built as a module, presumably since it's not loaded by the time it would have been called by of_clk_init(). This causes its second-step probe() to return -ENOMEM when trying to register clocks, as the necessary clock_data struct isn't initialized by the first step. MT2701 and MT6797 clock drivers also use this mechanism, but they try to allocate the necessary clock_data structure if missing in the second step. Mimic that for the MT8173 infracfg clock as well to make it work as a module. Signed-off-by: Alper Nebi Yasak <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 9f7809c commit 7f294d1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/clk/mediatek/clk-mt8173-infracfg.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,17 @@ CLK_OF_DECLARE_DRIVER(mtk_infrasys, "mediatek,mt8173-infracfg",
9898
static int clk_mt8173_infracfg_probe(struct platform_device *pdev)
9999
{
100100
struct device_node *node = pdev->dev.of_node;
101-
int r;
101+
int r, i;
102+
103+
if (!infra_clk_data) {
104+
infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
105+
if (!infra_clk_data)
106+
return -ENOMEM;
107+
} else {
108+
for (i = 0; i < CLK_INFRA_NR_CLK; i++)
109+
if (infra_clk_data->hws[i] == ERR_PTR(-EPROBE_DEFER))
110+
infra_clk_data->hws[i] = ERR_PTR(-ENOENT);
111+
}
102112

103113
r = mtk_clk_register_gates(&pdev->dev, node, infra_gates,
104114
ARRAY_SIZE(infra_gates), infra_clk_data);

0 commit comments

Comments
 (0)