From: Frank Mori Hess Date: Sat, 2 Feb 2002 17:21:44 +0000 (+0000) Subject: fixed error handling for mite_setup X-Git-Tag: r0_7_64~160 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=abb4572a5242431747b255cb42e73810c522980c;p=comedi.git fixed error handling for mite_setup --- diff --git a/comedi/drivers/mite.c b/comedi/drivers/mite.c index 11d48563..f581b800 100644 --- a/comedi/drivers/mite.c +++ b/comedi/drivers/mite.c @@ -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; } diff --git a/comedi/drivers/mite.h b/comedi/drivers/mite.h index 6fefaea5..2323af13 100644 --- a/comedi/drivers/mite.h +++ b/comedi/drivers/mite.h @@ -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); diff --git a/comedi/drivers/ni_670x.c b/comedi/drivers/ni_670x.c index 780be78c..b16bdc92 100644 --- a/comedi/drivers/ni_670x.c +++ b/comedi/drivers/ni_670x.c @@ -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); diff --git a/comedi/drivers/ni_labpc.c b/comedi/drivers/ni_labpc.c index 692f1b1e..5ae7432f 100644 --- a/comedi/drivers/ni_labpc.c +++ b/comedi/drivers/ni_labpc.c @@ -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: diff --git a/comedi/drivers/ni_pcidio.c b/comedi/drivers/ni_pcidio.c index b3968006..daa200d4 100644 --- a/comedi/drivers/ni_pcidio.c +++ b/comedi/drivers/ni_pcidio.c @@ -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); diff --git a/comedi/drivers/ni_pcimio.c b/comedi/drivers/ni_pcimio.c index 619759e6..799a39bb 100644 --- a/comedi/drivers/ni_pcimio.c +++ b/comedi/drivers/ni_pcimio.c @@ -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);