fixed pci_resource_start compatibility macro so it returns address without
authorFrank Mori Hess <fmhess@speakeasy.net>
Fri, 15 Feb 2002 22:39:17 +0000 (22:39 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Fri, 15 Feb 2002 22:39:17 +0000 (22:39 +0000)
and extra flag bits set.  Some hacks to fix amcc_s5933.c stuff on 2.4

comedi/drivers/amcc_s5933.c
comedi/drivers/amplc_pci230.c
comedi/drivers/cb_pcidas.c
comedi/drivers/cb_pcidas64.c
comedi/drivers/cb_pcidda.c
comedi/drivers/das08.c
comedi/drivers/icp_multi.h
comedi/drivers/rtd520.c
include/linux/pci.h
include/linux/vmalloc.h

index 4b8abb1b9920298c34a7753d2d1679ce528e6844..e06b7ca97d22278802d8d74f61c5ba68bead32c1 100644 (file)
@@ -49,12 +49,12 @@ void pci_card_list_init(unsigned short pci_vendor, char display)
                        amcc->pci_slot=PCI_SLOT(pcidev->devfn);
                        amcc->pci_func=PCI_FUNC(pcidev->devfn);
                        for (i=0;i<5;i++)
-                               amcc->io_addr[i]=pci_resource_start(pcidev, i) & PCI_BASE_ADDRESS_IO_MASK;
+                               amcc->io_addr[i]=pci_resource_start(pcidev, i);
                        amcc->irq=pcidev->irq;
 #if LINUX_VERSION_CODE < 0x020300
                        amcc->master=pcidev->master;
 #else
-//                     amcc->master=pcidev->master; // how get this information under 2.4 kernels?
+                       amcc->master=1; 
 #endif
                        
                }
@@ -121,7 +121,10 @@ int pci_card_alloc(struct pcilst_struct *amcc)
        if (!amcc) return -1;
 
        if (amcc->used) return 1;
+       if(pci_enable_device(amcc->pcidev)) return -1;
+       pci_set_master(amcc->pcidev);
        amcc->used=1;
+
        return 0;
 }
 
index 308ca4de68236fb9b6d9a62a97845a8469857df5..4f4b5c424ec5cee40884f2eea60d78c6668c9913 100644 (file)
@@ -335,8 +335,8 @@ static int pci230_attach(comedi_device *dev,comedi_devconfig *it)
        /* Read base addressses of the PCI230's two I/O regions from PCI configuration register. */
        if(pci_enable_device(pci_dev)<0)return -EIO;
 
-       pci_iobase = pci_resource_start(pci_dev, 2) & PCI_BASE_ADDRESS_IO_MASK;
-       iobase = pci_resource_start(pci_dev, 3) & PCI_BASE_ADDRESS_IO_MASK;
+       pci_iobase = pci_resource_start(pci_dev, 2);
+       iobase = pci_resource_start(pci_dev, 3);
 
        printk("comedi%d: amplc_pci230: I/O region 1 0x%04x I/O region 2 0x%04x\n",dev->minor, pci_iobase, iobase);
 
index 2f2f36c6ce3dc1fc5f3b232eaa704e708f33a77d..c3350e67cb0f99b381463a8c225f56982e2d2222 100644 (file)
@@ -534,16 +534,11 @@ found:
         */
        if(pci_enable_device(devpriv->pci_dev))
                return -EIO;
-       s5933_config = pci_resource_start(devpriv->pci_dev, S5933_BADRINDEX) &
-               PCI_BASE_ADDRESS_IO_MASK;
-       control_status = pci_resource_start(devpriv->pci_dev, CONT_STAT_BADRINDEX) &
-               PCI_BASE_ADDRESS_IO_MASK;
-       adc_fifo = pci_resource_start(devpriv->pci_dev, ADC_FIFO_BADRINDEX) &
-               PCI_BASE_ADDRESS_IO_MASK;
-       pacer_counter_dio = pci_resource_start(devpriv->pci_dev, PACER_BADRINDEX) &
-               PCI_BASE_ADDRESS_IO_MASK;
-       ao_registers = pci_resource_start(devpriv->pci_dev, AO_BADRINDEX) &
-               PCI_BASE_ADDRESS_IO_MASK;
+       s5933_config = pci_resource_start(devpriv->pci_dev, S5933_BADRINDEX); 
+       control_status = pci_resource_start(devpriv->pci_dev, CONT_STAT_BADRINDEX); 
+       adc_fifo = pci_resource_start(devpriv->pci_dev, ADC_FIFO_BADRINDEX); 
+       pacer_counter_dio = pci_resource_start(devpriv->pci_dev, PACER_BADRINDEX); 
+       ao_registers = pci_resource_start(devpriv->pci_dev, AO_BADRINDEX); 
 
        // reserve io ports
        err = 0;
