From: Frank Mori Hess Date: Sat, 22 Jan 2005 14:22:18 +0000 (+0000) Subject: got rid of pci_for_each_dev macro (which no longer exists in 2.6 X-Git-Tag: r0_7_70~62 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a97ac36ecd17dbab9146120a3b97f5c229b85907;p=comedi.git got rid of pci_for_each_dev macro (which no longer exists in 2.6 kernels) --- diff --git a/comedi/drivers/adl_pci6208.c b/comedi/drivers/adl_pci6208.c index 962c9f8d..c3a455c4 100644 --- a/comedi/drivers/adl_pci6208.c +++ b/comedi/drivers/adl_pci6208.c @@ -303,8 +303,8 @@ pci6208_find_device(comedi_device *dev, int bus, int slot) struct pci_dev *pci_dev; int i; - pci_for_each_dev(pci_dev) - { + for(pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pci_dev != NULL ; + pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { if (pci_dev->vendor == PCI_VENDOR_ID_ADLINK) { for (i= 0; i< pci6208_board_nbr; i++) diff --git a/comedi/drivers/adl_pci9111.c b/comedi/drivers/adl_pci9111.c index 734807ff..b21f483a 100644 --- a/comedi/drivers/adl_pci9111.c +++ b/comedi/drivers/adl_pci9111.c @@ -1192,143 +1192,143 @@ static int pci9111_reset (comedi_device *dev) static int pci9111_attach(comedi_device *dev,comedi_devconfig *it) { - - comedi_subdevice *subdevice; - int io_base, io_range, lcr_io_base, lcr_io_range; - struct pci_dev* pci_device; - int error,i; - pci9111_board_struct* board; - -// -// Probe the device to determine what device in the series it is. -// - - printk("comedi%d: " PCI9111_DRIVER_NAME " driver\n",dev->minor); - - pci_for_each_dev(pci_device) - { - if (pci_device->vendor == PCI_VENDOR_ID_ADLINK) - { - for (i= 0; i< pci9111_board_nbr; i++) - { - if(pci9111_boards[i].device_id == pci_device->device) + comedi_subdevice *subdevice; + int io_base, io_range, lcr_io_base, lcr_io_range; + struct pci_dev* pci_device; + int error,i; + pci9111_board_struct* board; + + // + // Probe the device to determine what device in the series it is. + // + + printk("comedi%d: " PCI9111_DRIVER_NAME " driver\n",dev->minor); + + for(pci_device = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pci_device != NULL ; + pci_device = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) { - // was a particular bus/slot requested? - if((it->options[0] != 0) || (it->options[1] != 0)) - { - // are we on the wrong bus/slot? - if(pci_device->bus->number != it->options[0] || - PCI_SLOT(pci_device->devfn) != it->options[1]) - { - continue; - } - } - - dev->board_ptr = pci9111_boards + i; - board = (pci9111_board_struct *) dev->board_ptr; - goto found; + if (pci_device->vendor == PCI_VENDOR_ID_ADLINK) + { + for (i= 0; i< pci9111_board_nbr; i++) + { + if(pci9111_boards[i].device_id == pci_device->device) + { + // was a particular bus/slot requested? + if((it->options[0] != 0) || (it->options[1] != 0)) + { + // are we on the wrong bus/slot? + if(pci_device->bus->number != it->options[0] || + PCI_SLOT(pci_device->devfn) != it->options[1]) + { + continue; + } + } + + dev->board_ptr = pci9111_boards + i; + board = (pci9111_board_struct *) dev->board_ptr; + goto found; + } + } + } } - } - } - } - - printk ("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", - dev->minor,it->options[0], it->options[1]); - return -EIO; - + + printk ("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", + dev->minor,it->options[0], it->options[1]); + return -EIO; + found: - - printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n", - dev->minor, - pci9111_boards[i].name, - pci_device->bus->number, - PCI_SLOT(pci_device->devfn), - PCI_FUNC(pci_device->devfn), - pci_device->irq); - - // TODO: Warn about non-tested boards. - - switch(board->device_id) - { - }; - - // Read local configuration register base address [PCI_BASE_ADDRESS #1]. - - lcr_io_base = pci_resource_start (pci_device, 1); - lcr_io_range = pci_resource_end (pci_device, 1) - lcr_io_base +1; - - printk ("comedi%d: local configuration registers at address 0x%4x [0x%4x]\n", - dev->minor, - lcr_io_base, - lcr_io_range); - - // Read PCI6308 register base address [PCI_BASE_ADDRESS #2]. - - io_base = pci_resource_start (pci_device, 2); - io_range = pci_resource_end (pci_device, 2) - io_base +1; - - printk ("comedi%d: 6503 registers at address 0x%4x [0x%4x]\n", - dev->minor, - io_base, - io_range); - - // Allocate IO ressources + + printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n", + dev->minor, + pci9111_boards[i].name, + pci_device->bus->number, + PCI_SLOT(pci_device->devfn), + PCI_FUNC(pci_device->devfn), + pci_device->irq); + + // TODO: Warn about non-tested boards. + + switch(board->device_id) + { + }; + + // Read local configuration register base address [PCI_BASE_ADDRESS #1]. + + lcr_io_base = pci_resource_start (pci_device, 1); + lcr_io_range = pci_resource_end (pci_device, 1) - lcr_io_base +1; + + printk ("comedi%d: local configuration registers at address 0x%4x [0x%4x]\n", + dev->minor, + lcr_io_base, + lcr_io_range); + + // Read PCI6308 register base address [PCI_BASE_ADDRESS #2]. + + io_base = pci_resource_start (pci_device, 2); + io_range = pci_resource_end (pci_device, 2) - io_base +1; + + printk ("comedi%d: 6503 registers at address 0x%4x [0x%4x]\n", + dev->minor, + io_base, + io_range); + + // Allocate IO ressources if(pci_request_regions(pci_device, PCI9111_DRIVER_NAME)) { printk("comedi%d: I/O port conflict\n",dev->minor); return -EIO; } - - dev->iobase=io_base; - dev->board_name = board->name; - - if(alloc_private(dev,sizeof(pci9111_private_data_struct))<0) - return -ENOMEM; - - dev_private->pci_device = pci_device; - dev_private->io_range = io_range; - dev_private->is_valid=0; - dev_private->lcr_io_base=lcr_io_base; - dev_private->lcr_io_range=lcr_io_range; - - pci9111_reset(dev); - - // Irq setup - - dev->irq=0; - if (pci_device->irq>0) - { - if (comedi_request_irq (pci_device->irq, - pci9111_interrupt, - SA_SHIRQ, - PCI9111_DRIVER_NAME, - dev)!=0) - { - printk ("comedi%d: unable to allocate irq %d\n", dev->minor, pci_device->irq); - return -EINVAL; - } - } - dev->irq = pci_device->irq; - -// -// TODO: Add external multiplexer setup (according to option[2]). -// - - if((error=alloc_subdevices(dev, 4))<0) - return error; - - subdevice = dev->subdevices + 0; - dev->read_subdev = subdevice; - - subdevice->type = COMEDI_SUBD_AI; - subdevice->subdev_flags = SDF_READABLE|SDF_COMMON; - -// -// TODO: Add external multiplexer data -// -// if (devpriv->usemux) { subdevice->n_chan = devpriv->usemux; } -// else { subdevice->n_chan = this_board->n_aichan; } -// + + dev->iobase=io_base; + dev->board_name = board->name; + + if(alloc_private(dev,sizeof(pci9111_private_data_struct))<0) + return -ENOMEM; + + dev_private->pci_device = pci_device; + dev_private->io_range = io_range; + dev_private->is_valid=0; + dev_private->lcr_io_base=lcr_io_base; + dev_private->lcr_io_range=lcr_io_range; + + pci9111_reset(dev); + + // Irq setup + + dev->irq=0; + if (pci_device->irq>0) + { + if (comedi_request_irq (pci_device->irq, + pci9111_interrupt, + SA_SHIRQ, + PCI9111_DRIVER_NAME, + dev)!=0) + { + printk ("comedi%d: unable to allocate irq %d\n", dev->minor, pci_device->irq); + return -EINVAL; + } + } + dev->irq = pci_device->irq; + + // + // TODO: Add external multiplexer setup (according to option[2]). + // + + if((error=alloc_subdevices(dev, 4))<0) + return error; + + subdevice = dev->subdevices + 0; + dev->read_subdev = subdevice; + + subdevice->type = COMEDI_SUBD_AI; + subdevice->subdev_flags = SDF_READABLE|SDF_COMMON; + + // + // TODO: Add external multiplexer data + // + // if (devpriv->usemux) { subdevice->n_chan = devpriv->usemux; } + // else { subdevice->n_chan = this_board->n_aichan; } + // subdevice->n_chan = board->ai_channel_nbr; subdevice->maxdata = board->ai_resolution_mask; diff --git a/comedi/drivers/adv_pci_dio.c b/comedi/drivers/adv_pci_dio.c index 56eeb757..286b560c 100644 --- a/comedi/drivers/adv_pci_dio.c +++ b/comedi/drivers/adv_pci_dio.c @@ -896,7 +896,8 @@ static int pci_dio_attach(comedi_device *dev, comedi_devconfig *it) return -ENOMEM; } - pci_for_each_dev(pcidev) { + for(pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; + pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { if ((pcidev->vendor!=this_board->vendor_id)|| (pcidev->device!=this_board->device_id)) continue; diff --git a/comedi/drivers/amcc_s5933.c b/comedi/drivers/amcc_s5933.c index 1b75fb8d..5fe23d17 100644 --- a/comedi/drivers/amcc_s5933.c +++ b/comedi/drivers/amcc_s5933.c @@ -31,7 +31,8 @@ void pci_card_list_init(unsigned short pci_vendor, char display) amcc_devices=NULL; last=NULL; - pci_for_each_dev(pcidev){ + for(pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; + pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { if(pcidev->vendor==pci_vendor){ amcc=kmalloc(sizeof(*amcc),GFP_KERNEL); memset(amcc,0,sizeof(*amcc)); diff --git a/comedi/drivers/amplc_pc236.c b/comedi/drivers/amplc_pc236.c index fd7231d7..cce66bb9 100644 --- a/comedi/drivers/amplc_pc236.c +++ b/comedi/drivers/amplc_pc236.c @@ -198,7 +198,8 @@ static int pc236_attach(comedi_device *dev,comedi_devconfig *it) } /* Look for matching PCI device. */ - pci_for_each_dev(pci_dev) { + for(pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pci_dev != NULL ; + pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { /* If bus/slot specified, check them. */ if (bus || slot) { if (bus != pci_dev->bus->number diff --git a/comedi/drivers/amplc_pc263.c b/comedi/drivers/amplc_pc263.c index d83cf77c..b9857219 100644 --- a/comedi/drivers/amplc_pc263.c +++ b/comedi/drivers/amplc_pc263.c @@ -169,7 +169,8 @@ static int pc263_attach(comedi_device *dev,comedi_devconfig *it) } /* Look for matching PCI device. */ - pci_for_each_dev(pci_dev) { + for(pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pci_dev != NULL ; + pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { /* If bus/slot specified, check them. */ if (bus || slot) { if (bus != pci_dev->bus->number diff --git a/comedi/drivers/amplc_pci230.c b/comedi/drivers/amplc_pci230.c index 109dfca0..35c559e2 100644 --- a/comedi/drivers/amplc_pci230.c +++ b/comedi/drivers/amplc_pci230.c @@ -332,7 +332,8 @@ static int pci230_attach(comedi_device *dev,comedi_devconfig *it) printk("comedi%d: amplc_pci230\n",dev->minor); /* Find card */ - pci_for_each_dev(pci_dev){ + for(pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pci_dev != NULL ; + pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) { if(pci_dev->vendor != PCI_VENDOR_ID_AMPLICON) continue; for(i=0;ivendor != PCI_VENDOR_ID_CB) diff --git a/comedi/drivers/cb_pcidas64.c b/comedi/drivers/cb_pcidas64.c index 428f778e..955bd353 100644 --- a/comedi/drivers/cb_pcidas64.c +++ b/comedi/drivers/cb_pcidas64.c @@ -1644,7 +1644,8 @@ static int attach(comedi_device *dev, comedi_devconfig *it) * Probe the device to determine what device in the series it is. */ - pci_for_each_dev( pcidev ) + for(pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; + pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { // is it not a computer boards card? if( pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS ) diff --git a/comedi/drivers/cb_pcidda.c b/comedi/drivers/cb_pcidda.c index 6fa9570a..dc299ea7 100644 --- a/comedi/drivers/cb_pcidda.c +++ b/comedi/drivers/cb_pcidda.c @@ -284,7 +284,8 @@ static int cb_pcidda_attach(comedi_device *dev, comedi_devconfig *it) */ printk("\n"); - pci_for_each_dev(pcidev){ + for(pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; + pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { if(pcidev->vendor==PCI_VENDOR_ID_CB){ if(it->options[0] || it->options[1]){ if(pcidev->bus->number==it->options[0] && diff --git a/comedi/drivers/cb_pcimdas.c b/comedi/drivers/cb_pcimdas.c index c13c3e28..57b8db5e 100644 --- a/comedi/drivers/cb_pcimdas.c +++ b/comedi/drivers/cb_pcimdas.c @@ -239,7 +239,8 @@ static int cb_pcimdas_attach(comedi_device *dev,comedi_devconfig *it) */ printk("\n"); - pci_for_each_dev(pcidev) + for(pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; + pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { // is it not a computer boards card? if(pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS) diff --git a/comedi/drivers/cb_pcimdda.c b/comedi/drivers/cb_pcimdda.c index faf09c57..6c88e461 100644 --- a/comedi/drivers/cb_pcimdda.c +++ b/comedi/drivers/cb_pcimdda.c @@ -438,7 +438,8 @@ static int probe(comedi_device *dev, const comedi_devconfig *it) struct pci_dev *pcidev; int index, registers; - pci_for_each_dev(pcidev) + for(pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; + pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { // is it not a computer boards card? if(pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS) diff --git a/comedi/drivers/contec_pci_dio.c b/comedi/drivers/contec_pci_dio.c index ab631b87..3b1ff3b1 100644 --- a/comedi/drivers/contec_pci_dio.c +++ b/comedi/drivers/contec_pci_dio.c @@ -107,7 +107,8 @@ static int contec_attach(comedi_device *dev,comedi_devconfig *it) if(alloc_subdevices(dev, 2)<0) return -ENOMEM; - pci_for_each_dev ( pcidev ) { + for(pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; + pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { if ( pcidev->vendor == PCI_VENDOR_ID_CONTEC && pcidev->device == PCI_DEVICE_ID_PIO1616L ) { diff --git a/comedi/drivers/das08.c b/comedi/drivers/das08.c index 6e777a35..ebba53da 100644 --- a/comedi/drivers/das08.c +++ b/comedi/drivers/das08.c @@ -943,7 +943,8 @@ static int das08_attach(comedi_device *dev,comedi_devconfig *it) } printk("\n"); // find card - pci_for_each_dev(pdev){ + for(pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pdev != NULL ; + pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) { if(pdev->vendor == PCI_VENDOR_ID_COMPUTERBOARDS && pdev->device == PCI_DEVICE_ID_PCIDAS08){ if(it->options[0] || it->options[1]){ diff --git a/comedi/drivers/icp_multi.h b/comedi/drivers/icp_multi.h index 0307aa2b..27cc3c4f 100644 --- a/comedi/drivers/icp_multi.h +++ b/comedi/drivers/icp_multi.h @@ -60,11 +60,8 @@ static void pci_card_list_init(unsigned short pci_vendor, char display) inova_devices=NULL; last=NULL; -#if LINUX_VERSION_CODE < 0x020300 - for(pcidev=pci_devices;pcidev;pcidev=pcidev->next){ -#else - pci_for_each_dev(pcidev){ -#endif + for(pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; + pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { if(pcidev->vendor==pci_vendor){ inova=kmalloc(sizeof(*inova),GFP_KERNEL); memset(inova,0,sizeof(*inova)); diff --git a/comedi/drivers/ke_counter.c b/comedi/drivers/ke_counter.c index 8aea37ee..0685c7e9 100644 --- a/comedi/drivers/ke_counter.c +++ b/comedi/drivers/ke_counter.c @@ -140,7 +140,8 @@ static int cnt_attach(comedi_device *dev, comedi_devconfig *it) int error, i; /* Probe the device to determine what device in the series it is. */ - pci_for_each_dev(pci_device) + for(pci_device = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pci_device != NULL ; + pci_device = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) { if(pci_device->vendor == PCI_VENDOR_ID_KOLTER) { diff --git a/comedi/drivers/me4000.c b/comedi/drivers/me4000.c index 0124d6db..a4b82150 100644 --- a/comedi/drivers/me4000.c +++ b/comedi/drivers/me4000.c @@ -397,7 +397,8 @@ static int me4000_probe(comedi_device *dev, comedi_devconfig *it){ /* * Probe the device to determine what device in the series it is. */ - pci_for_each_dev(pci_device){ + for(pci_device = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pci_device != NULL ; + pci_device = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) { if(pci_device->vendor == PCI_VENDOR_ID_MEILHAUS){ for(i = 0; i < ME4000_BOARD_VERSIONS; i++){ if(me4000_boards[i].device_id == pci_device->device){ diff --git a/comedi/drivers/me_daq.c b/comedi/drivers/me_daq.c index 617193c7..2785d7ad 100644 --- a/comedi/drivers/me_daq.c +++ b/comedi/drivers/me_daq.c @@ -684,7 +684,8 @@ static int me_attach(comedi_device *dev,comedi_devconfig *it) // // Probe the device to determine what device in the series it is. // - pci_for_each_dev(pci_device) + for(pci_device = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pci_device != NULL ; + pci_device = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) { if(pci_device->vendor == PCI_VENDOR_ID_MEILHAUS) { diff --git a/comedi/drivers/mite.c b/comedi/drivers/mite.c index 463b923c..6bdc4368 100644 --- a/comedi/drivers/mite.c +++ b/comedi/drivers/mite.c @@ -72,7 +72,8 @@ void mite_init(void) struct pci_dev *pcidev; struct mite_struct *mite; - pci_for_each_dev(pcidev){ + for(pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; + pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { if(pcidev->vendor==PCI_VENDOR_ID_NATINST){ mite=kmalloc(sizeof(*mite),GFP_KERNEL); if(!mite){ diff --git a/comedi/drivers/rtd520.c b/comedi/drivers/rtd520.c index bc0a072e..71df9d86 100644 --- a/comedi/drivers/rtd520.c +++ b/comedi/drivers/rtd520.c @@ -774,7 +774,8 @@ static int rtd_attach ( /* * Probe the device to determine what device in the series it is. */ - pci_for_each_dev (pcidev) { + for(pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL ; + pcidev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { if (pcidev->vendor == PCI_VENDOR_ID_RTD) { if (it->options[0] || it->options[1]) { if (pcidev->bus->number == it->options[0] diff --git a/comedi/rt.c b/comedi/rt.c index a5fea293..1a03fc84 100644 --- a/comedi/rt.c +++ b/comedi/rt.c @@ -135,10 +135,10 @@ int comedi_request_irq(unsigned irq, irqreturn_t (*handler)(int, void *,struct p struct comedi_irq_struct *it; int ret; - it=kmalloc(sizeof(*it),GFP_KERNEL); + it=kmalloc(sizeof(struct comedi_irq_struct),GFP_KERNEL); if(!it) return -ENOMEM; - memset(it,0,sizeof(*it)); + memset(it,0,sizeof(struct comedi_irq_struct)); it->handler=handler; it->irq=irq; diff --git a/include/linux/pci.h b/include/linux/pci.h index 600ae0b3..b4edba12 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -15,14 +15,6 @@ #include_next #define PCI_SUPPORT_VER2 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) -/* we should get rid of this, as it has been dropped from 2.6 */ -#define pci_for_each_dev(x) \ - for((x) = pci_find_device(PCI_ANY_ID,PCI_ANY_ID,NULL); \ - (x); \ - (x) = pci_find_device(PCI_ANY_ID,PCI_ANY_ID,(x))) -#endif - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) /* XXX */ struct pci_driver { @@ -39,9 +31,6 @@ struct pci_driver { static inline int pci_module_init(struct pci_driver *drv) { return 0; } static inline void pci_unregister_driver(struct pci_driver *) { return; } -#define pci_for_each_dev(x) \ - for((x)=pci_devices;(x);(x)=(x)->next) - static inline int pci_enable_device(struct pci_dev *dev){return 0;} #define pci_disable_device(x)