[PATCH v3 1/2] clk: eyeq: Use devm_platform_ioremap_resource()

From: Benoît Monin

Date: Wed Sep 16 2026 - 08:18:20 EST


Convert eqc_probe() from the open-coded platform_get_resource() +
ioremap() sequence to devm_platform_ioremap_resource(). Besides less
code, this requests the memory region so the OLB registers are properly
reserved in the iomem_resource tree.

Move devm_platform_ioremap_resource() before checking for device match
data, so OLBs bound without match data also get their memory region
mapped and reserved.

Unregister the clocks before devres unmaps the region if the clock
provider registration fails.

Suggested-by: Vladimir Kondratiev <vladimir.kondratiev@xxxxxxxxxxxx>
Signed-off-by: Benoît Monin <benoit.monin@xxxxxxxxxxx>
---
drivers/clk/clk-eyeq.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/clk-eyeq.c b/drivers/clk/clk-eyeq.c
index cf37feccc734..3c00be00889a 100644
--- a/drivers/clk/clk-eyeq.c
+++ b/drivers/clk/clk-eyeq.c
@@ -513,21 +513,16 @@ static int eqc_probe(struct platform_device *pdev)
const struct eqc_match_data *data;
struct clk_hw_onecell_data *cells;
unsigned int i, clk_count;
- struct resource *res;
void __iomem *base;
int ret;

+ base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
+
data = device_get_match_data(dev);
if (!data)
- return 0; /* No clocks nor auxdevs, we are done. */
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- return -ENODEV;
-
- base = ioremap(res->start, resource_size(res));
- if (!base)
- return -ENOMEM;
+ return 0; /* No clocks nor auxdevs, stop here but keep resource reserved */

/* Init optional auxiliary devices. */
eqc_auxdev_create_optional(dev, base, data->reset_auxdev_name);
@@ -559,7 +554,20 @@ static int eqc_probe(struct platform_device *pdev)
dev_warn(dev, "failed probing clock %s: %d\n", clk->name, ret);
}

- return of_clk_add_hw_provider(np, of_clk_hw_onecell_get, cells);
+ ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, cells);
+ if (ret) {
+ for (i = 0; i < data->clk_count; i++) {
+ const struct eqc_clock *clk = &data->clks[i];
+ struct clk_hw *hw = cells->hws[clk->index];
+
+ if (!IS_ERR_OR_NULL(hw) && clk->unregister)
+ clk->unregister(hw);
+ }
+
+ kfree(cells);
+ }
+
+ return ret;
}

#define DIV(_index, _parent_idx, _name, _parent_name, \

--
2.55.0