index 80ad91a3be57c21a12781933b3c413f681448cb5..863799bb31746bfc895536051a1da3de022ad119 100644 (file)
@@ -533,12 +533,9 @@ found:
 #ifdef PCIDMA
        pci_set_master(pcidev);
 #endif
-       plx9080_iobase = pci_resource_start(pcidev, PLX9080_BADRINDEX) &
-               PCI_BASE_ADDRESS_MEM_MASK;
-       main_iobase = pci_resource_start(pcidev, MAIN_BADRINDEX) &
-               PCI_BASE_ADDRESS_MEM_MASK;
-       dio_counter_iobase = pci_resource_start(pcidev, DIO_COUNTER_BADRINDEX) &
-               PCI_BASE_ADDRESS_MEM_MASK;
+       plx9080_iobase = pci_resource_start(pcidev, PLX9080_BADRINDEX); 
+       main_iobase = pci_resource_start(pcidev, MAIN_BADRINDEX); 
+       dio_counter_iobase = pci_resource_start(pcidev, DIO_COUNTER_BADRINDEX); 
 
        if(check_mem_region(plx9080_iobase, PLX9080_IOSIZE))
        {
index 80a29e8bf9630c77f386c3df49aa192edc9206d8..ce8644f80964dbcb39a1034f0504aea219220079 100644 (file)
@@ -337,10 +337,8 @@ found:
         */
        if(pci_enable_device(devpriv->pci_dev))
                return -EIO;
-       digitalio = pci_resource_start(devpriv->pci_dev, DIGITALIO_BADRINDEX) &
-               PCI_BASE_ADDRESS_IO_MASK;
-       dac = pci_resource_start(devpriv->pci_dev, DAC_BADRINDEX) &
-               PCI_BASE_ADDRESS_IO_MASK;
+       digitalio = pci_resource_start(devpriv->pci_dev, DIGITALIO_BADRINDEX); 
+       dac = pci_resource_start(devpriv->pci_dev, DAC_BADRINDEX); 
 
 /*
  * Allocate the I/O ports.
index ae0b797c2a5fca27ba814b3e92988c60e3c027cc..dab46232770c9b59e694ac31f01cebc6c96ff408 100644 (file)
@@ -772,8 +772,8 @@ static int das08_attach(comedi_device *dev,comedi_devconfig *it)
                // read base addresses
                if(pci_enable_device(pdev))
                        return -EIO;
-               pci_iobase = pci_resource_start(pdev, 1) & PCI_BASE_ADDRESS_IO_MASK;
-               iobase = pci_resource_start(pdev, 2) & PCI_BASE_ADDRESS_IO_MASK;
+               pci_iobase = pci_resource_start(pdev, 1);
+               iobase = pci_resource_start(pdev, 2);
                printk("pcibase 0x%x ", pci_iobase);
                // reserve io ports for 9052 pci chip
                if(check_region(pci_iobase,PCIDAS08_SIZE)<0){
index b7e80e781c97c0f2540abe453a38c1a89c0939fc..dd1b95d5576de7ea1408ab6234dda005fabe8c66 100644 (file)
@@ -74,30 +74,19 @@ void pci_card_list_init(unsigned short pci_vendor, char display)
                             else { inova_devices=inova; }
                        last=inova;
                        
-#if LINUX_VERSION_CODE < 0x020300
                        inova->vendor=pcidev->vendor;           
                        inova->device=pcidev->device;
+#if LINUX_VERSION_CODE < 0x020300
                        inova->master=pcidev->master;
-                       inova->pci_bus=pcidev->bus->number;
-                       inova->pci_slot=PCI_SLOT(pcidev->devfn);
-                       inova->pci_func=PCI_FUNC(pcidev->devfn);
-                       for (i=0;i<5;i++)
-                               inova->io_addr[i]=pcidev->base_address[i] & PCI_BASE_ADDRESS_MEM_MASK;
-                       inova->irq=pcidev->irq;
 #else
-                       inova->vendor=pcidev->vendor;           
-                       inova->device=pcidev->device;
-#if 0
-                       inova->master=pcidev->master; // how get this information under 2.4 kernels?
+inova->master = 1;     //XXX
 #endif
                        inova->pci_bus=pcidev->bus->number;
                        inova->pci_slot=PCI_SLOT(pcidev->devfn);
                        inova->pci_func=PCI_FUNC(pcidev->devfn);
                        for (i=0;i<5;i++)
-                               inova->io_addr[i]=pcidev->resource[i].start & PCI_BASE_ADDRESS_MEM_MASK;
+                               inova->io_addr[i]=pci_resource_start(pcidev, i);
                        inova->irq=pcidev->irq;
-#endif
-                       
                }
        }
 
@@ -188,7 +177,7 @@ void pci_card_list_display(void)
 
        for (inova=inova_devices; inova; inova=next) {
                next=inova->next;
-               printk("%2d   %2d   %2d  0x%4x 0x%4x   %3s   0x%8xl 0x%8xl  %2d  %2d\n",
+               printk("%2d   %2d   %2d  0x%4x 0x%4x   %3s   0x%8lx 0x%8lx  %2d  %2d\n",
                        inova->pci_bus,inova->pci_slot,inova->pci_func,inova->vendor,inova->device,inova->master?"yes":"no",
                        inova->io_addr[0],inova->io_addr[2],inova->irq,inova->used);
                
index 0f5a1eb70a2a02928238e984d1e9a62e0b9b8320..64618467f4e8ab1685ebf7b3a5b498ac1f2b7b63 100644 (file)
@@ -659,12 +659,9 @@ static int rtd_attach (
      * Initialize base addresses
      */
     /* Get the physical address from PCI config */
-       physLas0 = pci_resource_start(devpriv->pci_dev, LAS0_PCIINDEX) &
-               PCI_BASE_ADDRESS_MEM_MASK;
-       physLas1 = pci_resource_start(devpriv->pci_dev, LAS1_PCIINDEX) &
-               PCI_BASE_ADDRESS_MEM_MASK;
-       physLcfg = pci_resource_start(devpriv->pci_dev, LCFG_PCIINDEX) &
-               PCI_BASE_ADDRESS_MEM_MASK;
+       physLas0 = pci_resource_start(devpriv->pci_dev, LAS0_PCIINDEX); 
+       physLas1 = pci_resource_start(devpriv->pci_dev, LAS1_PCIINDEX); 
+       physLcfg = pci_resource_start(devpriv->pci_dev, LCFG_PCIINDEX); 
     /* Now have the kernel map this into memory */
                                        /* ASSUME page aligned */
     devpriv->las0 = ioremap(physLas0, LAS0_PCISIZE);
index 7f01307b6dfaacf68483116736a850e85267800b..77a2610a795908a72f4d6207efc0af378026121c 100644 (file)
@@ -66,7 +66,12 @@ extern inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
 #define pci_dma_sync_single(cookie, address, size, dir)
 
 // for getting base addresses
-#define pci_resource_start(dev,bar)   ((dev)->base_address[(bar)])
+extern inline unsigned long pci_resource_start(struct pci_dev *dev, unsigned int bar)
+{
+       if(dev->base_address[bar] & PCI_BASE_ADDRESS_SPACE_IO)
+               return dev->base_address[bar] & PCI_BASE_ADDRESS_IO_MASK;
+       return dev->base_address[bar] & PCI_BASE_ADDRESS_MEM_MASK;
+}
 
 #else
 
index de4b57eed87e2ac9a6e76cbea6e173607a76a183..f959e51bb7c3aca9b3db8233a3f903f7c25d4601 100644 (file)
@@ -7,7 +7,8 @@
 
 #include <linux/version.h>
 
-#if LINUX_VERSION_CODE < 0x020300
+// XXX 2.2.19 already has vmalloc_32() compatibility, not sure when it was introduced
+#if LINUX_VERSION_CODE < 0x020200
 #define vmalloc_32(x) vmalloc((x))
 #endif