]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: das08: convert driver to use the comedi_8254 module
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 23 Feb 2015 21:57:42 +0000 (14:57 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Mar 2015 02:51:51 +0000 (18:51 -0800)
Some of the hardware supported by this driver include an 8254 timer that is
exposed to the user as a comedi_subdevice. Convert it to use the comedi_8254
module to provide support for the 8254 timer.

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/Kconfig
drivers/staging/comedi/drivers/das08.c

index f63626fd4c1978b6ffec7d25d9f34d57fe76f0ab..8d636ec11c1485580e0aaa38cdcd7d2cb84f301c 100644 (file)
@@ -1275,6 +1275,7 @@ config COMEDI_AMPLC_PC236
 
 config COMEDI_DAS08
        tristate
+       select COMEDI_8254
        select COMEDI_8255
 
 config COMEDI_ISADMA
index c78c0df9bbe30e731403db335be53262862b8ff5..ecd36390192202cb322e1555cb8d1804ef4eaa81 100644 (file)
@@ -23,7 +23,7 @@
 #include "../comedidev.h"
 
 #include "8255.h"
-#include "8253.h"
+#include "comedi_8254.h"
 #include "das08.h"
 
 /*
@@ -359,62 +359,6 @@ static int das08_ao_insn_write(struct comedi_device *dev,
        return insn->n;
 }
 
-static void i8254_initialize(struct comedi_device *dev)
-{
-       const struct das08_board_struct *thisboard = dev->board_ptr;
-       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(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)
-{
-       const struct das08_board_struct *thisboard = dev->board_ptr;
-       unsigned long i8254_iobase = dev->iobase + thisboard->i8254_offset;
-       int chan = insn->chanspec;
-
-       data[0] = i8254_read(i8254_iobase, 0, chan);
-       return 1;
-}
-
-static int das08_counter_write(struct comedi_device *dev,
-                              struct comedi_subdevice *s,
-                              struct comedi_insn *insn, unsigned int *data)
-{
-       const struct das08_board_struct *thisboard = dev->board_ptr;
-       unsigned long i8254_iobase = dev->iobase + thisboard->i8254_offset;
-       int chan = insn->chanspec;
-
-       i8254_write(i8254_iobase, 0, chan, data[0]);
-       return 1;
-}
-
-static int das08_counter_config(struct comedi_device *dev,
-                               struct comedi_subdevice *s,
-                               struct comedi_insn *insn, unsigned int *data)
-{
-       const struct das08_board_struct *thisboard = dev->board_ptr;
-       unsigned long i8254_iobase = dev->iobase + thisboard->i8254_offset;
-       int chan = insn->chanspec;
-
-       switch (data[0]) {
-       case INSN_CONFIG_SET_COUNTER_MODE:
-               i8254_set_mode(i8254_iobase, 0, chan, data[1]);
-               break;
-       case INSN_CONFIG_8254_READ_STATUS:
-               data[1] = i8254_status(i8254_iobase, 0, chan);
-               break;
-       default:
-               return -EINVAL;
-       }
-       return 2;
-}
-
 int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
 {
        const struct das08_board_struct *thisboard = dev->board_ptr;
@@ -511,17 +455,16 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
                s->type = COMEDI_SUBD_UNUSED;
        }
 
+       /* Counter subdevice (8254) */
        s = &dev->subdevices[5];
-       /* 8254 */
-       if (thisboard->i8254_offset != 0) {
-               s->type = COMEDI_SUBD_COUNTER;
-               s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
-               s->n_chan = 3;
-               s->maxdata = 0xFFFF;
-               s->insn_read = das08_counter_read;
-               s->insn_write = das08_counter_write;
-               s->insn_config = das08_counter_config;
-               i8254_initialize(dev);
+       if (thisboard->i8254_offset) {
+               dev->pacer = comedi_8254_init(dev->iobase +
+                                             thisboard->i8254_offset,
+                                             0, I8254_IO8, 0);
+               if (!dev->pacer)
+                       return -ENOMEM;
+
+               comedi_8254_subdevice_init(s, dev->pacer);
        } else {
                s->type = COMEDI_SUBD_UNUSED;
        }