fixed error handling for mite_setup
authorFrank Mori Hess <fmhess@speakeasy.net>
Sat, 2 Feb 2002 17:21:44 +0000 (17:21 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sat, 2 Feb 2002 17:21:44 +0000 (17:21 +0000)
comedi/drivers/mite.c
comedi/drivers/mite.h
comedi/drivers/ni_670x.c
comedi/drivers/ni_labpc.c
comedi/drivers/ni_pcidio.c
comedi/drivers/ni_pcimio.c

index 11d485638e7190999cf7b8f37b4e36ef29127efa..f581b8007f352e6db3ee2f7499cd724260070105 100644 (file)
@@ -185,7 +185,7 @@ int mite_setup(struct mite_struct *mite)
        }
        request_mem_region(start, length, "mite (daq)");
        mite->daq_io_addr = ioremap(start, length) + offset;
-       printk("DAQ:0x%08lx mapped to %p",mite->daq_phys_addr,mite->daq_io_addr);
+       printk("DAQ:0x%08lx mapped to %p\n",mite->daq_phys_addr,mite->daq_io_addr);
 
        /* XXX don't know what the 0xc0 and 0x80 mean */
        /* It must be here for the driver to work though */
@@ -208,7 +208,7 @@ int mite_setup(struct mite_struct *mite)
 
        mite->used = 1;
 
-       return (int) mite->daq_io_addr;
+       return 0;
 }
 
 
index 6fefaea51d38da269c2a7e28ee77bf44b071b3fb..2323af13cdfb4af3f221228653d5722bcde801d2 100644 (file)
@@ -73,14 +73,29 @@ struct mite_struct{
 extern struct mite_struct *mite_devices;
 
 #ifdef PCI_SUPPORT_VER1
-#define mite_irq(a)            ((a)->irq)
-#define mite_device_id(a)      ((a)->device_id)
+extern inline unsigned int mite_irq(struct mite_struct *mite)
+{
+       return mite->irq;
+};
+extern inline unsigned int mite_device_id(struct mite_struct *mite)
+{
+       return mite->device_id;
+};
 #else
-#define mite_irq(a)            ((a)->pcidev->irq)
-#define mite_device_id(a)      ((a)->pcidev->device)
+extern inline unsigned int mite_irq(struct mite_struct *mite)
+{
+       return mite->pcidev->irq;
+};
+extern inline unsigned int mite_device_id(struct mite_struct *mite)
+{
+       return mite->pcidev->device;
+};
 #endif
 
-#define mite_iobase(a)         ((a)->daq_io_addr)
+extern inline unsigned long mite_iobase(struct mite_struct *mite)
+{
+       return (unsigned long) mite->daq_io_addr;
+};
 
 
 void mite_init(void);
index 780be78ce50920e689cb909f5b894f59166307c8..b16bdc92fe7683b30445804f84c7eb9aa7a51447 100644 (file)
@@ -141,7 +141,13 @@ static int ni_670x_attach(comedi_device *dev,comedi_devconfig *it)
        ret=ni_670x_find_device(dev,it->options[0],it->options[1]);
        if(ret<0) return ret;
        
-       dev->iobase=mite_setup(devpriv->mite);
+       ret = mite_setup(devpriv->mite);
+       if(ret < 0)
+       {
+               printk("error setting up mite\n");
+               return ret;
+       }
+       dev->iobase=mite_iobase(devpriv->mite);
        dev->board_name=thisboard->name;
        dev->irq=mite_irq(devpriv->mite);
        printk(" %s",dev->board_name);
index 692f1b1e88c1a2ee772d6f488b0aad854bad4579..5ae7432f1866ea42ba31f64f62e8f4139f9f231f 100644 (file)
@@ -513,6 +513,7 @@ static int labpc_attach(comedi_device *dev, comedi_devconfig *it)
        int lsb, msb;
        int i;
        unsigned long flags, isr_flags;
+       int ret;
 #ifdef CONFIG_PCMCIA
        dev_link_t *link;
 #endif
@@ -540,8 +541,9 @@ static int labpc_attach(comedi_device *dev, comedi_devconfig *it)
                                printk("bug! mite device id does not match boardtype definition\n");
                                return -EINVAL;
                        }
-                       iobase = mite_setup(devpriv->mite);
-                       if(iobase < 0) return -EIO;
+                       ret = mite_setup(devpriv->mite);
+                       if(ret < 0) return ret;
+                       iobase = mite_iobase(devpriv->mite);
                        irq = mite_irq(devpriv->mite);
                        break;
                case pcmcia_bustype:
index b3968006aaf340fc6aee80f653fe3a7c3e5fe697..daa200d409f6b333a18ab0cc29bcf429c9c3a9fd 100644 (file)
@@ -778,7 +778,13 @@ static int nidio_attach(comedi_device *dev,comedi_devconfig *it)
        ret=nidio_find_device(dev,it->options[0],it->options[1]);
        if(ret<0)return ret;
 
-       dev->iobase=mite_setup(devpriv->mite);
+       ret = mite_setup(devpriv->mite);
+       if(ret < 0)
+       {
+               printk("error setting up mite\n");
+               return ret;
+       }
+       dev->iobase = mite_iobase(devpriv->mite);
 
        dev->board_name=this_board->name;
        dev->irq=mite_irq(devpriv->mite);
index 619759e6c1279a7fc51b018275e8aa802e8c5725..799a39bb61e69709c3893c7810c37f00a49fc9ae 100644 (file)
@@ -610,7 +610,13 @@ static int pcimio_attach(comedi_device *dev,comedi_devconfig *it)
        printk(" %s",boardtype.name);
        dev->board_name=boardtype.name;
        
-       dev->iobase=mite_setup(devpriv->mite);
+       ret = mite_setup(devpriv->mite);
+       if(ret < 0)
+       {
+               printk(" error setting up mite\n");
+               return ret;
+       }
+       dev->iobase = mite_iobase(devpriv->mite);
 
        dev->irq=mite_irq(devpriv->mite);