Merge branch 'for-linus' of git://git390.marist.edu/pub/scm/linux-2.6
[safe/jmp/linux-2.6] / drivers / clocksource / sh_cmt.c
index 2964f5f..744f748 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
 #include <linux/sh_timer.h>
+#include <linux/slab.h>
 
 struct sh_cmt_priv {
        void __iomem *mapbase;
@@ -431,6 +432,11 @@ static void sh_cmt_clocksource_disable(struct clocksource *cs)
        sh_cmt_stop(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE);
 }
 
+static void sh_cmt_clocksource_resume(struct clocksource *cs)
+{
+       sh_cmt_start(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE);
+}
+
 static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
                                       char *name, unsigned long rating)
 {
@@ -441,6 +447,8 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
        cs->read = sh_cmt_clocksource_read;
        cs->enable = sh_cmt_clocksource_enable;
        cs->disable = sh_cmt_clocksource_disable;
+       cs->suspend = sh_cmt_clocksource_disable;
+       cs->resume = sh_cmt_clocksource_resume;
        cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
        cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
        pr_info("sh_cmt: %s used as clock source\n", cs->name);
@@ -602,18 +610,13 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
        p->irqaction.handler = sh_cmt_interrupt;
        p->irqaction.dev_id = p;
        p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL;
-       ret = setup_irq(irq, &p->irqaction);
-       if (ret) {
-               pr_err("sh_cmt: failed to request irq %d\n", irq);
-               goto err1;
-       }
 
        /* get hold of clock */
        p->clk = clk_get(&p->pdev->dev, cfg->clk);
        if (IS_ERR(p->clk)) {
                pr_err("sh_cmt: cannot get clock \"%s\"\n", cfg->clk);
                ret = PTR_ERR(p->clk);
-               goto err2;
+               goto err1;
        }
 
        if (resource_size(res) == 6) {
@@ -626,14 +629,25 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
                p->clear_bits = ~0xc000;
        }
 
-       return sh_cmt_register(p, cfg->name,
-                              cfg->clockevent_rating,
-                              cfg->clocksource_rating);
- err2:
-       remove_irq(irq, &p->irqaction);
- err1:
+       ret = sh_cmt_register(p, cfg->name,
+                             cfg->clockevent_rating,
+                             cfg->clocksource_rating);
+       if (ret) {
+               pr_err("sh_cmt: registration failed\n");
+               goto err1;
+       }
+
+       ret = setup_irq(irq, &p->irqaction);
+       if (ret) {
+               pr_err("sh_cmt: failed to request irq %d\n", irq);
+               goto err1;
+       }
+
+       return 0;
+
+err1:
        iounmap(p->mapbase);
- err0:
+err0:
        return ret;
 }