]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/watchdog/coh901327_wdt.c
net/mlx5e: Move mlx5e_rq struct declaration
[karo-tx-linux.git] / drivers / watchdog / coh901327_wdt.c
index 1385a920df4f19daf4617d738673d374b91a1854..38dd60f0cfcc636d0b5df5197c06ffcb9f09adbf 100644 (file)
@@ -68,8 +68,6 @@
 
 /* Default timeout in seconds = 1 minute */
 static unsigned int margin = 60;
-static resource_size_t phybase;
-static resource_size_t physize;
 static int irq;
 static void __iomem *virtbase;
 static struct device *parent;
@@ -248,79 +246,61 @@ static int __exit coh901327_remove(struct platform_device *pdev)
        free_irq(irq, pdev);
        clk_disable_unprepare(clk);
        clk_put(clk);
-       iounmap(virtbase);
-       release_mem_region(phybase, physize);
        return 0;
 }
 
 static int __init coh901327_probe(struct platform_device *pdev)
 {
+       struct device *dev = &pdev->dev;
        int ret;
        u16 val;
        struct resource *res;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res)
-               return -ENOENT;
-
-       parent = &pdev->dev;
-       physize = resource_size(res);
-       phybase = res->start;
-
-       if (request_mem_region(phybase, physize, DRV_NAME) == NULL) {
-               ret = -EBUSY;
-               goto out;
-       }
+       parent = dev;
 
-       virtbase = ioremap(phybase, physize);
-       if (!virtbase) {
-               ret = -ENOMEM;
-               goto out_no_remap;
-       }
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       virtbase = devm_ioremap_resource(dev, res);
+       if (IS_ERR(virtbase))
+               return PTR_ERR(virtbase);
 
-       clk = clk_get(&pdev->dev, NULL);
+       clk = clk_get(dev, NULL);
        if (IS_ERR(clk)) {
                ret = PTR_ERR(clk);
-               dev_err(&pdev->dev, "could not get clock\n");
-               goto out_no_clk;
+               dev_err(dev, "could not get clock\n");
+               return ret;
        }
        ret = clk_prepare_enable(clk);
        if (ret) {
-               dev_err(&pdev->dev, "could not prepare and enable clock\n");
+               dev_err(dev, "could not prepare and enable clock\n");
                goto out_no_clk_enable;
        }
 
        val = readw(virtbase + U300_WDOG_SR);
        switch (val) {
        case U300_WDOG_SR_STATUS_TIMED_OUT:
-               dev_info(&pdev->dev,
-                       "watchdog timed out since last chip reset!\n");
+               dev_info(dev, "watchdog timed out since last chip reset!\n");
                coh901327_wdt.bootstatus |= WDIOF_CARDRESET;
                /* Status will be cleared below */
                break;
        case U300_WDOG_SR_STATUS_NORMAL:
-               dev_info(&pdev->dev,
-                       "in normal status, no timeouts have occurred.\n");
+               dev_info(dev, "in normal status, no timeouts have occurred.\n");
                break;
        default:
-               dev_info(&pdev->dev,
-                       "contains an illegal status code (%08x)\n", val);
+               dev_info(dev, "contains an illegal status code (%08x)\n", val);
                break;
        }
 
        val = readw(virtbase + U300_WDOG_D2R);
        switch (val) {
        case U300_WDOG_D2R_DISABLE_STATUS_DISABLED:
-               dev_info(&pdev->dev, "currently disabled.\n");
+               dev_info(dev, "currently disabled.\n");
                break;
        case U300_WDOG_D2R_DISABLE_STATUS_ENABLED:
-               dev_info(&pdev->dev,
-                        "currently enabled! (disabling it now)\n");
+               dev_info(dev, "currently enabled! (disabling it now)\n");
                coh901327_disable();
                break;
        default:
-               dev_err(&pdev->dev,
-                       "contains an illegal enable/disable code (%08x)\n",
+               dev_err(dev, "contains an illegal enable/disable code (%08x)\n",
                        val);
                break;
        }
@@ -335,16 +315,16 @@ static int __init coh901327_probe(struct platform_device *pdev)
                goto out_no_irq;
        }
 
-       ret = watchdog_init_timeout(&coh901327_wdt, margin, &pdev->dev);
+       ret = watchdog_init_timeout(&coh901327_wdt, margin, dev);
        if (ret < 0)
                coh901327_wdt.timeout = 60;
 
-       coh901327_wdt.parent = &pdev->dev;
+       coh901327_wdt.parent = dev;
        ret = watchdog_register_device(&coh901327_wdt);
        if (ret)
                goto out_no_wdog;
 
-       dev_info(&pdev->dev, "initialized. timer margin=%d sec\n", margin);
+       dev_info(dev, "initialized. timer margin=%d sec\n", margin);
        return 0;
 
 out_no_wdog:
@@ -353,11 +333,6 @@ out_no_irq:
        clk_disable_unprepare(clk);
 out_no_clk_enable:
        clk_put(clk);
-out_no_clk:
-       iounmap(virtbase);
-out_no_remap:
-       release_mem_region(phybase, SZ_4K);
-out:
        return ret;
 }