#define DIR_IN 1
#define DIR_OUT 2
-#define rudimentary_check(dir) \
-do { \
- if (!dev) \
- return -EFAULT; \
- if (!dev->probed) \
- return -ENODEV; \
- if (!dev->attached) \
- return -ENODEV; \
- if ((dir) & DIR_IN) { \
- if (test_bit(TRANS_IN_BUSY, &dev->flags)) \
- return -EBUSY; \
- } else { /* DIR_OUT */ \
- if (test_bit(TRANS_OUT_BUSY, &dev->flags)) \
- return -EBUSY; \
- } \
-} while (0)
+static int rudimentary_check(struct vmk80xx_usb *dev, int dir)
+{
+ if (!dev)
+ return -EFAULT;
+ if (!dev->probed)
+ return -ENODEV;
+ if (!dev->attached)
+ return -ENODEV;
+ if (dir & DIR_IN) {
+ if (test_bit(TRANS_IN_BUSY, &dev->flags))
+ return -EBUSY;
+ } else { /* DIR_OUT */
+ if (test_bit(TRANS_OUT_BUSY, &dev->flags))
+ return -EBUSY;
+ }
+
+ return 0;
+}
static int vmk80xx_ai_rinsn(struct comedi_device *cdev,
struct comedi_subdevice *s,
dbgvm("vmk80xx: %s\n", __func__);
- rudimentary_check(DIR_IN);
+ n = rudimentary_check(dev, DIR_IN);
+ if (n)
+ return n;
down(&dev->limit_sem);
chan = CR_CHAN(insn->chanspec);
dbgvm("vmk80xx: %s\n", __func__);
- rudimentary_check(DIR_OUT);
+ n = rudimentary_check(dev, DIR_OUT);
+ if (n)
+ return n;
down(&dev->limit_sem);
chan = CR_CHAN(insn->chanspec);
dbgvm("vmk80xx: %s\n", __func__);
- rudimentary_check(DIR_IN);
+ n = rudimentary_check(dev, DIR_IN);
+ if (n)
+ return n;
down(&dev->limit_sem);
chan = CR_CHAN(insn->chanspec);
dbgvm("vmk80xx: %s\n", __func__);
- rudimentary_check(DIR_IN);
+ n = rudimentary_check(dev, DIR_IN);
+ if (n)
+ return n;
down(&dev->limit_sem);
chan = CR_CHAN(insn->chanspec);
dbgvm("vmk80xx: %s\n", __func__);
- rudimentary_check(DIR_OUT);
+ n = rudimentary_check(dev, DIR_OUT);
+ if (n)
+ return n;
down(&dev->limit_sem);
chan = CR_CHAN(insn->chanspec);
dbgvm("vmk80xx: %s\n", __func__);
- rudimentary_check(DIR_IN);
+ n = rudimentary_check(dev, DIR_IN);
+ if (n)
+ return n;
down(&dev->limit_sem);
chan = CR_CHAN(insn->chanspec);
dbgvm("vmk80xx: %s\n", __func__);
- rudimentary_check(DIR_IN);
+ n = rudimentary_check(dev, DIR_IN);
+ if (n)
+ return n;
down(&dev->limit_sem);
chan = CR_CHAN(insn->chanspec);
dbgvm("vmk80xx: %s\n", __func__);
- rudimentary_check(DIR_OUT);
+ n = rudimentary_check(dev, DIR_OUT);
+ if (n)
+ return n;
down(&dev->limit_sem);
dbgvm("vmk80xx: %s\n", __func__);
- rudimentary_check(DIR_OUT);
+ n = rudimentary_check(dev, DIR_OUT);
+ if (n)
+ return n;
down(&dev->limit_sem);
chan = CR_CHAN(insn->chanspec);
dbgvm("vmk80xx: %s\n", __func__);
- rudimentary_check(DIR_IN);
+ n = rudimentary_check(dev, DIR_IN);
+ if (n)
+ return n;
down(&dev->limit_sem);
dbgvm("vmk80xx: %s\n", __func__);
- rudimentary_check(DIR_OUT);
+ n = rudimentary_check(dev, DIR_OUT);
+ if (n)
+ return n;
down(&dev->limit_sem);