watchdog: at32ap700x_wdt: use devm_*() functions
PATCH 1/7 watchdog: at32ap700x_wdt: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
--- drivers/watchdog/at32ap700x_wdt.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/watchdog/at32ap700x_wdt.c +4 -8
@@ -321,13 +321,14 @@ static int __init at32_wdt_probe(struct platform_device *pdev)return -ENXIO ; } - wdt =kzalloc (sizeof (struct wdt_at32ap700x ),GFP_KERNEL ); + wdt =devm_kzalloc (&pdev->dev,sizeof (struct wdt_at32ap700x ), +GFP_KERNEL );if (!wdt) {dev_dbg (&pdev->dev,"no memory for wdt structure\n" );return -ENOMEM ; } - wdt->regs =ioremap (regs->start,resource_size (regs)); + wdt->regs =devm_ioremap (&pdev->dev, regs->start,resource_size (regs));if (!wdt->regs) { ret = -ENOMEM ;dev_dbg (&pdev->dev,"could not map I/O memory\n" );
@@ -342,7 +343,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev)dev_info (&pdev->dev,"CPU must be reset with external " "reset or POR due to silicon errata.\n" ); ret = -EIO ; - goto err_iounmap; + goto err_free; }else { wdt->users =0 ; }
@@ -375,10 +376,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev) err_register:platform_set_drvdata (pdev,NULL ); -err_iounmap: -iounmap (wdt->regs); err_free: -kfree (wdt); wdt =NULL ;return ret; }
@@ -391,8 +389,6 @@ static int __exit at32_wdt_remove(struct platform_device *pdev)at32_wdt_stop ();misc_deregister (&wdt->miscdev); -iounmap (wdt->regs); -kfree (wdt); wdt =NULL ;platform_set_drvdata (pdev,NULL ); }
Signature · 1 line
1.7.2.5
PATCH 2/7 watchdog: bcm63xx_wdt: use devm_ioremap_nocache()
Use devm_ioremap_nocache() to make cleanup paths simpler.
--- drivers/watchdog/bcm63xx_wdt.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
drivers/watchdog/bcm63xx_wdt.c +4 -5
@@ -16,6 +16,7 @@#include <linux/errno.h> #include <linux/fs.h> #include <linux/init.h> +#include <linux/io.h> #include <linux/kernel.h> #include <linux/miscdevice.h> #include <linux/module.h>
@@ -249,7 +250,8 @@ static int bcm63xx_wdt_probe(struct platform_device *pdev)return -ENODEV ; } - bcm63xx_wdt_device.regs =ioremap_nocache (r->start,resource_size (r)); + bcm63xx_wdt_device.regs =devm_ioremap_nocache (&pdev->dev, r->start, +resource_size (r));if (!bcm63xx_wdt_device.regs) {dev_err (&pdev->dev,"failed to remap I/O resources\n" );return -ENXIO ;
@@ -258,7 +260,7 @@ static int bcm63xx_wdt_probe(struct platform_device *pdev) ret =bcm63xx_timer_register (TIMER_WDT_ID , bcm63xx_wdt_isr,NULL );if (ret <0 ) {dev_err (&pdev->dev,"failed to register wdt timer isr\n" ); - goto unmap; +return ret; }if (bcm63xx_wdt_settimeout (wdt_time)) {
@@ -281,8 +283,6 @@ static int bcm63xx_wdt_probe(struct platform_device *pdev) unregister_timer:bcm63xx_timer_unregister (TIMER_WDT_ID ); -unmap: -iounmap (bcm63xx_wdt_device.regs);return ret; }
@@ -293,7 +293,6 @@ static int bcm63xx_wdt_remove(struct platform_device *pdev)misc_deregister (&bcm63xx_wdt_miscdev);bcm63xx_timer_unregister (TIMER_WDT_ID ); -iounmap (bcm63xx_wdt_device.regs);return 0 ; }
Signature · 1 line
1.7.2.5
PATCH 3/7 watchdog: mv64x60_wdt: use devm_ioremap()
In reply to Jingoo HanUse devm_ioremap() to make cleanup paths simpler.
--- drivers/watchdog/mv64x60_wdt.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/watchdog/mv64x60_wdt.c +1 -3
@@ -276,7 +276,7 @@ static int mv64x60_wdt_probe(struct platform_device *dev)if (!r)return -ENODEV ; - mv64x60_wdt_regs =ioremap (r->start,resource_size (r)); + mv64x60_wdt_regs =devm_ioremap (&dev->dev, r->start,resource_size (r));if (mv64x60_wdt_regs ==NULL )return -ENOMEM ;
@@ -293,8 +293,6 @@ static int mv64x60_wdt_remove(struct platform_device *dev)mv64x60_wdt_handler_disable (); -iounmap (mv64x60_wdt_regs); -return 0 ; }
Signature · 1 line
1.7.2.5
PATCH 4/7 watchdog: nuc900_wdt: use devm_*() functions
In reply to Jingoo HanUse devm_*() functions to make cleanup paths simpler.
--- drivers/watchdog/nuc900_wdt.c | 45 ++++++++-------------------------------- 1 files changed, 9 insertions(+), 36 deletions(-)
drivers/watchdog/nuc900_wdt.c +9 -36
@@ -246,7 +246,8 @@ static int nuc900wdt_probe(struct platform_device *pdev) {int ret =0 ; - nuc900_wdt =kzalloc (sizeof (struct nuc900_wdt ),GFP_KERNEL ); + nuc900_wdt =devm_kzalloc (&pdev->dev,sizeof (struct nuc900_wdt ), +GFP_KERNEL );if (!nuc900_wdt)return -ENOMEM ;
@@ -257,30 +258,18 @@ static int nuc900wdt_probe(struct platform_device *pdev) nuc900_wdt->res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (nuc900_wdt->res ==NULL ) {dev_err (&pdev->dev,"no memory resource specified\n" ); - ret = -ENOENT ; - goto err_get; +return -ENOENT ; } -if (!request_mem_region (nuc900_wdt->res->start, -resource_size (nuc900_wdt->res), pdev->name)) { -dev_err (&pdev->dev,"failed to get memory region\n" ); - ret = -ENOENT ; - goto err_get; - } - - nuc900_wdt->wdt_base =ioremap (nuc900_wdt->res->start, -resource_size (nuc900_wdt->res)); -if (nuc900_wdt->wdt_base ==NULL ) { -dev_err (&pdev->dev,"failed to ioremap() region\n" ); - ret = -EINVAL ; - goto err_req; - } + nuc900_wdt->wdt_base =devm_ioremap_resource (&pdev->dev, + nuc900_wdt->res); +if (IS_ERR (nuc900_wdt->wdt_base)) +return PTR_ERR (nuc900_wdt->wdt_base); - nuc900_wdt->wdt_clock =clk_get (&pdev->dev,NULL ); + nuc900_wdt->wdt_clock =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (nuc900_wdt->wdt_clock)) {dev_err (&pdev->dev,"failed to find watchdog clock source\n" ); - ret =PTR_ERR (nuc900_wdt->wdt_clock); - goto err_map; +return PTR_ERR (nuc900_wdt->wdt_clock); }clk_enable (nuc900_wdt->wdt_clock);
@@ -298,14 +287,6 @@ static int nuc900wdt_probe(struct platform_device *pdev) err_clk:clk_disable (nuc900_wdt->wdt_clock); -clk_put (nuc900_wdt->wdt_clock); -err_map: -iounmap (nuc900_wdt->wdt_base); -err_req: -release_mem_region (nuc900_wdt->res->start, -resource_size (nuc900_wdt->res)); -err_get: -kfree (nuc900_wdt);return ret; }
@@ -314,14 +295,6 @@ static int nuc900wdt_remove(struct platform_device *pdev)misc_deregister (&nuc900wdt_miscdev);clk_disable (nuc900_wdt->wdt_clock); -clk_put (nuc900_wdt->wdt_clock); - -iounmap (nuc900_wdt->wdt_base); - -release_mem_region (nuc900_wdt->res->start, -resource_size (nuc900_wdt->res)); - -kfree (nuc900_wdt);return 0 ; }
Signature · 1 line
1.7.2.5
PATCH 5/7 watchdog: rc32434_wdt: use devm_ioremap_nocache() functions
In reply to Jingoo HanUse devm_ioremap_nocache() functions to make cleanup paths simpler.
--- drivers/watchdog/rc32434_wdt.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
drivers/watchdog/rc32434_wdt.c +3 -7
@@ -32,6 +32,7 @@#include <linux/platform_device.h> /* For platform_driver framework */ #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ #include <linux/uaccess.h> /* For copy_to_user/put_user/... */ +#include <linux/io.h> /* For devm_ioremap_nocache */ #include <asm/mach-rc32434/integ.h> /* For the Watchdog registers */
@@ -271,7 +272,7 @@ static int rc32434_wdt_probe(struct platform_device *pdev)return -ENODEV ; } - wdt_reg =ioremap_nocache (r->start,resource_size (r)); + wdt_reg =devm_ioremap_nocache (&pdev->dev, r->start,resource_size (r));if (!wdt_reg) {pr_err ("failed to remap I/O resources\n" );return -ENXIO ;
@@ -293,23 +294,18 @@ static int rc32434_wdt_probe(struct platform_device *pdev) ret =misc_register (&rc32434_wdt_miscdev);if (ret <0 ) {pr_err ("failed to register watchdog device\n" ); - goto unmap; +return ret; }pr_info ("Watchdog Timer version " VERSION ", timer margin: %d sec\n" , timeout);return 0 ; - -unmap: -iounmap (wdt_reg); -return ret; }static int rc32434_wdt_remove (struct platform_device *pdev) {misc_deregister (&rc32434_wdt_miscdev); -iounmap (wdt_reg);return 0 ; }
Signature · 1 line
1.7.2.5
PATCH 6/7 watchdog: riowd: use devm_kzalloc()
In reply to Jingoo HanUse devm_kzalloc() to make cleanup paths simpler.
--- drivers/watchdog/riowd.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/watchdog/riowd.c +2 -6
@@ -183,7 +183,7 @@ static int riowd_probe(struct platform_device *op) goto out; err = -ENOMEM ; - p =kzalloc (sizeof (*p),GFP_KERNEL ); + p =devm_kzalloc (&op->dev,sizeof (*p),GFP_KERNEL );if (!p) goto out;
@@ -192,7 +192,7 @@ static int riowd_probe(struct platform_device *op) p->regs =of_ioremap (&op->resource[0 ],0 ,2 ,DRIVER_NAME );if (!p->regs) {pr_err ("Cannot map registers\n" ); - goto out_free; + goto out; }/* Make miscdev useable right away */ riowd_device = p;
@@ -213,9 +213,6 @@ out_iounmap: riowd_device =NULL ;of_iounmap (&op->resource[0 ], p->regs,2 ); -out_free: -kfree (p); - out:return err; }
@@ -226,7 +223,6 @@ static int riowd_remove(struct platform_device *op)misc_deregister (&riowd_miscdev);of_iounmap (&op->resource[0 ], p->regs,2 ); -kfree (p);return 0 ; }
Signature · 1 line
1.7.2.5
PATCH 7/7 watchdog: ts72xx_wdt: use devm_*() functions
In reply to Jingoo HanUse devm_*() functions to make cleanup paths simpler.
--- drivers/watchdog/ts72xx_wdt.c | 64 +++++++---------------------------------- 1 files changed, 11 insertions(+), 53 deletions(-)
drivers/watchdog/ts72xx_wdt.c +11 -53
@@ -396,7 +396,7 @@ static int ts72xx_wdt_probe(struct platform_device *pdev)struct resource *r1, *r2;int error =0 ; - wdt =kzalloc (sizeof (struct ts72xx_wdt ),GFP_KERNEL ); + wdt =devm_kzalloc (&pdev->dev,sizeof (struct ts72xx_wdt ),GFP_KERNEL );if (!wdt) {dev_err (&pdev->dev,"failed to allocate memory\n" );return -ENOMEM ;
@@ -405,44 +405,22 @@ static int ts72xx_wdt_probe(struct platform_device *pdev) r1 =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!r1) {dev_err (&pdev->dev,"failed to get memory resource\n" ); - error = -ENODEV ; - goto fail; - } - - r1 =request_mem_region (r1->start,resource_size (r1), pdev->name); -if (!r1) { -dev_err (&pdev->dev,"cannot request memory region\n" ); - error = -EBUSY ; - goto fail; +return -ENODEV ; } - wdt->control_reg =ioremap (r1->start,resource_size (r1)); -if (!wdt->control_reg) { -dev_err (&pdev->dev,"failed to map memory\n" ); - error = -ENODEV ; - goto fail_free_control; - } + wdt->control_reg =devm_ioremap_resource (&pdev->dev, r1); +if (IS_ERR (wdt->control_reg)) +return PTR_ERR (wdt->control_reg); r2 =platform_get_resource (pdev,IORESOURCE_MEM ,1 );if (!r2) {dev_err (&pdev->dev,"failed to get memory resource\n" ); - error = -ENODEV ; - goto fail_unmap_control; +return -ENODEV ; } - r2 =request_mem_region (r2->start,resource_size (r2), pdev->name); -if (!r2) { -dev_err (&pdev->dev,"cannot request memory region\n" ); - error = -EBUSY ; - goto fail_unmap_control; - } - - wdt->feed_reg =ioremap (r2->start,resource_size (r2)); -if (!wdt->feed_reg) { -dev_err (&pdev->dev,"failed to map memory\n" ); - error = -ENODEV ; - goto fail_free_feed; - } + wdt->feed_reg =devm_ioremap_resource (&pdev->dev, r2); +if (IS_ERR (wdt->feed_reg)) +return PTR_ERR (wdt->feed_reg);platform_set_drvdata (pdev, wdt); ts72xx_wdt_pdev = pdev;
@@ -455,45 +433,25 @@ static int ts72xx_wdt_probe(struct platform_device *pdev) error =misc_register (&ts72xx_wdt_miscdev);if (error) {dev_err (&pdev->dev,"failed to register miscdev\n" ); - goto fail_unmap_feed; + goto fail; }dev_info (&pdev->dev,"TS-72xx Watchdog driver\n" );return 0 ; -fail_unmap_feed: -platform_set_drvdata (pdev,NULL ); -iounmap (wdt->feed_reg); -fail_free_feed: -release_mem_region (r2->start,resource_size (r2)); -fail_unmap_control: -iounmap (wdt->control_reg); -fail_free_control: -release_mem_region (r1->start,resource_size (r1)); fail: -kfree (wdt); +platform_set_drvdata (pdev,NULL );return error; }static int ts72xx_wdt_remove (struct platform_device *pdev) { -struct ts72xx_wdt *wdt =platform_get_drvdata (pdev); -struct resource *res;int error; error =misc_deregister (&ts72xx_wdt_miscdev);platform_set_drvdata (pdev,NULL ); -iounmap (wdt->feed_reg); - res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -release_mem_region (res->start,resource_size (res)); - -iounmap (wdt->control_reg); - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -release_mem_region (res->start,resource_size (res)); - -kfree (wdt);return error; }
Signature · 1 line
1.7.2.5