From: OGAWA Hirofumi Now, init_acpi_pm_clocksource() is called via module_init() as usual driver (i.e. called after pci_fixup_device(pci_fixup_early)), so we can simply use DECLARE_PCI_FIXUP_EARLY(). This cleanups and tweaks it. NOTE: this renames "pmtmr_good" to "acpi_pm_good", it seems to be in consistency with "clocksource=acpi_pm". Signed-off-by: OGAWA Hirofumi Cc: john stultz Signed-off-by: Andrew Morton --- drivers/clocksource/acpi_pm.c | 90 ++++++++++++++------------------ 1 files changed, 41 insertions(+), 49 deletions(-) diff -puN drivers/clocksource/acpi_pm.c~time-i386-clocksource-drivers-pm-timer-doesnt-use-workaround-if-chipset-is-not-buggy-acpi_pm-cleanup drivers/clocksource/acpi_pm.c --- devel/drivers/clocksource/acpi_pm.c~time-i386-clocksource-drivers-pm-timer-doesnt-use-workaround-if-chipset-is-not-buggy-acpi_pm-cleanup 2006-03-25 15:31:41.000000000 -0800 +++ devel-akpm/drivers/clocksource/acpi_pm.c 2006-03-25 15:31:41.000000000 -0800 @@ -31,7 +31,6 @@ * in arch/i386/acpi/boot.c */ u32 pmtmr_ioport; -static int pmtmr_need_workaround = 1; #define ACPI_PM_MASK 0xFFFFFF /* limit it to 24 bits */ @@ -78,6 +77,20 @@ static struct clocksource clocksource_ac #ifdef CONFIG_PCI +static int acpi_pm_good; +static int __init acpi_pm_good_setup(char *__str) +{ + acpi_pm_good = 1; + return 1; +} +__setup("acpi_pm_good", acpi_pm_good_setup); + +static inline void acpi_pm_need_workaround(void) +{ + clocksource_acpi_pm.read = acpi_pm_read_verified; + clocksource_acpi_pm.rating = 110; +} + /* * PIIX4 Errata: * @@ -88,59 +101,44 @@ static struct clocksource clocksource_ac * incorrect when read). As a result, the ACPI free running count up * timer specification is violated due to erroneous reads. */ -static void __init pmtmr_bug_check(void) +static void __devinit acpi_pm_check_blacklist(struct pci_dev *dev) { - static struct pci_device_id gray_list[] __initdata = { - /* these chipsets may have bug. */ - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_INTEL_82801DB_0) }, - { }, - }; - struct pci_dev *dev; - int pmtmr_has_bug = 0; u8 rev; - if (!pmtmr_need_workaround) + if (acpi_pm_good) return; - dev = pci_get_device(PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_INTEL_82371AB_3, NULL); - if (dev) { - pci_read_config_byte(dev, PCI_REVISION_ID, &rev); - /* the bug has been fixed in PIIX4M */ - if (rev < 3) { - printk(KERN_WARNING "* Found PM-Timer Bug on this" - " chipset. Due to workarounds for a bug,\n" - "* this time source is slow. Consider trying" - " other time sources (clock=)\n"); - pmtmr_has_bug = 1; - } - pci_dev_put(dev); - } + pci_read_config_byte(dev, PCI_REVISION_ID, &rev); + /* the bug has been fixed in PIIX4M */ + if (rev < 3) { + printk(KERN_WARNING "* Found PM-Timer Bug on the chipset." + " Due to workarounds for a bug,\n" + "* this clock source is slow. Consider trying" + " other clock sources\n"); - if (pci_dev_present(gray_list)) { - printk(KERN_WARNING "* This chipset may have PM-Timer Bug." - " Due to workarounds for a bug,\n" - "* this time source is slow. If you are sure your" - " timer does not have\n" - "* this bug, please use \"pmtmr_good\" to disable?" - " the workaround\n"); - pmtmr_has_bug = 1; + acpi_pm_need_workaround(); } - - if (!pmtmr_has_bug) - pmtmr_need_workaround = 0; } -#else -#define pmtmr_bug_check() -#endif +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, + acpi_pm_check_blacklist); -static int __init pmtr_good_setup(char *__str) +static void __devinit acpi_pm_check_graylist(struct pci_dev *dev) { - pmtmr_need_workaround = 0; - return 1; + if (acpi_pm_good) + return; + + printk(KERN_WARNING "* The chipset may have PM-Timer Bug. Due to" + " workarounds for a bug,\n" + "* this clock source is slow. If you are sure your timer" + " does not have\n" + "* this bug, please use \"acpi_pm_good\" to disable the" + " workaround\n"); + + acpi_pm_need_workaround(); } -__setup("pmtmr_good", pmtr_good_setup); +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, + acpi_pm_check_graylist); +#endif static int __init init_acpi_pm_clocksource(void) @@ -173,12 +171,6 @@ static int __init init_acpi_pm_clocksour return -ENODEV; pm_good: - pmtmr_bug_check(); - /* check to see if pmtmr is known buggy: */ - if (pmtmr_need_workaround) { - clocksource_acpi_pm.read = acpi_pm_read_verified; - clocksource_acpi_pm.rating = 110; - } return register_clocksource(&clocksource_acpi_pm); } _