From 3bd69ad077a955b469baa90d938fd83510297335 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 18 Feb 2016 11:38:58 +0100 Subject: driver: replace dev_request_mem_region with dev_request_mem_resource dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // Signed-off-by: Sascha Hauer --- drivers/clk/mvebu/common.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'drivers/clk/mvebu/common.c') diff --git a/drivers/clk/mvebu/common.c b/drivers/clk/mvebu/common.c index 1eded90378..a06b29f4e7 100644 --- a/drivers/clk/mvebu/common.c +++ b/drivers/clk/mvebu/common.c @@ -42,6 +42,7 @@ static struct of_device_id mvebu_coreclk_ids[] = { int mvebu_coreclk_probe(struct device_d *dev) { + struct resource *iores; struct device_node *np = dev->device_node; const struct of_device_id *match; const struct coreclk_soc_desc *desc; @@ -57,9 +58,10 @@ int mvebu_coreclk_probe(struct device_d *dev) desc = (const struct coreclk_soc_desc *)match->data; /* Get SAR base address */ - base = dev_request_mem_region(dev, 0); - if (IS_ERR(base)) - return PTR_ERR(base); + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) + return PTR_ERR(iores); + base = IOMEM(iores->start); /* Allocate struct for TCLK, cpu clk, and core ratio clocks */ clk_data.clk_num = 2 + desc->num_ratios; @@ -151,6 +153,7 @@ static struct of_device_id mvebu_clk_gating_ids[] = { int mvebu_clk_gating_probe(struct device_d *dev) { + struct resource *iores; struct device_node *np = dev->device_node; const struct of_device_id *match; const struct clk_gating_soc_desc *desc; @@ -166,9 +169,10 @@ int mvebu_clk_gating_probe(struct device_d *dev) return -EINVAL; desc = (const struct clk_gating_soc_desc *)match->data; - base = dev_request_mem_region(dev, 0); - if (IS_ERR(base)) - return PTR_ERR(base); + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) + return PTR_ERR(iores); + base = IOMEM(iores->start); clk = of_clk_get(np, 0); if (IS_ERR(clk)) -- cgit v1.2.3