sampl_t dataPoint;
comedi_device *dev = d;
comedi_subdevice *s = dev->read_subdev; /* analog input subdevice */
- comedi_async *async = s->async;
+ comedi_async *async;
int status;
unsigned long irq_flags;
static const int max_loops = 256;
status = inb(dev->iobase + DAS800_STATUS);
- /* if interupt was not generated by board, quit */
+ /* if interupt was not generated by board or driver not attached, quit */
if(!(status & IRQ) || !(dev->attached))
return;
+ /* wait until here to initialize async, since we will get null dereference
+ * if interrupt occurs before driver is fully attached!
+ */
+ async = s->async;
+
// if hardware conversions are not enabled, then quit
comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select base address + 7 to be STATUS2 register */
{
if( dataPoint & FIFO_OVF )
{
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
comedi_error(dev, "DAS800 FIFO overflow");
das800_cancel(dev, dev->subdevices + 0);
comedi_error_done(dev, s);
}
printk("\n");
+ /* allocate and initialize dev->private */
+ if(alloc_private(dev, sizeof(das800_private)) < 0)
+ return -ENOMEM;
+
if(iobase == 0)
{
printk("io base address required for das800\n");
dev->board_name = thisboard->name;
- /* allocate and initialize dev->private */
- if(alloc_private(dev, sizeof(das800_private)) < 0)
- return -ENOMEM;
-
dev->n_subdevices = 3;
if(alloc_subdevices(dev) < 0)
return -ENOMEM;