staging: comedi: ke_counter: expose clock source options to user space
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 20 Jun 2014 17:39:43 +0000 (10:39 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2014 00:00:43 +0000 (20:00 -0400)
As pointed out by Ian Abbott, the INSN_CONFIG_SET_CLOCK_SRC options should
be exposed in the user header comedi.h.

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/comedi.h
drivers/staging/comedi/drivers/ke_counter.c

index 6bbbe5b08954100e9ddedd9f5a19a94eeb9c4199..dbaeba7469ac56dbb163760f711ef552fba04da5 100644 (file)
@@ -976,4 +976,15 @@ enum amplc_dio_gate_source {
        AMPLC_DIO_GAT_NPAT_GONE /* negated "pattern gone away" */
 };
 
+/*
+ * Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for
+ * the counter subdevice on the Kolter Electronic PCI-Counter board
+ * (ke_counter driver).
+ */
+enum ke_counter_clock_source {
+       KE_CLK_20MHZ,   /* internal 20MHz (default) */
+       KE_CLK_4MHZ,    /* internal 4MHz (option) */
+       KE_CLK_EXT      /* external clock on pin 21 of D-Sub */
+};
+
 #endif /* _COMEDI_H */
index ed873c45e011e5fceb9494dc24d0db2ba2fc75c7..f46722c2648fff5aa4fcd8884c8cecb0e7f0b72b 100644 (file)
@@ -106,33 +106,42 @@ static int ke_counter_insn_config(struct comedi_device *dev,
                                  struct comedi_insn *insn,
                                  unsigned int *data)
 {
+       unsigned char src;
+
        switch (data[0]) {
        case INSN_CONFIG_SET_CLOCK_SRC:
                switch (data[1]) {
-               case KE_OSC_SEL_EXT:    /* Pin 21 on D-sub */
-               case KE_OSC_SEL_4MHZ:   /* option */
-               case KE_OSC_SEL_20MHZ:  /* default */
+               case KE_CLK_20MHZ:      /* default */
+                       src = KE_OSC_SEL_20MHZ;
+                       break;
+               case KE_CLK_4MHZ:       /* option */
+                       src = KE_OSC_SEL_4MHZ;
+                       break;
+               case KE_CLK_EXT:        /* Pin 21 on D-sub */
+                       src = KE_OSC_SEL_EXT;
                        break;
                default:
                        return -EINVAL;
                }
-               outb(data[1], dev->iobase + KE_OSC_SEL_REG);
+               outb(src, dev->iobase + KE_OSC_SEL_REG);
                break;
        case INSN_CONFIG_GET_CLOCK_SRC:
-               data[1] = inb(dev->iobase + KE_OSC_SEL_REG);
-               switch (data[1]) {
-               case KE_OSC_SEL_EXT:
-                       data[2] = 0;    /* Unknown */
+               src = inb(dev->iobase + KE_OSC_SEL_REG);
+               switch (src) {
+               case KE_OSC_SEL_20MHZ:
+                       data[1] = KE_CLK_20MHZ;
+                       data[2] = 50;   /* 50ns */
                        break;
                case KE_OSC_SEL_4MHZ:
+                       data[1] = KE_CLK_4MHZ;
                        data[2] = 250;  /* 250ns */
                        break;
-               case KE_OSC_SEL_20MHZ:
-                       data[2] = 50;   /* 50ns */
+               case KE_OSC_SEL_EXT:
+                       data[1] = KE_CLK_EXT;
+                       data[2] = 0;    /* Unknown */
                        break;
                default:
-                       data[2] = 0;    /* Invalid? */
-                       break;
+                       return -EINVAL;
                }
                break;
        case INSN_CONFIG_RESET: