staging: comedi: das08: Remove i8254_iobase from private data
authorIan Abbott <abbotti@mev.co.uk>
Fri, 31 Aug 2012 19:41:39 +0000 (20:41 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 4 Sep 2012 19:00:42 +0000 (12:00 -0700)
The I/O port base address for the counter subdevice doesn't need to be
stored in the private data.  It can be calculated on the fly using the
offset in the static board data.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/das08.c
drivers/staging/comedi/drivers/das08.h

index 9d33b5aed8ab7e3bb63951f5f1fdc6c1be7c5074..9a97bc2aa2f16f21dd8c040075642e632753306c 100644 (file)
@@ -425,22 +425,24 @@ das08ao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
 
 static void i8254_initialize(struct comedi_device *dev)
 {
-       struct das08_private_struct *devpriv = dev->private;
+       const struct das08_board_struct *thisboard = comedi_board(dev);
+       unsigned long i8254_iobase = dev->iobase + thisboard->i8254_offset;
        unsigned int mode = I8254_MODE0 | I8254_BINARY;
        int i;
 
        for (i = 0; i < 3; ++i)
-               i8254_set_mode(devpriv->i8254_iobase, 0, i, mode);
+               i8254_set_mode(i8254_iobase, 0, i, mode);
 }
 
 static int das08_counter_read(struct comedi_device *dev,
                              struct comedi_subdevice *s,
                              struct comedi_insn *insn, unsigned int *data)
 {
-       struct das08_private_struct *devpriv = dev->private;
+       const struct das08_board_struct *thisboard = comedi_board(dev);
+       unsigned long i8254_iobase = dev->iobase + thisboard->i8254_offset;
        int chan = insn->chanspec;
 
-       data[0] = i8254_read(devpriv->i8254_iobase, 0, chan);
+       data[0] = i8254_read(i8254_iobase, 0, chan);
        return 1;
 }
 
@@ -448,10 +450,11 @@ static int das08_counter_write(struct comedi_device *dev,
                               struct comedi_subdevice *s,
                               struct comedi_insn *insn, unsigned int *data)
 {
-       struct das08_private_struct *devpriv = dev->private;
+       const struct das08_board_struct *thisboard = comedi_board(dev);
+       unsigned long i8254_iobase = dev->iobase + thisboard->i8254_offset;
        int chan = insn->chanspec;
 
-       i8254_write(devpriv->i8254_iobase, 0, chan, data[0]);
+       i8254_write(i8254_iobase, 0, chan, data[0]);
        return 1;
 }
 
@@ -459,7 +462,8 @@ static int das08_counter_config(struct comedi_device *dev,
                                struct comedi_subdevice *s,
                                struct comedi_insn *insn, unsigned int *data)
 {
-       struct das08_private_struct *devpriv = dev->private;
+       const struct das08_board_struct *thisboard = comedi_board(dev);
+       unsigned long i8254_iobase = dev->iobase + thisboard->i8254_offset;
        int chan = insn->chanspec;
 
        if (insn->n != 2)
@@ -467,10 +471,10 @@ static int das08_counter_config(struct comedi_device *dev,
 
        switch (data[0]) {
        case INSN_CONFIG_SET_COUNTER_MODE:
-               i8254_set_mode(devpriv->i8254_iobase, 0, chan, data[1]);
+               i8254_set_mode(i8254_iobase, 0, chan, data[1]);
                break;
        case INSN_CONFIG_8254_READ_STATUS:
-               data[1] = i8254_status(devpriv->i8254_iobase, 0, chan);
+               data[1] = i8254_status(i8254_iobase, 0, chan);
                break;
        default:
                return -EINVAL;
@@ -734,8 +738,6 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
                s->insn_read = das08_counter_read;
                s->insn_write = das08_counter_write;
                s->insn_config = das08_counter_config;
-
-               devpriv->i8254_iobase = iobase + thisboard->i8254_offset;
                i8254_initialize(dev);
        } else {
                s->type = COMEDI_SUBD_UNUSED;
index af3024ee6de337d2d0f6c41f1426412f4d567ba7..5a339934f1ba4b47450108e0f840caebcf19e4b7 100644 (file)
@@ -52,7 +52,6 @@ struct das08_private_struct {
        unsigned int do_bits;   /*  bits for do register on boards with register dedicated to digital out only */
        const unsigned int *pg_gainlist;
        struct pci_dev *pdev;   /*  struct for pci-das08 */
-       unsigned int i8254_iobase;
 };
 
 int das08_common_attach(struct comedi_device *dev, unsigned long iobase);