Skip to content

Commit

Permalink
watchdog: Convert to devm_ioremap_resource()
Browse files Browse the repository at this point in the history
Convert all uses of devm_request_and_ioremap() to the newly introduced
devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit
error messages can be removed from the failure code paths.

Signed-off-by: Thierry Reding <[email protected]>
Cc: Wim Van Sebroeck <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Thierry Reding authored and gregkh committed Jan 25, 2013
1 parent ca36b1b commit 4c271bb
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 30 deletions.
8 changes: 3 additions & 5 deletions drivers/watchdog/ar7_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,9 @@ static int ar7_wdt_probe(struct platform_device *pdev)
return -ENODEV;
}

ar7_wdt = devm_request_and_ioremap(&pdev->dev, ar7_regs_wdt);
if (!ar7_wdt) {
pr_err("could not ioremap registers\n");
return -ENXIO;
}
ar7_wdt = devm_ioremap_resource(&pdev->dev, ar7_regs_wdt);
if (IS_ERR(ar7_wdt))
return PTR_ERR(ar7_wdt);

vbus_clk = clk_get(NULL, "vbus");
if (IS_ERR(vbus_clk)) {
Expand Down
6 changes: 3 additions & 3 deletions drivers/watchdog/dw_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
if (!mem)
return -EINVAL;

dw_wdt.regs = devm_request_and_ioremap(&pdev->dev, mem);
if (!dw_wdt.regs)
return -ENOMEM;
dw_wdt.regs = devm_ioremap_resource(&pdev->dev, mem);
if (IS_ERR(dw_wdt.regs))
return PTR_ERR(dw_wdt.regs);

dw_wdt.clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(dw_wdt.clk))
Expand Down
8 changes: 3 additions & 5 deletions drivers/watchdog/imx2_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,9 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
return -ENODEV;
}

imx2_wdt.base = devm_request_and_ioremap(&pdev->dev, res);
if (!imx2_wdt.base) {
dev_err(&pdev->dev, "ioremap failed\n");
return -ENOMEM;
}
imx2_wdt.base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(imx2_wdt.base))
return PTR_ERR(imx2_wdt.base);

imx2_wdt.clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(imx2_wdt.clk)) {
Expand Down
6 changes: 3 additions & 3 deletions drivers/watchdog/jz4740_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ static int jz4740_wdt_probe(struct platform_device *pdev)
watchdog_set_drvdata(jz4740_wdt, drvdata);

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
drvdata->base = devm_request_and_ioremap(&pdev->dev, res);
if (drvdata->base == NULL) {
ret = -EBUSY;
drvdata->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(drvdata->base)) {
ret = PTR_ERR(drvdata->base);
goto err_out;
}

Expand Down
8 changes: 3 additions & 5 deletions drivers/watchdog/lantiq_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,9 @@ ltq_wdt_probe(struct platform_device *pdev)
return -ENOENT;
}

ltq_wdt_membase = devm_request_and_ioremap(&pdev->dev, res);
if (!ltq_wdt_membase) {
dev_err(&pdev->dev, "cannot remap I/O memory region\n");
return -ENOMEM;
}
ltq_wdt_membase = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(ltq_wdt_membase))
return PTR_ERR(ltq_wdt_membase);

/* we do not need to enable the clock as it is always running */
clk = clk_get_io();
Expand Down
7 changes: 4 additions & 3 deletions drivers/watchdog/max63xx_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* another interface, some abstraction will have to be introduced.
*/

#include <linux/err.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/types.h>
Expand Down Expand Up @@ -198,9 +199,9 @@ static int max63xx_wdt_probe(struct platform_device *pdev)
heartbeat = current_timeout->twd;

wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
wdt_base = devm_request_and_ioremap(&pdev->dev, wdt_mem);
if (!wdt_base)
return -ENOMEM;
wdt_base = devm_ioremap_resource(&pdev->dev, wdt_mem);
if (IS_ERR(wdt_base))
return PTR_ERR(wdt_base);

max63xx_wdt_dev.timeout = heartbeat;
watchdog_set_nowayout(&max63xx_wdt_dev, nowayout);
Expand Down
6 changes: 3 additions & 3 deletions drivers/watchdog/pnx4008_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ static int pnx4008_wdt_probe(struct platform_device *pdev)
heartbeat = DEFAULT_HEARTBEAT;

r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
wdt_base = devm_request_and_ioremap(&pdev->dev, r);
if (!wdt_base)
return -EADDRINUSE;
wdt_base = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(wdt_base))
return PTR_ERR(wdt_base);

wdt_clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(wdt_clk))
Expand Down
6 changes: 3 additions & 3 deletions drivers/watchdog/txx9wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ static int __init txx9wdt_probe(struct platform_device *dev)
}

res = platform_get_resource(dev, IORESOURCE_MEM, 0);
txx9wdt_reg = devm_request_and_ioremap(&dev->dev, res);
if (!txx9wdt_reg) {
ret = -EBUSY;
txx9wdt_reg = devm_ioremap_resource(&dev->dev, res);
if (IS_ERR(txx9wdt_reg)) {
ret = PTR_ERR(txx9wdt_reg);
goto exit;
}

Expand Down

0 comments on commit 4c271bb

Please sign in to comment.