Merge branch '85xx' into for_paulus
[powerpc.git] / arch / i386 / kernel / hpet.c
index 23e7d2c..0b29d41 100644 (file)
@@ -6,13 +6,13 @@
 #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 */
 #define FSEC_PER_NSEC  1000000
 
-static void *hpet_ptr;
+static void __iomem *hpet_ptr;
 
 static cycle_t read_hpet(void)
 {
@@ -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,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);