staging: comedi: remove inline alloc_private()
[deliverable/linux.git] / drivers / staging / comedi / drivers / adq12b.c
index 6df51c8a602a2e3a90338c3b3b1ed6fc0dd447fd..f7950dfe2ddbca536a112310d56a54bb5bd12913 100644 (file)
@@ -116,15 +116,6 @@ static const struct comedi_lrange range_adq12b_ai_unipolar = { 4, {
                                                                   }
 };
 
-struct adq12b_board {
-       const char *name;
-       int ai_se_chans;
-       int ai_diff_chans;
-       int ai_bits;
-       int di_chans;
-       int do_chans;
-};
-
 struct adq12b_private {
        int unipolar;           /* option 2 of comedi_config (1 is iobase) */
        int differential;       /* option 3 of comedi_config */
@@ -133,8 +124,6 @@ struct adq12b_private {
        unsigned int digital_state;
 };
 
-#define devpriv ((struct adq12b_private *)dev->private)
-
 /*
  * "instructions" read/write data in "one-shot" or "software-triggered"
  * mode.
@@ -144,6 +133,7 @@ static int adq12b_ai_rinsn(struct comedi_device *dev,
                           struct comedi_subdevice *s, struct comedi_insn *insn,
                           unsigned int *data)
 {
+       struct adq12b_private *devpriv = dev->private;
        int n, i;
        int range, channel;
        unsigned char hi, lo, status;
@@ -200,6 +190,7 @@ static int adq12b_do_insn_bits(struct comedi_device *dev,
                               struct comedi_subdevice *s,
                               struct comedi_insn *insn, unsigned int *data)
 {
+       struct adq12b_private *devpriv = dev->private;
        int channel;
 
        for (channel = 0; channel < 8; channel++)
@@ -220,12 +211,14 @@ 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 adq12b_private *devpriv;
        struct comedi_subdevice *s;
        unsigned long iobase;
        int unipolar, differential;
        int ret;
 
+       dev->board_name = dev->driver->driver_name;
+
        iobase = it->options[0];
        unipolar = it->options[1];
        differential = it->options[2];
@@ -250,21 +243,18 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        }
        dev->iobase = iobase;
 
-       dev->board_name = board->name;
-
-/*
- * Allocate the private structure area.  alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
-       if (alloc_private(dev, sizeof(struct adq12b_private)) < 0)
+       devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
+       if (!devpriv)
                return -ENOMEM;
+       dev->private = devpriv;
 
-/* fill in devpriv structure */
        devpriv->unipolar = unipolar;
        devpriv->differential = differential;
        devpriv->digital_state = 0;
-/* initialize channel and range to -1 so we make sure we always write
-   at least once to the CTREG in the instruction */
+       /*
+        * initialize channel and range to -1 so we make sure we
+        * always write at least once to the CTREG in the instruction
+        */
        devpriv->last_channel = -1;
        devpriv->last_range = -1;
 
@@ -272,15 +262,15 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        if (ret)
                return ret;
 
-       s = dev->subdevices + 0;
+       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 = board->ai_diff_chans;
+               s->n_chan = 8;
        } else {
                s->subdev_flags = SDF_READABLE | SDF_GROUND;
-               s->n_chan = board->ai_se_chans;
+               s->n_chan = 16;
        }
 
        if (unipolar)
@@ -288,26 +278,26 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        else
                s->range_table = &range_adq12b_ai_bipolar;
 
-       s->maxdata = (1 << board->ai_bits) - 1;
+       s->maxdata = 0xfff;
 
        s->len_chanlist = 4;    /* This is the maximum chanlist length that
                                   the board can handle */
        s->insn_read = adq12b_ai_rinsn;
 
-       s = dev->subdevices + 1;
+       s = &dev->subdevices[1];
        /* digital input subdevice */
        s->type = COMEDI_SUBD_DI;
        s->subdev_flags = SDF_READABLE;
-       s->n_chan = board->di_chans;
+       s->n_chan = 5;
        s->maxdata = 1;
        s->range_table = &range_digital;
        s->insn_bits = adq12b_di_insn_bits;
 
-       s = dev->subdevices + 2;
+       s = &dev->subdevices[2];
        /* digital output subdevice */
        s->type = COMEDI_SUBD_DO;
        s->subdev_flags = SDF_WRITABLE;
-       s->n_chan = board->do_chans;
+       s->n_chan = 8;
        s->maxdata = 1;
        s->range_table = &range_digital;
        s->insn_bits = adq12b_do_insn_bits;
@@ -321,28 +311,13 @@ static void adq12b_detach(struct comedi_device *dev)
 {
        if (dev->iobase)
                release_region(dev->iobase, ADQ12B_SIZE);
-       kfree(devpriv);
 }
 
-static const struct adq12b_board adq12b_boards[] = {
-       {
-               .name           = "adq12b",
-               .ai_se_chans    = 16,
-               .ai_diff_chans  = 8,
-               .ai_bits        = 12,
-               .di_chans       = 5,
-               .do_chans       = 8,
-       },
-};
-
 static struct comedi_driver adq12b_driver = {
        .driver_name    = "adq12b",
        .module         = THIS_MODULE,
        .attach         = adq12b_attach,
        .detach         = adq12b_detach,
-       .board_name     = &adq12b_boards[0].name,
-       .offset         = sizeof(struct adq12b_board),
-       .num_names      = ARRAY_SIZE(adq12b_boards),
 };
 module_comedi_driver(adq12b_driver);
 
This page took 0.029884 seconds and 5 git commands to generate.