From: Ian Abbott <abbotti@mev.co.uk>
To: devel@driverdev.osuosl.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Ian Abbott <abbotti@mev.co.uk>,
H Hartley Sweeten <hsweeten@visionengravers.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 10/14] staging: comedi: daqboard2000: redo DAC status macros and fix busy
Date: Wed, 18 May 2016 13:37:05 +0100 [thread overview]
Message-ID: <1463575029-12089-11-git-send-email-abbotti@mev.co.uk> (raw)
In-Reply-To: <1463575029-12089-1-git-send-email-abbotti@mev.co.uk>
Rename the macros defining values for the DAC status register to avoid
CamelCase, and to make it clear which register they are associated with.
Refactor the macros defining the regular DAC channel "busy" bits into a
single macro that takes the DAC channel number as a parameter.
Add a macro to define the offset of the read-only DAC status register.
It is the same offset as the DAC control register, which is write-only.
The code in `daqboard2000_ao_eoc()` that checks the status for
completion of the DAC conversion looks wrong. The register has a "busy"
bit for each channel, but the existing code only works for channels 0
and 1. The driver only supports two DAC channels at the moment, so the
bug is currently harmless, but fix it so we can support four DAC
channels on some board models.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
---
v2: Shortened prefix from `DAQBOARD2000_` to `DB2K_`.
squash! staging: comedi: daqboard2000: redo DAC status macros and fix busy
---
drivers/staging/comedi/drivers/daqboard2000.c | 28 +++++++++++++--------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c
index aea40ee..37aa3a4 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -162,7 +162,8 @@ static const struct comedi_lrange range_daqboard2000_ai = {
#define DB2K_REG_ACQ_RESULTS_SHADOW 0x14 /* u16 */
#define DB2K_REG_ACQ_ADC_RESULT 0x18 /* u16 */
#define DB2K_REG_DAC_SCAN_COUNTER 0x1c /* u16 */
-#define DB2K_REG_DAC_CONTROL 0x20 /* u16 */
+#define DB2K_REG_DAC_CONTROL 0x20 /* u16 (w) */
+#define DB2K_REG_DAC_STATUS 0x20 /* u16 (r) */
#define DB2K_REG_DAC_FIFO 0x24 /* s16 */
#define DB2K_REG_DAC_PACER_CLOCK_DIV 0x2a /* u16 */
#define DB2K_REG_REF_DACS 0x2c /* u16 */
@@ -215,14 +216,11 @@ static const struct comedi_lrange range_daqboard2000_ai = {
#define DB2K_ACQ_STATUS_DAC_PACER_OVERRUN 0x0200
/* DAC status */
-#define DAQBOARD2000_DacFull 0x0001
-#define DAQBOARD2000_RefBusy 0x0002
-#define DAQBOARD2000_TrgBusy 0x0004
-#define DAQBOARD2000_CalBusy 0x0008
-#define DAQBOARD2000_Dac0Busy 0x0010
-#define DAQBOARD2000_Dac1Busy 0x0020
-#define DAQBOARD2000_Dac2Busy 0x0040
-#define DAQBOARD2000_Dac3Busy 0x0080
+#define DB2K_DAC_STATUS_DAC_FULL 0x0001
+#define DB2K_DAC_STATUS_REF_BUSY 0x0002
+#define DB2K_DAC_STATUS_TRIG_BUSY 0x0004
+#define DB2K_DAC_STATUS_CAL_BUSY 0x0008
+#define DB2K_DAC_STATUS_DAC_BUSY(x) (0x0010 << (x))
/* DAC control */
#define DB2K_DAC_CONTROL_ENABLE_BIT 0x0001
@@ -400,8 +398,8 @@ static int daqboard2000_ao_eoc(struct comedi_device *dev,
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int status;
- status = readw(dev->mmio + DB2K_REG_DAC_CONTROL);
- if ((status & ((chan + 1) * 0x0010)) == 0)
+ status = readw(dev->mmio + DB2K_REG_DAC_STATUS);
+ if ((status & DB2K_DAC_STATUS_DAC_BUSY(chan)) == 0)
return 0;
return -EBUSY;
}
@@ -574,8 +572,8 @@ static void daqboard2000_activateReferenceDacs(struct comedi_device *dev)
writew(0x80 | DAQBOARD2000_PosRefDacSelect,
dev->mmio + DB2K_REG_REF_DACS);
for (timeout = 0; timeout < 20; timeout++) {
- val = readw(dev->mmio + DB2K_REG_DAC_CONTROL);
- if ((val & DAQBOARD2000_RefBusy) == 0)
+ val = readw(dev->mmio + DB2K_REG_DAC_STATUS);
+ if ((val & DB2K_DAC_STATUS_REF_BUSY) == 0)
break;
udelay(2);
}
@@ -584,8 +582,8 @@ static void daqboard2000_activateReferenceDacs(struct comedi_device *dev)
writew(0x80 | DAQBOARD2000_NegRefDacSelect,
dev->mmio + DB2K_REG_REF_DACS);
for (timeout = 0; timeout < 20; timeout++) {
- val = readw(dev->mmio + DB2K_REG_DAC_CONTROL);
- if ((val & DAQBOARD2000_RefBusy) == 0)
+ val = readw(dev->mmio + DB2K_REG_DAC_STATUS);
+ if ((val & DB2K_DAC_STATUS_REF_BUSY) == 0)
break;
udelay(2);
}
--
2.8.1
next prev parent reply other threads:[~2016-05-18 12:37 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-17 9:52 [PATCH 00/14] staging: comedi: daqboard2000: checkpatch clean-ups Ian Abbott
2016-05-17 9:52 ` [PATCH 01/14] staging: comedi: daqboard2000: remove commented out code Ian Abbott
2016-05-17 17:14 ` Hartley Sweeten
2016-05-18 10:21 ` Ian Abbott
2016-05-17 9:52 ` [PATCH 02/14] staging: comedi: daqboard2000: use usual block comment style Ian Abbott
2016-05-17 9:52 ` [PATCH 03/14] staging: comedi: daqboard2000: CHECK: spaces preferred around that '*' Ian Abbott
2016-05-17 9:52 ` [PATCH 04/14] staging: comedi: daqboard2000: add blank line after struct declaration Ian Abbott
2016-05-17 9:52 ` [PATCH 05/14] staging: comedi: daqboard2000: rename serial EEPROM register macros Ian Abbott
2016-05-17 17:22 ` Hartley Sweeten
2016-05-18 10:25 ` Ian Abbott
2016-05-17 9:52 ` [PATCH 06/14] staging: comedi: daqboard2000: rename register offset macros Ian Abbott
2016-05-17 17:27 ` Hartley Sweeten
2016-05-18 10:27 ` Ian Abbott
2016-05-17 9:52 ` [PATCH 07/14] staging: comedi: daqboard2000: rename acquisition control register macros Ian Abbott
2016-05-17 9:52 ` [PATCH 08/14] staging: comedi: daqboard2000: rename acq status " Ian Abbott
2016-05-17 9:52 ` [PATCH 09/14] staging: comedi: daqboard2000: redo DAC control " Ian Abbott
2016-05-17 9:52 ` [PATCH 10/14] staging: comedi: daqboard2000: redo DAC status macros and fix busy Ian Abbott
2016-05-17 9:52 ` [PATCH 11/14] staging: comedi: daqboard2000: rename trigger control register macros Ian Abbott
2016-05-17 9:52 ` [PATCH 12/14] staging: comedi: daqboard2000: rename reference DACs " Ian Abbott
2016-05-17 9:52 ` [PATCH 13/14] staging: comedi: daqboard2000: rename CamelCase functions Ian Abbott
2016-05-17 9:52 ` [PATCH 14/14] staging: comedi: daqboard2000: prefer usleep_range() Ian Abbott
2016-05-17 17:42 ` Hartley Sweeten
2016-05-18 10:28 ` Ian Abbott
2016-05-17 17:46 ` [PATCH 00/14] staging: comedi: daqboard2000: checkpatch clean-ups Hartley Sweeten
2016-05-18 12:00 ` Ian Abbott
2016-05-18 12:36 ` [PATCH v2 " Ian Abbott
2016-05-18 12:36 ` [PATCH v2 01/14] staging: comedi: daqboard2000: remove commented out code Ian Abbott
2016-05-18 12:36 ` [PATCH v2 02/14] staging: comedi: daqboard2000: use usual block comment style Ian Abbott
2016-05-18 12:36 ` [PATCH v2 03/14] staging: comedi: daqboard2000: CHECK: spaces preferred around that '*' Ian Abbott
2016-05-18 12:36 ` [PATCH v2 04/14] staging: comedi: daqboard2000: add blank line after struct declaration Ian Abbott
2016-05-18 12:37 ` [PATCH v2 05/14] staging: comedi: daqboard2000: rename serial EEPROM register macros Ian Abbott
2016-05-18 12:37 ` [PATCH v2 06/14] staging: comedi: daqboard2000: rename register offset macros Ian Abbott
2016-05-18 22:45 ` Hartley Sweeten
2016-05-19 9:55 ` [PATCH v3 " Ian Abbott
2016-05-19 16:49 ` Hartley Sweeten
2016-05-19 17:42 ` Ian Abbott
2016-05-18 12:37 ` [PATCH v2 07/14] staging: comedi: daqboard2000: rename acquisition control register macros Ian Abbott
2016-05-18 12:37 ` [PATCH v2 08/14] staging: comedi: daqboard2000: rename acq status " Ian Abbott
2016-05-18 12:37 ` [PATCH v2 09/14] staging: comedi: daqboard2000: redo DAC control " Ian Abbott
2016-05-18 12:37 ` Ian Abbott [this message]
2016-05-18 12:37 ` [PATCH v2 11/14] staging: comedi: daqboard2000: rename trigger " Ian Abbott
2016-05-18 12:37 ` [PATCH v2 12/14] staging: comedi: daqboard2000: rename reference DACs " Ian Abbott
2016-05-18 22:35 ` Hartley Sweeten
2016-05-19 9:58 ` [PATCH v3 " Ian Abbott
2016-05-19 10:07 ` Ian Abbott
2016-05-19 10:11 ` [PATCH v4 " Ian Abbott
2016-05-18 12:37 ` [PATCH v2 13/14] staging: comedi: daqboard2000: rename CamelCase functions Ian Abbott
2016-05-18 12:37 ` [PATCH v2 14/14] staging: comedi: daqboard2000: prefer usleep_range() Ian Abbott
2016-05-19 10:02 ` [PATCH v2 00/14] staging: comedi: daqboard2000: checkpatch clean-ups Ian Abbott
2016-05-19 10:16 ` Ian Abbott
2016-05-19 18:04 ` Ian Abbott
2016-05-19 18:15 ` [PATCH v4 " Ian Abbott
2016-05-19 18:15 ` [PATCH v4 01/14] staging: comedi: daqboard2000: remove commented out code Ian Abbott
2016-05-19 18:15 ` [PATCH v4 02/14] staging: comedi: daqboard2000: use usual block comment style Ian Abbott
2016-05-19 18:15 ` [PATCH v4 03/14] staging: comedi: daqboard2000: CHECK: spaces preferred around that '*' Ian Abbott
2016-05-19 18:15 ` [PATCH v4 04/14] staging: comedi: daqboard2000: add blank line after struct declaration Ian Abbott
2016-05-19 18:15 ` [PATCH v4 05/14] staging: comedi: daqboard2000: rename serial EEPROM register macros Ian Abbott
2016-05-19 18:15 ` [PATCH v4 06/14] staging: comedi: daqboard2000: rename register offset macros Ian Abbott
2016-05-19 18:15 ` [PATCH v4 07/14] staging: comedi: daqboard2000: rename acquisition control register macros Ian Abbott
2016-05-19 18:15 ` [PATCH v4 08/14] staging: comedi: daqboard2000: rename acq status " Ian Abbott
2016-05-19 18:15 ` [PATCH v4 09/14] staging: comedi: daqboard2000: redo DAC control " Ian Abbott
2016-05-19 18:15 ` [PATCH v4 10/14] staging: comedi: daqboard2000: redo DAC status macros and fix busy Ian Abbott
2016-05-19 18:15 ` [PATCH v4 11/14] staging: comedi: daqboard2000: rename trigger control register macros Ian Abbott
2016-05-19 18:15 ` [PATCH v4 12/14] staging: comedi: daqboard2000: rename reference DACs " Ian Abbott
2016-05-19 18:15 ` [PATCH v4 13/14] staging: comedi: daqboard2000: rename CamelCase functions Ian Abbott
2016-05-19 18:15 ` [PATCH v4 14/14] staging: comedi: daqboard2000: prefer usleep_range() Ian Abbott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463575029-12089-11-git-send-email-abbotti@mev.co.uk \
--to=abbotti@mev.co.uk \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hsweeten@visionengravers.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).