{
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock,flags);
+ comedi_spin_lock_irqsave(&devpriv->window_lock,flags);
ni_writew(addr,AO_Window_Address_611x);
ni_writew(data,AO_Window_Data_611x);
- comedi_spin_unlock_irqrestore(&dev->spinlock,flags);
+ comedi_spin_unlock_irqrestore(&devpriv->window_lock,flags);
}
static inline void ni_ao_win_outl(comedi_device *dev, uint32_t data, int addr)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&dev->spinlock,flags);
+ comedi_spin_lock_irqsave(&devpriv->window_lock,flags);
ni_writew(addr,AO_Window_Address_611x);
ni_writel(data,AO_Window_Data_611x);
- comedi_spin_unlock_irqrestore(&dev->spinlock,flags);
+ comedi_spin_unlock_irqrestore(&devpriv->window_lock,flags);
}
static inline unsigned short ni_ao_win_inw( comedi_device *dev, int addr )
unsigned long flags;
unsigned short data;
- comedi_spin_lock_irqsave(&dev->spinlock,flags);
+ comedi_spin_lock_irqsave(&devpriv->window_lock,flags);
ni_writew(addr, AO_Window_Address_611x);
data = ni_readw(AO_Window_Data_611x);
- comedi_spin_unlock_irqrestore(&dev->spinlock,flags);
+ comedi_spin_unlock_irqrestore(&devpriv->window_lock,flags);
return data;
}
{
unsigned long flags;
- comedi_spin_lock_irqsave( &dev->spinlock, flags );
+ comedi_spin_lock_irqsave( &devpriv->window_lock, flags );
switch (reg){
case Interrupt_A_Enable_Register:
if(value)
devpriv->int_a_enable_reg |= bits;
else
devpriv->int_a_enable_reg &= ~bits;
- comedi_spin_unlock_irqrestore( &dev->spinlock, flags );
+ comedi_spin_unlock_irqrestore( &devpriv->window_lock, flags );
win_out(devpriv->int_a_enable_reg,Interrupt_A_Enable_Register);
break;
case Interrupt_B_Enable_Register:
devpriv->int_b_enable_reg |= bits;
else
devpriv->int_b_enable_reg &= ~bits;
- comedi_spin_unlock_irqrestore( &dev->spinlock, flags );
+ comedi_spin_unlock_irqrestore( &devpriv->window_lock, flags );
win_out(devpriv->int_b_enable_reg,Interrupt_B_Enable_Register);
break;
case IO_Bidirection_Pin_Register:
devpriv->io_bidirection_pin_reg |= bits;
else
devpriv->io_bidirection_pin_reg &= ~bits;
- comedi_spin_unlock_irqrestore( &dev->spinlock, flags );
+ comedi_spin_unlock_irqrestore( &devpriv->window_lock, flags );
win_out(devpriv->io_bidirection_pin_reg,IO_Bidirection_Pin_Register);
break;
default:
printk("Warning ni_set_bits() called with invalid arguments\n");
printk("reg is %d\n",reg);
- comedi_spin_unlock_irqrestore( &dev->spinlock, flags );
+ comedi_spin_unlock_irqrestore( &devpriv->window_lock, flags );
break;
}
}
static int ni_ai_poll(comedi_device *dev,comedi_subdevice *s)
{
+ unsigned long flags;
+ int count;
+
+ // lock to avoid race with interrupt handler
+ comedi_spin_lock_irqsave(&dev->spinlock, flags);
#ifndef PCIDMA
ni_handle_fifo_dregs(dev);
-
- //comedi_event(dev,s,s->async->events);
-
- return s->async->buf_write_count - s->async->buf_read_count;
#else
- /* XXX we don't support this yet. */
- return -EINVAL;
+ ni_sync_ai_dma(devpriv->mite, dev);
#endif
+ count = s->async->buf_write_count - s->async->buf_read_count;
+ comedi_spin_unlock_irqrestore(&dev->spinlock, flags);
+
+ return count;
}
ni_ao_win_outw(dev, AO_Channel(i) | 0x0, AO_Configuration_2_67xx);
}
+static int ni_alloc_private(comedi_device *dev)
+{
+ int ret;
+
+ ret = alloc_private(dev, sizeof(ni_private));
+ if(ret < 0) return ret;
+
+ spin_lock_init(&devpriv->window_lock);
+
+ return 0;
+};
+
static int ni_E_init(comedi_device *dev,comedi_devconfig *it)
{
comedi_subdevice *s;