Pull button into test branch
[linux-drm-fsl-dcu.git] / arch / i386 / kernel / hpet.c
index 23e7d2c5d25315eefae9b1bbbe3aafd0a2c279d4..45a8685bb60bb5e21e638cd6c0b6df95586606f2 100644 (file)
@@ -6,7 +6,7 @@
 #include <asm/hpet.h>
 #include <asm/io.h>
 
-#define HPET_MASK      0xFFFFFFFF
+#define HPET_MASK      CLOCKSOURCE_MASK(32)
 #define HPET_SHIFT     22
 
 /* FSEC = 10^-15 NSEC = 10^-9 */
@@ -23,7 +23,7 @@ static struct clocksource clocksource_hpet = {
        .name           = "hpet",
        .rating         = 250,
        .read           = read_hpet,
-       .mask           = (cycle_t)HPET_MASK,
+       .mask           = HPET_MASK,
        .mult           = 0, /* set below */
        .shift          = HPET_SHIFT,
        .is_continuous  = 1,
@@ -34,8 +34,9 @@ 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: */
@@ -61,7 +62,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);