Commit 4b0ff3dc authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: amplc_pci230: replace `state` member with bitfields

The `state` member of `struct pci230_private` is used with the atomic
bit-op functions and has a couple of bits defined, `AI_CMD_STARTED` and
`AO_CMD_STARTED`.  Spin-locks are used to protect the clearing of these
bits and other stuff.  No special protection is used for setting these
bits.  Replace the `state` member with a couple of new, single-bit
bitfield members, `ai_cmd_started` and `ao_cmd_started` to save some
space.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent abea4ff4
......@@ -443,10 +443,6 @@ enum {
/* Current CPU. XXX should this be hard_smp_processor_id()? */
#define THISCPU smp_processor_id()
/* State flags for atomic bit operations */
#define AI_CMD_STARTED 0
#define AO_CMD_STARTED 1
/*
* Board descriptions for the two boards supported.
*/
......@@ -495,7 +491,6 @@ struct pci230_private {
spinlock_t ai_stop_spinlock; /* Spin lock for stopping AI command */
spinlock_t ao_stop_spinlock; /* Spin lock for stopping AO command */
unsigned long daqio; /* PCI230's DAQ I/O space */
unsigned long state; /* State flags */
unsigned int ai_scan_count; /* Number of AI scans remaining */
unsigned int ai_scan_pos; /* Current position within AI scan */
unsigned int ao_scan_count; /* Number of AO scans remaining. */
......@@ -511,6 +506,8 @@ struct pci230_private {
bool intr_running:1; /* Flag set in interrupt routine */
bool ai_bipolar:1; /* Flag AI range is bipolar */
bool ao_bipolar:1; /* Flag AO range is bipolar */
bool ai_cmd_started:1; /* Flag AI command started */
bool ao_cmd_started:1; /* Flag AO command started */
};
/* PCI230 clock source periods in ns */
......@@ -1060,11 +1057,12 @@ static void pci230_ao_stop(struct comedi_device *dev,
struct pci230_private *devpriv = dev->private;
unsigned long irqflags;
unsigned char intsrc;
int started;
bool started;
struct comedi_cmd *cmd;
spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags);
started = test_and_clear_bit(AO_CMD_STARTED, &devpriv->state);
started = devpriv->ao_cmd_started;
devpriv->ao_cmd_started = false;
spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags);
if (!started)
return;
......@@ -1263,7 +1261,7 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
return -EINVAL;
spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags);
if (test_bit(AO_CMD_STARTED, &devpriv->state)) {
if (devpriv->ao_cmd_started) {
/* Perform scan. */
if (devpriv->hwver < 2) {
/* Not using DAC FIFO. */
......@@ -1296,7 +1294,7 @@ static void pci230_ao_start(struct comedi_device *dev,
struct comedi_cmd *cmd = &async->cmd;
unsigned long irqflags;
set_bit(AO_CMD_STARTED, &devpriv->state);
devpriv->ao_cmd_started = true;
if (cmd->stop_src == TRIG_COUNT && devpriv->ao_scan_count == 0) {
/* An empty acquisition! */
async->events |= COMEDI_CB_EOA;
......@@ -1852,7 +1850,7 @@ static int pci230_ai_inttrig_convert(struct comedi_device *dev,
return -EINVAL;
spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags);
if (test_bit(AI_CMD_STARTED, &devpriv->state)) {
if (devpriv->ai_cmd_started) {
unsigned int delayus;
/*
......@@ -1899,7 +1897,7 @@ static int pci230_ai_inttrig_scan_begin(struct comedi_device *dev,
return -EINVAL;
spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags);
if (test_bit(AI_CMD_STARTED, &devpriv->state)) {
if (devpriv->ai_cmd_started) {
/* Trigger scan by waggling CT0 gate source. */
zgat = GAT_CONFIG(0, GAT_GND);
outb(zgat, dev->iobase + PCI230_ZGAT_SCE);
......@@ -1917,10 +1915,11 @@ static void pci230_ai_stop(struct comedi_device *dev,
struct pci230_private *devpriv = dev->private;
unsigned long irqflags;
struct comedi_cmd *cmd;
int started;
bool started;
spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags);
started = test_and_clear_bit(AI_CMD_STARTED, &devpriv->state);
started = devpriv->ai_cmd_started;
devpriv->ai_cmd_started = false;
spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags);
if (!started)
return;
......@@ -1970,7 +1969,7 @@ static void pci230_ai_start(struct comedi_device *dev,
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
set_bit(AI_CMD_STARTED, &devpriv->state);
devpriv->ai_cmd_started = true;
if (cmd->stop_src == TRIG_COUNT && devpriv->ai_scan_count == 0) {
/* An empty acquisition! */
async->events |= COMEDI_CB_EOA;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment