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/watchdog/davinci_wdt.c | 8 +++++--- drivers/watchdog/im28wd.c | 8 +++++--- drivers/watchdog/imxwd.c | 8 +++++--- drivers/watchdog/jz4740.c | 8 +++++--- drivers/watchdog/omap_wdt.c | 8 +++++--- 5 files changed, 25 insertions(+), 15 deletions(-) (limited to 'drivers/watchdog') diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c index dfabee230c..03dc83408e 100644 --- a/drivers/watchdog/davinci_wdt.c +++ b/drivers/watchdog/davinci_wdt.c @@ -131,14 +131,16 @@ static int davinci_wdt_set_timeout(struct watchdog *wd, unsigned timeout) static int davinci_wdt_probe(struct device_d *dev) { + struct resource *iores; int ret = 0; struct davinci_wdt *davinci_wdt; davinci_wdt = xzalloc(sizeof(*davinci_wdt)); - davinci_wdt->base = dev_request_mem_region(dev, 0); - if (IS_ERR(davinci_wdt->base)) - return PTR_ERR(davinci_wdt->base); + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) + return PTR_ERR(iores); + davinci_wdt->base = IOMEM(iores->start); davinci_wdt->clk = clk_get(dev, NULL); if (WARN_ON(IS_ERR(davinci_wdt->clk))) diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c index 3510776a3a..1956fdb73d 100644 --- a/drivers/watchdog/im28wd.c +++ b/drivers/watchdog/im28wd.c @@ -189,13 +189,15 @@ static void __maybe_unused imx28_detect_reset_source(const struct imx28_wd *p) static int imx28_wd_probe(struct device_d *dev) { + struct resource *iores; struct imx28_wd *priv; int rc; priv = xzalloc(sizeof(struct imx28_wd)); - priv->regs = dev_request_mem_region(dev, 0); - if (IS_ERR(priv->regs)) - return PTR_ERR(priv->regs); + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) + return PTR_ERR(iores); + priv->regs = IOMEM(iores->start); priv->wd.set_timeout = imx28_watchdog_set_timeout; priv->wd.dev = dev; diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c index 14588947f0..03e116ea20 100644 --- a/drivers/watchdog/imxwd.c +++ b/drivers/watchdog/imxwd.c @@ -173,6 +173,7 @@ static int imx21_wd_init(struct imx_wd *priv) static int imx_wd_probe(struct device_d *dev) { + struct resource *iores; struct imx_wd *priv; void *ops; int ret; @@ -182,11 +183,12 @@ static int imx_wd_probe(struct device_d *dev) return ret; priv = xzalloc(sizeof(struct imx_wd)); - priv->base = dev_request_mem_region(dev, 0); - if (IS_ERR(priv->base)) { + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) { dev_err(dev, "could not get memory region\n"); - return PTR_ERR(priv->base); + return PTR_ERR(iores); } + priv->base = IOMEM(iores->start); priv->ops = ops; priv->wd.set_timeout = imx_watchdog_set_timeout; priv->wd.dev = dev; diff --git a/drivers/watchdog/jz4740.c b/drivers/watchdog/jz4740.c index 85a1c1d1e9..f28bb9177a 100644 --- a/drivers/watchdog/jz4740.c +++ b/drivers/watchdog/jz4740.c @@ -67,14 +67,16 @@ static void __noreturn jz4740_reset_soc(struct restart_handler *rst) static int jz4740_wdt_probe(struct device_d *dev) { + struct resource *iores; struct jz4740_wdt_drvdata *priv; priv = xzalloc(sizeof(struct jz4740_wdt_drvdata)); - priv->base = dev_request_mem_region(dev, 0); - if (IS_ERR(priv->base)) { + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) { dev_err(dev, "could not get memory region\n"); - return PTR_ERR(priv->base); + return PTR_ERR(iores); } + priv->base = IOMEM(iores->start); dev->priv = priv; diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index 06301b3b9e..27fdfd13a0 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c @@ -154,6 +154,7 @@ static int omap_wdt_set_timeout(struct watchdog *wdog, static int omap_wdt_probe(struct device_d *dev) { + struct resource *iores; struct omap_wdt_dev *wdev; int ret; @@ -162,11 +163,12 @@ static int omap_wdt_probe(struct device_d *dev) wdev->wdt_trgr_pattern = 0x1234; /* reserve static register mappings */ - wdev->base = dev_request_mem_region(dev, 0); - if (IS_ERR(wdev->base)) { - ret = PTR_ERR(wdev->base); + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) { + ret = PTR_ERR(iores); goto error; } + wdev->base = IOMEM(iores->start); wdev->timeout = TIMER_MARGIN_DEFAULT; -- cgit v1.2.3