summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoît Monin <benoit.monin@bootlin.com>2026-09-16 14:08:54 +0200
committerBrian Masney <bmasney@redhat.com>2026-09-17 11:23:30 -0400
commit904e5ef5ac48495ed439ca37dde7f0ce1e9c4af7 (patch)
treedecc235f91bdefa94ab81b966caa48c7b9f059b9
parent4539402e0b34c8c239208d5f5b90248c040fee89 (diff)
downloadlinux-next-904e5ef5ac48495ed439ca37dde7f0ce1e9c4af7.tar.gz
linux-next-904e5ef5ac48495ed439ca37dde7f0ce1e9c4af7.zip
clk: eyeq: Use devm_platform_ioremap_resource()
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@mobileye.com> Signed-off-by: Benoît Monin <benoit.monin@bootlin.com> Signed-off-by: Brian Masney <bmasney@redhat.com>
-rw-r--r--drivers/clk/clk-eyeq.c30
1 files 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, \