mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
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>
This commit is contained in:
parent
4539402e0b
commit
904e5ef5ac
|
|
@ -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, \
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user