},
};
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct cb_pcidas_board *)dev->board_ptr)
-
/* this structure is for data unique to this hardware driver. If
several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device struct. */
unsigned int calibration_source;
};
-/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((struct cb_pcidas_private *)dev->private)
-
static inline unsigned int cal_enable_bits(struct comedi_device *dev)
{
+ struct cb_pcidas_private *devpriv = dev->private;
+
return CAL_EN_BIT | CAL_SRC_BITS(devpriv->calibration_source);
}
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
int n, i;
unsigned int bits;
static const int timeout = 10000;
static int ai_config_calibration_source(struct comedi_device *dev,
unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
static const int num_calibration_sources = 8;
unsigned int source = data[1];
struct comedi_insn *insn,
unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
int channel;
unsigned long flags;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
int channel;
unsigned long flags;
struct comedi_insn *insn,
unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
+
data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)];
return 1;
static int nvram_read(struct comedi_device *dev, unsigned int address,
uint8_t *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
unsigned long iobase = devpriv->s5933_config;
if (wait_for_nvram_ready(iobase) < 0)
unsigned int bitstream,
unsigned int bitstream_length)
{
+ struct cb_pcidas_private *devpriv = dev->private;
static const int write_delay = 1;
unsigned int bit;
static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
uint8_t value)
{
+ struct cb_pcidas_private *devpriv = dev->private;
static const int num_caldac_channels = 8;
static const int bitstream_length = 11;
unsigned int bitstream = ((address & 0x7) << 8) | value;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
+
data[0] = devpriv->caldac_value[CR_CHAN(insn->chanspec)];
return 1;
/* 1602/16 pregain offset */
static int dac08_write(struct comedi_device *dev, unsigned int value)
{
+ struct cb_pcidas_private *devpriv = dev->private;
+
if (devpriv->dac08_value == value)
return 1;
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
+
data[0] = devpriv->dac08_value;
return 1;
static int trimpot_7376_write(struct comedi_device *dev, uint8_t value)
{
+ struct cb_pcidas_private *devpriv = dev->private;
static const int bitstream_length = 7;
unsigned int bitstream = value & 0x7f;
unsigned int register_bits;
static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel,
uint8_t value)
{
+ struct cb_pcidas_private *devpriv = dev->private;
static const int bitstream_length = 10;
unsigned int bitstream = ((channel & 0x3) << 8) | (value & 0xff);
unsigned int register_bits;
static int cb_pcidas_trimpot_write(struct comedi_device *dev,
unsigned int channel, unsigned int value)
{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
+
if (devpriv->trimpot_value[channel] == value)
return 1;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
unsigned int channel = CR_CHAN(insn->chanspec);
data[0] = devpriv->trimpot_value[channel];
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
int err = 0;
int tmp;
int i, gain, start_chan;
static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns,
int rounding_flags)
{
+ struct cb_pcidas_private *devpriv = dev->private;
+
i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
&(devpriv->divisor2), ns,
rounding_flags & TRIG_ROUND_MASK);
static int cb_pcidas_ai_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int bits;
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
int err = 0;
int tmp;
static int cb_pcidas_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct cb_pcidas_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags);
struct comedi_subdevice *s,
unsigned int trig_num)
{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
unsigned int num_bytes, num_points = thisboard->fifo_size;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &s->async->cmd;
static int cb_pcidas_ao_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct cb_pcidas_private *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int i;
static int cb_pcidas_ao_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct cb_pcidas_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags);
static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->write_subdev;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
{
struct comedi_device *dev = (struct comedi_device *)d;
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async;
int status, s5933_status;
static int cb_pcidas_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ const struct cb_pcidas_board *thisboard;
+ struct cb_pcidas_private *devpriv;
struct comedi_subdevice *s;
struct pci_dev *pcidev = NULL;
int index;
*/
if (alloc_private(dev, sizeof(struct cb_pcidas_private)) < 0)
return -ENOMEM;
+ devpriv = dev->private;
/*
* Probe the device to determine what device in the series it is.
return -EIO;
found:
-
+ thisboard = comedi_board(dev);
dev_dbg(dev->class_dev, "Found %s on bus %i, slot %i\n",
cb_pcidas_boards[index].name, pcidev->bus->number,
PCI_SLOT(pcidev->devfn));
static void cb_pcidas_detach(struct comedi_device *dev)
{
+ struct cb_pcidas_private *devpriv = dev->private;
+
if (devpriv) {
if (devpriv->s5933_config) {
outl(INTCSR_INBOX_INTR_STATUS,