Re: PATCH 2.3.41.2: Replace Via support for ACPI

From: Martin Mares (mj@suse.cz)
Date: Mon Jan 24 2000 - 05:39:10 EST


Hi Jeff,

> Attached is a patch against 2.3.41-pre2 which adds back Via support. It
> does so using the new PCI table-driven device matching code, which
> should make it easy to add other chipsets.

   I don't understand why did you introduce the acpi_chip_info[] table
and especially why does it contain CH_xxx constants which are equivalent
to entry indices. To me, it looks best to use the driver data field
in acpi_pci_tbl[] to point directly to the init function.

   Here I attach my patch to an older version of the ACPI driver, feel
free to adapt it for the new version.

                                Have a nice fortnight

-- 
Martin `MJ' Mares <mj@ucw.cz> <mj@suse.cz> http://atrey.karlin.mff.cuni.cz/~mj/
"IBM = Inferior, But Marketable"

--- arch/i386/kernel/acpi.c.mj Fri Jan 14 12:02:56 2000 +++ arch/i386/kernel/acpi.c Fri Jan 14 12:11:47 2000 @@ -516,7 +516,7 @@ pci_read_config_byte(dev, ACPI_PIIX4_PMREGMISC, &pmregmisc); if (!(pmregmisc & ACPI_PIIX4_PMIOSE)) return -ENODEV; - + pci_read_config_dword(dev, 0x40, &base); if (!(base & PCI_BASE_ADDRESS_SPACE_IO)) return -ENODEV; @@ -572,7 +572,7 @@ if (!(tmp & 0x80)) return -ENODEV; - pci_read_config_byte(dev, 8, &tmp); + pci_read_config_byte(dev, PCI_CLASS_REVISION, &tmp); tmp = (tmp & 0x10 ? 0x48 : 0x20); pci_read_config_dword(dev, tmp, &base); @@ -626,31 +626,35 @@ return 0; } -static struct pci_simple_probe_entry acpi_devices[] __initdata = +static struct pci_device_id acpi_id_table[] __initdata = { - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, 0, 0, - acpi_init_piix4}, - {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, 0, 0, - acpi_init_via}, + {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + (unsigned long) acpi_init_piix4}, + {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, + (unsigned long) acpi_init_via}, {0,} }; /* * Probe for matching PCI device */ -static int __init acpi_probe(struct pci_dev *dev, - int match, - const struct pci_simple_probe_entry *entry, - void *data) -{ - if(entry->dev_data) { - typedef int (*init_fn)(struct pci_dev*); - init_fn init = (init_fn) entry->dev_data; - return (*init)(dev); - } - return -ENODEV; +static int __init acpi_probe(struct pci_dev *dev, struct pci_device_id *id) +{ + typedef int (*init_fn)(struct pci_dev*); + init_fn init = (init_fn) id->driver_data; + return (*init)(dev); } +static struct pci_driver acpi_driver = { + name: "acpi", + id_table: acpi_id_table, + probe: acpi_probe +}; + +static int acpi_chipset_known; + /* * Handle an ACPI SCI (fixed or general purpose event) */ @@ -1254,10 +1258,11 @@ if (acpi_disabled) return -ENODEV; - if (acpi_find_tables() - && pci_simple_probe(acpi_devices, 0, acpi_probe, NULL) <= 0) { - // no ACPI tables and not a recognized ACPI chipset - return -ENODEV; + if (acpi_find_tables()) { + // no ACPI tables, try to recognize the chipset + if (!pci_register_driver(&acpi_driver)) + return -ENODEV; + acpi_chipset_known = 1; } /* @@ -1287,6 +1292,8 @@ printk(KERN_ERR "ACPI: SCI (IRQ%d) allocation failed\n", acpi_facp->sci_int); acpi_destroy_tables(); + if (acpi_chipset_known) + pci_unregister_driver(&acpi_driver); return -ENODEV; } @@ -1333,6 +1340,8 @@ free_irq(acpi_facp->sci_int, acpi_facp); acpi_destroy_tables(); + if (acpi_chipset_known) + pci_unregister_driver(&acpi_driver); } static int __init acpi_setup(char *str)

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jan 31 2000 - 21:00:11 EST