More PCI fixes for 2.5.70
Subsystems (4)
PATCH 1/1 More PCI fixes for 2.5.70
Hi,
Here's some more PCI changes against the latest 2.5.70 bk tree. They contain the following:
- fix up the fusion driver due to errors from my last round of pci patches.
- remove last direct accesses of the pci_devices variable.
Now the pci_devices variable is not exported for drivers to touch directly. Only the pci core and arch specific pci code should access this variable.
Please pull from:
bk://kernel.bkbits.net/gregkh/linux/pci-2.5
thanks,
greg k-h
p.s. I'll send these as patches in response to this email to lkml for those who want to see them.
arch/m68k/atari/hades-pci.c | 4 +-- drivers/ide/setup-pci.c | 2 - drivers/macintosh/via-pmu68k.c | 11 +++++---- drivers/message/fusion/linux_compat.h | 7 +---- drivers/message/fusion/mptbase.c | 2 - drivers/pci/probe.c | 1 drivers/pci/search.c | 40 ++++++++++++++++++++++++++++++++++ include/linux/pci.h | 20 +++++++---------- 8 files changed, 61 insertions(+), 26 deletions(-)
-----
Greg Kroah-Hartman:
o PCI: remove EXPORT_SYMBOL(pci_devices)
o PCI: move pci_present() into drivers/pci/search.c
o PCI: remove pci_for_each_dev_reverse() now that all users of it are gone
o PCI: remove usage of pci_for_each_dev_reverse() in
o PCI: add pci_find_device_reverse() for users of pci_find_each_dev_reverse() to use
o PCI: fix up previous fusion driver pci changes
o PCI: remove direct access of pci_devices from drivers/macintosh/via-pmu68k.c
o PCI: remove direct access of pci_devices from arch/m68k/atari/hades-pci.c
PATCH 1/1 More PCI fixes for 2.5.70
ChangeSet 1.1311, 2003/06/05 12:03:29-07:00, [email protected]
[PATCH] PCI: remove direct access of pci_devices from arch/m68k/atari/hades-pci.c
arch/m68k/atari/hades-pci.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/m68k/atari/hades-pci.c +2 -2
@@ -297,14 +297,14 @@IRQ_TT_MFP_SCC ,/* Slot 2. */ IRQ_TT_MFP_SCSIDMA /* Slot 3. */ }; -struct pci_dev *dev; +struct pci_dev *dev =NULL ;unsigned char slot;/* * Go through all devices, fixing up irqs as we see fit: */ -for (dev = pci_devices; dev; dev = dev->next) +while ((dev =pci_find_device (PCI_ANY_ID ,PCI_ANY_ID , dev)) !=NULL ) {if (dev->class >>16 !=PCI_BASE_CLASS_BRIDGE ) {
ChangeSet 1.1312, 2003/06/05 12:03:40-07:00, [email protected]
[PATCH] PCI: remove direct access of pci_devices from drivers/macintosh/via-pmu68k.c
Yeah, this is commented out code, but just trying to be complete...
drivers/macintosh/via-pmu68k.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/macintosh/via-pmu68k.c +6 -5
@@ -839,11 +839,11 @@pbook_pci_save (void) {int npci; -struct pci_dev *pd; +struct pci_dev *pd =NULL ;struct pci_save *ps; npci =0 ; -for (pd = pci_devices; pd !=NULL ; pd = pd->next) +while ((pd =pci_find_device (PCI_ANY_ID ,PCI_ANY_ID , pd)) !=NULL ) ++npci; n_pbook_pci_saves = npci;if (npci ==0 )
@@ -853,7 +853,8 @@if (ps ==NULL )return ; -for (pd = pci_devices; pd !=NULL && npci !=0 ; pd = pd->next) { + pd =NULL ; +while ((pd =pci_find_device (PCI_ANY_ID ,PCI_ANY_ID , pd)) !=NULL ) {pci_read_config_word (pd,PCI_COMMAND , &ps->command);pci_read_config_word (pd,PCI_CACHE_LINE_SIZE , &ps->cache_lat);pci_read_config_word (pd,PCI_INTERRUPT_LINE , &ps->intr);
@@ -867,10 +868,10 @@ {u16 cmd;struct pci_save *ps = pbook_pci_saves; -struct pci_dev *pd; +struct pci_dev *pd =NULL ;int j; -for (pd = pci_devices; pd !=NULL ; pd = pd->next, ++ps) { +while ((pd =pci_find_device (PCI_ANY_ID ,PCI_ANY_ID , pd)) !=NULL ) {if (ps->command ==0 )continue ;pci_read_config_word (pd,PCI_COMMAND , &cmd);
ChangeSet 1.1313, 2003/06/05 12:03:52-07:00, [email protected]
[PATCH] PCI: fix up previous fusion driver pci changes
This makes the driver build properly now, and removes a direct access of the pci_devices variable.
drivers/message/fusion/linux_compat.h | 7 ++----- drivers/message/fusion/mptbase.c | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/message/fusion/linux_compat.h +2 -5
@@ -147,9 +147,7 @@/* PCI/driver subsystem { */ -#ifndef pci_for_each_dev -#define pci_for_each_dev (dev) for((dev)=pci_devices; (dev)!=NULL; (dev)=(dev)->next) -#define pci_peek_next_dev (dev) ((dev)->next ? (dev)->next : NULL) +#if 0 /* FIXME Don't know what to use to check for the proper kernel version */ #define DEVICE_COUNT_RESOURCE 6#define PCI_BASEADDR_FLAGS (idx) base_address[idx]#define PCI_BASEADDR_START (idx) base_address[idx] & ~0xFUL
@@ -169,11 +167,10 @@ (4 - size); \ })#else -#define pci_peek_next_dev (dev) ((dev) != pci_dev_g(&pci_devices) ? pci_dev_g((dev)->global_list.next) : NULL)#define PCI_BASEADDR_FLAGS (idx) resource[idx].flags#define PCI_BASEADDR_START (idx) resource[idx].start#define PCI_BASEADDR_SIZE (dev,idx) (dev)->resource[idx].end - (dev)->resource[idx].start + 1 -#endif /* } ifndef pci_for_each_dev */ +#endif /* } ifndef 0 */ /* Compatability for the 2.3.x PCI DMA API. */
drivers/message/fusion/mptbase.c +1 -1
@@ -1184,7 +1184,7 @@* Do some kind of look ahead here... */ if (pdev->devfn &1 ) { - pdev2 =pci_peek_next_dev (pdev); + pdev2 =pci_find_device (PCI_ANY_ID ,PCI_ANY_ID , pdev); if (pdev2 && (pdev2->vendor == 0x1000) && (PCI_SLOT(pdev2->devfn) == PCI_SLOT(pdev->devfn)) && (pdev2->device == pdev->device) &&
ChangeSet 1.1314, 2003/06/05 12:04:02-07:00, [email protected]
[PATCH] PCI: add pci_find_device_reverse() for users of pci_find_each_dev_reverse() to use
drivers/pci/search.c | 29 +++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 30 insertions(+)
drivers/pci/search.c +29 -0
@@ -118,6 +118,34 @@/** +* pci_find_device_reverse - begin or continue searching for a PCI device by vendor/device id +* @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids +* @device: PCI device id to match, or %PCI_ANY_ID to match all device ids +* @from: Previous PCI device found in search, or %NULL for new search. +* +* Iterates through the list of known PCI devices in the reverse order of pci_find_device(). +* If a PCI device is found with a matching @vendor and @device, a pointer to +* its device structure is returned. Otherwise, %NULL is returned. +* A new search is initiated by passing %NULL to the @from argument. +* Otherwise if @from is not %NULL, searches continue from previous device on the global list. +*/ +struct pci_dev * +pci_find_device_reverse (unsigned int vendor,unsigned int device,const struct pci_dev *from) +{ +struct list_head *n = from ? from->global_list.prev : pci_devices.prev; + +while (n != &pci_devices) { +struct pci_dev *dev =pci_dev_g (n); +if ((vendor ==PCI_ANY_ID || dev->vendor == vendor) && + (device ==PCI_ANY_ID || dev->device == device)) +return dev; + n = n->prev; + } +return NULL ; +} + + +/** * pci_find_class - begin or continue searching for a PCI device by class * @class: search for a PCI device with this class designation * @from: Previous PCI device found in search, or %NULL for new search.
@@ -146,5 +174,6 @@EXPORT_SYMBOL (pci_find_bus);EXPORT_SYMBOL (pci_find_class);EXPORT_SYMBOL (pci_find_device); +EXPORT_SYMBOL (pci_find_device_reverse);EXPORT_SYMBOL (pci_find_slot);EXPORT_SYMBOL (pci_find_subsys);
include/linux/pci.h +1 -0
@@ -564,6 +564,7 @@/* Generic PCI functions exported to card drivers */ struct pci_dev *pci_find_device (unsigned int vendor,unsigned int device,const struct pci_dev *from); +struct pci_dev *pci_find_device_reverse (unsigned int vendor,unsigned int device,const struct pci_dev *from);struct pci_dev *pci_find_subsys (unsigned int vendor,unsigned int device,unsigned int ss_vendor,unsigned int ss_device,const struct pci_dev *from);
ChangeSet 1.1315, 2003/06/05 12:04:12-07:00, [email protected]
[PATCH] PCI: remove usage of pci_for_each_dev_reverse() in
drivers/ide/setup-pci.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/ide/setup-pci.c +1 -1
@@ -880,7 +880,7 @@ide_scan_pcidev (dev); } }else { -pci_for_each_dev_reverse (dev) { +while ((dev =pci_find_device_reverse (PCI_ANY_ID ,PCI_ANY_ID , dev)) !=NULL ) {ide_scan_pcidev (dev); } }
ChangeSet 1.1316, 2003/06/05 12:04:22-07:00, [email protected]
[PATCH] PCI: remove pci_for_each_dev_reverse() now that all users of it are gone.
include/linux/pci.h | 2 -- 1 files changed, 2 deletions(-)
include/linux/pci.h +0 -2
@@ -527,8 +527,6 @@return !list_empty (&pci_devices); } -#define pci_for_each_dev_reverse (dev) \ - for(dev = pci_dev_g(pci_devices.prev); dev != pci_dev_g(&pci_devices); dev = pci_dev_g(dev->global_list.prev))#define pci_for_each_bus (bus) \ for(bus = pci_bus_b(pci_root_buses.next); bus != pci_bus_b(&pci_root_buses); bus = pci_bus_b(bus->node.next))
ChangeSet 1.1317, 2003/06/05 12:04:33-07:00, [email protected]
[PATCH] PCI: move pci_present() into drivers/pci/search.c
This will let not have to export the pci_devices variable.
drivers/pci/search.c | 11 +++++++++++ include/linux/pci.h | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-)
drivers/pci/search.c +11 -0
@@ -171,9 +171,20 @@return NULL ; } +/** +* pci_present - determine if there are any pci devices on this system +* +* Returns 0 if no pci devices are present, 1 if pci devices are present. +*/ +int pci_present (void ) +{ +return !list_empty (&pci_devices); +} +EXPORT_SYMBOL (pci_find_bus);EXPORT_SYMBOL (pci_find_class);EXPORT_SYMBOL (pci_find_device);EXPORT_SYMBOL (pci_find_device_reverse);EXPORT_SYMBOL (pci_find_slot);EXPORT_SYMBOL (pci_find_subsys); +EXPORT_SYMBOL (pci_present);
include/linux/pci.h +1 -5
@@ -522,14 +522,10 @@/* these external functions are only available when PCI support is enabled */ #ifdef CONFIG_PCI -static inline int pci_present (void ) -{ -return !list_empty (&pci_devices); -} -#define pci_for_each_bus (bus) \ for(bus = pci_bus_b(pci_root_buses.next); bus != pci_bus_b(&pci_root_buses); bus = pci_bus_b(bus->node.next)) +int pci_present (void );void pcibios_fixup_bus (struct pci_bus *);int pcibios_enable_device (struct pci_dev *,int mask);char *pcibios_setup (char *str);
ChangeSet 1.1318, 2003/06/05 12:04:44-07:00, [email protected]
[PATCH] PCI: remove EXPORT_SYMBOL(pci_devices)
Now the only users of this directly should be the pci core and arch specific pci core code.
drivers/pci/probe.c | 1 - include/linux/pci.h | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/pci/probe.c +0 -1
@@ -689,7 +689,6 @@ }EXPORT_SYMBOL (pci_scan_bus_parented); -EXPORT_SYMBOL (pci_devices);EXPORT_SYMBOL (pci_root_buses);#ifdef CONFIG_HOTPLUG
include/linux/pci.h +7 -4
@@ -468,10 +468,6 @@#define pci_bus_b (n) list_entry(n, struct pci_bus, node) -extern struct list_head pci_root_buses;/* list of all known PCI buses */ -extern struct list_head pci_devices;/* list of all devices */ -extern struct bus_type pci_bus_type; -/* * Error values that may be returned by PCI functions. */
@@ -521,6 +517,13 @@/* these external functions are only available when PCI support is enabled */ #ifdef CONFIG_PCI + +extern struct bus_type pci_bus_type; + +/* Do NOT directly access these two variables, unless you are arch specific pci +* code, or pci core code. */ +extern struct list_head pci_root_buses;/* list of all known PCI buses */ +extern struct list_head pci_devices;/* list of all devices */ #define pci_for_each_bus (bus) \ for(bus = pci_bus_b(pci_root_buses.next); bus != pci_bus_b(&pci_root_buses); bus = pci_bus_b(bus->node.next))