Merge branch 'master' into for_paulus
[linux-drm-fsl-dcu.git] / arch / i386 / kernel / hpet.c
index c6737c35815db8fff2ede01f0322773eda864a34..0b29d41322a2620c50a0bdc98fa1ec314d397ac9 100644 (file)
@@ -12,7 +12,7 @@
 /* FSEC = 10^-15 NSEC = 10^-9 */
 #define FSEC_PER_NSEC  1000000
 
-static void *hpet_ptr;
+static void __iomem *hpet_ptr;
 
 static cycle_t read_hpet(void)
 {
@@ -34,13 +34,13 @@ static int __init init_hpet_clocksource(void)
        unsigned long hpet_period;
        void __iomem* hpet_base;
        u64 tmp;
+       int err;
 
-       if (!hpet_address)
+       if (!is_hpet_enabled())
                return -ENODEV;
 
        /* calculate the hpet address: */
-       hpet_base =
-               (void __iomem*)ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
+       hpet_base = ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
        hpet_ptr = hpet_base + HPET_COUNTER;
 
        /* calculate the frequency: */
@@ -61,7 +61,11 @@ static int __init init_hpet_clocksource(void)
        do_div(tmp, FSEC_PER_NSEC);
        clocksource_hpet.mult = (u32)tmp;
 
-       return clocksource_register(&clocksource_hpet);
+       err = clocksource_register(&clocksource_hpet);
+       if (err)
+               iounmap(hpet_base);
+
+       return err;
 }
 
 module_init(init_hpet_clocksource);