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/clocksource/bcm2835.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/clocksource/bcm2835.c') diff --git a/drivers/clocksource/bcm2835.c b/drivers/clocksource/bcm2835.c index 0cb8e57993..b5831d5f10 100644 --- a/drivers/clocksource/bcm2835.c +++ b/drivers/clocksource/bcm2835.c @@ -42,6 +42,7 @@ static struct clocksource bcm2835_stc = { static int bcm2835_cs_probe(struct device_d *dev) { + struct resource *iores; static struct clk *stc_clk; u32 rate; int ret; @@ -61,9 +62,10 @@ static int bcm2835_cs_probe(struct device_d *dev) } rate = clk_get_rate(stc_clk); - stc_base = dev_request_mem_region(dev, 0); - if (IS_ERR(stc_base)) - return PTR_ERR(stc_base); + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) + return PTR_ERR(iores); + stc_base = IOMEM(iores->start); clocks_calc_mult_shift(&bcm2835_stc.mult, &bcm2835_stc.shift, rate, NSEC_PER_SEC, 60); -- cgit v1.2.3