clocksource: Convert tcb_clksrc to use clocksource_register_hz/khz
[linux-2.6.git] / drivers / clocksource / sh_tmu.c
index 44c39a3..8081357 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
 #include <linux/sh_timer.h>
+#include <linux/slab.h>
 
 struct sh_tmu_priv {
        void __iomem *mapbase;
@@ -201,13 +202,9 @@ static int sh_tmu_clocksource_enable(struct clocksource *cs)
        int ret;
 
        ret = sh_tmu_enable(p);
-       if (ret)
-               return ret;
-
-       /* TODO: calculate good shift from rate and counter bit width */
-       cs->shift = 10;
-       cs->mult = clocksource_hz2mult(p->rate, cs->shift);
-       return 0;
+       if (!ret)
+               __clocksource_updatefreq_hz(cs, p->rate);
+       return ret;
 }
 
 static void sh_tmu_clocksource_disable(struct clocksource *cs)
@@ -227,8 +224,11 @@ static int sh_tmu_register_clocksource(struct sh_tmu_priv *p,
        cs->disable = sh_tmu_clocksource_disable;
        cs->mask = CLOCKSOURCE_MASK(32);
        cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
+
        dev_info(&p->pdev->dev, "used as clock source\n");
-       clocksource_register(cs);
+
+       /* Register with dummy 1 Hz value, gets updated in ->enable() */
+       clocksource_register_hz(cs, 1);
        return 0;
 }
 
@@ -390,13 +390,9 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev)
        /* get hold of clock */
        p->clk = clk_get(&p->pdev->dev, "tmu_fck");
        if (IS_ERR(p->clk)) {
-               dev_warn(&p->pdev->dev, "using deprecated clock lookup\n");
-               p->clk = clk_get(&p->pdev->dev, cfg->clk);
-               if (IS_ERR(p->clk)) {
-                       dev_err(&p->pdev->dev, "cannot get clock\n");
-                       ret = PTR_ERR(p->clk);
-                       goto err1;
-               }
+               dev_err(&p->pdev->dev, "cannot get clock\n");
+               ret = PTR_ERR(p->clk);
+               goto err1;
        }
 
        return sh_tmu_register(p, (char *)dev_name(&p->pdev->dev),