dev->board_name = board->name;
ret = alloc_private(dev, sizeof(*devpriv));
- if (ret < 0)
+ if (ret)
return ret;
devpriv = dev->private;
dev->board_name = boardinfo->name;
ret = alloc_private(dev, sizeof(*devpriv));
- if (ret < 0)
+ if (ret)
return ret;
devpriv = dev->private;
master = 1;
ret = alloc_private(dev, sizeof(*devpriv));
- if (ret < 0) {
- printk(" - Allocation failed!\n");
- return -ENOMEM;
- }
+ if (ret)
+ return ret;
devpriv = dev->private;
pcidev = pci9118_find_pci(dev, it);
dev->board_name = this_board->name;
ret = alloc_private(dev, sizeof(*devpriv));
- if (ret < 0)
+ if (ret)
return ret;
devpriv = dev->private;
dev->board_name = dev->driver->driver_name;
ret = alloc_private(dev, sizeof(*devpriv));
- if (ret < 0)
+ if (ret)
return ret;
devpriv = dev->private;
dev->board_name = this_board->name;
ret = alloc_private(dev, sizeof(*devpriv));
- if (ret < 0)
+ if (ret)
return ret;
devpriv = dev->private;
static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct dio200_board *thisboard = comedi_board(dev);
+ struct dio200_private *devpriv;
int ret;
dev_info(dev->class_dev, DIO200_DRIVER_NAME ": attach\n");
- ret = alloc_private(dev, sizeof(struct dio200_private));
- if (ret < 0) {
- dev_err(dev->class_dev, "error! out of memory!\n");
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
- }
+ devpriv = dev->private;
/* Process options and reserve resources according to bus type. */
if (is_isa_board(thisboard)) {
static int __devinit dio200_attach_pci(struct comedi_device *dev,
struct pci_dev *pci_dev)
{
+ struct dio200_private *devpriv;
int ret;
if (!DO_PCI)
dev_info(dev->class_dev, DIO200_DRIVER_NAME ": attach pci %s\n",
pci_name(pci_dev));
- ret = alloc_private(dev, sizeof(struct dio200_private));
- if (ret < 0) {
- dev_err(dev->class_dev, "error! out of memory!\n");
+
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
- }
+ devpriv = dev->private;
+
dev->board_ptr = dio200_find_pci_board(pci_dev);
if (dev->board_ptr == NULL) {
dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pc236_board *thisboard = comedi_board(dev);
+ struct pc236_private *devpriv;
int ret;
dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach\n");
- ret = alloc_private(dev, sizeof(struct pc236_private));
- if (ret < 0) {
- dev_err(dev->class_dev, "error! out of memory!\n");
+
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
- }
+ devpriv = dev->private;
+
/* Process options according to bus type. */
if (is_isa_board(thisboard)) {
unsigned long iobase = it->options[0];
static int __devinit pc236_attach_pci(struct comedi_device *dev,
struct pci_dev *pci_dev)
{
+ struct pc236_private *devpriv;
int ret;
if (!DO_PCI)
dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach pci %s\n",
pci_name(pci_dev));
- ret = alloc_private(dev, sizeof(struct pc236_private));
- if (ret < 0) {
- dev_err(dev->class_dev, "error! out of memory!\n");
+
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
- }
+ devpriv = dev->private;
+
dev->board_ptr = pc236_find_pci_board(pci_dev);
if (dev->board_ptr == NULL) {
dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct pci224_private *devpriv;
struct pci_dev *pci_dev;
int ret;
dev_info(dev->class_dev, DRIVER_NAME ": attach\n");
- ret = alloc_private(dev, sizeof(struct pci224_private));
- if (ret < 0) {
- dev_err(dev->class_dev, "error! out of memory!\n");
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
- }
+ devpriv = dev->private;
pci_dev = pci224_find_pci_dev(dev, it);
if (!pci_dev)
static int __devinit
pci224_attach_pci(struct comedi_device *dev, struct pci_dev *pci_dev)
{
+ struct pci224_private *devpriv;
int ret;
dev_info(dev->class_dev, DRIVER_NAME ": attach_pci %s\n",
pci_name(pci_dev));
- ret = alloc_private(dev, sizeof(struct pci224_private));
- if (ret < 0) {
- dev_err(dev->class_dev, "error! out of memory!\n");
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
- }
+ devpriv = dev->private;
dev->board_ptr = pci224_find_pci_board(pci_dev);
if (dev->board_ptr == NULL) {
struct pci230_private *devpriv;
int err;
- /* sets dev->private to allocated memory */
- err = alloc_private(dev, sizeof(struct pci230_private));
- if (err) {
- dev_err(dev->class_dev, "error! out of memory!\n");
+ err = alloc_private(dev, sizeof(*devpriv));
+ if (err)
return err;
- }
devpriv = dev->private;
+
spin_lock_init(&devpriv->isr_spinlock);
spin_lock_init(&devpriv->res_spinlock);
spin_lock_init(&devpriv->ai_stop_spinlock);
dev_info(dev->class_dev, "amplc_pci230: attach %s %d,%d\n",
thisboard->name, it->options[0], it->options[1]);
- rc = pci230_alloc_private(dev); /* sets dev->private */
+
+ rc = pci230_alloc_private(dev);
if (rc)
return rc;
+
pci_dev = pci230_find_pci_dev(dev, it);
if (!pci_dev)
return -EIO;
dev_info(dev->class_dev, "amplc_pci230: attach pci %s\n",
pci_name(pci_dev));
- rc = pci230_alloc_private(dev); /* sets dev->private */
+
+ rc = pci230_alloc_private(dev);
if (rc)
return rc;
+
dev->board_ptr = pci230_find_pci_board(pci_dev);
if (dev->board_ptr == NULL) {
dev_err(dev->class_dev,
struct comedi_devconfig *it)
{
const struct das16cs_board *thisboard;
+ struct das16cs_private *devpriv;
struct pcmcia_device *link;
struct comedi_subdevice *s;
int ret;
return ret;
dev->irq = link->irq;
- if (alloc_private(dev, sizeof(struct das16cs_private)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
ret = comedi_alloc_subdevices(dev, 3);
if (ret)
return ret;
ret = alloc_private(dev, sizeof(*devpriv));
- if (ret < 0)
+ if (ret)
return ret;
devpriv = dev->private;
dev->board_name = dev->driver->driver_name;
ret = alloc_private(dev, sizeof(*devpriv));
- if (ret < 0)
+ if (ret)
return ret;
devpriv = dev->private;
dev->board_name = board->name;
result = alloc_private(dev, sizeof(*devpriv));
- if (result < 0)
- return -ENOMEM;
+ if (result)
+ return result;
devpriv = dev->private;
result = comedi_pci_enable(pcidev, dev->driver->driver_name);
static int __devinit __maybe_unused
das08_attach_pci(struct comedi_device *dev, struct pci_dev *pdev)
{
+ struct das08_private_struct *devpriv;
unsigned long iobase;
int ret;
if (!DO_PCI)
return -EINVAL;
- ret = alloc_private(dev, sizeof(struct das08_private_struct));
- if (ret < 0)
+
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
+
dev_info(dev->class_dev, "attach pci %s\n", pci_name(pdev));
dev->board_ptr = das08_find_pci_board(pdev);
if (dev->board_ptr == NULL) {
int ret;
unsigned long iobase;
- ret = alloc_private(dev, sizeof(struct das08_private_struct));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
devpriv = dev->private;
struct comedi_devconfig *it)
{
const struct das08_board_struct *thisboard = comedi_board(dev);
+ struct das08_private_struct *devpriv;
int ret;
unsigned long iobase;
struct pcmcia_device *link = cur_dev; /* XXX hack */
- ret = alloc_private(dev, sizeof(struct das08_private_struct));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
dev_info(dev->class_dev, "das08_cs: attach\n");
/* deal with a pci board */
volatile short timer_running;
volatile short timer_mode; /* true if using timer mode */
};
-#define devpriv ((struct das16_private_struct *)(dev->private))
static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
const struct das16_board *board = comedi_board(dev);
+ struct das16_private_struct *devpriv = dev->private;
int err = 0, tmp;
int gain, start_chan, i;
int mask;
static unsigned int das16_suggest_transfer_size(struct comedi_device *dev,
const struct comedi_cmd *cmd)
{
+ struct das16_private_struct *devpriv = dev->private;
unsigned int size;
unsigned int freq;
static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
int rounding_flags)
{
+ struct das16_private_struct *devpriv = dev->private;
+
i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1),
&(devpriv->divisor2), &ns,
rounding_flags & TRIG_ROUND_MASK);
static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
{
const struct das16_board *board = comedi_board(dev);
+ struct das16_private_struct *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int byte;
static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
const struct das16_board *board = comedi_board(dev);
+ struct das16_private_struct *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags);
struct comedi_insn *insn, unsigned int *data)
{
const struct das16_board *board = comedi_board(dev);
+ struct das16_private_struct *devpriv = dev->private;
int i, n;
int range;
int chan;
*/
static int disable_dma_on_even(struct comedi_device *dev)
{
+ struct das16_private_struct *devpriv = dev->private;
int residue;
int i;
static const int disable_limit = 100;
static const int enable_timeout = 100;
+
disable_dma(devpriv->dma_chan);
residue = get_dma_residue(devpriv->dma_chan);
for (i = 0; i < disable_limit && (residue % 2); ++i) {
static void das16_interrupt(struct comedi_device *dev)
{
const struct das16_board *board = comedi_board(dev);
+ struct das16_private_struct *devpriv = dev->private;
unsigned long dma_flags, spin_flags;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async;
static void das16_timer_interrupt(unsigned long arg)
{
struct comedi_device *dev = (struct comedi_device *)arg;
+ struct das16_private_struct *devpriv = dev->private;
das16_interrupt(dev);
static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct das16_board *board = comedi_board(dev);
+ struct das16_private_struct *devpriv = dev->private;
int status;
int diobits;
static int das1600_mode_detect(struct comedi_device *dev)
{
+ struct das16_private_struct *devpriv = dev->private;
int status = 0;
status = inb(dev->iobase + DAS1600_STATUS_B);
static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct das16_board *board = comedi_board(dev);
+ struct das16_private_struct *devpriv;
struct comedi_subdevice *s;
int ret;
unsigned int irq;
}
}
- ret = alloc_private(dev, sizeof(struct das16_private_struct));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
if (board->size < 0x400) {
printk(" 0x%04lx-0x%04lx\n", iobase, iobase + board->size);
static void das16_detach(struct comedi_device *dev)
{
const struct das16_board *board = comedi_board(dev);
+ struct das16_private_struct *devpriv = dev->private;
das16_reset(dev);
if (dev->subdevices)
unsigned int divisor1; /* divides master clock to obtain conversion speed */
unsigned int divisor2; /* divides master clock to obtain conversion speed */
};
-#define devpriv ((struct das16m1_private_struct *)(dev->private))
static inline short munge_sample(short data)
{
static int das16m1_cmd_test(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
+ struct das16m1_private_struct *devpriv = dev->private;
unsigned int err = 0, tmp, i;
/* Step 1 : check if triggers are trivially valid */
static unsigned int das16m1_set_pacer(struct comedi_device *dev,
unsigned int ns, int rounding_flags)
{
+ struct das16m1_private_struct *devpriv = dev->private;
+
i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL, &(devpriv->divisor1),
&(devpriv->divisor2), &ns,
rounding_flags & TRIG_ROUND_MASK);
static int das16m1_cmd_exec(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct das16m1_private_struct *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int byte, i;
static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct das16m1_private_struct *devpriv = dev->private;
+
devpriv->control_state &= ~INTE & ~PACER_MASK;
outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das16m1_private_struct *devpriv = dev->private;
int i, n;
int byte;
const int timeout = 1000;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das16m1_private_struct *devpriv = dev->private;
unsigned int wbits;
/* only set bits that have been masked */
static void das16m1_handler(struct comedi_device *dev, unsigned int status)
{
+ struct das16m1_private_struct *devpriv = dev->private;
struct comedi_subdevice *s;
struct comedi_async *async;
struct comedi_cmd *cmd;
static int das16m1_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct das16m1_private_struct *devpriv;
struct comedi_subdevice *s;
int ret;
unsigned int irq;
iobase = it->options[0];
- ret = alloc_private(dev, sizeof(struct das16m1_private_struct));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
if (!request_region(iobase, DAS16M1_SIZE, dev->board_name)) {
comedi_error(dev, "I/O port conflict\n");
short ao_update_bits; /* remembers the last write to the 'update' dac */
};
-#define devpriv ((struct das1800_private *)dev->private)
-
/* analog out range for boards with basic analog out */
static const struct comedi_lrange range_ao_1 = {
1,
static void das1800_handle_fifo_half_full(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct das1800_private *devpriv = dev->private;
int numPoints = 0; /* number of points to read */
struct comedi_cmd *cmd = &s->async->cmd;
static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct das1800_private *devpriv = dev->private;
short dpnt;
int unipolar;
struct comedi_cmd *cmd = &s->async->cmd;
struct comedi_subdevice *s,
unsigned int channel, uint16_t *buffer)
{
+ struct das1800_private *devpriv = dev->private;
unsigned int num_bytes, num_samples;
struct comedi_cmd *cmd = &s->async->cmd;
static void das1800_flush_dma(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct das1800_private *devpriv = dev->private;
unsigned long flags;
const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
static void das1800_handle_dma(struct comedi_device *dev,
struct comedi_subdevice *s, unsigned int status)
{
+ struct das1800_private *devpriv = dev->private;
unsigned long flags;
const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct das1800_private *devpriv = dev->private;
+
outb(0x0, dev->iobase + DAS1800_STATUS); /* disable conversions */
outb(0x0, dev->iobase + DAS1800_CONTROL_B); /* disable interrupts and dma */
outb(0x0, dev->iobase + DAS1800_CONTROL_A); /* disable and clear fifo and stop triggering */
/* the guts of the interrupt handler, that is shared with das1800_ai_poll */
static void das1800_ai_handler(struct comedi_device *dev)
{
+ struct das1800_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
+ struct das1800_private *devpriv = dev->private;
int err = 0;
unsigned int tmp_arg;
int i;
/* loads counters with divisor1, divisor2 from private structure */
static int das1800_set_frequency(struct comedi_device *dev)
{
+ struct das1800_private *devpriv = dev->private;
int err = 0;
/* counter 1, mode 2 */
static int setup_counters(struct comedi_device *dev,
const struct comedi_cmd *cmd)
{
+ struct das1800_private *devpriv = dev->private;
unsigned int period;
/* setup cascaded counters for conversion/scan frequency */
/* sets up dma */
static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
{
+ struct das1800_private *devpriv = dev->private;
unsigned long lock_flags;
const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
static int das1800_ai_do_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct das1800_private *devpriv = dev->private;
int ret;
int control_a, control_c;
struct comedi_async *async = s->async;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das1800_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec);
/* int range = CR_RANGE(insn->chanspec); */
int update_chan = thisboard->ao_n_chan - 1;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das1800_private *devpriv = dev->private;
unsigned int wbits;
/* only set bits that have been masked */
static int das1800_init_dma(struct comedi_device *dev, unsigned int dma0,
unsigned int dma1)
{
+ struct das1800_private *devpriv = dev->private;
unsigned long flags;
/* need an irq to do dma */
static int das1800_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct das1800_private *devpriv;
struct comedi_subdevice *s;
unsigned long iobase = it->options[0];
unsigned int irq = it->options[1];
int board;
int retval;
- /* allocate and initialize dev->private */
- if (alloc_private(dev, sizeof(struct das1800_private)) < 0)
- return -ENOMEM;
+ retval = alloc_private(dev, sizeof(*devpriv));
+ if (retval)
+ return retval;
+ devpriv = dev->private;
printk(KERN_DEBUG "comedi%d: %s: io 0x%lx", dev->minor,
dev->driver->driver_name, iobase);
static void das1800_detach(struct comedi_device *dev)
{
+ struct das1800_private *devpriv = dev->private;
+
if (dev->iobase)
release_region(dev->iobase, DAS1800_SIZE);
if (dev->irq)
free_irq(dev->irq, dev);
- if (dev->private) {
+ if (devpriv) {
if (devpriv->iobase2)
release_region(devpriv->iobase2, DAS1800_SIZE);
if (devpriv->dma0)
int das6402_ignoreirq;
};
-#define devpriv ((struct das6402_private *)dev->private)
static void das6402_ai_fifo_dregs(struct comedi_device *dev,
struct comedi_subdevice *s)
static irqreturn_t intr_handler(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct das6402_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
if (!dev->attached || devpriv->das6402_ignoreirq) {
static int das6402_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct das6402_private *devpriv = dev->private;
+
/*
* This function should reset the board from whatever condition it
* is in (i.e., acquiring data), to a non-active state.
static int das6402_ai_mode2(struct comedi_device *dev,
struct comedi_subdevice *s, comedi_trig * it)
{
+ struct das6402_private *devpriv = dev->private;
+
devpriv->das6402_ignoreirq = 1;
dev_dbg(dev->class_dev, "Starting acquisition\n");
outb_p(0x03, dev->iobase + 10); /* enable external trigging */
static int board_init(struct comedi_device *dev)
{
+ struct das6402_private *devpriv = dev->private;
BYTE b;
devpriv->das6402_ignoreirq = 1;
static int das6402_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct das6402_private *devpriv;
unsigned int irq;
unsigned long iobase;
int ret;
return ret;
dev->irq = irq;
- ret = alloc_private(dev, sizeof(struct das6402_private));
- if (ret < 0)
+
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
ret = comedi_alloc_subdevices(dev, 1);
if (ret)
volatile int do_bits; /* digital output bits */
};
-#define devpriv ((struct das800_private *)dev->private)
-
static int das800_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static void das800_detach(struct comedi_device *dev);
short i; /* loop index */
short dataPoint = 0;
struct comedi_device *dev = d;
+ struct das800_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev; /* analog input subdevice */
struct comedi_async *async;
int status;
static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct das800_private *devpriv;
struct comedi_subdevice *s;
unsigned long iobase = it->options[0];
unsigned int irq = it->options[1];
if (irq)
dev_dbg(dev->class_dev, "irq %u\n", irq);
- /* allocate and initialize dev->private */
- if (alloc_private(dev, sizeof(struct das800_private)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
if (iobase == 0) {
dev_err(dev->class_dev,
static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct das800_private *devpriv = dev->private;
+
devpriv->forever = 0;
devpriv->count = 0;
disable_das800(dev);
/* enable_das800 makes the card start taking hardware triggered conversions */
static void enable_das800(struct comedi_device *dev)
{
+ struct das800_private *devpriv = dev->private;
unsigned long irq_flags;
+
spin_lock_irqsave(&dev->spinlock, irq_flags);
/* enable fifo-half full interrupts for cio-das802/16 */
if (thisboard->resolution == 16)
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
+ struct das800_private *devpriv = dev->private;
int err = 0;
int tmp;
int gain, startChan;
static int das800_ai_do_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct das800_private *devpriv = dev->private;
int startChan, endChan, scan, gain;
int conv_bits;
unsigned long irq_flags;
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct das800_private *devpriv = dev->private;
int i, n;
int chan;
int range;
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct das800_private *devpriv = dev->private;
int wbits;
unsigned long irq_flags;
/* loads counters with divisor1, divisor2 from private structure */
static int das800_set_frequency(struct comedi_device *dev)
{
+ struct das800_private *devpriv = dev->private;
int err = 0;
if (i8254_load(dev->iobase + DAS800_8254, 0, 1, devpriv->divisor1, 2))
dev->irq = irq;
}
- if (alloc_private(dev, sizeof(*devpriv)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
devpriv = dev->private;
ret = comedi_alloc_subdevices(dev, 3);
unsigned int ao_readback[2];
};
-#define devpriv ((struct dt2801_private *)dev->private)
-
/* These are the low-level routines:
writecommand: write a command to the board
writedata: write data byte
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt2801_private *devpriv = dev->private;
+
data[0] = devpriv->ao_readback[CR_CHAN(insn->chanspec)];
return 1;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt2801_private *devpriv = dev->private;
+
dt2801_writecmd(dev, DT_C_WRITE_DAIM);
dt2801_writedata(dev, CR_CHAN(insn->chanspec));
dt2801_writedata2(dev, data[0]);
*/
static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct dt2801_private *devpriv;
struct comedi_subdevice *s;
unsigned long iobase;
int board_code, type;
if (ret)
goto out;
- ret = alloc_private(dev, sizeof(struct dt2801_private));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
dev->board_name = boardtype.name;
unsigned int ao_readback[2];
};
-#define devpriv ((struct dt2811_private *)dev->private)
-
static const struct comedi_lrange *dac_range_types[] = {
&range_bipolar5,
&range_bipolar2_5,
int lo, hi;
int data;
struct comedi_device *dev = d;
+ struct dt2811_private *devpriv = dev->private;
if (!dev->attached) {
comedi_error(dev, "spurious interrupt");
static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt2811_private *devpriv = dev->private;
int i;
int chan;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt2811_private *devpriv = dev->private;
int i;
int chan;
/* long flags; */
const struct dt2811_board *board = comedi_board(dev);
+ struct dt2811_private *devpriv;
int ret;
struct comedi_subdevice *s;
unsigned long iobase;
if (ret)
return ret;
- ret = alloc_private(dev, sizeof(struct dt2811_private));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
switch (it->options[2]) {
case 0:
int curadchan;
};
-#define devpriv ((struct dt2814_private *)dev->private)
-
#define DT2814_TIMEOUT 10
#define DT2814_MAX_SPEED 100000 /* Arbitrary 10 khz limit */
static int dt2814_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct dt2814_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int chan;
int trigvar;
{
int lo, hi;
struct comedi_device *dev = d;
+ struct dt2814_private *devpriv = dev->private;
struct comedi_subdevice *s;
int data;
static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct dt2814_private *devpriv;
int i, irq;
int ret;
struct comedi_subdevice *s;
if (ret)
return ret;
- ret = alloc_private(dev, sizeof(struct dt2814_private));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
s = &dev->subdevices[0];
dev->read_subdev = s;
unsigned int ao_readback[8];
};
-#define devpriv ((struct dt2815_private *)dev->private)
-
static int dt2815_wait_for_status(struct comedi_device *dev, int status)
{
int i;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt2815_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt2815_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
unsigned int status;
static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct dt2815_private *devpriv;
struct comedi_subdevice *s;
int i;
const struct comedi_lrange *current_range_type, *voltage_range_type;
if (ret)
return ret;
- if (alloc_private(dev, sizeof(struct dt2815_private)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
s = &dev->subdevices[0];
/* ao subdevice */
int dma_dir;
};
-#define devpriv ((struct dt282x_private *)dev->private)
#define boardtype (*(const struct dt282x_board *)dev->board_ptr)
/*
static void dt282x_munge(struct comedi_device *dev, short *buf,
unsigned int nbytes)
{
+ struct dt282x_private *devpriv = dev->private;
unsigned int i;
unsigned short mask = (1 << boardtype.adbits) - 1;
unsigned short sign = 1 << (boardtype.adbits - 1);
static void dt282x_ao_dma_interrupt(struct comedi_device *dev)
{
+ struct dt282x_private *devpriv = dev->private;
void *ptr;
int size;
int i;
static void dt282x_ai_dma_interrupt(struct comedi_device *dev)
{
+ struct dt282x_private *devpriv = dev->private;
void *ptr;
int size;
int i;
static int prep_ai_dma(struct comedi_device *dev, int dma_index, int n)
{
+ struct dt282x_private *devpriv = dev->private;
int dma_chan;
unsigned long dma_ptr;
unsigned long flags;
static int prep_ao_dma(struct comedi_device *dev, int dma_index, int n)
{
+ struct dt282x_private *devpriv = dev->private;
int dma_chan;
unsigned long dma_ptr;
unsigned long flags;
static irqreturn_t dt282x_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct dt282x_private *devpriv = dev->private;
struct comedi_subdevice *s;
struct comedi_subdevice *s_ao;
unsigned int supcsr, adcsr, dacsr;
static void dt282x_load_changain(struct comedi_device *dev, int n,
unsigned int *chanlist)
{
+ struct dt282x_private *devpriv = dev->private;
unsigned int i;
unsigned int chan, range;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt282x_private *devpriv = dev->private;
int i;
/* XXX should we really be enabling the ad clock here? */
static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
const struct dt282x_board *board = comedi_board(dev);
+ struct dt282x_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int timer;
static void dt282x_disable_dma(struct comedi_device *dev)
{
+ struct dt282x_private *devpriv = dev->private;
+
if (devpriv->usedma) {
disable_dma(devpriv->dma[0].chan);
disable_dma(devpriv->dma[1].chan);
static int dt282x_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct dt282x_private *devpriv = dev->private;
+
dt282x_disable_dma(dev);
devpriv->adcsr = 0;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt282x_private *devpriv = dev->private;
+
data[0] = devpriv->ao[CR_CHAN(insn->chanspec)];
return 1;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt282x_private *devpriv = dev->private;
short d;
unsigned int chan;
static int dt282x_ao_inttrig(struct comedi_device *dev,
struct comedi_subdevice *s, unsigned int x)
{
+ struct dt282x_private *devpriv = dev->private;
int size;
if (x != 0)
static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct dt282x_private *devpriv = dev->private;
int timer;
struct comedi_cmd *cmd = &s->async->cmd;
static int dt282x_ao_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct dt282x_private *devpriv = dev->private;
+
dt282x_disable_dma(dev);
devpriv->dacsr = 0;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt282x_private *devpriv = dev->private;
int mask;
mask = (CR_CHAN(insn->chanspec) < 8) ? 0x00ff : 0xff00;
static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2)
{
+ struct dt282x_private *devpriv = dev->private;
int ret;
devpriv->usedma = 0;
static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct dt282x_board *board = comedi_board(dev);
+ struct dt282x_private *devpriv;
int i, irq;
int ret;
struct comedi_subdevice *s;
#endif
}
- ret = alloc_private(dev, sizeof(struct dt282x_private));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
ret = dt282x_grab_dma(dev, it->options[opt_dma1],
it->options[opt_dma2]);
static void dt282x_detach(struct comedi_device *dev)
{
+ struct dt282x_private *devpriv = dev->private;
+
if (dev->irq)
free_irq(dev->irq, dev);
if (dev->iobase)
unsigned int ai_rear;
};
-#define devpriv ((struct dt3k_private *)dev->private)
-
static void dt3k_ai_empty_fifo(struct comedi_device *dev,
struct comedi_subdevice *s);
static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *arg,
static int dt3k_send_cmd(struct comedi_device *dev, unsigned int cmd)
{
+ struct dt3k_private *devpriv = dev->private;
int i;
unsigned int status = 0;
unsigned int subsys, unsigned int chan,
unsigned int gain)
{
+ struct dt3k_private *devpriv = dev->private;
+
writew(subsys, devpriv->io_addr + DPR_SubSys);
writew(chan, devpriv->io_addr + DPR_Params(0));
static void dt3k_writesingle(struct comedi_device *dev, unsigned int subsys,
unsigned int chan, unsigned int data)
{
+ struct dt3k_private *devpriv = dev->private;
+
writew(subsys, devpriv->io_addr + DPR_SubSys);
writew(chan, devpriv->io_addr + DPR_Params(0));
static irqreturn_t dt3k_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct dt3k_private *devpriv = dev->private;
struct comedi_subdevice *s;
unsigned int status;
static void dt3k_ai_empty_fifo(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct dt3k_private *devpriv = dev->private;
int front;
int rear;
int count;
static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct dt3k_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int i;
unsigned int chan, range, aref;
static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct dt3k_private *devpriv = dev->private;
int ret;
writew(SUBS_AI, devpriv->io_addr + DPR_SubSys);
static int dt3k_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt3k_private *devpriv = dev->private;
int i;
unsigned int chan;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt3k_private *devpriv = dev->private;
int i;
unsigned int chan;
static void dt3k_dio_config(struct comedi_device *dev, int bits)
{
+ struct dt3k_private *devpriv = dev->private;
+
/* XXX */
writew(SUBS_DOUT, devpriv->io_addr + DPR_SubSys);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dt3k_private *devpriv = dev->private;
unsigned int addr = CR_CHAN(insn->chanspec);
int i;
static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct dt3k_private *devpriv;
struct pci_dev *pcidev;
struct comedi_subdevice *s;
resource_size_t pci_base;
dev_dbg(dev->class_dev, "dt3000:\n");
- ret = alloc_private(dev, sizeof(struct dt3k_private));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
pcidev = dt3000_find_pci_dev(dev, it);
if (!pcidev)
static void dt3000_detach(struct comedi_device *dev)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+ struct dt3k_private *devpriv = dev->private;
if (dev->irq)
free_irq(dev->irq, dev);
static struct slot_dt9812 dt9812[DT9812_NUM_SLOTS];
-/* Useful shorthand access to private data */
-#define devpriv ((struct comedi_dt9812 *)dev->private)
-
static inline struct usb_dt9812 *to_dt9812_dev(struct kref *d)
{
return container_of(d, struct usb_dt9812, kref);
static int dt9812_comedi_open(struct comedi_device *dev)
{
+ struct comedi_dt9812 *devpriv = dev->private;
int result = -ENODEV;
down(&devpriv->slot->mutex);
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct comedi_dt9812 *devpriv = dev->private;
int n;
u8 bits = 0;
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct comedi_dt9812 *devpriv = dev->private;
int n;
u8 bits = 0;
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct comedi_dt9812 *devpriv = dev->private;
int n;
for (n = 0; n < insn->n; n++) {
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct comedi_dt9812 *devpriv = dev->private;
int n;
u16 value;
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct comedi_dt9812 *devpriv = dev->private;
int n;
for (n = 0; n < insn->n; n++)
static int dt9812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct comedi_dt9812 *devpriv;
int i;
struct comedi_subdevice *s;
int ret;
dev->board_name = "dt9812";
- if (alloc_private(dev, sizeof(struct comedi_dt9812)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
/*
* Special open routine, since USB unit may be unattached at
short ao_readback[2];
};
-#define devpriv ((struct fl512_private *) dev->private)
-
static const struct comedi_lrange range_fl512 = { 4, {
BIP_RANGE(0.5),
BIP_RANGE(1),
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct fl512_private *devpriv = dev->private;
int n;
int chan = CR_CHAN(insn->chanspec); /* get chan to write */
unsigned long iobase = dev->iobase; /* get base address */
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct fl512_private *devpriv = dev->private;
int n;
int chan = CR_CHAN(insn->chanspec);
static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct fl512_private *devpriv;
unsigned long iobase;
int ret;
}
dev->iobase = iobase;
dev->board_name = "fl512";
- if (alloc_private(dev, sizeof(struct fl512_private)) < 0)
- return -ENOMEM;
+
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
#if DEBUG
printk(KERN_DEBUG "malloc ok\n");
dev->board_name = dev->driver->driver_name;
ret = alloc_private(dev, sizeof(*devpriv));
- if (ret < 0)
+ if (ret)
return ret;
devpriv = dev->private;
union pci20xxx_subdev_private subdev_private[PCI20000_MODULES];
};
-#define devpriv ((struct pci20xxx_private *)dev->private)
#define CHAN (CR_CHAN(it->chanlist[0]))
static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
static int pci20xxx_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct pci20xxx_private *devpriv;
unsigned char i;
int ret;
int id;
if (ret)
return ret;
- ret = alloc_private(dev, sizeof(struct pci20xxx_private));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
devpriv->ioaddr = (void __iomem *)(unsigned long)it->options[0];
dev->board_name = "pci20kc";
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pci20xxx_private *devpriv = dev->private;
unsigned int mask = data[0];
s->state &= ~mask;
static void pci20xxx_dio_config(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pci20xxx_private *devpriv = dev->private;
unsigned char control_01;
unsigned char control_23;
unsigned char buffer;
#if 0
static void pci20xxx_do(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct pci20xxx_private *devpriv = dev->private;
+
/* XXX if the channel is configured for input, does this
do bad things? */
/* XXX it would be a good idea to only update the registers
static unsigned int pci20xxx_di(struct comedi_device *dev,
struct comedi_subdevice *s)
{
- /* XXX same note as above */
+ struct pci20xxx_private *devpriv = dev->private;
unsigned int bits;
+ /* XXX same note as above */
bits = readb(devpriv->ioaddr + PCI20000_DIO_0);
bits |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8;
bits |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16;
return -EINVAL;
}
- result = alloc_private(dev, sizeof(struct jr3_pci_dev_private));
- if (result < 0)
- return -ENOMEM;
- card = NULL;
+ result = alloc_private(dev, sizeof(*devpriv));
+ if (result)
+ return result;
devpriv = dev->private;
+
+ card = NULL;
init_timer(&devpriv->timer);
while (1) {
card = pci_get_device(PCI_VENDOR_ID_JR3, PCI_ANY_ID, card);
int ao_readback[4]; /* Mirror of analog output data */
};
-#define dev_private ((struct me_private_data *)dev->private)
-
/*
* ------------------------------------------------------------------
*
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct me_private_data *dev_private = dev->private;
int bits;
int mask = 1 << CR_CHAN(insn->chanspec);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct me_private_data *dev_private = dev->private;
unsigned int mask = data[0];
+
s->state &= ~mask;
s->state |= (mask & data[1]);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct me_private_data *dev_private = dev->private;
unsigned short value;
int chan = CR_CHAN((&insn->chanspec)[0]);
int rang = CR_RANGE((&insn->chanspec)[0]);
/* Cancel analog input autoscan */
static int me_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct me_private_data *dev_private = dev->private;
+
/* disable interrupts */
/* stop any running conversion */
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct me_private_data *dev_private = dev->private;
int chan;
int rang;
int i;
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct me_private_data *dev_private = dev->private;
int i;
for (i = 0; i < insn->n; i++) {
static int me2600_xilinx_download(struct comedi_device *dev,
const u8 *data, size_t size)
{
+ struct me_private_data *dev_private = dev->private;
unsigned int value;
unsigned int file_length;
unsigned int i;
/* Reset device */
static int me_reset(struct comedi_device *dev)
{
+ struct me_private_data *dev_private = dev->private;
+
/* Reset board */
writew(0x00, dev_private->me_regbase + ME_CONTROL_1);
writew(0x00, dev_private->me_regbase + ME_CONTROL_2);
static int me_attach_pci(struct comedi_device *dev, struct pci_dev *pcidev)
{
const struct me_board *board;
+ struct me_private_data *dev_private;
struct comedi_subdevice *s;
resource_size_t plx_regbase_tmp;
unsigned long plx_regbase_size_tmp;
dev->board_ptr = board;
dev->board_name = board->name;
- /* Allocate private memory */
- if (alloc_private(dev, sizeof(struct me_private_data)) < 0)
- return -ENOMEM;
+ error = alloc_private(dev, sizeof(*dev_private));
+ if (error)
+ return error;
+ dev_private = dev->private;
/* Enable PCI device and request PCI regions */
if (comedi_pci_enable(pcidev, dev->board_name) < 0) {
static void me_detach(struct comedi_device *dev)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+ struct me_private_data *dev_private = dev->private;
if (dev_private) {
if (dev_private->me_regbase) {
#define MPC624_SPEED_6_875_Hz \
(MPC624_OSR4 | MPC624_OSR3 | MPC624_OSR2 | MPC624_OSR1 | MPC624_OSR0)
/* -------------------------------------------------------------------------- */
-struct skel_private {
+struct mpc624_private {
/* set by mpc624_attach() from driver's parameters */
unsigned long int ulConvertionRate;
};
-#define devpriv ((struct skel_private *)dev->private)
/* -------------------------------------------------------------------------- */
static const struct comedi_lrange range_mpc624_bipolar1 = {
1,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct mpc624_private *devpriv = dev->private;
int n, i;
unsigned long int data_in, data_out;
unsigned char ucPort;
static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct mpc624_private *devpriv;
struct comedi_subdevice *s;
unsigned long iobase;
int ret;
dev->iobase = iobase;
dev->board_name = "mpc624";
- /* Private structure initialization */
- if (alloc_private(dev, sizeof(struct skel_private)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
switch (it->options[1]) {
case 0:
struct multiq3_private {
unsigned int ao_readback[2];
};
-#define devpriv ((struct multiq3_private *)dev->private)
static int multiq3_ai_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct multiq3_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct multiq3_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
static int multiq3_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct multiq3_private *devpriv;
int result = 0;
unsigned long iobase;
unsigned int irq;
if (result)
return result;
- result = alloc_private(dev, sizeof(struct multiq3_private));
- if (result < 0)
+ result = alloc_private(dev, sizeof(*devpriv));
+ if (result)
return result;
+ devpriv = dev->private;
s = &dev->subdevices[0];
/* ai subdevice */
unsigned int filter_enable;
};
-#define devpriv ((struct ni6527_private *)dev->private)
-
static int ni6527_di_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct ni6527_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec);
unsigned int interval;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct ni6527_private *devpriv = dev->private;
+
data[1] = readb(devpriv->mite->daq_io_addr + Port_Register(0));
data[1] |= readb(devpriv->mite->daq_io_addr + Port_Register(1)) << 8;
data[1] |= readb(devpriv->mite->daq_io_addr + Port_Register(2)) << 16;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct ni6527_private *devpriv = dev->private;
+
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
static irqreturn_t ni6527_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct ni6527_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[2];
unsigned int status;
static int ni6527_intr_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct ni6527_private *devpriv = dev->private;
/* struct comedi_cmd *cmd = &s->async->cmd; */
writeb(ClrEdge | ClrOverflow,
static int ni6527_intr_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct ni6527_private *devpriv = dev->private;
+
writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control);
return 0;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct ni6527_private *devpriv = dev->private;
+
if (insn->n < 1)
return -EINVAL;
if (data[0] != INSN_CONFIG_CHANGE_NOTIFY)
static int __devinit ni6527_attach_pci(struct comedi_device *dev,
struct pci_dev *pcidev)
{
+ struct ni6527_private *devpriv;
struct comedi_subdevice *s;
int ret;
- ret = alloc_private(dev, sizeof(struct ni6527_private));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
dev->board_ptr = ni6527_find_boardinfo(pcidev);
if (!dev->board_ptr)
static void ni6527_detach(struct comedi_device *dev)
{
+ struct ni6527_private *devpriv = dev->private;
+
if (devpriv && devpriv->mite && devpriv->mite->daq_io_addr)
writeb(0x00,
devpriv->mite->daq_io_addr + Master_Interrupt_Control);
int i;
ret = alloc_private(dev, sizeof(*devpriv));
- if (ret < 0)
+ if (ret)
return ret;
devpriv = dev->private;
+
dev->board_ptr = ni_670x_find_boardinfo(pcidev);
if (!dev->board_ptr)
return -ENODEV;
int config_bits; /* config register bits */
};
-#define devpriv ((struct a2150_private *)dev->private)
-
static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
static void ni_dump_regs(struct comedi_device *dev)
{
+ struct a2150_private *devpriv = dev->private;
+
printk("config bits 0x%x\n", devpriv->config_bits);
printk("irq dma bits 0x%x\n", devpriv->irq_dma_bits);
printk("status bits 0x%x\n", inw(dev->iobase + STATUS_REG));
int status;
unsigned long flags;
struct comedi_device *dev = d;
+ struct a2150_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async;
struct comedi_cmd *cmd;
static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct a2150_private *devpriv = dev->private;
+
/* disable dma on card */
devpriv->irq_dma_bits &= ~DMA_INTR_EN_BIT & ~DMA_EN_BIT;
outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG);
static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct a2150_private *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned long lock_flags;
static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct a2150_private *devpriv = dev->private;
unsigned int i, n;
static const int timeout = 100000;
static const int filter_delay = 36;
static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
int flags)
{
+ struct a2150_private *devpriv = dev->private;
int lub, glb, temp;
int lub_divisor_shift, lub_index, glb_divisor_shift, glb_index;
int i, j;
unsigned int start_channel,
unsigned int num_channels)
{
+ struct a2150_private *devpriv = dev->private;
+
if (start_channel + num_channels > 4)
return -1;
static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct a2150_private *devpriv;
struct comedi_subdevice *s;
unsigned long iobase = it->options[0];
unsigned int irq = it->options[1];
}
printk("\n");
- /* allocate and initialize dev->private */
- if (alloc_private(dev, sizeof(struct a2150_private)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
if (iobase == 0) {
printk(" io base address required\n");
static void a2150_detach(struct comedi_device *dev)
{
+ struct a2150_private *devpriv = dev->private;
+
if (dev->iobase) {
outw(APD_BIT | DPD_BIT, dev->iobase + CONFIG_REG);
release_region(dev->iobase, A2150_SIZE);
unsigned int ao_readback[10];
};
-#define devpriv ((struct atao_private *)dev->private)
-
static void atao_reset(struct comedi_device *dev)
{
+ struct atao_private *devpriv = dev->private;
+
/* This is the reset sequence described in the manual */
devpriv->cfg1 = 0;
static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct atao_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
short bits;
static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct atao_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct atao_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec);
unsigned int mask, bit;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct atao_private *devpriv = dev->private;
unsigned int bitstring, bit;
unsigned int chan = CR_CHAN(insn->chanspec);
static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct atao_board *board = comedi_board(dev);
+ struct atao_private *devpriv;
struct comedi_subdevice *s;
unsigned long iobase;
int ao_unipolar;
dev->board_name = board->name;
- if (alloc_private(dev, sizeof(struct atao_private)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
ret = comedi_alloc_subdevices(dev, 4);
if (ret)
#define CLOCK_100_HZ 0x8F25
/* Other miscellaneous defines */
#define ATMIO16D_SIZE 32 /* bus address range */
-#define devpriv ((struct atmio16d_private *)dev->private)
#define ATMIO16D_TIMEOUT 10
struct atmio16_board_t {
static void reset_atmio16d(struct comedi_device *dev)
{
+ struct atmio16d_private *devpriv = dev->private;
int i;
/* now we need to initialize the board */
static int atmio16d_ai_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct atmio16d_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int timer, base_clock;
unsigned int sample_count, tmp, chan, gain;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct atmio16d_private *devpriv = dev->private;
int i, t;
int chan;
int gain;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct atmio16d_private *devpriv = dev->private;
int i;
for (i = 0; i < insn->n; i++)
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct atmio16d_private *devpriv = dev->private;
int i;
int chan;
int d;
struct comedi_insn *insn,
unsigned int *data)
{
+ struct atmio16d_private *devpriv = dev->private;
int i;
int mask;
struct comedi_devconfig *it)
{
const struct atmio16_board_t *board = comedi_board(dev);
+ struct atmio16d_private *devpriv;
unsigned int irq;
unsigned long iobase;
int ret;
if (ret)
return ret;
- ret = alloc_private(dev, sizeof(struct atmio16d_private));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
/* reset the atmio16d hardware */
reset_atmio16d(dev);
int data; /* number of data points left to be taken */
};
-#define devpriv ((struct dio24_private *)dev->private)
-
static struct comedi_driver driver_dio24 = {
.driver_name = "ni_daq_dio24",
.module = THIS_MODULE,
static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct dio24_private *devpriv;
struct comedi_subdevice *s;
unsigned long iobase = 0;
#ifdef incomplete
struct pcmcia_device *link;
int ret;
- /* allocate and initialize dev->private */
- if (alloc_private(dev, sizeof(struct dio24_private)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
/* get base address, irq etc. based on bustype */
switch (thisboard->bustype) {
/* 2 bytes per sample */
static const int sample_size = 2;
-#define devpriv ((struct labpc_private *)dev->private)
-
static inline int labpc_counter_load(struct comedi_device *dev,
unsigned long base_address,
unsigned int counter_number,
int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
unsigned int irq, unsigned int dma_chan)
{
+ struct labpc_private *devpriv = dev->private;
struct comedi_subdevice *s;
int i;
unsigned long isr_flags;
static int __devinit labpc_attach_pci(struct comedi_device *dev,
struct pci_dev *pcidev)
{
+ struct labpc_private *devpriv;
unsigned long iobase;
unsigned int irq;
int ret;
if (!IS_ENABLED(CONFIG_COMEDI_PCI_DRIVERS))
return -ENODEV;
- ret = alloc_private(dev, sizeof(struct labpc_private));
- if (ret < 0)
+
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
+
dev->board_ptr = labpc_pci_find_boardinfo(pcidev);
if (!dev->board_ptr)
return -ENODEV;
static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct labpc_private *devpriv;
unsigned long iobase = 0;
unsigned int irq = 0;
unsigned int dma_chan = 0;
+ int ret;
- /* allocate and initialize dev->private */
- if (alloc_private(dev, sizeof(struct labpc_private)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
/* get base address, irq etc. based on bustype */
switch (thisboard->bustype) {
void labpc_common_detach(struct comedi_device *dev)
{
+ struct labpc_private *devpriv = dev->private;
struct comedi_subdevice *s;
if (dev->subdevices) {
static void labpc_clear_adc_fifo(const struct comedi_device *dev)
{
+ struct labpc_private *devpriv = dev->private;
+
devpriv->write_byte(0x1, dev->iobase + ADC_CLEAR_REG);
devpriv->read_byte(dev->iobase + ADC_FIFO_REG);
devpriv->read_byte(dev->iobase + ADC_FIFO_REG);
static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct labpc_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags);
static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct labpc_private *devpriv = dev->private;
int channel, range, aref;
#ifdef CONFIG_ISA_DMA_API
unsigned long irq_flags;
static irqreturn_t labpc_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct labpc_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async;
struct comedi_cmd *cmd;
/* read all available samples from ai fifo */
static int labpc_drain_fifo(struct comedi_device *dev)
{
+ struct labpc_private *devpriv = dev->private;
unsigned int lsb, msb;
short data;
struct comedi_async *async = dev->read_subdev->async;
#ifdef CONFIG_ISA_DMA_API
static void labpc_drain_dma(struct comedi_device *dev)
{
+ struct labpc_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async;
int status;
static void handle_isa_dma(struct comedi_device *dev)
{
+ struct labpc_private *devpriv = dev->private;
+
labpc_drain_dma(dev);
enable_dma(devpriv->dma_chan);
static void labpc_drain_dregs(struct comedi_device *dev)
{
#ifdef CONFIG_ISA_DMA_API
+ struct labpc_private *devpriv = dev->private;
+
if (devpriv->current_transfer == isa_dma_transfer)
labpc_drain_dma(dev);
#endif
static int labpc_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct labpc_private *devpriv = dev->private;
int i, n;
int chan, range;
int lsb, msb;
static int labpc_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct labpc_private *devpriv = dev->private;
int channel, range;
unsigned long flags;
int lsb, msb;
static int labpc_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct labpc_private *devpriv = dev->private;
+
data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)];
return 1;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct labpc_private *devpriv = dev->private;
+
data[0] = devpriv->caldac[CR_CHAN(insn->chanspec)];
return 1;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct labpc_private *devpriv = dev->private;
+
data[0] = devpriv->eeprom_data[CR_CHAN(insn->chanspec)];
return 1;
static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd,
enum scan_mode mode)
{
+ struct labpc_private *devpriv = dev->private;
/* max value for 16 bit counter in mode 2 */
const int max_counter_value = 0x10000;
/* min value for 16 bit counter in mode 2 */
static void labpc_serial_out(struct comedi_device *dev, unsigned int value,
unsigned int value_width)
{
+ struct labpc_private *devpriv = dev->private;
int i;
for (i = 1; i <= value_width; i++) {
/* lowlevel read from eeprom */
static unsigned int labpc_serial_in(struct comedi_device *dev)
{
+ struct labpc_private *devpriv = dev->private;
unsigned int value = 0;
int i;
const int value_width = 8; /* number of bits wide values are */
static unsigned int labpc_eeprom_read(struct comedi_device *dev,
unsigned int address)
{
+ struct labpc_private *devpriv = dev->private;
unsigned int value;
/* bits to tell eeprom to expect a read */
const int read_instruction = 0x3;
static int labpc_eeprom_write(struct comedi_device *dev,
unsigned int address, unsigned int value)
{
+ struct labpc_private *devpriv = dev->private;
const int write_enable_instruction = 0x6;
const int write_instruction = 0x2;
const int write_length = 8; /* 8 bit write lengths to eeprom */
static unsigned int labpc_eeprom_read_status(struct comedi_device *dev)
{
+ struct labpc_private *devpriv = dev->private;
unsigned int value;
const int read_status_instruction = 0x5;
const int write_length = 8; /* 8 bit write lengths to eeprom */
static void write_caldac(struct comedi_device *dev, unsigned int channel,
unsigned int value)
{
+ struct labpc_private *devpriv = dev->private;
+
if (value == devpriv->caldac[channel])
return;
devpriv->caldac[channel] = value;
static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct labpc_private *devpriv;
unsigned long iobase = 0;
unsigned int irq = 0;
struct pcmcia_device *link;
+ int ret;
- /* allocate and initialize dev->private */
- if (alloc_private(dev, sizeof(struct labpc_private)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
/* get base address, irq etc. based on bustype */
switch (thisboard->bustype) {
struct mite_dma_descriptor_ring *di_mite_ring;
spinlock_t mite_channel_lock;
};
-#define devpriv ((struct nidio96_private *)dev->private)
static int ni_pcidio_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
static int ni_pcidio_request_di_mite_channel(struct comedi_device *dev)
{
+ struct nidio96_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
static void ni_pcidio_release_di_mite_channel(struct comedi_device *dev)
{
+ struct nidio96_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
static int ni_pcidio_poll(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct nidio96_private *devpriv = dev->private;
unsigned long irq_flags;
int count;
static irqreturn_t nidio_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct nidio96_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
struct comedi_async *async = s->async;
struct mite_struct *mite = devpriv->mite;
#ifdef unused
static void debug_int(struct comedi_device *dev)
{
+ struct nidio96_private *devpriv = dev->private;
int a, b;
static int n_int;
struct timeval tv;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct nidio96_private *devpriv = dev->private;
+
if (insn->n != 1)
return -EINVAL;
switch (data[0]) {
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct nidio96_private *devpriv = dev->private;
+
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
static int ni_pcidio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct nidio96_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
/* XXX configure ports for input */
static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct nidio96_private *devpriv = dev->private;
int retval;
unsigned long flags;
static int ni_pcidio_inttrig(struct comedi_device *dev,
struct comedi_subdevice *s, unsigned int trignum)
{
+ struct nidio96_private *devpriv = dev->private;
+
if (trignum != 0)
return -EINVAL;
static int ni_pcidio_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct nidio96_private *devpriv = dev->private;
+
writeb(0x00,
devpriv->mite->daq_io_addr + Master_DMA_And_Interrupt_Control);
ni_pcidio_release_di_mite_channel(dev);
static int ni_pcidio_change(struct comedi_device *dev,
struct comedi_subdevice *s, unsigned long new_size)
{
+ struct nidio96_private *devpriv = dev->private;
int ret;
ret = mite_buf_change(devpriv->di_mite_ring, s->async);
static int pci_6534_load_fpga(struct comedi_device *dev, int fpga_index,
const u8 *data, size_t data_len)
{
+ struct nidio96_private *devpriv = dev->private;
static const int timeout = 1000;
int i;
size_t j;
static int pci_6534_reset_fpgas(struct comedi_device *dev)
{
+ struct nidio96_private *devpriv = dev->private;
int ret;
int i;
+
writew(0x0, devpriv->mite->daq_io_addr + Firmware_Control_Register);
for (i = 0; i < 3; ++i) {
ret = pci_6534_reset_fpga(dev, i);
static void pci_6534_init_main_fpga(struct comedi_device *dev)
{
+ struct nidio96_private *devpriv = dev->private;
+
writel(0, devpriv->mite->daq_io_addr + FPGA_Control1_Register);
writel(0, devpriv->mite->daq_io_addr + FPGA_Control2_Register);
writel(0, devpriv->mite->daq_io_addr + FPGA_SCALS_Counter_Register);
static int pci_6534_upload_firmware(struct comedi_device *dev)
{
+ struct nidio96_private *devpriv = dev->private;
int ret;
const struct firmware *fw;
static const char *const fw_file[3] = {
static int __devinit nidio_attach_pci(struct comedi_device *dev,
struct pci_dev *pcidev)
{
+ struct nidio96_private *devpriv;
struct comedi_subdevice *s;
int ret;
unsigned int irq;
- ret = alloc_private(dev, sizeof(struct nidio96_private));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
+
spin_lock_init(&devpriv->mite_channel_lock);
dev->board_ptr = nidio_find_boardinfo(pcidev);
static void nidio_detach(struct comedi_device *dev)
{
+ struct nidio96_private *devpriv = dev->private;
+
if (dev->irq)
free_irq(dev->irq, dev);
if (devpriv) {
unsigned int divisor2;
};
-#define devpriv ((struct pcl711_private *)dev->private)
-
static irqreturn_t pcl711_interrupt(int irq, void *d)
{
int lo, hi;
int data;
struct comedi_device *dev = d;
const struct pcl711_board *board = comedi_board(dev);
+ struct pcl711_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
if (!dev->attached) {
static int pcl711_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
+ struct pcl711_private *devpriv = dev->private;
int tmp;
int err = 0;
static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct pcl711_private *devpriv = dev->private;
int timer1, timer2;
struct comedi_cmd *cmd = &s->async->cmd;
static int pcl711_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pcl711_private *devpriv = dev->private;
int n;
int chan = CR_CHAN(insn->chanspec);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pcl711_private *devpriv = dev->private;
int n;
int chan = CR_CHAN(insn->chanspec);
static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pcl711_board *board = comedi_board(dev);
+ struct pcl711_private *devpriv;
int ret;
unsigned long iobase;
unsigned int irq;
if (ret)
return ret;
- ret = alloc_private(dev, sizeof(struct pcl711_private));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
s = &dev->subdevices[0];
/* AI subdevice */
unsigned int ao_readback[12];
};
-#define devpriv ((struct pcl726_private *)dev->private)
-
static int pcl726_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pcl726_private *devpriv = dev->private;
int hi, lo;
int n;
int chan = CR_CHAN(insn->chanspec);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pcl726_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec);
int n;
static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pcl726_board *board = comedi_board(dev);
+ struct pcl726_private *devpriv;
struct comedi_subdevice *s;
unsigned long iobase;
unsigned int iorange;
dev->board_name = board->name;
- ret = alloc_private(dev, sizeof(struct pcl726_private));
- if (ret < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
for (i = 0; i < 12; i++) {
devpriv->bipolar[i] = 0;
unsigned int ao_readback[2]; /* data for AO readback */
};
-#define devpriv ((struct pcl812_private *)dev->private)
-
/*
==============================================================================
*/
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pcl812_private *devpriv = dev->private;
int n;
int timeout, hi;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pcl812_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec);
int i;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pcl812_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec);
int i;
struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
const struct pcl812_board *board = comedi_board(dev);
+ struct pcl812_private *devpriv = dev->private;
int err = 0;
unsigned int flags;
int tmp, divisor1, divisor2;
static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
const struct pcl812_board *board = comedi_board(dev);
+ struct pcl812_private *devpriv = dev->private;
unsigned int divisor1 = 0, divisor2 = 0, i, dma_flags, bytes;
struct comedi_cmd *cmd = &s->async->cmd;
char err = 1;
unsigned int mask, timeout;
struct comedi_device *dev = d;
+ struct pcl812_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
unsigned int next_chan;
struct comedi_subdevice *s, short *ptr,
unsigned int bufptr, unsigned int len)
{
+ struct pcl812_private *devpriv = dev->private;
unsigned int i;
s->async->events = 0;
static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct pcl812_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
unsigned long dma_flags;
int len, bufptr;
static irqreturn_t interrupt_pcl812(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct pcl812_private *devpriv = dev->private;
if (!dev->attached) {
comedi_error(dev, "spurious interrupt");
*/
static int pcl812_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct pcl812_private *devpriv = dev->private;
unsigned long flags;
unsigned int top1, top2, i;
struct comedi_subdevice *s,
unsigned int rangechan, char wait)
{
+ struct pcl812_private *devpriv = dev->private;
unsigned char chan_reg = CR_CHAN(rangechan); /* normal board */
/* gain index */
unsigned char gain_reg = CR_RANGE(rangechan) +
static void free_resources(struct comedi_device *dev)
{
const struct pcl812_board *board = comedi_board(dev);
+ struct pcl812_private *devpriv = dev->private;
- if (dev->private) {
+ if (devpriv) {
if (devpriv->dmabuf[0])
free_pages(devpriv->dmabuf[0], devpriv->dmapages[0]);
if (devpriv->dmabuf[1])
static int pcl812_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pcl812_private *devpriv = dev->private;
+
if (devpriv->ai_dma)
disable_dma(devpriv->dma);
outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */
static void pcl812_reset(struct comedi_device *dev)
{
const struct pcl812_board *board = comedi_board(dev);
+ struct pcl812_private *devpriv = dev->private;
outb(0, dev->iobase + PCL812_MUX);
outb(0 + devpriv->range_correction, dev->iobase + PCL812_GAIN);
static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pcl812_board *board = comedi_board(dev);
+ struct pcl812_private *devpriv;
int ret, subdev;
unsigned long iobase;
unsigned int irq;
}
dev->iobase = iobase;
- ret = alloc_private(dev, sizeof(struct pcl812_private));
- if (ret < 0) {
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret) {
free_resources(dev);
- return ret; /* Can't alloc mem */
+ return ret;
}
+ devpriv = dev->private;
dev->board_name = board->name;
int i8254_osc_base; /* 1/frequency of on board oscilator in ns */
};
-#define devpriv ((struct pcl816_private *)dev->private)
-
#ifdef unused
static int RTC_lock; /* RTC lock */
static int RTC_timer_lock; /* RTC int lock */
static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct pcl816_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
int low, hi;
int timeout = 50; /* wait max 50us */
struct comedi_subdevice *s, short *ptr,
unsigned int bufptr, unsigned int len)
{
+ struct pcl816_private *devpriv = dev->private;
int i;
s->async->events = 0;
static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct pcl816_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
int len, bufptr, this_dma_buf;
unsigned long dma_flags;
static irqreturn_t interrupt_pcl816(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct pcl816_private *devpriv = dev->private;
+
DPRINTK("<I>");
if (!dev->attached) {
static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
const struct pcl816_board *board = comedi_board(dev);
+ struct pcl816_private *devpriv = dev->private;
unsigned int divisor1 = 0, divisor2 = 0, dma_flags, bytes, dmairq;
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int seglen;
static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct pcl816_private *devpriv = dev->private;
unsigned long flags;
unsigned int top1, top2, i;
static int pcl816_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pcl816_private *devpriv = dev->private;
+
/* DEBUG(printk("pcl816_ai_cancel()\n");) */
if (devpriv->irq_blocked > 0) {
struct comedi_subdevice *s, unsigned int *chanlist,
unsigned int seglen)
{
+ struct pcl816_private *devpriv = dev->private;
unsigned int i;
devpriv->ai_act_chanlist_len = seglen;
static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pcl816_board *board = comedi_board(dev);
+ struct pcl816_private *devpriv;
int ret;
unsigned long iobase;
unsigned int irq, dma;
return -EIO;
}
- ret = alloc_private(dev, sizeof(struct pcl816_private));
- if (ret < 0)
- return ret; /* Can't alloc mem */
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
dev->board_name = board->name;
static void pcl816_detach(struct comedi_device *dev)
{
const struct pcl816_board *board = comedi_board(dev);
+ struct pcl816_private *devpriv = dev->private;
if (dev->private) {
pcl816_ai_cancel(dev, devpriv->sub_ai);
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
};
-#define devpriv ((struct pcl818_private *)dev->private)
-
/*
==============================================================================
*/
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pcl818_private *devpriv = dev->private;
int n;
int chan = CR_CHAN(insn->chanspec);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pcl818_private *devpriv = dev->private;
int n;
int chan = CR_CHAN(insn->chanspec);
static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct pcl818_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
int low;
int timeout = 50; /* wait max 50us */
static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct pcl818_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
int i, len, bufptr;
unsigned long flags;
static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct pcl818_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
unsigned long tmp;
unsigned int top1, top2, i, bufptr;
static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct pcl818_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
int i, len, lo;
static irqreturn_t interrupt_pcl818(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct pcl818_private *devpriv = dev->private;
if (!dev->attached) {
comedi_error(dev, "premature interrupt");
static void pcl818_ai_mode13dma_int(int mode, struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pcl818_private *devpriv = dev->private;
unsigned int flags;
unsigned int bytes;
static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pcl818_private *devpriv = dev->private;
unsigned int flags;
short *pole;
static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pcl818_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int divisor1 = 0, divisor2 = 0;
unsigned int seglen;
static int pcl818_ao_mode13(int mode, struct comedi_device *dev,
struct comedi_subdevice *s, comedi_trig * it)
{
+ struct pcl818_private *devpriv = dev->private;
int divisor1 = 0, divisor2 = 0;
if (!dev->irq) {
unsigned int *chanlist, unsigned int n_chan,
unsigned int seglen)
{
+ struct pcl818_private *devpriv = dev->private;
int i;
devpriv->act_chanlist_len = seglen;
struct comedi_cmd *cmd)
{
const struct pcl818_board *board = comedi_board(dev);
+ struct pcl818_private *devpriv = dev->private;
int err = 0;
int tmp, divisor1 = 0, divisor2 = 0;
*/
static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct pcl818_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int retval;
static int pcl818_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pcl818_private *devpriv = dev->private;
+
if (devpriv->irq_blocked > 0) {
dev_dbg(dev->class_dev, "pcl818_ai_cancel()\n");
devpriv->irq_was_now_closed = 1;
static void pcl818_reset(struct comedi_device *dev)
{
const struct pcl818_board *board = comedi_board(dev);
+ struct pcl818_private *devpriv = dev->private;
if (devpriv->usefifo) { /* FIFO shutdown */
outb(0, dev->iobase + PCL818_FI_INTCLR);
static void rtc_dropped_irq(unsigned long data)
{
struct comedi_device *dev = (void *)data;
+ struct pcl818_private *devpriv = dev->private;
unsigned long flags, tmp;
switch (devpriv->int818_mode) {
static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pcl818_board *board = comedi_board(dev);
+ struct pcl818_private *devpriv;
int ret;
unsigned long iobase;
unsigned int irq;
unsigned long pages;
struct comedi_subdevice *s;
- ret = alloc_private(dev, sizeof(struct pcl818_private));
- if (ret < 0)
- return ret; /* Can't alloc mem */
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
/* claim our I/O space */
iobase = it->options[0];
static void pcl818_detach(struct comedi_device *dev)
{
- if (dev->private) {
+ struct pcl818_private *devpriv = dev->private;
+
+ if (devpriv) {
pcl818_ai_cancel(dev, devpriv->sub_ai);
pcl818_reset(dev);
if (devpriv->dma)
static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s,
int chanspec)
{
+ struct priv_pcm3724 *priv = dev->private;
struct comedi_subdevice *s_dio1 = &dev->subdevices[0];
unsigned int mask;
int gatecfg;
- struct priv_pcm3724 *priv;
gatecfg = 0;
- priv = dev->private;
mask = 1 << CR_CHAN(chanspec);
if (s == s_dio1)
static int pcm3724_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct priv_pcm3724 *priv;
struct comedi_subdevice *s;
unsigned long iobase;
unsigned int iorange;
iobase = it->options[0];
iorange = PCM3724_SIZE;
- ret = alloc_private(dev, sizeof(struct priv_pcm3724));
- if (ret < 0)
- return -ENOMEM;
-
- ((struct priv_pcm3724 *)(dev->private))->dio_1 = 0;
- ((struct priv_pcm3724 *)(dev->private))->dio_2 = 0;
+ ret = alloc_private(dev, sizeof(*priv));
+ if (ret)
+ return ret;
+ priv = dev->private;
printk(KERN_INFO "comedi%d: pcm3724: board=%s, 0x%03lx ", dev->minor,
dev->board_name, iobase);
int differential;
int twos_comp;
};
-#define devpriv ((struct pcmad_priv_struct *)dev->private)
#define TIMEOUT 100
struct comedi_insn *insn, unsigned int *data)
{
const struct pcmad_board_struct *board = comedi_board(dev);
+ struct pcmad_priv_struct *devpriv = dev->private;
int i;
int chan;
int n;
static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pcmad_board_struct *board = comedi_board(dev);
+ struct pcmad_priv_struct *devpriv;
int ret;
struct comedi_subdevice *s;
unsigned long iobase;
if (ret)
return ret;
- ret = alloc_private(dev, sizeof(struct pcmad_priv_struct));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
dev->board_name = board->name;
int simultaneous_xfer_mode;
};
-#define devpriv ((struct pcmda12_private *)(dev->private))
-
static void zero_chans(struct comedi_device *dev)
{ /* sets up an
ASIC chip to defaults */
static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pcmda12_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pcmda12_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
static int pcmda12_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct pcmda12_private *devpriv;
struct comedi_subdevice *s;
unsigned long iobase;
int ret;
dev->board_name = dev->driver->driver_name;
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct pcmda12_private)) < 0) {
- printk(KERN_ERR "cannot allocate private data structure\n");
- return -ENOMEM;
- }
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
devpriv->simultaneous_xfer_mode = it->options[1];
struct pcmmio_subdev_private *sprivs;
};
-/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((struct pcmmio_private *)dev->private)
#define subpriv ((struct pcmmio_subdev_private *)s->private)
/* DIO devices are slightly special. Although it is possible to
static void switch_page(struct comedi_device *dev, int asic, int page)
{
+ struct pcmmio_private *devpriv = dev->private;
+
if (asic < 0 || asic >= 1)
return; /* paranoia */
if (page < 0 || page >= NUM_PAGES)
static void init_asics(struct comedi_device *dev)
{ /* sets up an
ASIC chip to defaults */
+ struct pcmmio_private *devpriv = dev->private;
int asic;
for (asic = 0; asic < 1; ++asic) {
#ifdef notused
static void lock_port(struct comedi_device *dev, int asic, int port)
{
+ struct pcmmio_private *devpriv = dev->private;
+
if (asic < 0 || asic >= 1)
return; /* paranoia */
if (port < 0 || port >= PORTS_PER_ASIC)
static void unlock_port(struct comedi_device *dev, int asic, int port)
{
+ struct pcmmio_private *devpriv = dev->private;
+
if (asic < 0 || asic >= 1)
return; /* paranoia */
if (port < 0 || port >= PORTS_PER_ASIC)
static void pcmmio_stop_intr(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pcmmio_private *devpriv = dev->private;
int nports, firstport, asic, port;
asic = subpriv->dio.intr.asic;
{
int asic, got1 = 0;
struct comedi_device *dev = (struct comedi_device *)d;
+ struct pcmmio_private *devpriv = dev->private;
int i;
for (asic = 0; asic < MAX_ASICS; ++asic) {
static int pcmmio_start_intr(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pcmmio_private *devpriv = dev->private;
+
if (!subpriv->dio.intr.continuous && subpriv->dio.intr.stop_count == 0) {
/* An empty acquisition! */
s->async->events |= COMEDI_CB_EOA;
static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct pcmmio_private *devpriv;
struct comedi_subdevice *s;
int sdev_no, chans_left, n_dio_subdevs, n_subdevs, port, asic,
thisasic_chanct = 0;
return -EIO;
}
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct pcmmio_private)) < 0) {
- printk(KERN_ERR "comedi%d: cannot allocate private data structure\n",
- dev->minor);
- return -ENOMEM;
- }
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
for (asic = 0; asic < MAX_ASICS; ++asic) {
devpriv->asics[asic].num = asic;
static void pcmmio_detach(struct comedi_device *dev)
{
+ struct pcmmio_private *devpriv = dev->private;
int i;
if (dev->iobase)
struct pcmuio_subdev_private *sprivs;
};
-/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((struct pcmuio_private *)dev->private)
#define subpriv ((struct pcmuio_subdev_private *)s->private)
/* DIO devices are slightly special. Although it is possible to
static void switch_page(struct comedi_device *dev, int asic, int page)
{
const struct pcmuio_board *board = comedi_board(dev);
+ struct pcmuio_private *devpriv = dev->private;
if (asic < 0 || asic >= board->num_asics)
return; /* paranoia */
static void lock_port(struct comedi_device *dev, int asic, int port)
{
const struct pcmuio_board *board = comedi_board(dev);
+ struct pcmuio_private *devpriv = dev->private;
if (asic < 0 || asic >= board->num_asics)
return; /* paranoia */
static void unlock_port(struct comedi_device *dev, int asic, int port)
{
const struct pcmuio_board *board = comedi_board(dev);
+ struct pcmuio_private *devpriv = dev->private;
if (asic < 0 || asic >= board->num_asics)
return; /* paranoia */
struct comedi_subdevice *s)
{
int nports, firstport, asic, port;
+ struct pcmuio_private *devpriv = dev->private;
asic = subpriv->intr.asic;
if (asic < 0)
{
int asic, got1 = 0;
struct comedi_device *dev = (struct comedi_device *)d;
+ struct pcmuio_private *devpriv = dev->private;
int i;
for (asic = 0; asic < MAX_ASICS; ++asic) {
static int pcmuio_start_intr(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pcmuio_private *devpriv = dev->private;
+
if (!subpriv->intr.continuous && subpriv->intr.stop_count == 0) {
/* An empty acquisition! */
s->async->events |= COMEDI_CB_EOA;
static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pcmuio_board *board = comedi_board(dev);
+ struct pcmuio_private *devpriv;
struct comedi_subdevice *s;
int sdev_no, chans_left, n_subdevs, port, asic, thisasic_chanct = 0;
unsigned long iobase;
dev->board_name = board->name;
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct pcmuio_private)) < 0) {
- dev_warn(dev->class_dev,
- "cannot allocate private data structure\n");
- return -ENOMEM;
- }
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
for (asic = 0; asic < MAX_ASICS; ++asic) {
devpriv->asics[asic].num = asic;
static void pcmuio_detach(struct comedi_device *dev)
{
const struct pcmuio_board *board = comedi_board(dev);
+ struct pcmuio_private *devpriv = dev->private;
int i;
if (dev->iobase)
comedi_debug = 1;
#endif
- /*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct rtdPrivate)) < 0)
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
devpriv = dev->private;
pcidev = rtd_find_pci(dev, it);
int muxgain_bits;
};
-#define devpriv ((struct rti800_private *)dev->private)
-
#define RTI800_TIMEOUT 100
static irqreturn_t rti800_interrupt(int irq, void *dev)
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct rti800_private *devpriv = dev->private;
int i, t;
int status;
int chan = CR_CHAN(insn->chanspec);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct rti800_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct rti800_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec);
int d;
int i;
static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct rti800_board *board = comedi_board(dev);
+ struct rti800_private *devpriv;
unsigned int irq;
unsigned long iobase;
int ret;
if (ret)
return ret;
- ret = alloc_private(dev, sizeof(struct rti800_private));
- if (ret < 0)
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
return ret;
+ devpriv = dev->private;
devpriv->adc_mux = it->options[2];
devpriv->adc_range = it->options[3];
unsigned int ao_readback[8];
};
-#define devpriv ((struct rti802_private *)dev->private)
-
static int rti802_ao_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct rti802_private *devpriv = dev->private;
int i;
for (i = 0; i < insn->n; i++)
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct rti802_private *devpriv = dev->private;
int i, d;
int chan = CR_CHAN(insn->chanspec);
static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct rti802_private *devpriv;
struct comedi_subdevice *s;
int i;
unsigned long iobase;
dev->board_name = "rti802";
- if (alloc_private(dev, sizeof(struct rti802_private)))
- return -ENOMEM;
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
ret = comedi_alloc_subdevices(dev, 1);
if (ret)
struct serial2002_range_table_t in_range[32], out_range[32];
};
-/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((struct serial2002_private *)dev->private)
-
struct serial_data {
enum { is_invalid, is_digital, is_channel } kind;
int index;
static int serial_2002_open(struct comedi_device *dev)
{
+ struct serial2002_private *devpriv = dev->private;
int result;
char port[20];
static void serial_2002_close(struct comedi_device *dev)
{
+ struct serial2002_private *devpriv = dev->private;
+
if (!IS_ERR(devpriv->tty) && devpriv->tty)
filp_close(devpriv->tty, NULL);
}
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct serial2002_private *devpriv = dev->private;
int n;
int chan;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct serial2002_private *devpriv = dev->private;
int n;
int chan;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct serial2002_private *devpriv = dev->private;
int n;
int chan;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct serial2002_private *devpriv = dev->private;
int n;
int chan;
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct serial2002_private *devpriv = dev->private;
int n;
int chan = CR_CHAN(insn->chanspec);
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct serial2002_private *devpriv = dev->private;
int n;
int chan;
static int serial2002_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct serial2002_private *devpriv;
struct comedi_subdevice *s;
int ret;
dev_dbg(dev->class_dev, "serial2002: attach\n");
dev->board_name = dev->driver->driver_name;
- if (alloc_private(dev, sizeof(struct serial2002_private)) < 0)
- return -ENOMEM;
+
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
+
dev->open = serial_2002_open;
dev->close = serial_2002_close;
devpriv->port = it->options[0];
unsigned int ao_readback[2];
};
-/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((struct skel_private *)dev->private)
-
/*
* The struct comedi_driver structure tells the Comedi core module
* which functions to call to configure/deconfigure (attach/detach)
*/
static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct skel_private *devpriv;
struct comedi_subdevice *s;
int ret;
*/
dev->board_name = thisboard->name;
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct skel_private)) < 0)
- return -ENOMEM;
+ /* Allocate the private data */
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret)
+ return ret;
+ devpriv = dev->private;
ret = comedi_alloc_subdevices(dev, 3);
if (ret)
static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct skel_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
static int skel_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct skel_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);