priv(dev)->dio_counter_iobase = ioremap(priv(dev)->dio_counter_phys_iobase,
pci_resource_len(pcidev, DIO_COUNTER_BADDRINDEX));
+ if (!priv(dev)->plx9080_iobase || !priv(dev)->main_iobase || !priv(dev)->dio_counter_iobase)
+ {
+ printk(" failed to remap io memory\n");
+ return -ENOMEM;
+ }
+
DEBUG_PRINT(" plx9080 remapped to 0x%lx\n", priv(dev)->plx9080_iobase);
DEBUG_PRINT(" main remapped to 0x%lx\n", priv(dev)->main_iobase);
DEBUG_PRINT(" diocounter remapped to 0x%lx\n", priv(dev)->dio_counter_iobase);
struct pci_dev *pci_dev;
void *daq;
void *plx;
+ int got_regions;
lsampl_t ao_readback[2];
} daqboard2000_private;
if((result = pci_request_regions(card, "daqboard2000")) < 0) {
return -EIO;
}
+ devpriv->got_regions = 1;
devpriv->plx = ioremap(pci_resource_start(card,0), DAQBOARD2000_PLX_SIZE);
devpriv->daq = ioremap(pci_resource_start(card,2), DAQBOARD2000_DAQ_SIZE);
+ if(!devpriv->plx || !devpriv->daq){
+ return -ENOMEM;
+ }
result = alloc_subdevices(dev, 3);
if(result<0)goto out;
iounmap(devpriv->plx);
if(devpriv->pci_dev)
{
- if(devpriv->daq)
+ if(devpriv->got_regions)
{
pci_release_regions(devpriv->pci_dev);
pci_disable_device(devpriv->pci_dev);
static int setup_pci(comedi_device *dev)
{
- unsigned long offset;
u32 addr;
int ret;
addr=pci_resource_start(devpriv->pci_dev,0);
devpriv->phys_addr=addr;
- offset = devpriv->phys_addr & ~PAGE_MASK;
- devpriv->io_addr = ioremap(devpriv->phys_addr & PAGE_MASK, DT3000_SIZE + offset )
- + offset;
+ devpriv->io_addr = ioremap(devpriv->phys_addr, DT3000_SIZE);
+ if(!devpriv->io_addr) return -ENOMEM;
#if DEBUG
printk("0x%08lx mapped to %p, ",devpriv->phys_addr,devpriv->io_addr);
#endif
pci_resource_len( pcidev, PLX9080_BADDRINDEX ) );
priv(dev)->hpdi_iobase = ioremap( priv(dev)->hpdi_phys_iobase,
pci_resource_len( pcidev, HPDI_BADDRINDEX ) );
+ if (!priv(dev)->plx9080_iobase || !priv(dev)->hpdi_iobase)
+ {
+ printk(" failed to remap io memory\n");
+ return -ENOMEM;
+ }
DEBUG_PRINT(" plx9080 remapped to 0x%lx\n", priv(dev)->plx9080_iobase);
DEBUG_PRINT(" hpdi remapped to 0x%lx\n", priv(dev)->hpdi_iobase);
plx_regbase_size_tmp = pci_resource_end(pci_device, 0) - plx_regbase_tmp + 1;
dev_private->plx_regbase = ioremap(plx_regbase_tmp, plx_regbase_size_tmp);
dev_private->plx_regbase_size = plx_regbase_size_tmp;
+ if(!dev_private->plx_regbase)
+ {
+ printk("comedi%d: Failed to remap I/O memory\n", dev->minor);
+ return -ENOMEM;
+ }
// Read Swap base address [PCI_BASE_ADDRESS #5].
me_regbase_size_tmp = pci_resource_end(pci_device, 2) - me_regbase_tmp + 1;
dev_private->me_regbase_size = me_regbase_size_tmp;
dev_private->me_regbase = ioremap(me_regbase_tmp, me_regbase_size_tmp);
+ if(!dev_private->me_regbase)
+ {
+ printk("comedi%d: Failed to remap I/O memory\n", dev->minor);
+ return -ENOMEM;
+ }
// Download firmware and reset card
if(board->device_id == ME2600_DEVICE_ID)
if (dev_private->me_regbase)
{
me_reset(dev);
+ iounmap(dev_private->me_regbase);
}
+ if (dev_private->plx_regbase)
+ iounmap(dev_private->plx_regbase);
if(dev_private->pci_device)
{
- if(dev_private->plx_regbase)
+ if(dev_private->plx_regbase_size)
{
pci_release_regions(dev_private->pci_device);
pci_disable_device(dev_private->pci_device);
int mite_setup(struct mite_struct *mite)
{
- unsigned long offset, start, length;
+ unsigned long length;
u32 addr;
int i;
u32 csigr_bits;
addr = pci_resource_start(mite->pcidev, 0);
mite->mite_phys_addr = addr;
- offset = mite->mite_phys_addr & ~PAGE_MASK;
- start = mite->mite_phys_addr & PAGE_MASK;
- length = PCI_MITE_SIZE + offset;
- mite->mite_io_addr = ioremap(start, length) + offset;
+ mite->mite_io_addr = ioremap(addr, PCI_MITE_SIZE);
+ if( !mite->mite_io_addr ) {
+ printk("failed to remap mite io memory address\n");
+ return -ENOMEM;
+ }
printk("MITE:0x%08lx mapped to %p ",mite->mite_phys_addr,mite->mite_io_addr);
addr=pci_resource_start(mite->pcidev, 1);
mite->daq_phys_addr=addr;
- offset = mite->daq_phys_addr & ~PAGE_MASK;
- start = mite->daq_phys_addr & PAGE_MASK;
// In case of a 660x board, DAQ size is 8k instead of 4k (see as shown by lspci output)
if ((mite->pcidev->device == 0x1310) || (mite->pcidev->device == 0x2c60)){
- length = PCI_DAQ_SIZE_660X + offset;
+ length = PCI_DAQ_SIZE_660X;
printk("mite: detected NI660X board, using PCI DAQ SIZE of 8k\n");
}
- else length = PCI_DAQ_SIZE + offset;
- mite->daq_io_addr = ioremap(start, length) + offset;
+ else length = PCI_DAQ_SIZE;
+ mite->daq_io_addr = ioremap(mite->daq_phys_addr, length);
+ if( !mite->daq_io_addr ) {
+ printk("failed to remap daq io memory address\n");
+ return -ENOMEM;
+ }
printk("DAQ:0x%08lx mapped to %p\n",mite->daq_phys_addr,mite->daq_io_addr);
// The 6602 board needs different initalisation, see the
iounmap(mite->daq_io_addr);
mite->daq_io_addr=NULL;
}
- if( mite->used ){
+ if( mite->mite_phys_addr ){
pci_release_regions( mite->pcidev );
pci_disable_device( mite->pcidev );
}
/* PCI device info */
struct pci_dev *pci_dev;
+ int got_regions; /* non-zero if PCI regions owned */
/* channel list info */
/* chanBipolar tracks whether a channel is bipolar (and needs +2048) */
if((ret=pci_request_regions(pcidev, "rtd520"))<0){
return ret;
}
+ devpriv->got_regions = 1;
/*
* Initialize base addresses
iounmap (devpriv->lcfg);
}
if (devpriv->pci_dev) {
- if(devpriv->las0)
+ if(devpriv->got_regions)
{
pci_release_regions(devpriv->pci_dev);
pci_disable_device(devpriv->pci_dev);
typedef struct{
struct pci_dev *pdev;
void *base_addr;
+ int got_regions;
short allocatedBuf;
uint8_t ai_cmd_running; // ai_cmd is running
uint8_t ai_continous; // continous aquisition
printk("s626_attach: pci_request_regions fails\n");
return -ENODEV;
}
+ devpriv->got_regions = 1;
resourceStart=(uint64_t)pci_resource_start(devpriv->pdev,0);
}
if(devpriv->pdev){
- if(devpriv->base_addr)
+ if(devpriv->got_regions)
{
pci_release_regions(devpriv->pdev);
pci_disable_device(devpriv->pdev);