diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-19 17:48:32 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-19 17:48:32 -0700 |
commit | fb20871a54961b82d35303b43452928186c1361d (patch) | |
tree | 1beeb39e45eda1c8b5893090904b583fceeb07ef /drivers/staging/comedi/drivers/ni_atmio16d.c | |
parent | bee89ab228e6f51c4ddd3481b9bd491859a8ee7b (diff) | |
parent | c7a5d70796379e3d51d0c652fbe1634b81d3bbd5 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6: (342 commits)
Staging: comedi: fix build errors
Staging: udlfb: update to version 0.2.3
Staging: udlfb: fix some sparse warnings.
Staging: udlfb: clean up checkpatch warnings in udlfb.c
Staging: udlfb: clean up checkpatch warnings in udlfb.h
Staging: udlfb: add udlfb driver to build
Staging: add udlfb driver
Staging: pata_rdc: remove pointless comments
Staging: pata_rdc: remove DRIVER macros
Staging: pata_rdc: remove dbgprintf macro
Staging: pata_rdc: remove broken flag
Staging: pata_rdc: fix build warnings
Staging: pata_rdc: use PCI_DEVICE
Staging: pata_rdc: remove function prototypes
Staging: pata_rdc: coding style fixes
Staging: pata_rdc: convert code to work in 2.6.29
Staging: pata_rdc: add driver to the build system
Staging: add pata_rdc driver
Staging: remove obsolete serqt_usb driver
Staging: serqt_usb2 add the driver to the build
...
Diffstat (limited to 'drivers/staging/comedi/drivers/ni_atmio16d.c')
-rw-r--r-- | drivers/staging/comedi/drivers/ni_atmio16d.c | 117 |
1 files changed, 62 insertions, 55 deletions
diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 35fcd172af2..1a8c2ab20d3 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -35,6 +35,7 @@ Devices: [National Instruments] AT-MIO-16 (atmio16), AT-MIO-16D (atmio16d) * */ +#include <linux/interrupt.h> #include "../comedidev.h" #include <linux/ioport.h> @@ -111,12 +112,12 @@ struct atmio16_board_t { static const struct atmio16_board_t atmio16_boards[] = { { - name: "atmio16", - has_8255:0, + .name = "atmio16", + .has_8255 = 0, }, { - name: "atmio16d", - has_8255:1, + .name = "atmio16d", + .has_8255 = 1, }, }; @@ -125,25 +126,25 @@ static const struct atmio16_board_t atmio16_boards[] = { #define boardtype ((const struct atmio16_board_t *)dev->board_ptr) /* function prototypes */ -static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * it); -static int atmio16d_detach(struct comedi_device * dev); -static irqreturn_t atmio16d_interrupt(int irq, void *d PT_REGS_ARG); -static int atmio16d_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd); -static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s); -static int atmio16d_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s); -static void reset_counters(struct comedi_device * dev); -static void reset_atmio16d(struct comedi_device * dev); +static int atmio16d_attach(struct comedi_device *dev, struct comedi_devconfig *it); +static int atmio16d_detach(struct comedi_device *dev); +static irqreturn_t atmio16d_interrupt(int irq, void *d); +static int atmio16d_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd); +static int atmio16d_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s); +static int atmio16d_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s); +static void reset_counters(struct comedi_device *dev); +static void reset_atmio16d(struct comedi_device *dev); /* main driver struct */ static struct comedi_driver driver_atmio16d = { - driver_name:"atmio16", - module:THIS_MODULE, - attach:atmio16d_attach, - detach:atmio16d_detach, - board_name:&atmio16_boards[0].name, - num_names:n_atmio16_boards, - offset:sizeof(struct atmio16_board_t), + .driver_name = "atmio16", + .module = THIS_MODULE, + .attach = atmio16d_attach, + .detach = atmio16d_detach, + .board_name = &atmio16_boards[0].name, + .num_names = n_atmio16_boards, + .offset = sizeof(struct atmio16_board_t), }; COMEDI_INITCLEANUP(driver_atmio16d); @@ -187,7 +188,7 @@ struct atmio16d_private { unsigned int com_reg_2_state; /* current state of command register 2 */ }; -static void reset_counters(struct comedi_device * dev) +static void reset_counters(struct comedi_device *dev) { /* Counter 2 */ outw(0xFFC2, dev->iobase + AM9513A_COM_REG); @@ -225,7 +226,7 @@ static void reset_counters(struct comedi_device * dev) outw(0, dev->iobase + AD_CLEAR_REG); } -static void reset_atmio16d(struct comedi_device * dev) +static void reset_atmio16d(struct comedi_device *dev) { int i; @@ -257,12 +258,12 @@ static void reset_atmio16d(struct comedi_device * dev) outw(2048, dev->iobase + DAC1_REG); } -static irqreturn_t atmio16d_interrupt(int irq, void *d PT_REGS_ARG) +static irqreturn_t atmio16d_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->subdevices + 0; -// printk("atmio16d_interrupt!\n"); +/* printk("atmio16d_interrupt!\n"); */ comedi_buf_put(s->async, inw(dev->iobase + AD_FIFO_REG)); @@ -270,8 +271,8 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d PT_REGS_ARG) return IRQ_HANDLED; } -static int atmio16d_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_cmd * cmd) +static int atmio16d_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0, tmp; #ifdef DEBUG1 @@ -371,7 +372,7 @@ static int atmio16d_ai_cmdtest(struct comedi_device * dev, struct comedi_subdevi return 0; } -static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s) +static int atmio16d_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; unsigned int timer, base_clock; @@ -417,10 +418,10 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * } else if (cmd->convert_arg < 655360000) { base_clock = CLOCK_100_KHZ; timer = cmd->convert_arg / 10000; - } else if (cmd->convert_arg <= 0xffffffff /* 6553600000 */ ) { + } else if (cmd->convert_arg <= 0xffffffff /* 6553600000 */) { base_clock = CLOCK_10_KHZ; timer = cmd->convert_arg / 100000; - } else if (cmd->convert_arg <= 0xffffffff /* 65536000000 */ ) { + } else if (cmd->convert_arg <= 0xffffffff /* 65536000000 */) { base_clock = CLOCK_1_KHZ; timer = cmd->convert_arg / 1000000; } @@ -449,11 +450,13 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * outw(devpriv->com_reg_1_state, dev->iobase + COM_REG_1); } else { /* Counter 4 and 5 are needed */ - if ((tmp = sample_count & 0xFFFF)) { + + tmp = sample_count & 0xFFFF; + if (tmp) outw(tmp - 1, dev->iobase + AM9513A_DATA_REG); - } else { + else outw(0xFFFF, dev->iobase + AM9513A_DATA_REG); - } + outw(0xFF48, dev->iobase + AM9513A_COM_REG); outw(0, dev->iobase + AM9513A_DATA_REG); outw(0xFF28, dev->iobase + AM9513A_COM_REG); @@ -483,10 +486,10 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * } else if (cmd->scan_begin_arg < 655360000) { base_clock = CLOCK_100_KHZ; timer = cmd->scan_begin_arg / 10000; - } else if (cmd->scan_begin_arg < 0xffffffff /* 6553600000 */ ) { + } else if (cmd->scan_begin_arg < 0xffffffff /* 6553600000 */) { base_clock = CLOCK_10_KHZ; timer = cmd->scan_begin_arg / 100000; - } else if (cmd->scan_begin_arg < 0xffffffff /* 65536000000 */ ) { + } else if (cmd->scan_begin_arg < 0xffffffff /* 65536000000 */) { base_clock = CLOCK_1_KHZ; timer = cmd->scan_begin_arg / 1000000; } @@ -519,7 +522,7 @@ static int atmio16d_ai_cmd(struct comedi_device * dev, struct comedi_subdevice * } /* This will cancel a running acquisition operation */ -static int atmio16d_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s) +static int atmio16d_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { reset_atmio16d(dev); @@ -527,8 +530,8 @@ static int atmio16d_ai_cancel(struct comedi_device * dev, struct comedi_subdevic } /* Mode 0 is used to get a single conversion on demand */ -static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atmio16d_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i, t; int chan; @@ -542,9 +545,9 @@ static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subde gain = CR_RANGE(insn->chanspec); /* reset the Analog input circuitry */ - //outw( 0, dev->iobase+AD_CLEAR_REG ); + /* outw( 0, dev->iobase+AD_CLEAR_REG ); */ /* reset the Analog Input MUX Counter to 0 */ - //outw( 0, dev->iobase+MUX_CNTR_REG ); + /* outw( 0, dev->iobase+MUX_CNTR_REG ); */ /* set the Input MUX gain */ outw(chan | (gain << 6), dev->iobase + MUX_GAIN_REG); @@ -577,7 +580,7 @@ static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subde } /* end waiting, now check if it timed out */ if (t == ATMIO16D_TIMEOUT) { - rt_printk("atmio16d: timeout\n"); + printk("atmio16d: timeout\n"); return -ETIME; } @@ -586,8 +589,8 @@ static int atmio16d_ai_insn_read(struct comedi_device * dev, struct comedi_subde return i; } -static int atmio16d_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atmio16d_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; #ifdef DEBUG1 @@ -601,8 +604,8 @@ static int atmio16d_ao_insn_read(struct comedi_device * dev, struct comedi_subde return i; } -static int atmio16d_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atmio16d_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int chan; @@ -636,8 +639,8 @@ static int atmio16d_ao_insn_write(struct comedi_device * dev, struct comedi_subd return i; } -static int atmio16d_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atmio16d_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (insn->n != 2) return -EINVAL; @@ -652,8 +655,8 @@ static int atmio16d_dio_insn_bits(struct comedi_device * dev, struct comedi_subd return 2; } -static int atmio16d_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s, - struct comedi_insn * insn, unsigned int * data) +static int atmio16d_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { int i; int mask; @@ -706,7 +709,7 @@ static int atmio16d_dio_insn_config(struct comedi_device * dev, struct comedi_su options[12] - dac1 coding */ -static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * it) +static int atmio16d_attach(struct comedi_device *dev, struct comedi_devconfig *it) { unsigned int irq; unsigned long iobase; @@ -726,9 +729,12 @@ static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * /* board name */ dev->board_name = boardtype->name; - if ((ret = alloc_subdevices(dev, 4)) < 0) + ret = alloc_subdevices(dev, 4); + if (ret < 0) return ret; - if ((ret = alloc_private(dev, sizeof(struct atmio16d_private))) < 0) + + ret = alloc_private(dev, sizeof(struct atmio16d_private)); + if (ret < 0) return ret; /* reset the atmio16d hardware */ @@ -737,8 +743,9 @@ static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * /* check if our interrupt is available and get it */ irq = it->options[1]; if (irq) { - if ((ret = comedi_request_irq(irq, atmio16d_interrupt, - 0, "atmio16d", dev)) < 0) { + + ret = request_irq(irq, atmio16d_interrupt, 0, "atmio16d", dev); + if (ret < 0) { printk("failed to allocate irq %u\n", irq); return ret; } @@ -841,7 +848,7 @@ static int atmio16d_attach(struct comedi_device * dev, struct comedi_devconfig * return 0; } -static int atmio16d_detach(struct comedi_device * dev) +static int atmio16d_detach(struct comedi_device *dev) { printk("comedi%d: atmio16d: remove\n", dev->minor); @@ -849,7 +856,7 @@ static int atmio16d_detach(struct comedi_device * dev) subdev_8255_cleanup(dev, dev->subdevices + 3); if (dev->irq) - comedi_free_irq(dev->irq, dev); + free_irq(dev->irq, dev); reset_atmio16d(dev); |