ata_piix: Add HP Compaq nc6000 to the broken poweroff list
[safe/jmp/linux-2.6] / drivers / clocksource / acpi_pm.c
index 4eee533..40bd8c6 100644 (file)
@@ -57,12 +57,7 @@ u32 acpi_pm_read_verified(void)
        return v2;
 }
 
-static cycle_t acpi_pm_read_slow(void)
-{
-       return (cycle_t)acpi_pm_read_verified();
-}
-
-static cycle_t acpi_pm_read(void)
+static cycle_t acpi_pm_read(struct clocksource *cs)
 {
        return (cycle_t)read_pmtmr();
 }
@@ -88,6 +83,11 @@ static int __init acpi_pm_good_setup(char *__str)
 }
 __setup("acpi_pm_good", acpi_pm_good_setup);
 
+static cycle_t acpi_pm_read_slow(struct clocksource *cs)
+{
+       return (cycle_t)acpi_pm_read_verified();
+}
+
 static inline void acpi_pm_need_workaround(void)
 {
        clocksource_acpi_pm.read = acpi_pm_read_slow;
@@ -143,7 +143,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_LE,
 #endif
 
 #ifndef CONFIG_X86_64
-#include "mach_timer.h"
+#include <asm/mach_timer.h>
 #define PMTMR_EXPECTED_RATE \
   ((CALIBRATE_LATCH * (PMTMR_TICKS_PER_SEC >> 10)) / (CLOCK_TICK_RATE>>10))
 /*
@@ -156,9 +156,9 @@ static int verify_pmtmr_rate(void)
        unsigned long count, delta;
 
        mach_prepare_counter();
-       value1 = clocksource_acpi_pm.read();
+       value1 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
        mach_countup(&count);
-       value2 = clocksource_acpi_pm.read();
+       value2 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
        delta = (value2 - value1) & ACPI_PM_MASK;
 
        /* Check that the PMTMR delta is within 5% of what we expect */
@@ -178,11 +178,13 @@ static int verify_pmtmr_rate(void)
 
 /* Number of monotonicity checks to perform during initialization */
 #define ACPI_PM_MONOTONICITY_CHECKS 10
+/* Number of reads we try to get two different values */
+#define ACPI_PM_READ_CHECKS 10000
 
 static int __init init_acpi_pm_clocksource(void)
 {
        cycle_t value1, value2;
-       unsigned int i, j, good = 0;
+       unsigned int i, j = 0;
 
        if (!pmtmr_ioport)
                return -ENODEV;
@@ -192,29 +194,26 @@ static int __init init_acpi_pm_clocksource(void)
 
        /* "verify" this timing source: */
        for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) {
-               value1 = clocksource_acpi_pm.read();
-               for (i = 0; i < 10000; i++) {
-                       value2 = clocksource_acpi_pm.read();
+               udelay(100 * j);
+               value1 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
+               for (i = 0; i < ACPI_PM_READ_CHECKS; i++) {
+                       value2 = clocksource_acpi_pm.read(&clocksource_acpi_pm);
                        if (value2 == value1)
                                continue;
                        if (value2 > value1)
-                               good++;
                                break;
                        if ((value2 < value1) && ((value2) < 0xFFF))
-                               good++;
                                break;
                        printk(KERN_INFO "PM-Timer had inconsistent results:"
                               " 0x%#llx, 0x%#llx - aborting.\n",
                               value1, value2);
                        return -EINVAL;
                }
-               udelay(300 * i);
-       }
-
-       if (good != ACPI_PM_MONOTONICITY_CHECKS) {
-               printk(KERN_INFO "PM-Timer failed consistency check "
-                      " (0x%#llx) - aborting.\n", value1);
-               return -ENODEV;
+               if (i == ACPI_PM_READ_CHECKS) {
+                       printk(KERN_INFO "PM-Timer failed consistency check "
+                              " (0x%#llx) - aborting.\n", value1);
+                       return -ENODEV;
+               }
        }
 
        if (verify_pmtmr_rate() != 0)
@@ -238,9 +237,12 @@ static int __init parse_pmtmr(char *arg)
 
        if (strict_strtoul(arg, 16, &base))
                return -EINVAL;
-
+#ifdef CONFIG_X86_64
+       if (base > UINT_MAX)
+               return -ERANGE;
+#endif
        printk(KERN_INFO "PMTMR IOPort override: 0x%04x -> 0x%04lx\n",
-              (unsigned int)pmtmr_ioport, base);
+              pmtmr_ioport, base);
        pmtmr_ioport = base;
 
        return 1;