aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/drivers/dt282x.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-09-17 20:52:23 +0200
committerIngo Molnar <mingo@elte.hu>2009-09-17 20:53:10 +0200
commit45bd00d31de886f8425b4dd33204b911b0a466a9 (patch)
tree06204f2452e02ca916666173d50f5035d69065ef /drivers/staging/comedi/drivers/dt282x.c
parentMerge branch 'tip/tracing/core4' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into tracing/core (diff)
parentMerge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6 (diff)
downloadlinux-dev-45bd00d31de886f8425b4dd33204b911b0a466a9.tar.xz
linux-dev-45bd00d31de886f8425b4dd33204b911b0a466a9.zip
Merge branch 'linus' into tracing/core
Merge reason: Pick up kernel/softirq.c update for dependent fix. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/staging/comedi/drivers/dt282x.c')
-rw-r--r--drivers/staging/comedi/drivers/dt282x.c264
1 files changed, 152 insertions, 112 deletions
diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c
index 22b7304af396..a4c96c02fa2b 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -155,46 +155,78 @@ Notes:
#define DT2821_BDINIT 0x0001 /* (W) initialize board */
static const struct comedi_lrange range_dt282x_ai_lo_bipolar = { 4, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25)
- }
+ RANGE(-10,
+ 10),
+ RANGE(-5,
+ 5),
+ RANGE(-2.5,
+ 2.5),
+ RANGE
+ (-1.25,
+ 1.25)
+ }
};
+
static const struct comedi_lrange range_dt282x_ai_lo_unipolar = { 4, {
- RANGE(0, 10),
- RANGE(0, 5),
- RANGE(0, 2.5),
- RANGE(0, 1.25)
- }
+ RANGE(0,
+ 10),
+ RANGE(0,
+ 5),
+ RANGE(0,
+ 2.5),
+ RANGE(0,
+ 1.25)
+ }
};
+
static const struct comedi_lrange range_dt282x_ai_5_bipolar = { 4, {
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25),
- RANGE(-0.625, 0.625),
- }
+ RANGE(-5,
+ 5),
+ RANGE(-2.5,
+ 2.5),
+ RANGE(-1.25,
+ 1.25),
+ RANGE
+ (-0.625,
+ 0.625),
+ }
};
+
static const struct comedi_lrange range_dt282x_ai_5_unipolar = { 4, {
- RANGE(0, 5),
- RANGE(0, 2.5),
- RANGE(0, 1.25),
- RANGE(0, 0.625),
- }
+ RANGE(0,
+ 5),
+ RANGE(0,
+ 2.5),
+ RANGE(0,
+ 1.25),
+ RANGE(0,
+ 0.625),
+ }
};
+
static const struct comedi_lrange range_dt282x_ai_hi_bipolar = { 4, {
- RANGE(-10, 10),
- RANGE(-1, 1),
- RANGE(-0.1, 0.1),
- RANGE(-0.02, 0.02)
- }
+ RANGE(-10,
+ 10),
+ RANGE(-1,
+ 1),
+ RANGE(-0.1,
+ 0.1),
+ RANGE
+ (-0.02,
+ 0.02)
+ }
};
+
static const struct comedi_lrange range_dt282x_ai_hi_unipolar = { 4, {
- RANGE(0, 10),
- RANGE(0, 1),
- RANGE(0, 0.1),
- RANGE(0, 0.02)
- }
+ RANGE(0,
+ 10),
+ RANGE(0,
+ 1),
+ RANGE(0,
+ 0.1),
+ RANGE(0,
+ 0.02)
+ }
};
struct dt282x_board {
@@ -217,7 +249,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2821-f",
.adbits = 12,
.adchan_se = 16,
@@ -226,7 +258,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2821-g",
.adbits = 12,
.adchan_se = 16,
@@ -235,7 +267,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2823",
.adbits = 16,
.adchan_se = 0,
@@ -244,16 +276,16 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 16,
- },
+ },
{.name = "dt2824-pgh",
- .adbits = 12,
- .adchan_se = 16,
- .adchan_di = 8,
- .ai_speed = 20000,
- .ispgl = 0,
- .dachan = 0,
- .dabits = 0,
- },
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 20000,
+ .ispgl = 0,
+ .dachan = 0,
+ .dabits = 0,
+ },
{.name = "dt2824-pgl",
.adbits = 12,
.adchan_se = 16,
@@ -262,7 +294,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 1,
.dachan = 0,
.dabits = 0,
- },
+ },
{.name = "dt2825",
.adbits = 12,
.adchan_se = 16,
@@ -271,7 +303,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 1,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2827",
.adbits = 16,
.adchan_se = 0,
@@ -280,7 +312,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2828",
.adbits = 12,
.adchan_se = 4,
@@ -289,7 +321,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt2829",
.adbits = 16,
.adchan_se = 8,
@@ -298,7 +330,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 16,
- },
+ },
{.name = "dt21-ez",
.adbits = 12,
.adchan_se = 16,
@@ -307,7 +339,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 2,
.dabits = 12,
- },
+ },
{.name = "dt23-ez",
.adbits = 16,
.adchan_se = 16,
@@ -316,7 +348,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 0,
.dabits = 0,
- },
+ },
{.name = "dt24-ez",
.adbits = 12,
.adchan_se = 16,
@@ -325,7 +357,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 0,
.dachan = 0,
.dabits = 0,
- },
+ },
{.name = "dt24-ez-pgl",
.adbits = 12,
.adchan_se = 16,
@@ -334,7 +366,7 @@ static const struct dt282x_board boardtypes[] = {
.ispgl = 1,
.dachan = 0,
.dabits = 0,
- },
+ },
};
#define n_boardtypes sizeof(boardtypes)/sizeof(struct dt282x_board)
@@ -394,7 +426,8 @@ struct dt282x_private {
if (_i){b} \
}while (0)
-static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt282x_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it);
static int dt282x_detach(struct comedi_device *dev);
static struct comedi_driver driver_dt282x = {
.driver_name = "dt282x",
@@ -411,15 +444,17 @@ COMEDI_INITCLEANUP(driver_dt282x);
static void free_resources(struct comedi_device *dev);
static int prep_ai_dma(struct comedi_device *dev, int chan, int size);
static int prep_ao_dma(struct comedi_device *dev, int chan, int size);
-static int dt282x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-static int dt282x_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int dt282x_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s);
+static int dt282x_ao_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s);
static int dt282x_ns_to_timer(int *nanosec, int round_mode);
static void dt282x_disable_dma(struct comedi_device *dev);
static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2);
static void dt282x_munge(struct comedi_device *dev, short *buf,
- unsigned int nbytes)
+ unsigned int nbytes)
{
unsigned int i;
unsigned short mask = (1 << boardtype.adbits) - 1;
@@ -628,7 +663,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
int ret;
short data;
- data = (short) inw(dev->iobase + DT2821_ADDAT);
+ data = (short)inw(dev->iobase + DT2821_ADDAT);
data &= (1 << boardtype.adbits) - 1;
if (devpriv->ad_2scomp) {
data ^= 1 << (boardtype.adbits - 1);
@@ -654,7 +689,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
}
static void dt282x_load_changain(struct comedi_device *dev, int n,
- unsigned int *chanlist)
+ unsigned int *chanlist)
{
unsigned int i;
unsigned int chan, range;
@@ -674,8 +709,9 @@ static void dt282x_load_changain(struct comedi_device *dev, int n,
* - preload multiplexer
* - trigger conversion and wait for it to finish
*/
-static int dt282x_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int dt282x_ai_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int i;
@@ -686,18 +722,15 @@ static int dt282x_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
dt282x_load_changain(dev, 1, &insn->chanspec);
update_supcsr(DT2821_PRLD);
- wait_for(!mux_busy(), comedi_error(dev, "timeout\n");
- return -ETIME;
- );
+ wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);
for (i = 0; i < insn->n; i++) {
update_supcsr(DT2821_STRIG);
wait_for(ad_done(), comedi_error(dev, "timeout\n");
- return -ETIME;
- );
+ return -ETIME;);
data[i] =
- inw(dev->iobase +
+ inw(dev->iobase +
DT2821_ADDAT) & ((1 << boardtype.adbits) - 1);
if (devpriv->ad_2scomp)
data[i] ^= (1 << (boardtype.adbits - 1));
@@ -706,8 +739,8 @@ static int dt282x_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
return i;
}
-static int dt282x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+static int dt282x_ai_cmdtest(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -746,7 +779,7 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
/* note that mutual compatiblity is not an issue here */
if (cmd->scan_begin_src != TRIG_FOLLOW &&
- cmd->scan_begin_src != TRIG_EXT)
+ cmd->scan_begin_src != TRIG_EXT)
err++;
if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
err++;
@@ -825,7 +858,7 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (devpriv->usedma == 0) {
comedi_error(dev,
- "driver requires 2 dma channels to execute command");
+ "driver requires 2 dma channels to execute command");
return -EIO;
}
@@ -865,9 +898,7 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
update_adcsr(0);
update_supcsr(DT2821_PRLD);
- wait_for(!mux_busy(), comedi_error(dev, "timeout\n");
- return -ETIME;
- );
+ wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);
if (cmd->scan_begin_src == TRIG_FOLLOW) {
update_supcsr(DT2821_STRIG);
@@ -887,7 +918,8 @@ static void dt282x_disable_dma(struct comedi_device *dev)
}
}
-static int dt282x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int dt282x_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
dt282x_disable_dma(dev);
@@ -937,16 +969,18 @@ static int dt282x_ns_to_timer(int *nanosec, int round_mode)
* offset binary if necessary, loads the data into the DAC
* data register, and performs the conversion.
*/
-static int dt282x_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int dt282x_ao_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = devpriv->ao[CR_CHAN(insn->chanspec)];
return 1;
}
-static int dt282x_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int dt282x_ao_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
short d;
unsigned int chan;
@@ -978,8 +1012,8 @@ static int dt282x_ao_insn_write(struct comedi_device *dev, struct comedi_subdevi
return 1;
}
-static int dt282x_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+static int dt282x_ao_cmdtest(struct comedi_device *dev,
+ struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
int err = 0;
int tmp;
@@ -1029,7 +1063,7 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice
cmd->start_arg = 0;
err++;
}
- if (cmd->scan_begin_arg < 5000 /* XXX unknown */) {
+ if (cmd->scan_begin_arg < 5000 /* XXX unknown */ ) {
cmd->scan_begin_arg = 5000;
err++;
}
@@ -1069,8 +1103,8 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice
}
-static int dt282x_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
- unsigned int x)
+static int dt282x_ao_inttrig(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int x)
{
int size;
@@ -1078,7 +1112,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice
return -EINVAL;
size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf,
- devpriv->dma_maxsize);
+ devpriv->dma_maxsize);
if (size == 0) {
printk("dt282x: AO underrun\n");
return -EPIPE;
@@ -1086,7 +1120,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice
prep_ao_dma(dev, 0, size);
size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf,
- devpriv->dma_maxsize);
+ devpriv->dma_maxsize);
if (size == 0) {
printk("dt282x: AO underrun\n");
return -EPIPE;
@@ -1106,7 +1140,7 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (devpriv->usedma == 0) {
comedi_error(dev,
- "driver requires 2 dma channels to execute command");
+ "driver requires 2 dma channels to execute command");
return -EIO;
}
@@ -1132,7 +1166,8 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
return 0;
}
-static int dt282x_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int dt282x_ao_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
dt282x_disable_dma(dev);
@@ -1145,8 +1180,9 @@ static int dt282x_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *
return 0;
}
-static int dt282x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int dt282x_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
@@ -1159,8 +1195,9 @@ static int dt282x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
return 2;
}
-static int dt282x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int dt282x_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int mask;
@@ -1190,10 +1227,12 @@ static const struct comedi_lrange *const ai_range_table[] = {
&range_dt282x_ai_5_bipolar,
&range_dt282x_ai_5_unipolar
};
+
static const struct comedi_lrange *const ai_range_pgl_table[] = {
&range_dt282x_ai_hi_bipolar,
&range_dt282x_ai_hi_unipolar
};
+
static const struct comedi_lrange *opt_ai_range_lkup(int ispgl, int x)
{
if (ispgl) {
@@ -1206,6 +1245,7 @@ static const struct comedi_lrange *opt_ai_range_lkup(int ispgl, int x)
return ai_range_table[x];
}
}
+
static const struct comedi_lrange *const ao_range_table[] = {
&range_bipolar10,
&range_unipolar10,
@@ -1213,6 +1253,7 @@ static const struct comedi_lrange *const ao_range_table[] = {
&range_unipolar5,
&range_bipolar2_5
};
+
static const struct comedi_lrange *opt_ao_range_lkup(int x)
{
if (x < 0 || x >= 5)
@@ -1264,23 +1305,23 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
i = inw(dev->iobase + DT2821_ADCSR);
#ifdef DEBUG
printk(" fingerprint=%x,%x,%x,%x,%x",
- inw(dev->iobase + DT2821_ADCSR),
- inw(dev->iobase + DT2821_CHANCSR),
- inw(dev->iobase + DT2821_DACSR),
- inw(dev->iobase + DT2821_SUPCSR),
- inw(dev->iobase + DT2821_TMRCTR));
+ inw(dev->iobase + DT2821_ADCSR),
+ inw(dev->iobase + DT2821_CHANCSR),
+ inw(dev->iobase + DT2821_DACSR),
+ inw(dev->iobase + DT2821_SUPCSR),
+ inw(dev->iobase + DT2821_TMRCTR));
#endif
if (((inw(dev->iobase + DT2821_ADCSR) & DT2821_ADCSR_MASK)
- != DT2821_ADCSR_VAL) ||
- ((inw(dev->iobase + DT2821_CHANCSR) & DT2821_CHANCSR_MASK)
- != DT2821_CHANCSR_VAL) ||
- ((inw(dev->iobase + DT2821_DACSR) & DT2821_DACSR_MASK)
- != DT2821_DACSR_VAL) ||
- ((inw(dev->iobase + DT2821_SUPCSR) & DT2821_SUPCSR_MASK)
- != DT2821_SUPCSR_VAL) ||
- ((inw(dev->iobase + DT2821_TMRCTR) & DT2821_TMRCTR_MASK)
- != DT2821_TMRCTR_VAL)) {
+ != DT2821_ADCSR_VAL) ||
+ ((inw(dev->iobase + DT2821_CHANCSR) & DT2821_CHANCSR_MASK)
+ != DT2821_CHANCSR_VAL) ||
+ ((inw(dev->iobase + DT2821_DACSR) & DT2821_DACSR_MASK)
+ != DT2821_DACSR_VAL) ||
+ ((inw(dev->iobase + DT2821_SUPCSR) & DT2821_SUPCSR_MASK)
+ != DT2821_SUPCSR_VAL) ||
+ ((inw(dev->iobase + DT2821_TMRCTR) & DT2821_TMRCTR_MASK)
+ != DT2821_TMRCTR_VAL)) {
printk(" board not found");
return -EIO;
}
@@ -1302,7 +1343,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
irq = probe_irq_off(irqs);
restore_flags(flags);
- if (0 /* error */) {
+ if (0 /* error */ ) {
printk(" error probing irq (bad)");
}
}
@@ -1330,7 +1371,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return ret;
ret = dt282x_grab_dma(dev, it->options[opt_dma1],
- it->options[opt_dma2]);
+ it->options[opt_dma2]);
if (ret < 0)
return ret;
@@ -1344,10 +1385,9 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* ai subdevice */
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_CMD_READ |
- ((it->options[opt_diff]) ? SDF_DIFF : SDF_COMMON);
+ ((it->options[opt_diff]) ? SDF_DIFF : SDF_COMMON);
s->n_chan =
- (it->options[opt_diff]) ? boardtype.adchan_di : boardtype.
- adchan_se;
+ (it->options[opt_diff]) ? boardtype.adchan_di : boardtype.adchan_se;
s->insn_read = dt282x_ai_insn_read;
s->do_cmdtest = dt282x_ai_cmdtest;
s->do_cmd = dt282x_ai_cmd;
@@ -1355,7 +1395,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->maxdata = (1 << boardtype.adbits) - 1;
s->len_chanlist = 16;
s->range_table =
- opt_ai_range_lkup(boardtype.ispgl, it->options[opt_ai_range]);
+ opt_ai_range_lkup(boardtype.ispgl, it->options[opt_ai_range]);
devpriv->ad_2scomp = it->options[opt_ai_twos];
s++;
@@ -1375,9 +1415,9 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->len_chanlist = 2;
s->range_table_list = devpriv->darangelist;
devpriv->darangelist[0] =
- opt_ao_range_lkup(it->options[opt_ao0_range]);
+ opt_ao_range_lkup(it->options[opt_ao0_range]);
devpriv->darangelist[1] =
- opt_ao_range_lkup(it->options[opt_ao1_range]);
+ opt_ao_range_lkup(it->options[opt_ao1_range]);
devpriv->da0_2scomp = it->options[opt_ao0_twos];
devpriv->da1_2scomp = it->options[opt_ao1_twos];
} else {