staging: comedi: propogate error code from comedi_alloc_subdevices
[deliverable/linux.git] / drivers / staging / comedi / drivers / adq12b.c
index 7d585a12050f52412bcb549cc974af17db34fab7..f7bb14589c9bd7865c4b5e8983111e25bc1ac808 100644 (file)
@@ -125,8 +125,6 @@ struct adq12b_board {
        int do_chans;
 };
 
-#define thisboard ((const struct adq12b_board *)dev->board_ptr)
-
 struct adq12b_private {
        int unipolar;           /* option 2 of comedi_config (1 is iobase) */
        int differential;       /* option 3 of comedi_config */
@@ -222,9 +220,11 @@ static int adq12b_do_insn_bits(struct comedi_device *dev,
 
 static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
+       const struct adq12b_board *board = comedi_board(dev);
        struct comedi_subdevice *s;
        unsigned long iobase;
        int unipolar, differential;
+       int ret;
 
        iobase = it->options[0];
        unipolar = it->options[1];
@@ -250,11 +250,7 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        }
        dev->iobase = iobase;
 
-/*
- * Initialize dev->board_name.  Note that we can use the "thisboard"
- * macro now, since we just initialized it in the last line.
- */
-       dev->board_name = thisboard->name;
+       dev->board_name = board->name;
 
 /*
  * Allocate the private structure area.  alloc_private() is a
@@ -272,22 +268,19 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        devpriv->last_channel = -1;
        devpriv->last_range = -1;
 
-/*
- * Allocate the subdevice structures.  alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
-       if (alloc_subdevices(dev, 3) < 0)
-               return -ENOMEM;
+       ret = comedi_alloc_subdevices(dev, 3);
+       if (ret)
+               return ret;
 
        s = dev->subdevices + 0;
        /* analog input subdevice */
        s->type = COMEDI_SUBD_AI;
        if (differential) {
                s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
-               s->n_chan = thisboard->ai_diff_chans;
+               s->n_chan = board->ai_diff_chans;
        } else {
                s->subdev_flags = SDF_READABLE | SDF_GROUND;
-               s->n_chan = thisboard->ai_se_chans;
+               s->n_chan = board->ai_se_chans;
        }
 
        if (unipolar)
@@ -295,7 +288,7 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        else
                s->range_table = &range_adq12b_ai_bipolar;
 
-       s->maxdata = (1 << thisboard->ai_bits) - 1;
+       s->maxdata = (1 << board->ai_bits) - 1;
 
        s->len_chanlist = 4;    /* This is the maximum chanlist length that
                                   the board can handle */
@@ -305,7 +298,7 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        /* digital input subdevice */
        s->type = COMEDI_SUBD_DI;
        s->subdev_flags = SDF_READABLE;
-       s->n_chan = thisboard->di_chans;
+       s->n_chan = board->di_chans;
        s->maxdata = 1;
        s->range_table = &range_digital;
        s->insn_bits = adq12b_di_insn_bits;
@@ -314,7 +307,7 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        /* digital output subdevice */
        s->type = COMEDI_SUBD_DO;
        s->subdev_flags = SDF_WRITABLE;
-       s->n_chan = thisboard->do_chans;
+       s->n_chan = board->do_chans;
        s->maxdata = 1;
        s->range_table = &range_digital;
        s->insn_bits = adq12b_do_insn_bits;
This page took 0.046005 seconds and 5 git commands to generate.