From d11a7d361e1e7af1cbc0d92dccc54193cb5b4165 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Mon, 28 Feb 2005 00:07:24 +0000 Subject: [PATCH] implementation of pci_find_subsys for old kernels from abbotti@mev.co.uk (Ian Abbott), and #defines for pci_get_subsys() and pci_dev_put() from me. --- include/linux/pci.h | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/include/linux/pci.h b/include/linux/pci.h index b4edba12..828a0469 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -142,15 +142,35 @@ static inline void pci_release_regions(struct pci_dev *dev) } } +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,15) static inline 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) { - rt_printk( "pci_find_subsys() not supported in kernels older than 2.4!\n" ); - return NULL; + struct pci_dev *dev = (struct pci_dev *)from; /* ignore const */ + + while((dev=pci_find_device(vendor,device,dev))!=NULL){ + if(ss_vendor!=PCI_ANY_ID){ + u16 temp; + pci_read_config_word(dev,PCI_SUBSYSTEM_VENDOR_ID,&temp); + if(ss_vendor!=temp){ + continue; + } + } + if(ss_device!=PCI_ANY_ID){ + u16 temp; + pci_read_config_word(dev,PCI_SUBSYSTEM_ID,&temp); + if(ss_device!=temp){ + continue; + } + } + break; /* match */ + } + return dev; } - -#endif +#endif // <2.3.15 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,14) static inline void pci_set_master(struct pci_dev *dev) @@ -162,6 +182,11 @@ static inline unsigned long pci_resource_len (struct pci_dev *dev, int n_base) { return 0; } #endif // 2.2.18 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +#define pci_get_subsys pci_find_subsys +#define pci_dev_put(x) +#endif + #endif #endif /* _COMPAT_PCI_H */ -- 2.26.2