From fba5963c9259252747f79f778805ca7b368d9000 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:07 +0100 Subject: staging: comedi: das08: use indexed initializer for AI range table types The "das08" common module for DAS08 ISA, PCI, and PCMCIA drivers includes a predefined set of AI range tables. The static board data (of type `struct das08_board_struct`) for a particular board contains an index in its `ai_pg` member (of type `enum das08_lrange`) indicating which of the predefined AI range tables to use. The "das08" common module looks up this index in `das08_ai_lranges[]` to get a pointer to the predefined range table for the board. The same index is also looked up in `das08_gainlists[]` to get a corresponding pointer to a list of hardware gain values for each range supported by the board (NULL for boards without programmable gain). To make this clearer, used indexed initializers for `das08_ai_lranges[]` and `das08_gainlists[]`, using the enumerated constants from `enum das08_lrange` as the indices. Also add a short comment to the definition of `enum das08_lrange`. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 73f4c8dbbde3..b1cd6eaacf61 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -165,11 +165,11 @@ static const struct comedi_lrange range_das08_pgm = { */ static const struct comedi_lrange *const das08_ai_lranges[] = { - &range_unknown, - &range_bipolar5, - &range_das08_pgh, - &range_das08_pgl, - &range_das08_pgm, + [das08_pg_none] = &range_unknown, + [das08_bipolar5] = &range_bipolar5, + [das08_pgh] = &range_das08_pgh, + [das08_pgl] = &range_das08_pgl, + [das08_pgm] = &range_das08_pgm, }; static const int das08_pgh_gainlist[] = { @@ -179,11 +179,11 @@ static const int das08_pgl_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 }; static const int das08_pgm_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 }; static const int *const das08_gainlists[] = { - NULL, - NULL, - das08_pgh_gainlist, - das08_pgl_gainlist, - das08_pgm_gainlist, + [das08_pg_none] = NULL, + [das08_bipolar5] = NULL, + [das08_pgh] = das08_pgh_gainlist, + [das08_pgl] = das08_pgl_gainlist, + [das08_pgm] = das08_pgm_gainlist, }; static int das08_ai_eoc(struct comedi_device *dev, -- cgit v1.2.3-59-g8ed1b From 2b56b35820eee978c9f4bee7e40e18ddb3d9bc26 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:08 +0100 Subject: staging: comedi: das08: improve test for programmable gain `das08_ai_rinsn()` handles Comedi `INSN_READ` instructions for the AI subdevice. This programs the gain for the analog input channel if the board has support for that, and acquires data from the channel. If programmable gain is supported, the gain code is read from the array pointed to by `devpriv->pg_gainlist` indexed by the range index. The function assumes that programmable gain is supported if the AI subdevice's range table supports more than one range. Replace that with a more direct test for `devpriv->pg_gainlist` being non-NULL, as it is only initialized to a non-NULL pointer for boards that support programmable gain. This will also allow range tables to be included for convenience for those boards that support multiple ranges by DIP switches. Those boards are currently initialized to use a single "unknown" range. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index b1cd6eaacf61..25213520e965 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -225,7 +225,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL); spin_unlock(&dev->spinlock); - if (s->range_table->length > 1) { + if (devpriv->pg_gainlist) { /* set gain/range */ range = CR_RANGE(insn->chanspec); outb(devpriv->pg_gainlist[range], -- cgit v1.2.3-59-g8ed1b From 5826d99aedda2442f89194cd3b85bc69970c175c Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:10 +0100 Subject: staging: comedi: das08: rename DAS08_LSB and DAS08_MSB The `DAS08_LSB` and `DAS08_MSB` macros contain the offsets to the least-significant and most-significant analog input data registers. Rename them to `DAS08_AI_LSB_REG` and `DAS08_AI_MSB_REG` respectively and add comments to document them. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 25213520e965..1d9e6a679327 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -42,8 +42,20 @@ */ -#define DAS08_LSB 0 -#define DAS08_MSB 1 +/* + * Data format of DAS08_AI_LSB_REG and DAS08_AI_MSB_REG depends on + * 'ai_encoding' member of board structure: + * + * das08_encode12 : DATA[11..4] = MSB[7..0], DATA[3..0] = LSB[7..4]. + * das08_pcm_encode12 : DATA[11..8] = MSB[3..0], DATA[7..9] = LSB[7..0]. + * das08_encode16 : SIGN = MSB[7], MAGNITUDE[14..8] = MSB[6..0], + * MAGNITUDE[7..0] = LSB[7..0]. + * SIGN==0 for negative input, SIGN==1 for positive input. + * Note: when read a second time after conversion + * complete, MSB[7] is an "over-range" bit. + */ +#define DAS08_AI_LSB_REG 0x00 /* (R) AI least significant bits */ +#define DAS08_AI_MSB_REG 0x01 /* (R) AI most significant bits */ #define DAS08_TRIG_12BIT 1 #define DAS08_STATUS 2 #define DAS08_EOC (1<<7) @@ -214,8 +226,8 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, range = CR_RANGE(insn->chanspec); /* clear crap */ - inb(dev->iobase + DAS08_LSB); - inb(dev->iobase + DAS08_MSB); + inb(dev->iobase + DAS08_AI_LSB_REG); + inb(dev->iobase + DAS08_AI_MSB_REG); /* set multiplexer */ /* lock to prevent race with digital output */ @@ -235,7 +247,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, for (n = 0; n < insn->n; n++) { /* clear over-range bits for 16-bit boards */ if (thisboard->ai_nbits == 16) - if (inb(dev->iobase + DAS08_MSB) & 0x80) + if (inb(dev->iobase + DAS08_AI_MSB_REG) & 0x80) dev_info(dev->class_dev, "over-range\n"); /* trigger conversion */ @@ -245,8 +257,8 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, if (ret) return ret; - msb = inb(dev->iobase + DAS08_MSB); - lsb = inb(dev->iobase + DAS08_LSB); + msb = inb(dev->iobase + DAS08_AI_MSB_REG); + lsb = inb(dev->iobase + DAS08_AI_LSB_REG); if (thisboard->ai_encoding == das08_encode12) { data[n] = (lsb >> 4) | (msb << 4); } else if (thisboard->ai_encoding == das08_pcm_encode12) { -- cgit v1.2.3-59-g8ed1b From c2ba9e96376dbfdbdff27ff99a602691b265b0c9 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:11 +0100 Subject: staging: comedi: das08: rename DAS08_TRIG_12BIT The `DAS08_TRIG_12BIT` macro contains the offset to the write-only software trigger register for 12-bit or 16-bit analog-to-digital conversions. Rename the macro to `DAS08_AI_TRIG_REG` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 1d9e6a679327..fa14fa105b00 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -56,7 +56,7 @@ */ #define DAS08_AI_LSB_REG 0x00 /* (R) AI least significant bits */ #define DAS08_AI_MSB_REG 0x01 /* (R) AI most significant bits */ -#define DAS08_TRIG_12BIT 1 +#define DAS08_AI_TRIG_REG 0x01 /* (W) AI software trigger */ #define DAS08_STATUS 2 #define DAS08_EOC (1<<7) #define DAS08_IRQ (1<<3) @@ -251,7 +251,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, dev_info(dev->class_dev, "over-range\n"); /* trigger conversion */ - outb_p(0, dev->iobase + DAS08_TRIG_12BIT); + outb_p(0, dev->iobase + DAS08_AI_TRIG_REG); ret = comedi_timeout(dev, s, insn, das08_ai_eoc, 0); if (ret) -- cgit v1.2.3-59-g8ed1b From b00b3f769abe1dd19cc51552734c44178cb1269d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:12 +0100 Subject: staging: comedi: das08: rename DAS08_STATUS The `DAS08_STATUS` macro contains the offset to the read-only status register. Rename it to `DAS08_STATUS_REG` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index fa14fa105b00..eecbf4d95942 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -57,7 +57,7 @@ #define DAS08_AI_LSB_REG 0x00 /* (R) AI least significant bits */ #define DAS08_AI_MSB_REG 0x01 /* (R) AI most significant bits */ #define DAS08_AI_TRIG_REG 0x01 /* (W) AI software trigger */ -#define DAS08_STATUS 2 +#define DAS08_STATUS_REG 0x02 /* (R) status */ #define DAS08_EOC (1<<7) #define DAS08_IRQ (1<<3) #define DAS08_IP(x) (((x)>>4)&0x7) @@ -205,7 +205,7 @@ static int das08_ai_eoc(struct comedi_device *dev, { unsigned int status; - status = inb(dev->iobase + DAS08_STATUS); + status = inb(dev->iobase + DAS08_STATUS_REG); if ((status & DAS08_EOC) == 0) return 0; return -EBUSY; @@ -282,7 +282,7 @@ static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { data[0] = 0; - data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS)); + data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS_REG)); return insn->n; } -- cgit v1.2.3-59-g8ed1b From 851e5d5475de796560683e2a4b28af0a7da177e1 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:13 +0100 Subject: staging: comedi: das08: rename and rewrite DAS08_EOC The `DAS08_EOC` macro contains a mask for the "end of A/D conversion" bit in the status register. The logic is reverse sense in that the bit is set to 1 while the conversion is in progress and set to 0 when the conversion is complete. Rename the macro to `DAS08_STATUS_AI_BUSY` and add a comment. Also make use of the `BIT()` macro to define the value. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index eecbf4d95942..04843080b5e8 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -58,7 +58,7 @@ #define DAS08_AI_MSB_REG 0x01 /* (R) AI most significant bits */ #define DAS08_AI_TRIG_REG 0x01 /* (W) AI software trigger */ #define DAS08_STATUS_REG 0x02 /* (R) status */ -#define DAS08_EOC (1<<7) +#define DAS08_STATUS_AI_BUSY BIT(7) /* AI conversion in progress */ #define DAS08_IRQ (1<<3) #define DAS08_IP(x) (((x)>>4)&0x7) #define DAS08_CONTROL 2 @@ -206,7 +206,7 @@ static int das08_ai_eoc(struct comedi_device *dev, unsigned int status; status = inb(dev->iobase + DAS08_STATUS_REG); - if ((status & DAS08_EOC) == 0) + if ((status & DAS08_STATUS_AI_BUSY) == 0) return 0; return -EBUSY; } -- cgit v1.2.3-59-g8ed1b From 2398391017ddec9427bdb94cc5d70326eaf8a3c5 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:14 +0100 Subject: staging: comedi: das08: rename and rewrite DAS08_IRQ The `DAS08_IRQ` macro contains a mask for the "IRQ" status bit. This is set to 1 when a rising edge is detected on the external interrupt input pin of the external connector (which may be jumpered to a pacer output). It is cleared by setting the "INTE" control bit to 0. It is not used on "JR" boards. Rename the macro to `DAS08_STATUS_IRQ` and add a comment. Also use the `BIT()` macro to define the value. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 04843080b5e8..935bbfb213e6 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -59,7 +59,12 @@ #define DAS08_AI_TRIG_REG 0x01 /* (W) AI software trigger */ #define DAS08_STATUS_REG 0x02 /* (R) status */ #define DAS08_STATUS_AI_BUSY BIT(7) /* AI conversion in progress */ -#define DAS08_IRQ (1<<3) +/* + * The IRQ status bit is set to 1 by a rising edge on the external interrupt + * input (which may be jumpered to the pacer output). It is cleared by + * setting the INTE control bit to 0. Not present on "JR" boards. + */ +#define DAS08_STATUS_IRQ BIT(3) /* latched interrupt input */ #define DAS08_IP(x) (((x)>>4)&0x7) #define DAS08_CONTROL 2 #define DAS08_MUX_MASK 0x7 -- cgit v1.2.3-59-g8ed1b From 4d14ac8a900961b44173a5dff38e138ecda8e4c7 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:15 +0100 Subject: staging: comedi: das08: rename and rewrite DAS08_IP The `DAS08_IP()` macro takes a value read from the status register and returns the state of the three digital input channels (except on "JR" boards). Rename it to `DAS08_STATUS_DI()` and add a comment. Also re-arrange the expression used to extract the state of the digital inputs for consistency with other register macros. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 935bbfb213e6..eef0456fdc70 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -65,7 +65,8 @@ * setting the INTE control bit to 0. Not present on "JR" boards. */ #define DAS08_STATUS_IRQ BIT(3) /* latched interrupt input */ -#define DAS08_IP(x) (((x)>>4)&0x7) +/* digital inputs (not "JR" boards) */ +#define DAS08_STATUS_DI(x) (((x) & 0x70) >> 4) #define DAS08_CONTROL 2 #define DAS08_MUX_MASK 0x7 #define DAS08_MUX(x) ((x) & DAS08_MUX_MASK) @@ -287,7 +288,7 @@ static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { data[0] = 0; - data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS_REG)); + data[1] = DAS08_STATUS_DI(inb(dev->iobase + DAS08_STATUS_REG)); return insn->n; } -- cgit v1.2.3-59-g8ed1b From c800e51310ad7204260100b978800e2b9828af3d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:16 +0100 Subject: staging: comedi: das08: rename DAS08_CONTROL The `DAS08_CONTROL` macro contains the offset to the write-only control register. Rename it to `DAS08_CONTROL_REG` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index eef0456fdc70..b43bc2d6ff5f 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -67,7 +67,7 @@ #define DAS08_STATUS_IRQ BIT(3) /* latched interrupt input */ /* digital inputs (not "JR" boards) */ #define DAS08_STATUS_DI(x) (((x) & 0x70) >> 4) -#define DAS08_CONTROL 2 +#define DAS08_CONTROL_REG 0x02 /* (W) control */ #define DAS08_MUX_MASK 0x7 #define DAS08_MUX(x) ((x) & DAS08_MUX_MASK) #define DAS08_INTE (1<<3) @@ -240,7 +240,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, spin_lock(&dev->spinlock); devpriv->do_mux_bits &= ~DAS08_MUX_MASK; devpriv->do_mux_bits |= DAS08_MUX(chan); - outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL); + outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL_REG); spin_unlock(&dev->spinlock); if (devpriv->pg_gainlist) { @@ -305,7 +305,7 @@ static int das08_do_wbits(struct comedi_device *dev, spin_lock(&dev->spinlock); devpriv->do_mux_bits &= ~DAS08_DO_MASK; devpriv->do_mux_bits |= DAS08_OP(s->state); - outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL); + outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL_REG); spin_unlock(&dev->spinlock); } -- cgit v1.2.3-59-g8ed1b From ac81df6097bb30c61bc8e7e3ce8100adcee14b66 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:17 +0100 Subject: staging: comedi: das08: rename DAS08_MUX() and DAS08_MUX_MASK The `DAS08_MUX_MASK` macro is a bitmask for the control register corresponding to the analog input multiplexor channel selection bits. Rename it to `DAS08_CONTROL_MUX_MASK` and add a comment. Note that the current setting of the multiplexor can also be read from the same bit positions in the status register, but the driver does not use it. Add a comment to that effect. The `DAS08_MUX(x)` macro takes an analog input channel number and returns the corresponding analog input multiplexor channel selection bits for the control register. Rename it to `DAS08_CONTROL_MUX(x)` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index b43bc2d6ff5f..f0ee617028db 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -68,8 +68,12 @@ /* digital inputs (not "JR" boards) */ #define DAS08_STATUS_DI(x) (((x) & 0x70) >> 4) #define DAS08_CONTROL_REG 0x02 /* (W) control */ -#define DAS08_MUX_MASK 0x7 -#define DAS08_MUX(x) ((x) & DAS08_MUX_MASK) +/* + * Note: The AI multiplexor channel can also be read from status register using + * the same mask. + */ +#define DAS08_CONTROL_MUX_MASK 0x7 /* multiplexor channel mask */ +#define DAS08_CONTROL_MUX(x) ((x) & DAS08_CONTROL_MUX_MASK) /* mux channel */ #define DAS08_INTE (1<<3) #define DAS08_DO_MASK 0xf0 #define DAS08_OP(x) (((x) << 4) & DAS08_DO_MASK) @@ -238,8 +242,8 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, /* set multiplexer */ /* lock to prevent race with digital output */ spin_lock(&dev->spinlock); - devpriv->do_mux_bits &= ~DAS08_MUX_MASK; - devpriv->do_mux_bits |= DAS08_MUX(chan); + devpriv->do_mux_bits &= ~DAS08_CONTROL_MUX_MASK; + devpriv->do_mux_bits |= DAS08_CONTROL_MUX(chan); outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL_REG); spin_unlock(&dev->spinlock); -- cgit v1.2.3-59-g8ed1b From 6a3a22bcada2209520180c8bf0045e4e241003af Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:18 +0100 Subject: staging: comedi: das08: rename and rewrite DAS08_INTE The `DAS08_INTE` macro contains a mask for the "INTE" bit in the control register (except on "JR" boards). Setting it to 1 enables interrupts. Setting it to 0 disables interrupts and clears the "IRQ" bit in the status register. Rename the macro to `DAS08_CONTROL_INTE` and add a comment. Also use the `BIT()` macro to define its value. (Note: the driver does not currently enable interrupts.) Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index f0ee617028db..9898ac0f1335 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -74,7 +74,7 @@ */ #define DAS08_CONTROL_MUX_MASK 0x7 /* multiplexor channel mask */ #define DAS08_CONTROL_MUX(x) ((x) & DAS08_CONTROL_MUX_MASK) /* mux channel */ -#define DAS08_INTE (1<<3) +#define DAS08_CONTROL_INTE BIT(3) /* interrupt enable (not "JR" boards) */ #define DAS08_DO_MASK 0xf0 #define DAS08_OP(x) (((x) << 4) & DAS08_DO_MASK) -- cgit v1.2.3-59-g8ed1b From 11e8457f02ee41bbd1c0437d340c692ce2d78431 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:19 +0100 Subject: staging: comedi: das08: rename DAS08_OP() and DAS08_DO_MASK The `DAS08_DO_MASK` macro is a bitmask for the control register corresponding to the digital output channels (except on "JR" boards). Rename it to `DAS08_CONTROL_DO_MASK` and add a comment. The `DAS08_OP(x)` macro takes a bitvector of the desired digital output channel states and returns the corresponding bits for the control register (except on "JR" boards). Rename it to `DAS08_CONTROL_DO(x)` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 9898ac0f1335..76e35d4aae93 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -75,8 +75,9 @@ #define DAS08_CONTROL_MUX_MASK 0x7 /* multiplexor channel mask */ #define DAS08_CONTROL_MUX(x) ((x) & DAS08_CONTROL_MUX_MASK) /* mux channel */ #define DAS08_CONTROL_INTE BIT(3) /* interrupt enable (not "JR" boards) */ -#define DAS08_DO_MASK 0xf0 -#define DAS08_OP(x) (((x) << 4) & DAS08_DO_MASK) +#define DAS08_CONTROL_DO_MASK 0xf0 /* digital outputs mask (not "JR") */ +/* digital outputs (not "JR" boards) */ +#define DAS08_CONTROL_DO(x) (((x) << 4) & DAS08_CONTROL_DO_MASK) /* cio-das08jr.pdf @@ -307,8 +308,8 @@ static int das08_do_wbits(struct comedi_device *dev, if (comedi_dio_update_state(s, data)) { /* prevent race with setting of analog input mux */ spin_lock(&dev->spinlock); - devpriv->do_mux_bits &= ~DAS08_DO_MASK; - devpriv->do_mux_bits |= DAS08_OP(s->state); + devpriv->do_mux_bits &= ~DAS08_CONTROL_DO_MASK; + devpriv->do_mux_bits |= DAS08_CONTROL_DO(s->state); outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL_REG); spin_unlock(&dev->spinlock); } -- cgit v1.2.3-59-g8ed1b From c47c0ed2d53ad829aff1f4ada00e98227c478a57 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:20 +0100 Subject: staging: comedi: das08: rename and split DAS08JR_DIO The `DAS08JR_DIO` macro contains the offset to the read-only digital input register and write-only digital output register on the "JR" boards. Replace the macro with two new macros (with the same numeric value) named `DAS08JR_DI_REG` for the digital input register and `DAS08JR_DO_REG` for the digital output register, and add some comments. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 76e35d4aae93..c015bb6507f3 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -95,7 +95,8 @@ */ -#define DAS08JR_DIO 3 +#define DAS08JR_DI_REG 0x03 /* (R) digital inputs ("JR" boards) */ +#define DAS08JR_DO_REG 0x03 /* (W) digital outputs ("JR" boards) */ #define DAS08JR_AO_LSB(x) ((x) ? 6 : 4) #define DAS08JR_AO_MSB(x) ((x) ? 7 : 5) @@ -324,7 +325,7 @@ static int das08jr_di_rbits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { data[0] = 0; - data[1] = inb(dev->iobase + DAS08JR_DIO); + data[1] = inb(dev->iobase + DAS08JR_DI_REG); return insn->n; } @@ -335,7 +336,7 @@ static int das08jr_do_wbits(struct comedi_device *dev, unsigned int *data) { if (comedi_dio_update_state(s, data)) - outb(s->state, dev->iobase + DAS08JR_DIO); + outb(s->state, dev->iobase + DAS08JR_DO_REG); data[1] = s->state; @@ -355,7 +356,7 @@ static void das08_ao_set_data(struct comedi_device *dev, outb(lsb, dev->iobase + DAS08JR_AO_LSB(chan)); outb(msb, dev->iobase + DAS08JR_AO_MSB(chan)); /* load DACs */ - inb(dev->iobase + DAS08JR_DIO); + inb(dev->iobase + DAS08JR_DI_REG); } else { outb(lsb, dev->iobase + DAS08AO_AO_LSB(chan)); outb(msb, dev->iobase + DAS08AO_AO_MSB(chan)); -- cgit v1.2.3-59-g8ed1b From 7b2098f626cfa490eb83eb4563efb1d5b8897ed8 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:21 +0100 Subject: staging: comedi: das08: rename DAS08JR_AO_LSB() and DAS08JR_AO_MSB() The `DAS08JR_AO_LSB(x)` macro returns the offset to the analog output low byte register for channel x (0 or 1) for "JR" boards with analog output support. The `DAS08JR_AO_MSB(x)` macro returns the offset to the corresponding high byte register. Rename the macros to `DAS08JR_AO_LSB_REG(x)` and `DAS08JR_AO_MSB_REG(x)` respectively, and add some comments. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index c015bb6507f3..51637b120ddb 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -97,8 +97,10 @@ #define DAS08JR_DI_REG 0x03 /* (R) digital inputs ("JR" boards) */ #define DAS08JR_DO_REG 0x03 /* (W) digital outputs ("JR" boards) */ -#define DAS08JR_AO_LSB(x) ((x) ? 6 : 4) -#define DAS08JR_AO_MSB(x) ((x) ? 7 : 5) +/* (W) analog output l.s.b. registers for 2 channels ("JR" boards) */ +#define DAS08JR_AO_LSB_REG(x) ((x) ? 0x06 : 0x04) +/* (W) analog output m.s.b. registers for 2 channels ("JR" boards) */ +#define DAS08JR_AO_MSB_REG(x) ((x) ? 0x07 : 0x05) /* cio-das08_aox.pdf @@ -353,8 +355,8 @@ static void das08_ao_set_data(struct comedi_device *dev, lsb = data & 0xff; msb = (data >> 8) & 0xff; if (thisboard->is_jr) { - outb(lsb, dev->iobase + DAS08JR_AO_LSB(chan)); - outb(msb, dev->iobase + DAS08JR_AO_MSB(chan)); + outb(lsb, dev->iobase + DAS08JR_AO_LSB_REG(chan)); + outb(msb, dev->iobase + DAS08JR_AO_MSB_REG(chan)); /* load DACs */ inb(dev->iobase + DAS08JR_DI_REG); } else { -- cgit v1.2.3-59-g8ed1b From 09ed1b72cf5ebebb37c2487e7269fc00027477df Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:22 +0100 Subject: staging: comedi: das08: add DAS08JR_AO_UPDATE_REG "JR" boards with analog output channels have a jumper that controls whether analog output channels are updated simultaneously or individually. When set to update individually, individual channels are updated when the high byte register is written. When set to update simultaneously, channels are not updated until the digital inputs register is read. The driver doesn't know how the jumper is set and is not interested in the simultaneous output feature, so it updates a channel by writing the low byte, then the high byte, then reading the digital inputs register. To make the code more explicit, add a macro `DAS08JR_AO_UPDATE_REG` with the same value as the `DAS08JR_DI_REG` macro (for digital inputs) and use it when reading the register to update the analog outputs. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 51637b120ddb..4e8756a822ae 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -101,6 +101,11 @@ #define DAS08JR_AO_LSB_REG(x) ((x) ? 0x06 : 0x04) /* (W) analog output m.s.b. registers for 2 channels ("JR" boards) */ #define DAS08JR_AO_MSB_REG(x) ((x) ? 0x07 : 0x05) +/* + * (R) update analog outputs ("JR" boards set for simultaneous output) + * (same register as digital inputs) + */ +#define DAS08JR_AO_UPDATE_REG 0x03 /* cio-das08_aox.pdf @@ -358,7 +363,7 @@ static void das08_ao_set_data(struct comedi_device *dev, outb(lsb, dev->iobase + DAS08JR_AO_LSB_REG(chan)); outb(msb, dev->iobase + DAS08JR_AO_MSB_REG(chan)); /* load DACs */ - inb(dev->iobase + DAS08JR_DI_REG); + inb(dev->iobase + DAS08JR_AO_UPDATE_REG); } else { outb(lsb, dev->iobase + DAS08AO_AO_LSB(chan)); outb(msb, dev->iobase + DAS08AO_AO_MSB(chan)); -- cgit v1.2.3-59-g8ed1b From f1c04fd42183ccbfa9820ae5a45168e80d70d282 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:23 +0100 Subject: staging: comedi: das08: replace DAS08AO_GAIN_CONTROL/STATUS The `DAS08AO_GAIN_CONTROL` and `DAS08AO_GAIN_STATUS` macros hold the offset to the "programmable gain" register on "PGL", "PGM", "PGH", "AOL", "AOM" and "AOH" boards. Writing a code to this register sets the gain for the current analog input channel (selected in the main control register). The written value can be read back in bits 3..0 of the register. Other bits of the register are read-only and not used by the driver. Rename `DAS08AO_GAIN_CONTROL` to `DAS08_GAIN_REG` and add a comment. Remove `DAS08AO_GAIN_STATUS` as the driver does not use it and the read-only parts of the register are documented in the comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 4e8756a822ae..8aa80116f1cf 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -78,6 +78,13 @@ #define DAS08_CONTROL_DO_MASK 0xf0 /* digital outputs mask (not "JR") */ /* digital outputs (not "JR" boards) */ #define DAS08_CONTROL_DO(x) (((x) << 4) & DAS08_CONTROL_DO_MASK) +/* + * (R/W) programmable AI gain ("PGx" and "AOx" boards): + * + bits 3..0 (R/W) show/set the gain for the current AI mux channel + * + bits 6..4 (R) show the current AI mux channel + * + bit 7 (R) not unused + */ +#define DAS08_GAIN_REG 0x03 /* cio-das08jr.pdf @@ -127,9 +134,6 @@ cdef 8255 */ -#define DAS08AO_GAIN_CONTROL 3 -#define DAS08AO_GAIN_STATUS 3 - #define DAS08AO_AO_LSB(x) ((x) ? 0xa : 8) #define DAS08AO_AO_MSB(x) ((x) ? 0xb : 9) #define DAS08AO_AO_UPDATE 8 @@ -260,7 +264,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, /* set gain/range */ range = CR_RANGE(insn->chanspec); outb(devpriv->pg_gainlist[range], - dev->iobase + DAS08AO_GAIN_CONTROL); + dev->iobase + DAS08_GAIN_REG); } for (n = 0; n < insn->n; n++) { -- cgit v1.2.3-59-g8ed1b From 3c98c1d3f1d3912738dca864fd00910654ed2a65 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:24 +0100 Subject: staging: comedi: das08: rename DAS08AO_AO_LSB() and DAS08AO_AO_MSB() The `DAS08AO_AO_LSB(x)` macro returns the offset to the analog output low byte register for channel x (0 or 1) for "AOL", "AOM", and "AOH" boards. The `DAS08AO_AO_MSB(x)` macro returns the offset to the corresponding high byte register. Rename the macros to `DAS08AOX_AO_LSB_REG(x)` and `DAS08AOX_AO_MSB_REG(x)` respectively, and add some comments. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 8aa80116f1cf..005a7ef89f8c 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -134,8 +134,10 @@ cdef 8255 */ -#define DAS08AO_AO_LSB(x) ((x) ? 0xa : 8) -#define DAS08AO_AO_MSB(x) ((x) ? 0xb : 9) +/* (W) analog output l.s.b. registers for 2 channels ("AOx" boards) */ +#define DAS08AOX_AO_LSB_REG(x) ((x) ? 0x0a : 0x08) +/* (W) analog output m.s.b. registers for 2 channels ("AOx" boards) */ +#define DAS08AOX_AO_MSB_REG(x) ((x) ? 0x0b : 0x09) #define DAS08AO_AO_UPDATE 8 /* gainlist same as _pgx_ below */ @@ -369,8 +371,8 @@ static void das08_ao_set_data(struct comedi_device *dev, /* load DACs */ inb(dev->iobase + DAS08JR_AO_UPDATE_REG); } else { - outb(lsb, dev->iobase + DAS08AO_AO_LSB(chan)); - outb(msb, dev->iobase + DAS08AO_AO_MSB(chan)); + outb(lsb, dev->iobase + DAS08AOX_AO_LSB_REG(chan)); + outb(msb, dev->iobase + DAS08AOX_AO_MSB_REG(chan)); /* load DACs */ inb(dev->iobase + DAS08AO_AO_UPDATE); } -- cgit v1.2.3-59-g8ed1b From 6814b4a3fd3867d4104eecc371f73beced6cb499 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:25 +0100 Subject: staging: comedi: das08: rename DAS08AO_AO_UPDATE "AOL", "AOM", and "AOH" boards have a jumper that controls whether analog output channels are updated simultaneously or individually. When set to update individually, individual channels are updated when the high byte register is written. When set to update simultaneously, channels are not updated until any of the analog output registers are read. The driver doesn't know the jumper setting and is not interested in the simultaneous update feature, so it updates a channel by writing the low byte register, the high byte register, and then reading channel 0's low byte register. The `DAS08AO_AO_UPDATE` macro contains the offset to the low byte register for analog output channel 0 on the "AOL", "AOM", and "AOH" boards, which the driver reads to update the analog outputs. Rename the macro to `DAS08AOX_AO_UPDATE_REG` and add a comment. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 005a7ef89f8c..837c96892fcb 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -138,7 +138,11 @@ #define DAS08AOX_AO_LSB_REG(x) ((x) ? 0x0a : 0x08) /* (W) analog output m.s.b. registers for 2 channels ("AOx" boards) */ #define DAS08AOX_AO_MSB_REG(x) ((x) ? 0x0b : 0x09) -#define DAS08AO_AO_UPDATE 8 +/* + * (R) update analog outputs ("AOx" boards set for simultaneous output) + * (any of the analog output registers could be used for this) + */ +#define DAS08AOX_AO_UPDATE_REG 0x08 /* gainlist same as _pgx_ below */ @@ -374,7 +378,7 @@ static void das08_ao_set_data(struct comedi_device *dev, outb(lsb, dev->iobase + DAS08AOX_AO_LSB_REG(chan)); outb(msb, dev->iobase + DAS08AOX_AO_MSB_REG(chan)); /* load DACs */ - inb(dev->iobase + DAS08AO_AO_UPDATE); + inb(dev->iobase + DAS08AOX_AO_UPDATE_REG); } } -- cgit v1.2.3-59-g8ed1b From 646e70c5d1611edf2d36448ef0d377a0cf239cc1 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:26 +0100 Subject: staging: comedi: das08: remove board register map comments The "das08" module contains some comments outlining the register maps for some of the ISA boards supported by this module in combination with the "das08_isa" module. The comments are somewhat sporadically placed, don't detail all the boards, and don't use the preferred block comment style. If anywhere, they should probably be in the "das08_isa" module. Just remove them. The comments for the register macros indicate which boards they apply to anyway, so we don't lose much information. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 68 +--------------------------------- 1 file changed, 1 insertion(+), 67 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 837c96892fcb..a4b21c6ac762 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -26,22 +26,6 @@ #include "comedi_8254.h" #include "das08.h" -/* - cio-das08.pdf - - "isa-das08" - - 0 a/d bits 0-3 start 8 bit - 1 a/d bits 4-11 start 12 bit - 2 eoc, ip1-3, irq, mux op1-4, inte, mux - 3 unused unused - 4567 8254 - 89ab 8255 - - requires hard-wiring for async ai - -*/ - /* * Data format of DAS08_AI_LSB_REG and DAS08_AI_MSB_REG depends on * 'ai_encoding' member of board structure: @@ -86,22 +70,6 @@ */ #define DAS08_GAIN_REG 0x03 -/* - cio-das08jr.pdf - - "das08/jr-ao" - - 0 a/d bits 0-3 unused - 1 a/d bits 4-11 start 12 bit - 2 eoc, mux mux - 3 di do - 4 unused ao0_lsb - 5 unused ao0_msb - 6 unused ao1_lsb - 7 unused ao1_msb - -*/ - #define DAS08JR_DI_REG 0x03 /* (R) digital inputs ("JR" boards) */ #define DAS08JR_DO_REG 0x03 /* (W) digital outputs ("JR" boards) */ /* (W) analog output l.s.b. registers for 2 channels ("JR" boards) */ @@ -114,26 +82,6 @@ */ #define DAS08JR_AO_UPDATE_REG 0x03 -/* - cio-das08_aox.pdf - - "das08-aoh" - "das08-aol" - "das08-aom" - - 0 a/d bits 0-3 start 8 bit - 1 a/d bits 4-11 start 12 bit - 2 eoc, ip1-3, irq, mux op1-4, inte, mux - 3 mux, gain status gain control - 4567 8254 - 8 unused ao0_lsb - 9 unused ao0_msb - a unused ao1_lsb - b unused ao1_msb - 89ab - cdef 8255 -*/ - /* (W) analog output l.s.b. registers for 2 channels ("AOx" boards) */ #define DAS08AOX_AO_LSB_REG(x) ((x) ? 0x0a : 0x08) /* (W) analog output m.s.b. registers for 2 channels ("AOx" boards) */ @@ -189,21 +137,7 @@ static const struct comedi_lrange range_das08_pgm = { UNI_RANGE(0.1), UNI_RANGE(0.01) } -}; /* - cio-das08jr.pdf - - "das08/jr-ao" - - 0 a/d bits 0-3 unused - 1 a/d bits 4-11 start 12 bit - 2 eoc, mux mux - 3 di do - 4 unused ao0_lsb - 5 unused ao0_msb - 6 unused ao1_lsb - 7 unused ao1_msb - - */ +}; static const struct comedi_lrange *const das08_ai_lranges[] = { [das08_pg_none] = &range_unknown, -- cgit v1.2.3-59-g8ed1b From 66774ce6ca9f4b5bf656de5c58834a4fb95a3c6e Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:27 +0100 Subject: staging: comedi: das08.c: reformat copyright comment Replace double spaces with single spaces at the start of each line in the copyright comment at the top of the file. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index a4b21c6ac762..898622ff8b79 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -1,21 +1,21 @@ /* - * comedi/drivers/das08.c - * comedi module for common DAS08 support (used by ISA/PCI/PCMCIA drivers) + * comedi/drivers/das08.c + * comedi module for common DAS08 support (used by ISA/PCI/PCMCIA drivers) * - * COMEDI - Linux Control and Measurement Device Interface - * Copyright (C) 2000 David A. Schleef - * Copyright (C) 2001,2002,2003 Frank Mori Hess - * Copyright (C) 2004 Salvador E. Tropea + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef + * Copyright (C) 2001,2002,2003 Frank Mori Hess + * Copyright (C) 2004 Salvador E. Tropea * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. */ #include -- cgit v1.2.3-59-g8ed1b From 194869dbe81145650cd436ed6d3a101d2451779d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:28 +0100 Subject: staging: comedi: das08.c: reformat remaining comments Use the preferred style for block comments. Squash double spaces after the comment opening sequence for single-line comments. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 898622ff8b79..4bde52a4a17a 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -193,7 +193,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, inb(dev->iobase + DAS08_AI_MSB_REG); /* set multiplexer */ - /* lock to prevent race with digital output */ + /* lock to prevent race with digital output */ spin_lock(&dev->spinlock); devpriv->do_mux_bits &= ~DAS08_CONTROL_MUX_MASK; devpriv->do_mux_bits |= DAS08_CONTROL_MUX(chan); @@ -354,7 +354,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) /* ai */ if (thisboard->ai_nbits) { s->type = COMEDI_SUBD_AI; - /* XXX some boards actually have differential + /* + * XXX some boards actually have differential * inputs instead of single ended. * The driver does nothing with arefs though, * so it's no big deal. -- cgit v1.2.3-59-g8ed1b From a76ccfa81e8268025b3dc3dfd76420f6049032f7 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:29 +0100 Subject: staging: comedi: das08: rename ai range tables The `range_das08_pgl`, `range_das08_pgm`, and `range_das08_pgh` variables define the analog input ranges for the "PGL", "PGM", and "PGH" board variants, and are also used for the "AOL", "AOM", and "AOH" board variants. Rename them to use the `das08_` prefix for consistency. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 4bde52a4a17a..9f2113c1e1fc 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -94,7 +94,7 @@ /* gainlist same as _pgx_ below */ -static const struct comedi_lrange range_das08_pgl = { +static const struct comedi_lrange das08_pgl_ai_range = { 9, { BIP_RANGE(10), BIP_RANGE(5), @@ -108,7 +108,7 @@ static const struct comedi_lrange range_das08_pgl = { } }; -static const struct comedi_lrange range_das08_pgh = { +static const struct comedi_lrange das08_pgh_ai_range = { 12, { BIP_RANGE(10), BIP_RANGE(5), @@ -125,7 +125,7 @@ static const struct comedi_lrange range_das08_pgh = { } }; -static const struct comedi_lrange range_das08_pgm = { +static const struct comedi_lrange das08_pgm_ai_range = { 9, { BIP_RANGE(10), BIP_RANGE(5), @@ -142,9 +142,9 @@ static const struct comedi_lrange range_das08_pgm = { static const struct comedi_lrange *const das08_ai_lranges[] = { [das08_pg_none] = &range_unknown, [das08_bipolar5] = &range_bipolar5, - [das08_pgh] = &range_das08_pgh, - [das08_pgl] = &range_das08_pgl, - [das08_pgm] = &range_das08_pgm, + [das08_pgh] = &das08_pgh_ai_range, + [das08_pgl] = &das08_pgl_ai_range, + [das08_pgm] = &das08_pgm_ai_range, }; static const int das08_pgh_gainlist[] = { -- cgit v1.2.3-59-g8ed1b From fcd63ec8f325d964cfdf0a7c92a9dcac475f85e6 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:30 +0100 Subject: staging: comedi: das08: rename the gainlist variables `das08_pgh_gainlist[]`, `das08_pgl_gainlist[]`, and `das08_pgm_gainlist[]` hold the gain codes indexed by range index for various boards that support programmable gain. `das08_gainlist[]` is a look-up table to find the appropriate gain list for a board. These are all associated with the analog input Comedi subdevice. Rename the variables to reflect that. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 9f2113c1e1fc..ec0998bdb58d 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -147,18 +147,18 @@ static const struct comedi_lrange *const das08_ai_lranges[] = { [das08_pgm] = &das08_pgm_ai_range, }; -static const int das08_pgh_gainlist[] = { +static const int das08_pgh_ai_gainlist[] = { 8, 0, 10, 2, 12, 4, 14, 6, 1, 3, 5, 7 }; -static const int das08_pgl_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 }; -static const int das08_pgm_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 }; +static const int das08_pgl_ai_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 }; +static const int das08_pgm_ai_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 }; -static const int *const das08_gainlists[] = { +static const int *const das08_ai_gainlists[] = { [das08_pg_none] = NULL, [das08_bipolar5] = NULL, - [das08_pgh] = das08_pgh_gainlist, - [das08_pgl] = das08_pgl_gainlist, - [das08_pgm] = das08_pgm_gainlist, + [das08_pgh] = das08_pgh_ai_gainlist, + [das08_pgl] = das08_pgl_ai_gainlist, + [das08_pgm] = das08_pgm_ai_gainlist, }; static int das08_ai_eoc(struct comedi_device *dev, @@ -365,7 +365,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s->maxdata = (1 << thisboard->ai_nbits) - 1; s->range_table = das08_ai_lranges[thisboard->ai_pg]; s->insn_read = das08_ai_rinsn; - devpriv->pg_gainlist = das08_gainlists[thisboard->ai_pg]; + devpriv->pg_gainlist = das08_ai_gainlists[thisboard->ai_pg]; } else { s->type = COMEDI_SUBD_UNUSED; } -- cgit v1.2.3-59-g8ed1b From c224a9195745e909b2c457bba1a7a6b57ac9e284 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:31 +0100 Subject: staging: comedi: das08: rename das08_ai_rinsn() `das08_ai_rinsn()` is the handler for Comedi `INSN_READ` instructions for the AI subdevice. Rename the function to `das08_ai_insn_read()` for consistency. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index ec0998bdb58d..98df71848184 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -174,8 +174,9 @@ static int das08_ai_eoc(struct comedi_device *dev, return -EBUSY; } -static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das08_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { const struct das08_board_struct *thisboard = dev->board_ptr; struct das08_private_struct *devpriv = dev->private; @@ -364,7 +365,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s->n_chan = 8; s->maxdata = (1 << thisboard->ai_nbits) - 1; s->range_table = das08_ai_lranges[thisboard->ai_pg]; - s->insn_read = das08_ai_rinsn; + s->insn_read = das08_ai_insn_read; devpriv->pg_gainlist = das08_ai_gainlists[thisboard->ai_pg]; } else { s->type = COMEDI_SUBD_UNUSED; -- cgit v1.2.3-59-g8ed1b From 9f05914d0c7ce5083e54bb37d50c41d942adf03b Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:32 +0100 Subject: staging: comedi: das08: rename das08_di_rbits() & das08jr_di_rbits() `das08_di_rbits()` and `das08jr_di_rbits()` are handlers for the Comedi `INSN_BITS` instruction for the digital input subdevice on "non-JR" and "JR" boards, respectively. Rename them to `das08_di_insn_bits()` and `das08jr_di_insn_bits()` respectively for consistency. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 98df71848184..5590f118e9ac 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -242,8 +242,9 @@ static int das08_ai_insn_read(struct comedi_device *dev, return n; } -static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das08_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = 0; data[1] = DAS08_STATUS_DI(inb(dev->iobase + DAS08_STATUS_REG)); @@ -272,9 +273,9 @@ static int das08_do_wbits(struct comedi_device *dev, return insn->n; } -static int das08jr_di_rbits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das08jr_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { data[0] = 0; data[1] = inb(dev->iobase + DAS08JR_DI_REG); @@ -402,8 +403,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s->n_chan = thisboard->di_nchan; s->maxdata = 1; s->range_table = &range_digital; - s->insn_bits = - thisboard->is_jr ? das08jr_di_rbits : das08_di_rbits; + s->insn_bits = thisboard->is_jr ? das08jr_di_insn_bits : + das08_di_insn_bits; } else { s->type = COMEDI_SUBD_UNUSED; } -- cgit v1.2.3-59-g8ed1b From 3919c3d5891b079b5d03c03b4df4e3fca9572eca Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:33 +0100 Subject: staging: comedi: das08: rename das08_do_wbits() & das08jr_do_wbits() `das08_do_wbits()` and `das08jr_do_wbits()` are handlers for the Comedi `INSN_BITS` instruction for the digital output subdevice on "non-JR" and "JR" boards, respectively. Rename them to `das08_do_insn_bits()` and `das08jr_do_insn_bits()` respectively for consistency. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 5590f118e9ac..f74c4b009d8b 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -252,10 +252,9 @@ static int das08_di_insn_bits(struct comedi_device *dev, return insn->n; } -static int das08_do_wbits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int das08_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct das08_private_struct *devpriv = dev->private; @@ -283,10 +282,9 @@ static int das08jr_di_insn_bits(struct comedi_device *dev, return insn->n; } -static int das08jr_do_wbits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int das08jr_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { if (comedi_dio_update_state(s, data)) outb(s->state, dev->iobase + DAS08JR_DO_REG); @@ -417,8 +415,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s->n_chan = thisboard->do_nchan; s->maxdata = 1; s->range_table = &range_digital; - s->insn_bits = - thisboard->is_jr ? das08jr_do_wbits : das08_do_wbits; + s->insn_bits = thisboard->is_jr ? das08jr_do_insn_bits : + das08_do_insn_bits; } else { s->type = COMEDI_SUBD_UNUSED; } -- cgit v1.2.3-59-g8ed1b From 34cce4628b8509dc894735cdc5de8b10db21873a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:34 +0100 Subject: staging: comedi: das08: clarify sign-magnitude conversion For DAS08/JR/16 and DAS08/JR/AO-16 boards, the 16-bit analog input readings are assumed to be in a sign-magnitude format and need converting to the COMEDI unsigned sample format. The expressions to do the conversion look a little messy. Use a local variable `magnitude` to make it easier to follow. Also, there seems to be some discrepancy between the manual for these boards and the COMEDI code. The manual implies that 0 is full-scale negative and 65535 is full-scale positive. However, the COMEDI code has used the sign-magnitude conversion for these boards since these two boards were initially supported by a patch from an external contributor to the COMEDI project back in 2001. Assume the code is correct for now, but add a comment to mention the discrepancy. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index f74c4b009d8b..6c9bd10243b7 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -228,11 +228,26 @@ static int das08_ai_insn_read(struct comedi_device *dev, } else if (thisboard->ai_encoding == das08_pcm_encode12) { data[n] = (msb << 8) + lsb; } else if (thisboard->ai_encoding == das08_encode16) { - /* FPOS 16-bit boards are sign-magnitude */ + /* + * "JR" 16-bit boards are sign-magnitude. + * + * XXX The manual seems to imply that 0 is full-scale + * negative and 65535 is full-scale positive, but the + * original COMEDI patch to add support for the + * DAS08/JR/16 and DAS08/JR/16-AO boards have it + * encoded as sign-magnitude. Assume the original + * COMEDI code is correct for now. + */ + unsigned int magnitude = lsb | ((msb & 0x7f) << 8); + + /* + * MSB bit 7 is 0 for negative, 1 for positive voltage. + * COMEDI 16-bit bipolar data value for 0V is 0x8000. + */ if (msb & 0x80) - data[n] = (1 << 15) | lsb | ((msb & 0x7f) << 8); + data[n] = (1 << 15) + magnitude; else - data[n] = (1 << 15) - (lsb | (msb & 0x7f) << 8); + data[n] = (1 << 15) - magnitude; } else { dev_err(dev->class_dev, "bug! unknown ai encoding\n"); return -1; -- cgit v1.2.3-59-g8ed1b From 57334a30c8da966e4470572d3096873e26c66076 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 5 Jun 2015 18:30:35 +0100 Subject: staging: comedi: das08: use better MODULE_DESCRIPTION() Replace the boiler-plate Comedi module description string with something more specific. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 6c9bd10243b7..700a40b23c5f 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -476,5 +476,5 @@ static void __exit das08_exit(void) module_exit(das08_exit); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi common DAS08 support module"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-59-g8ed1b From cf2f9224e7d0112b2a20056de7f8b23060140a1a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Jun 2015 10:54:46 -0700 Subject: staging: comedi: das08: rename 'thisboard' variables For aesthetics, rename the 'thisboard' variables to 'board'. That name is more commonly used for the boardinfo pointer in comedi drivers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 51 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'drivers/staging/comedi/drivers/das08.c') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 700a40b23c5f..3d8fc6ad44df 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -178,7 +178,7 @@ static int das08_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - const struct das08_board_struct *thisboard = dev->board_ptr; + const struct das08_board_struct *board = dev->board_ptr; struct das08_private_struct *devpriv = dev->private; int n; int chan; @@ -210,7 +210,7 @@ static int das08_ai_insn_read(struct comedi_device *dev, for (n = 0; n < insn->n; n++) { /* clear over-range bits for 16-bit boards */ - if (thisboard->ai_nbits == 16) + if (board->ai_nbits == 16) if (inb(dev->iobase + DAS08_AI_MSB_REG) & 0x80) dev_info(dev->class_dev, "over-range\n"); @@ -223,11 +223,11 @@ static int das08_ai_insn_read(struct comedi_device *dev, msb = inb(dev->iobase + DAS08_AI_MSB_REG); lsb = inb(dev->iobase + DAS08_AI_LSB_REG); - if (thisboard->ai_encoding == das08_encode12) { + if (board->ai_encoding == das08_encode12) { data[n] = (lsb >> 4) | (msb << 4); - } else if (thisboard->ai_encoding == das08_pcm_encode12) { + } else if (board->ai_encoding == das08_pcm_encode12) { data[n] = (msb << 8) + lsb; - } else if (thisboard->ai_encoding == das08_encode16) { + } else if (board->ai_encoding == das08_encode16) { /* * "JR" 16-bit boards are sign-magnitude. * @@ -312,13 +312,13 @@ static int das08jr_do_insn_bits(struct comedi_device *dev, static void das08_ao_set_data(struct comedi_device *dev, unsigned int chan, unsigned int data) { - const struct das08_board_struct *thisboard = dev->board_ptr; + const struct das08_board_struct *board = dev->board_ptr; unsigned char lsb; unsigned char msb; lsb = data & 0xff; msb = (data >> 8) & 0xff; - if (thisboard->is_jr) { + if (board->is_jr) { outb(lsb, dev->iobase + DAS08JR_AO_LSB_REG(chan)); outb(msb, dev->iobase + DAS08JR_AO_MSB_REG(chan)); /* load DACs */ @@ -351,7 +351,7 @@ static int das08_ao_insn_write(struct comedi_device *dev, int das08_common_attach(struct comedi_device *dev, unsigned long iobase) { - const struct das08_board_struct *thisboard = dev->board_ptr; + const struct das08_board_struct *board = dev->board_ptr; struct das08_private_struct *devpriv = dev->private; struct comedi_subdevice *s; int ret; @@ -359,7 +359,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) dev->iobase = iobase; - dev->board_name = thisboard->name; + dev->board_name = board->name; ret = comedi_alloc_subdevices(dev, 6); if (ret) @@ -367,7 +367,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s = &dev->subdevices[0]; /* ai */ - if (thisboard->ai_nbits) { + if (board->ai_nbits) { s->type = COMEDI_SUBD_AI; /* * XXX some boards actually have differential @@ -377,21 +377,21 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) */ s->subdev_flags = SDF_READABLE | SDF_GROUND; s->n_chan = 8; - s->maxdata = (1 << thisboard->ai_nbits) - 1; - s->range_table = das08_ai_lranges[thisboard->ai_pg]; + s->maxdata = (1 << board->ai_nbits) - 1; + s->range_table = das08_ai_lranges[board->ai_pg]; s->insn_read = das08_ai_insn_read; - devpriv->pg_gainlist = das08_ai_gainlists[thisboard->ai_pg]; + devpriv->pg_gainlist = das08_ai_gainlists[board->ai_pg]; } else { s->type = COMEDI_SUBD_UNUSED; } s = &dev->subdevices[1]; /* ao */ - if (thisboard->ao_nbits) { + if (board->ao_nbits) { s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; - s->maxdata = (1 << thisboard->ao_nbits) - 1; + s->maxdata = (1 << board->ao_nbits) - 1; s->range_table = &range_bipolar5; s->insn_write = das08_ao_insn_write; @@ -410,13 +410,13 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s = &dev->subdevices[2]; /* di */ - if (thisboard->di_nchan) { + if (board->di_nchan) { s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE; - s->n_chan = thisboard->di_nchan; + s->n_chan = board->di_nchan; s->maxdata = 1; s->range_table = &range_digital; - s->insn_bits = thisboard->is_jr ? das08jr_di_insn_bits : + s->insn_bits = board->is_jr ? das08jr_di_insn_bits : das08_di_insn_bits; } else { s->type = COMEDI_SUBD_UNUSED; @@ -424,13 +424,13 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s = &dev->subdevices[3]; /* do */ - if (thisboard->do_nchan) { + if (board->do_nchan) { s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_WRITABLE; - s->n_chan = thisboard->do_nchan; + s->n_chan = board->do_nchan; s->maxdata = 1; s->range_table = &range_digital; - s->insn_bits = thisboard->is_jr ? das08jr_do_insn_bits : + s->insn_bits = board->is_jr ? das08jr_do_insn_bits : das08_do_insn_bits; } else { s->type = COMEDI_SUBD_UNUSED; @@ -438,8 +438,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) s = &dev->subdevices[4]; /* 8255 */ - if (thisboard->i8255_offset != 0) { - ret = subdev_8255_init(dev, s, NULL, thisboard->i8255_offset); + if (board->i8255_offset != 0) { + ret = subdev_8255_init(dev, s, NULL, board->i8255_offset); if (ret) return ret; } else { @@ -448,9 +448,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) /* Counter subdevice (8254) */ s = &dev->subdevices[5]; - if (thisboard->i8254_offset) { - dev->pacer = comedi_8254_init(dev->iobase + - thisboard->i8254_offset, + if (board->i8254_offset) { + dev->pacer = comedi_8254_init(dev->iobase + board->i8254_offset, 0, I8254_IO8, 0); if (!dev->pacer) return -ENOMEM; -- cgit v1.2.3-59-g8ed1b