OSDN Git Service

staging: comedi: ni_mio_common: tidy up the Analog Input subdevice init
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 14 Jul 2014 19:23:55 +0000 (12:23 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jul 2014 20:24:43 +0000 (13:24 -0700)
For aesthetics, add some whitespace to the Analog Input subdevice init.

The callers of ni_E_init() do the request_irq() and set dev->irq if the
interrupt is available. Only hook up the async command support if we
have the irq.

Also, remove the '#ifdef PCIDMA' here. The ni_pcimio driver is the only
place PCIDMA is defined. That driver is also the only user of ni_mio_common
that allocates devpriv->mite. Use that test instead to determine if the
subdevice async_dma_dir member needs to be initialized.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ni_mio_common.c

index 2ab267b..800f4e3 100644 (file)
@@ -5503,36 +5503,37 @@ static int ni_E_init(struct comedi_device *dev,
        if (ret)
                return ret;
 
-       /* analog input subdevice */
-
+       /* Analog Input subdevice */
        s = &dev->subdevices[NI_AI_SUBDEV];
-       dev->read_subdev = s;
        if (board->n_adchan) {
-               s->type = COMEDI_SUBD_AI;
-               s->subdev_flags =
-                   SDF_READABLE | SDF_DIFF | SDF_DITHER | SDF_CMD_READ;
+               s->type         = COMEDI_SUBD_AI;
+               s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_DITHER;
                if (!devpriv->is_611x)
-                       s->subdev_flags |= SDF_GROUND | SDF_COMMON | SDF_OTHER;
+                       s->subdev_flags |= SDF_GROUND | SDF_COMMON | SDF_OTHER;
                if (board->ai_maxdata > 0xffff)
-                       s->subdev_flags |= SDF_LSAMPL;
+                       s->subdev_flags |= SDF_LSAMPL;
                if (devpriv->is_m_series)
-                       s->subdev_flags |= SDF_SOFT_CALIBRATED;
-               s->n_chan = board->n_adchan;
-               s->len_chanlist = 512;
-               s->maxdata = board->ai_maxdata;
-               s->range_table = ni_range_lkup[board->gainlkup];
-               s->insn_read = &ni_ai_insn_read;
-               s->insn_config = &ni_ai_insn_config;
-               s->do_cmdtest = &ni_ai_cmdtest;
-               s->do_cmd = &ni_ai_cmd;
-               s->cancel = &ni_ai_reset;
-               s->poll = &ni_ai_poll;
-               s->munge = &ni_ai_munge;
-#ifdef PCIDMA
-               s->async_dma_dir = DMA_FROM_DEVICE;
-#endif
+                       s->subdev_flags |= SDF_SOFT_CALIBRATED;
+               s->n_chan       = board->n_adchan;
+               s->maxdata      = board->ai_maxdata;
+               s->range_table  = ni_range_lkup[board->gainlkup];
+               s->insn_read    = ni_ai_insn_read;
+               s->insn_config  = ni_ai_insn_config;
+               if (dev->irq) {
+                       dev->read_subdev = s;
+                       s->subdev_flags |= SDF_CMD_READ;
+                       s->len_chanlist = 512;
+                       s->do_cmdtest   = ni_ai_cmdtest;
+                       s->do_cmd       = ni_ai_cmd;
+                       s->cancel       = ni_ai_reset;
+                       s->poll         = ni_ai_poll;
+                       s->munge        = ni_ai_munge;
+
+                       if (devpriv->mite)
+                               s->async_dma_dir = DMA_FROM_DEVICE;
+               }
        } else {
-               s->type = COMEDI_SUBD_UNUSED;
+               s->type         = COMEDI_SUBD_UNUSED;
        }
 
        /* analog output subdevice */