Merge tag 'iio-for-3.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Nov 2012 16:27:30 +0000 (09:27 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Nov 2012 16:27:30 +0000 (09:27 -0700)
Second round of new IIO drivers and cleanups for the 3.8 cycle.

Usual mixed bag of cleanups and minor improvements including
one reversion for a patch in the previous series.

* adt7310 and adt7410 drivers merged into one.
* Revert use devm_kcalloc in at91_adc (because it doesn't exist)
* unlocking fix for error path in the ad5449
* isl29018 suspend and resume support.
* improved pseudo floating point parsing for info_mask write
attributes (and hence into write_raw).  Reject some messed up
strings.

82 files changed:
drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c
drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h [deleted file]
drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c
drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h [deleted file]
drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c
drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h [deleted file]
drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c
drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h [deleted file]
drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c
drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h [deleted file]
drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c
drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h [deleted file]
drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c
drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h [deleted file]
drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c
drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h [deleted file]
drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c
drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h [deleted file]
drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h [deleted file]
drivers/staging/comedi/drivers/addi-data/addi_common.c
drivers/staging/comedi/drivers/addi-data/addi_common.h
drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c
drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.h [deleted file]
drivers/staging/comedi/drivers/addi_apci_035.c
drivers/staging/comedi/drivers/addi_apci_1032.c
drivers/staging/comedi/drivers/addi_apci_1500.c
drivers/staging/comedi/drivers/addi_apci_1516.c
drivers/staging/comedi/drivers/addi_apci_1564.c
drivers/staging/comedi/drivers/addi_apci_16xx.c
drivers/staging/comedi/drivers/addi_apci_1710.c
drivers/staging/comedi/drivers/addi_apci_2016.c
drivers/staging/comedi/drivers/addi_apci_2032.c
drivers/staging/comedi/drivers/addi_apci_2200.c
drivers/staging/comedi/drivers/addi_apci_3001.c
drivers/staging/comedi/drivers/addi_apci_3120.c
drivers/staging/comedi/drivers/addi_apci_3200.c
drivers/staging/comedi/drivers/addi_apci_3300.c
drivers/staging/comedi/drivers/addi_apci_3501.c
drivers/staging/comedi/drivers/addi_apci_3xxx.c
drivers/staging/comedi/drivers/gsc_hpdi.c
drivers/staging/comedi/drivers/jr3_pci.c
drivers/staging/comedi/drivers/ni_mio_cs.c
drivers/staging/comedi/drivers/rtd520.c
drivers/staging/comedi/drivers/skel.c
drivers/staging/csr/csr_wifi_nme_ap_lib.h
drivers/staging/csr/csr_wifi_nme_lib.h
drivers/staging/csr/csr_wifi_nme_task.h
drivers/staging/csr/inet.c
drivers/staging/csr/sme_blocking.c
drivers/staging/et131x/et131x.c
drivers/staging/ozwpan/ozhcd.c
drivers/staging/rtl8192e/rtllib_tx.c
drivers/staging/silicom/bp_mod.c
drivers/staging/silicom/bypasslib/bplibk.h
drivers/staging/zram/zram_drv.c
drivers/staging/zram/zram_sysfs.c

index 8656d0ef2c8df56a83449a892a9575d86bd3c034..d0702084caa281a5f0bf5c0c912f7c93f9ae460b 100644 (file)
   | Description :   APCI-1710 82X54 timer module                          |
 */
 
-#include "APCI1710_82x54.h"
+#define APCI1710_PCI_BUS_CLOCK                 0
+#define APCI1710_FRONT_CONNECTOR_INPUT         1
+#define APCI1710_TIMER_READVALUE               0
+#define APCI1710_TIMER_GETOUTPUTLEVEL          1
+#define APCI1710_TIMER_GETPROGRESSSTATUS       2
+#define APCI1710_TIMER_WRITEVALUE              3
+
+#define APCI1710_TIMER_READINTERRUPT           1
+#define APCI1710_TIMER_READALLTIMER            2
+
+#ifndef APCI1710_10MHZ
+#define APCI1710_10MHZ                         10
+#endif
 
 /*
 +----------------------------------------------------------------------------+
@@ -218,9 +230,10 @@ int i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s,
 |                    -9: Selection from hardware gate level is wrong         |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InsnConfigInitTimer(struct comedi_device *dev, struct comedi_subdevice *s,
-                                  struct comedi_insn *insn, unsigned int *data)
+static int i_APCI1710_InsnConfigInitTimer(struct comedi_device *dev,
+                                         struct comedi_subdevice *s,
+                                         struct comedi_insn *insn,
+                                         unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -447,10 +460,10 @@ i_ReturnValue=insn->n;
 |                        See function "i_APCI1710_SetBoardIntRoutineX"       |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,
-                                          struct comedi_subdevice *s,
-                                          struct comedi_insn *insn, unsigned int *data)
+static int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,
+                                                struct comedi_subdevice *s,
+                                                struct comedi_insn *insn,
+                                                unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -590,9 +603,10 @@ int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev,struct comedi_sub
 |                        "i_APCI1710_InitTimer"                              |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_subdevice *s,
-                                    struct comedi_insn *insn, unsigned int *data)
+static int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev,
+                                           struct comedi_subdevice *s,
+                                           struct comedi_insn *insn,
+                                           unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -668,70 +682,6 @@ int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_su
        return i_ReturnValue;
 }
 
-/*
-+----------------------------------------------------------------------------+
-| Function Name     :INT i_APCI1710_InsnBitsTimer(struct comedi_device *dev,
-struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)                   |
-+----------------------------------------------------------------------------+
-| Task              : Read write functions for Timer                                          |
-+----------------------------------------------------------------------------+
-| Input Parameters  :
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      :
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI1710_InsnBitsTimer(struct comedi_device *dev, struct comedi_subdevice *s,
-                            struct comedi_insn *insn, unsigned int *data)
-{
-       unsigned char b_BitsType;
-       int i_ReturnValue = 0;
-       b_BitsType = data[0];
-
-       printk("\n82X54");
-
-       switch (b_BitsType) {
-       case APCI1710_TIMER_READVALUE:
-               i_ReturnValue = i_APCI1710_ReadTimerValue(dev,
-                                                         (unsigned char)CR_AREF(insn->chanspec),
-                                                         (unsigned char)CR_CHAN(insn->chanspec),
-                                                         (unsigned int *) &data[0]);
-               break;
-
-       case APCI1710_TIMER_GETOUTPUTLEVEL:
-               i_ReturnValue = i_APCI1710_GetTimerOutputLevel(dev,
-                                                              (unsigned char)CR_AREF(insn->chanspec),
-                                                              (unsigned char)CR_CHAN(insn->chanspec),
-                                                              (unsigned char *) &data[0]);
-               break;
-
-       case APCI1710_TIMER_GETPROGRESSSTATUS:
-               i_ReturnValue = i_APCI1710_GetTimerProgressStatus(dev,
-                                                                 (unsigned char)CR_AREF(insn->chanspec),
-                                                                 (unsigned char)CR_CHAN(insn->chanspec),
-                                                                 (unsigned char *)&data[0]);
-               break;
-
-       case APCI1710_TIMER_WRITEVALUE:
-               i_ReturnValue = i_APCI1710_WriteTimerValue(dev,
-                                                          (unsigned char)CR_AREF(insn->chanspec),
-                                                          (unsigned char)CR_CHAN(insn->chanspec),
-                                                          (unsigned int)data[1]);
-
-               break;
-
-       default:
-               printk("Bits Config Parameter Wrong\n");
-               i_ReturnValue = -1;
-       }
-
-       if (i_ReturnValue >= 0)
-               i_ReturnValue = insn->n;
-       return i_ReturnValue;
-}
-
 /*
 +----------------------------------------------------------------------------+
 | Function Name     : _INT_     i_APCI1710_ReadTimerValue                    |
@@ -761,10 +711,10 @@ int i_APCI1710_InsnBitsTimer(struct comedi_device *dev, struct comedi_subdevice
 |                        "i_APCI1710_InitTimer"                              |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_ReadTimerValue(struct comedi_device *dev,
-                             unsigned char b_ModulNbr, unsigned char b_TimerNbr,
-                             unsigned int *pul_TimerValue)
+static int i_APCI1710_ReadTimerValue(struct comedi_device *dev,
+                                    unsigned char b_ModulNbr,
+                                    unsigned char b_TimerNbr,
+                                    unsigned int *pul_TimerValue)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -850,10 +800,10 @@ int i_APCI1710_ReadTimerValue(struct comedi_device *dev,
           |                        "i_APCI1710_InitTimer"                              |
           +----------------------------------------------------------------------------+
         */
-
-int i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev,
-                                  unsigned char b_ModulNbr, unsigned char b_TimerNbr,
-                                  unsigned char *pb_OutputLevel)
+static int i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev,
+                                         unsigned char b_ModulNbr,
+                                         unsigned char b_TimerNbr,
+                                         unsigned char *pb_OutputLevel)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -930,10 +880,10 @@ int i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev,
 |                        "i_APCI1710_InitTimer"                              |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
-                                     unsigned char b_ModulNbr, unsigned char b_TimerNbr,
-                                     unsigned char *pb_TimerStatus)
+static int i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
+                                            unsigned char b_ModulNbr,
+                                            unsigned char b_TimerNbr,
+                                            unsigned char *pb_TimerStatus)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1010,10 +960,10 @@ int i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
 |                        "i_APCI1710_InitTimer"                              |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_WriteTimerValue(struct comedi_device *dev,
-                              unsigned char b_ModulNbr, unsigned char b_TimerNbr,
-                              unsigned int ul_WriteValue)
+static int i_APCI1710_WriteTimerValue(struct comedi_device *dev,
+                                     unsigned char b_ModulNbr,
+                                     unsigned char b_TimerNbr,
+                                     unsigned int ul_WriteValue)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1051,3 +1001,68 @@ int i_APCI1710_WriteTimerValue(struct comedi_device *dev,
 
        return i_ReturnValue;
 }
+
+/*
++----------------------------------------------------------------------------+
+| Function Name     :INT i_APCI1710_InsnBitsTimer(struct comedi_device *dev,
+struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)                   |
++----------------------------------------------------------------------------+
+| Task              : Read write functions for Timer                                          |
++----------------------------------------------------------------------------+
+| Input Parameters  :
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      :
++----------------------------------------------------------------------------+
+*/
+static int i_APCI1710_InsnBitsTimer(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct comedi_insn *insn,
+                                   unsigned int *data)
+{
+       unsigned char b_BitsType;
+       int i_ReturnValue = 0;
+       b_BitsType = data[0];
+
+       printk("\n82X54");
+
+       switch (b_BitsType) {
+       case APCI1710_TIMER_READVALUE:
+               i_ReturnValue = i_APCI1710_ReadTimerValue(dev,
+                                                         (unsigned char)CR_AREF(insn->chanspec),
+                                                         (unsigned char)CR_CHAN(insn->chanspec),
+                                                         (unsigned int *) &data[0]);
+               break;
+
+       case APCI1710_TIMER_GETOUTPUTLEVEL:
+               i_ReturnValue = i_APCI1710_GetTimerOutputLevel(dev,
+                                                              (unsigned char)CR_AREF(insn->chanspec),
+                                                              (unsigned char)CR_CHAN(insn->chanspec),
+                                                              (unsigned char *) &data[0]);
+               break;
+
+       case APCI1710_TIMER_GETPROGRESSSTATUS:
+               i_ReturnValue = i_APCI1710_GetTimerProgressStatus(dev,
+                                                                 (unsigned char)CR_AREF(insn->chanspec),
+                                                                 (unsigned char)CR_CHAN(insn->chanspec),
+                                                                 (unsigned char *)&data[0]);
+               break;
+
+       case APCI1710_TIMER_WRITEVALUE:
+               i_ReturnValue = i_APCI1710_WriteTimerValue(dev,
+                                                          (unsigned char)CR_AREF(insn->chanspec),
+                                                          (unsigned char)CR_CHAN(insn->chanspec),
+                                                          (unsigned int)data[1]);
+
+               break;
+
+       default:
+               printk("Bits Config Parameter Wrong\n");
+               i_ReturnValue = -1;
+       }
+
+       if (i_ReturnValue >= 0)
+               i_ReturnValue = insn->n;
+       return i_ReturnValue;
+}
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.h
deleted file mode 100644 (file)
index 81346db..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#define APCI1710_PCI_BUS_CLOCK                         0
-#define APCI1710_FRONT_CONNECTOR_INPUT                 1
-#define APCI1710_TIMER_READVALUE               0
-#define APCI1710_TIMER_GETOUTPUTLEVEL          1
-#define APCI1710_TIMER_GETPROGRESSSTATUS       2
-#define APCI1710_TIMER_WRITEVALUE              3
-
-#define APCI1710_TIMER_READINTERRUPT           1
-#define APCI1710_TIMER_READALLTIMER            2
-
-/* BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */
-#ifndef APCI1710_10MHZ
-#define APCI1710_10MHZ 10
-#endif
-/* END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */
-
-/*
- * 82X54 TIMER INISIALISATION FUNCTION
- */
-int i_APCI1710_InsnConfigInitTimer(struct comedi_device *dev, struct comedi_subdevice *s,
-                                  struct comedi_insn *insn, unsigned int *data);
-
-int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,
-                                          struct comedi_subdevice *s,
-                                          struct comedi_insn *insn, unsigned int *data);
-
-/*
- * 82X54 READ FUNCTION
- */
-int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, struct comedi_subdevice *s,
-                                    struct comedi_insn *insn, unsigned int *data);
-
-int i_APCI1710_InsnBitsTimer(struct comedi_device *dev, struct comedi_subdevice *s,
-                            struct comedi_insn *insn, unsigned int *data);
-
-/*
- * 82X54 READ & WRITE FUNCTION
- */
-int i_APCI1710_ReadTimerValue(struct comedi_device *dev,
-                             unsigned char b_ModulNbr, unsigned char b_TimerNbr,
-                             unsigned int *pul_TimerValue);
-
-int i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev,
-                                  unsigned char b_ModulNbr, unsigned char b_TimerNbr,
-                                  unsigned char *pb_OutputLevel);
-
-int i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev,
-                                     unsigned char b_ModulNbr, unsigned char b_TimerNbr,
-                                     unsigned char *pb_TimerStatus);
-
-/*
- * 82X54 WRITE FUNCTION
- */
-int i_APCI1710_WriteTimerValue(struct comedi_device *dev,
-                              unsigned char b_ModulNbr, unsigned char b_TimerNbr,
-                              unsigned int ul_WriteValue);
index a30fb0ddb749fd41f468a6583bc164c58549b844..5bd7fe64637c16a06b3cbcc2d7d1c324b4251b14 100644 (file)
@@ -52,12 +52,22 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +-----------------------------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
-#include "APCI1710_Chrono.h"
+#define APCI1710_30MHZ                 30
+#define APCI1710_33MHZ                 33
+#define APCI1710_40MHZ                 40
+
+#define APCI1710_SINGLE                        0
+#define APCI1710_CONTINUOUS            1
+
+#define APCI1710_CHRONO_PROGRESS_STATUS        0
+#define APCI1710_CHRONO_READVALUE      1
+#define APCI1710_CHRONO_CONVERTVALUE   2
+#define APCI1710_CHRONO_READINTERRUPT  3
+
+#define APCI1710_CHRONO_SET_CHANNELON  0
+#define APCI1710_CHRONO_SET_CHANNELOFF 1
+#define APCI1710_CHRONO_READ_CHANNEL   2
+#define APCI1710_CHRONO_READ_PORT      3
 
 /*
 +----------------------------------------------------------------------------+
@@ -130,9 +140,10 @@ You should also find the complete GPL in the COPYING file accompanying this sour
 |                         this CHRONOS version                               |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+static int i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev,
+                                          struct comedi_subdevice *s,
+                                          struct comedi_insn *insn,
+                                          unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -840,9 +851,10 @@ struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)                                             |
                       -8: data[0] wrong input    |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
-       struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+static int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
+                                                  struct comedi_subdevice *s,
+                                                  struct comedi_insn *insn,
+                                                  unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1077,88 +1089,6 @@ int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
        return i_ReturnValue;
 }
 
-/*
-+----------------------------------------------------------------------------+
-| Function Name     :INT       i_APCI1710_InsnReadChrono(struct comedi_device *dev,struct comedi_subdevice *s,
-struct comedi_insn *insn,unsigned int *data)                   |
-+----------------------------------------------------------------------------+
-| Task              : Read  functions for Timer                                     |
-+----------------------------------------------------------------------------+
-| Input Parameters  :
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      :
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI1710_InsnReadChrono(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned char b_ReadType;
-       int i_ReturnValue = insn->n;
-
-       b_ReadType = CR_CHAN(insn->chanspec);
-
-       switch (b_ReadType) {
-       case APCI1710_CHRONO_PROGRESS_STATUS:
-               i_ReturnValue = i_APCI1710_GetChronoProgressStatus(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
-               break;
-
-       case APCI1710_CHRONO_READVALUE:
-               i_ReturnValue = i_APCI1710_ReadChronoValue(dev,
-                       (unsigned char) CR_AREF(insn->chanspec),
-                       (unsigned int) insn->unused[0],
-                       (unsigned char *) &data[0], (unsigned int *) &data[1]);
-               break;
-
-       case APCI1710_CHRONO_CONVERTVALUE:
-               i_ReturnValue = i_APCI1710_ConvertChronoValue(dev,
-                       (unsigned char) CR_AREF(insn->chanspec),
-                       (unsigned int) insn->unused[0],
-                       (unsigned int *) &data[0],
-                       (unsigned char *) &data[1],
-                       (unsigned char *) &data[2],
-                       (unsigned int *) &data[3],
-                       (unsigned int *) &data[4], (unsigned int *) &data[5]);
-               break;
-
-       case APCI1710_CHRONO_READINTERRUPT:
-               printk("In Chrono Read Interrupt\n");
-
-               data[0] = devpriv->s_InterruptParameters.
-                       s_FIFOInterruptParameters[devpriv->
-                       s_InterruptParameters.ui_Read].b_OldModuleMask;
-               data[1] = devpriv->s_InterruptParameters.
-                       s_FIFOInterruptParameters[devpriv->
-                       s_InterruptParameters.ui_Read].ul_OldInterruptMask;
-               data[2] = devpriv->s_InterruptParameters.
-                       s_FIFOInterruptParameters[devpriv->
-                       s_InterruptParameters.ui_Read].ul_OldCounterLatchValue;
-
-                            /**************************/
-               /* Increment the read FIFO */
-                            /***************************/
-
-               devpriv->
-                       s_InterruptParameters.
-                       ui_Read = (devpriv->
-                       s_InterruptParameters.
-                       ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
-               break;
-
-       default:
-               printk("ReadType Parameter wrong\n");
-       }
-
-       if (i_ReturnValue >= 0)
-               i_ReturnValue = insn->n;
-       return i_ReturnValue;
-
-}
-
 /*
 +----------------------------------------------------------------------------+
 | Function Name     : _INT_ i_APCI1710_GetChronoProgressStatus               |
@@ -1196,9 +1126,9 @@ int i_APCI1710_InsnReadChrono(struct comedi_device *dev, struct comedi_subdevice
 |                         "i_APCI1710_InitChrono"                            |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char *pb_ChronoStatus)
+static int i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev,
+                                             unsigned char b_ModulNbr,
+                                             unsigned char *pb_ChronoStatus)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1358,10 +1288,11 @@ int i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev,
 |                         directly the chronometer measured timing.          |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_ReadChronoValue(struct comedi_device *dev,
-       unsigned char b_ModulNbr,
-       unsigned int ui_TimeOut, unsigned char *pb_ChronoStatus, unsigned int *pul_ChronoValue)
+static int i_APCI1710_ReadChronoValue(struct comedi_device *dev,
+                                     unsigned char b_ModulNbr,
+                                     unsigned int ui_TimeOut,
+                                     unsigned char *pb_ChronoStatus,
+                                     unsigned int *pul_ChronoValue)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1622,14 +1553,15 @@ int i_APCI1710_ReadChronoValue(struct comedi_device *dev,
 |                         "i_APCI1710_InitChrono"                            |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_ConvertChronoValue(struct comedi_device *dev,
-       unsigned char b_ModulNbr,
-       unsigned int ul_ChronoValue,
-       unsigned int *pul_Hour,
-       unsigned char *pb_Minute,
-       unsigned char *pb_Second,
-       unsigned int *pui_MilliSecond, unsigned int *pui_MicroSecond, unsigned int *pui_NanoSecond)
+static int i_APCI1710_ConvertChronoValue(struct comedi_device *dev,
+                                        unsigned char b_ModulNbr,
+                                        unsigned int ul_ChronoValue,
+                                        unsigned int *pul_Hour,
+                                        unsigned char *pb_Minute,
+                                        unsigned char *pb_Second,
+                                        unsigned int *pui_MilliSecond,
+                                        unsigned int *pui_MicroSecond,
+                                        unsigned int *pui_NanoSecond)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1760,6 +1692,89 @@ int i_APCI1710_ConvertChronoValue(struct comedi_device *dev,
        return i_ReturnValue;
 }
 
+/*
++----------------------------------------------------------------------------+
+| Function Name     :INT       i_APCI1710_InsnReadChrono(struct comedi_device *dev,struct comedi_subdevice *s,
+struct comedi_insn *insn,unsigned int *data)                   |
++----------------------------------------------------------------------------+
+| Task              : Read  functions for Timer                                     |
++----------------------------------------------------------------------------+
+| Input Parameters  :
++----------------------------------------------------------------------------+
+| Output Parameters : -                                                      |
++----------------------------------------------------------------------------+
+| Return Value      :
++----------------------------------------------------------------------------+
+*/
+static int i_APCI1710_InsnReadChrono(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_insn *insn,
+                                    unsigned int *data)
+{
+       struct addi_private *devpriv = dev->private;
+       unsigned char b_ReadType;
+       int i_ReturnValue = insn->n;
+
+       b_ReadType = CR_CHAN(insn->chanspec);
+
+       switch (b_ReadType) {
+       case APCI1710_CHRONO_PROGRESS_STATUS:
+               i_ReturnValue = i_APCI1710_GetChronoProgressStatus(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
+               break;
+
+       case APCI1710_CHRONO_READVALUE:
+               i_ReturnValue = i_APCI1710_ReadChronoValue(dev,
+                       (unsigned char) CR_AREF(insn->chanspec),
+                       (unsigned int) insn->unused[0],
+                       (unsigned char *) &data[0], (unsigned int *) &data[1]);
+               break;
+
+       case APCI1710_CHRONO_CONVERTVALUE:
+               i_ReturnValue = i_APCI1710_ConvertChronoValue(dev,
+                       (unsigned char) CR_AREF(insn->chanspec),
+                       (unsigned int) insn->unused[0],
+                       (unsigned int *) &data[0],
+                       (unsigned char *) &data[1],
+                       (unsigned char *) &data[2],
+                       (unsigned int *) &data[3],
+                       (unsigned int *) &data[4], (unsigned int *) &data[5]);
+               break;
+
+       case APCI1710_CHRONO_READINTERRUPT:
+               printk("In Chrono Read Interrupt\n");
+
+               data[0] = devpriv->s_InterruptParameters.
+                       s_FIFOInterruptParameters[devpriv->
+                       s_InterruptParameters.ui_Read].b_OldModuleMask;
+               data[1] = devpriv->s_InterruptParameters.
+                       s_FIFOInterruptParameters[devpriv->
+                       s_InterruptParameters.ui_Read].ul_OldInterruptMask;
+               data[2] = devpriv->s_InterruptParameters.
+                       s_FIFOInterruptParameters[devpriv->
+                       s_InterruptParameters.ui_Read].ul_OldCounterLatchValue;
+
+                            /**************************/
+               /* Increment the read FIFO */
+                            /***************************/
+
+               devpriv->
+                       s_InterruptParameters.
+                       ui_Read = (devpriv->
+                       s_InterruptParameters.
+                       ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
+               break;
+
+       default:
+               printk("ReadType Parameter wrong\n");
+       }
+
+       if (i_ReturnValue >= 0)
+               i_ReturnValue = insn->n;
+       return i_ReturnValue;
+
+}
+
 /*
 +----------------------------------------------------------------------------+
 | Function Name     : int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,struct comedi_subdevice *s,
@@ -1880,9 +1895,10 @@ int i_APCI1710_ConvertChronoValue(struct comedi_device *dev,
 |                         "i_APCI1710_InitChrono"                            |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,
-       struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+static int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,
+                                             struct comedi_subdevice *s,
+                                             struct comedi_insn *insn,
+                                             unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.h
deleted file mode 100644 (file)
index 29bad1d..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data-com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#define APCI1710_30MHZ                 30
-#define APCI1710_33MHZ                 33
-#define APCI1710_40MHZ                 40
-
-#define APCI1710_SINGLE                        0
-#define APCI1710_CONTINUOUS            1
-
-#define APCI1710_CHRONO_PROGRESS_STATUS        0
-#define APCI1710_CHRONO_READVALUE      1
-#define APCI1710_CHRONO_CONVERTVALUE   2
-#define APCI1710_CHRONO_READINTERRUPT  3
-
-#define APCI1710_CHRONO_SET_CHANNELON  0
-#define APCI1710_CHRONO_SET_CHANNELOFF 1
-#define APCI1710_CHRONO_READ_CHANNEL   2
-#define APCI1710_CHRONO_READ_PORT      3
-
-/*
- * CHRONOMETER INISIALISATION FUNCTION
- */
-int i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev, struct comedi_subdevice *s,
-                                   struct comedi_insn *insn, unsigned int *data);
-
-int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev,
-                                           struct comedi_subdevice *s,
-                                           struct comedi_insn *insn,
-                                           unsigned int *data);
-
-/*
- * CHRONOMETER READ FUNCTION
- */
-int i_APCI1710_InsnReadChrono(struct comedi_device *dev, struct comedi_subdevice *s,
-                             struct comedi_insn *insn, unsigned int *data);
-
-int i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev,
-                                      unsigned char b_ModulNbr, unsigned char *pb_ChronoStatus);
-
-int i_APCI1710_ReadChronoValue(struct comedi_device *dev,
-                              unsigned char b_ModulNbr,
-                              unsigned int ui_TimeOut, unsigned char *pb_ChronoStatus,
-                              unsigned int *pul_ChronoValue);
-
-int i_APCI1710_ConvertChronoValue(struct comedi_device *dev,
-                                 unsigned char b_ModulNbr,
-                                 unsigned int ul_ChronoValue,
-                                 unsigned int *pul_Hour,
-                                 unsigned char *pb_Minute,
-                                 unsigned char *pb_Second,
-                                 unsigned int *pui_MilliSecond, unsigned int *pui_MicroSecond,
-                                 unsigned int *pui_NanoSecond);
-
-/*
- * CHRONOMETER DIGITAL INPUT OUTPUT FUNCTION
- */
-int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,
-                                      struct comedi_subdevice *s, struct comedi_insn *insn,
-                                      unsigned int *data);
index aa4122e618bd580d04357d87505a8031dc38822c..6b38ce7a275be2a3f3d81f92c5dc9052b578fdf5 100644 (file)
@@ -52,12 +52,16 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +-----------------------------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
-#include "APCI1710_Dig_io.h"
+/* Digital Output ON or OFF */
+#define APCI1710_ON                    1
+#define APCI1710_OFF                   0
+
+/* Digital I/O */
+#define APCI1710_INPUT                 0
+#define APCI1710_OUTPUT                        1
+
+#define APCI1710_DIGIO_MEMORYONOFF     0x10
+#define APCI1710_DIGIO_INIT            0x11
 
 /*
 +----------------------------------------------------------------------------+
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.h
deleted file mode 100644 (file)
index 0783808..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#define APCI1710_ON                    1       /* Digital  Output ON or OFF */
-#define APCI1710_OFF                   0
-
-#define APCI1710_INPUT                 0       /* Digital I/O */
-#define APCI1710_OUTPUT                        1
-
-#define APCI1710_DIGIO_MEMORYONOFF     0x10
-#define APCI1710_DIGIO_INIT            0x11
index 834685b1885f2f2cd26c7fc030b1894f26eab945..70a7f953fa2f3f97282f94c08917b147a7736c44 100644 (file)
@@ -51,95 +51,121 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +-----------------------------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
-
-#include "APCI1710_INCCPT.h"
-
-/*
-+----------------------------------------------------------------------------+
-| int  i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev,struct comedi_subdevice *s,
-struct comedi_insn *insn,unsigned int *data)
-
-+----------------------------------------------------------------------------+
-| Task              : Configuration function for INC_CPT                             |
-+----------------------------------------------------------------------------+
-| Input Parameters  :                                                                                                           |
-+----------------------------------------------------------------------------+
-| Output Parameters : *data
-+----------------------------------------------------------------------------+
-| Return Value      :                 |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_ConfigType;
-       int i_ReturnValue = 0;
-
-       ui_ConfigType = CR_CHAN(insn->chanspec);
-
-       printk("\nINC_CPT");
-
-       devpriv->tsk_Current = current; /*  Save the current process task structure */
-       switch (ui_ConfigType) {
-       case APCI1710_INCCPT_INITCOUNTER:
-               i_ReturnValue = i_APCI1710_InitCounter(dev,
-                       CR_AREF(insn->chanspec),
-                       (unsigned char) data[0],
-                       (unsigned char) data[1],
-                       (unsigned char) data[2], (unsigned char) data[3], (unsigned char) data[4]);
-               break;
-
-       case APCI1710_INCCPT_COUNTERAUTOTEST:
-               i_ReturnValue = i_APCI1710_CounterAutoTest(dev,
-                       (unsigned char *) &data[0]);
-               break;
-
-       case APCI1710_INCCPT_INITINDEX:
-               i_ReturnValue = i_APCI1710_InitIndex(dev,
-                       CR_AREF(insn->chanspec),
-                       (unsigned char) data[0],
-                       (unsigned char) data[1], (unsigned char) data[2], (unsigned char) data[3]);
-               break;
-
-       case APCI1710_INCCPT_INITREFERENCE:
-               i_ReturnValue = i_APCI1710_InitReference(dev,
-                       CR_AREF(insn->chanspec), (unsigned char) data[0]);
-               break;
-
-       case APCI1710_INCCPT_INITEXTERNALSTROBE:
-               i_ReturnValue = i_APCI1710_InitExternalStrobe(dev,
-                       CR_AREF(insn->chanspec),
-                       (unsigned char) data[0], (unsigned char) data[1]);
-               break;
-
-       case APCI1710_INCCPT_INITCOMPARELOGIC:
-               i_ReturnValue = i_APCI1710_InitCompareLogic(dev,
-                       CR_AREF(insn->chanspec), (unsigned int) data[0]);
-               break;
-
-       case APCI1710_INCCPT_INITFREQUENCYMEASUREMENT:
-               i_ReturnValue = i_APCI1710_InitFrequencyMeasurement(dev,
-                       CR_AREF(insn->chanspec),
-                       (unsigned char) data[0],
-                       (unsigned char) data[1], (unsigned int) data[2], (unsigned int *) &data[0]);
-               break;
-
-       default:
-               printk("Insn Config : Config Parameter Wrong\n");
-
-       }
-
-       if (i_ReturnValue >= 0)
-               i_ReturnValue = insn->n;
-       return i_ReturnValue;
-}
+#define APCI1710_16BIT_COUNTER                 0x10
+#define APCI1710_32BIT_COUNTER                 0x0
+#define APCI1710_QUADRUPLE_MODE                        0x0
+#define APCI1710_DOUBLE_MODE                   0x3
+#define APCI1710_SIMPLE_MODE                   0xF
+#define APCI1710_DIRECT_MODE                   0x80
+#define APCI1710_HYSTERESIS_ON                 0x60
+#define APCI1710_HYSTERESIS_OFF                        0x0
+#define APCI1710_INCREMENT                     0x60
+#define APCI1710_DECREMENT                     0x0
+#define APCI1710_LATCH_COUNTER                 0x1
+#define APCI1710_CLEAR_COUNTER                 0x0
+#define APCI1710_LOW                           0x0
+#define APCI1710_HIGH                          0x1
+
+/*********************/
+/* Version 0600-0229 */
+/*********************/
+#define APCI1710_HIGH_EDGE_CLEAR_COUNTER               0x0
+#define APCI1710_HIGH_EDGE_LATCH_COUNTER               0x1
+#define APCI1710_LOW_EDGE_CLEAR_COUNTER                        0x2
+#define APCI1710_LOW_EDGE_LATCH_COUNTER                        0x3
+#define APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER     0x4
+#define APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER      0x5
+#define APCI1710_SOURCE_0                              0x0
+#define APCI1710_SOURCE_1                              0x1
+
+#define APCI1710_30MHZ                         30
+#define APCI1710_33MHZ                         33
+#define APCI1710_40MHZ                         40
+
+#define APCI1710_ENABLE_LATCH_INT              0x80
+#define APCI1710_DISABLE_LATCH_INT             (~APCI1710_ENABLE_LATCH_INT)
+
+#define APCI1710_INDEX_LATCH_COUNTER           0x10
+#define APCI1710_INDEX_AUTO_MODE               0x8
+#define APCI1710_ENABLE_INDEX                  0x4
+#define APCI1710_DISABLE_INDEX                 (~APCI1710_ENABLE_INDEX)
+#define APCI1710_ENABLE_LATCH_AND_CLEAR                0x8
+#define APCI1710_DISABLE_LATCH_AND_CLEAR       (~APCI1710_ENABLE_LATCH_AND_CLEAR)
+#define APCI1710_SET_LOW_INDEX_LEVEL           0x4
+#define APCI1710_SET_HIGH_INDEX_LEVEL          (~APCI1710_SET_LOW_INDEX_LEVEL)
+#define APCI1710_INVERT_INDEX_RFERENCE         0x2
+#define APCI1710_DEFAULT_INDEX_RFERENCE         (~APCI1710_INVERT_INDEX_RFERENCE)
+
+#define APCI1710_ENABLE_INDEX_INT              0x1
+#define APCI1710_DISABLE_INDEX_INT             (~APCI1710_ENABLE_INDEX_INT)
+
+#define APCI1710_ENABLE_FREQUENCY              0x4
+#define APCI1710_DISABLE_FREQUENCY             (~APCI1710_ENABLE_FREQUENCY)
+
+#define APCI1710_ENABLE_FREQUENCY_INT          0x8
+#define APCI1710_DISABLE_FREQUENCY_INT         (~APCI1710_ENABLE_FREQUENCY_INT)
+
+#define APCI1710_ENABLE_40MHZ_FREQUENCY                0x40
+#define APCI1710_DISABLE_40MHZ_FREQUENCY       (~APCI1710_ENABLE_40MHZ_FREQUENCY)
+
+#define APCI1710_ENABLE_40MHZ_FILTER           0x80
+#define APCI1710_DISABLE_40MHZ_FILTER          (~APCI1710_ENABLE_40MHZ_FILTER)
+
+#define APCI1710_ENABLE_COMPARE_INT            0x2
+#define APCI1710_DISABLE_COMPARE_INT           (~APCI1710_ENABLE_COMPARE_INT)
+
+#define APCI1710_ENABLE_INDEX_ACTION           0x20
+#define APCI1710_DISABLE_INDEX_ACTION          (~APCI1710_ENABLE_INDEX_ACTION)
+#define APCI1710_REFERENCE_HIGH                        0x40
+#define APCI1710_REFERENCE_LOW                 (~APCI1710_REFERENCE_HIGH)
+
+#define APCI1710_TOR_GATE_LOW                  0x40
+#define APCI1710_TOR_GATE_HIGH                 (~APCI1710_TOR_GATE_LOW)
+
+/* INSN CONFIG */
+#define        APCI1710_INCCPT_INITCOUNTER                     100
+#define APCI1710_INCCPT_COUNTERAUTOTEST                        101
+#define APCI1710_INCCPT_INITINDEX                      102
+#define APCI1710_INCCPT_INITREFERENCE                  103
+#define APCI1710_INCCPT_INITEXTERNALSTROBE             104
+#define APCI1710_INCCPT_INITCOMPARELOGIC               105
+#define APCI1710_INCCPT_INITFREQUENCYMEASUREMENT       106
+
+/* INSN READ */
+#define APCI1710_INCCPT_READLATCHREGISTERSTATUS                200
+#define APCI1710_INCCPT_READLATCHREGISTERVALUE         201
+#define APCI1710_INCCPT_READ16BITCOUNTERVALUE          202
+#define APCI1710_INCCPT_READ32BITCOUNTERVALUE          203
+#define APCI1710_INCCPT_GETINDEXSTATUS                 204
+#define APCI1710_INCCPT_GETREFERENCESTATUS             205
+#define APCI1710_INCCPT_GETUASSTATUS                   206
+#define APCI1710_INCCPT_GETCBSTATUS                    207
+#define APCI1710_INCCPT_GET16BITCBSTATUS               208
+#define APCI1710_INCCPT_GETUDSTATUS                    209
+#define APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS    210
+#define APCI1710_INCCPT_READFREQUENCYMEASUREMENT       211
+#define APCI1710_INCCPT_READINTERRUPT                  212
+
+/* INSN BITS */
+#define APCI1710_INCCPT_CLEARCOUNTERVALUE              300
+#define APCI1710_INCCPT_CLEARALLCOUNTERVALUE           301
+#define APCI1710_INCCPT_SETINPUTFILTER                 302
+#define APCI1710_INCCPT_LATCHCOUNTER                   303
+#define APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE     304
+#define APCI1710_INCCPT_SETDIGITALCHLON                        305
+#define APCI1710_INCCPT_SETDIGITALCHLOFF               306
+
+/* INSN WRITE */
+#define APCI1710_INCCPT_ENABLELATCHINTERRUPT           400
+#define APCI1710_INCCPT_DISABLELATCHINTERRUPT          401
+#define APCI1710_INCCPT_WRITE16BITCOUNTERVALUE         402
+#define APCI1710_INCCPT_WRITE32BITCOUNTERVALUE         403
+#define APCI1710_INCCPT_ENABLEINDEX                    404
+#define APCI1710_INCCPT_DISABLEINDEX                   405
+#define APCI1710_INCCPT_ENABLECOMPARELOGIC             406
+#define APCI1710_INCCPT_DISABLECOMPARELOGIC            407
+#define APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT     408
+#define APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT    409
 
 /*
 +----------------------------------------------------------------------------+
@@ -300,13 +326,13 @@ int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, struct comedi_subdevi
 |                        wrong.                                              |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InitCounter(struct comedi_device *dev,
-       unsigned char b_ModulNbr,
-       unsigned char b_CounterRange,
-       unsigned char b_FirstCounterModus,
-       unsigned char b_FirstCounterOption,
-       unsigned char b_SecondCounterModus, unsigned char b_SecondCounterOption)
+static int i_APCI1710_InitCounter(struct comedi_device *dev,
+                                 unsigned char b_ModulNbr,
+                                 unsigned char b_CounterRange,
+                                 unsigned char b_FirstCounterModus,
+                                 unsigned char b_FirstCounterOption,
+                                 unsigned char b_SecondCounterModus,
+                                 unsigned char b_SecondCounterOption)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -547,8 +573,8 @@ int i_APCI1710_InitCounter(struct comedi_device *dev,
 |                     -2: No counter module found                            |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_CounterAutoTest(struct comedi_device *dev, unsigned char *pb_TestStatus)
+static int i_APCI1710_CounterAutoTest(struct comedi_device *dev,
+                                     unsigned char *pb_TestStatus)
 {
        struct addi_private *devpriv = dev->private;
        unsigned char b_ModulCpt = 0;
@@ -711,11 +737,12 @@ int i_APCI1710_CounterAutoTest(struct comedi_device *dev, unsigned char *pb_Test
 |                         See function "i_APCI1710_SetBoardIntRoutineX"      |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InitIndex(struct comedi_device *dev,
-       unsigned char b_ModulNbr,
-       unsigned char b_ReferenceAction,
-       unsigned char b_IndexOperation, unsigned char b_AutoMode, unsigned char b_InterruptEnable)
+static int i_APCI1710_InitIndex(struct comedi_device *dev,
+                               unsigned char b_ModulNbr,
+                               unsigned char b_ReferenceAction,
+                               unsigned char b_IndexOperation,
+                               unsigned char b_AutoMode,
+                               unsigned char b_InterruptEnable)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1156,9 +1183,9 @@ int i_APCI1710_InitIndex(struct comedi_device *dev,
 |                     -4: Reference level parameter is wrong                 |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InitReference(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char b_ReferenceLevel)
+static int i_APCI1710_InitReference(struct comedi_device *dev,
+                                   unsigned char b_ModulNbr,
+                                   unsigned char b_ReferenceLevel)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1282,9 +1309,10 @@ int i_APCI1710_InitReference(struct comedi_device *dev,
 |                     -5: External strobe level parameter is wrong           |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InitExternalStrobe(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char b_ExternalStrobe, unsigned char b_ExternalStrobeLevel)
+static int i_APCI1710_InitExternalStrobe(struct comedi_device *dev,
+                                        unsigned char b_ModulNbr,
+                                        unsigned char b_ExternalStrobe,
+                                        unsigned char b_ExternalStrobeLevel)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1397,9 +1425,9 @@ int i_APCI1710_InitExternalStrobe(struct comedi_device *dev,
           |                         "i_APCI1710_InitCounter"                           |
           +----------------------------------------------------------------------------+
         */
-
-int i_APCI1710_InitCompareLogic(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned int ui_CompareValue)
+static int i_APCI1710_InitCompareLogic(struct comedi_device *dev,
+                                      unsigned char b_ModulNbr,
+                                      unsigned int ui_CompareValue)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1494,12 +1522,12 @@ int i_APCI1710_InitCompareLogic(struct comedi_device *dev,
 |                    -7: 40MHz quartz not on board                          |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev,
-       unsigned char b_ModulNbr,
-       unsigned char b_PCIInputClock,
-       unsigned char b_TimingUnity,
-       unsigned int ul_TimingInterval, unsigned int *pul_RealTimingInterval)
+static int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev,
+                                              unsigned char b_ModulNbr,
+                                              unsigned char b_PCIInputClock,
+                                              unsigned char b_TimingUnity,
+                                              unsigned int ul_TimingInterval,
+                                              unsigned int *pul_RealTimingInterval)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -2004,74 +2032,70 @@ int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev,
        return i_ReturnValue;
 }
 
-/*########################################################################### */
-
-                                                       /* INSN BITS */
-/*########################################################################### */
-
 /*
-+----------------------------------------------------------------------------+
-| Function Name     :INT       i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev,struct comedi_subdevice *s,
-struct comedi_insn *insn,unsigned int *data)                   |
-+----------------------------------------------------------------------------+
-| Task              : Set & Clear Functions for INC_CPT                                          |
-+----------------------------------------------------------------------------+
-| Input Parameters  :
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      :
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+ * Configuration function for INC_CPT
+ */
+static int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev,
+                                      struct comedi_subdevice *s,
+                                      struct comedi_insn *insn,
+                                      unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
-       unsigned int ui_BitsType;
+       unsigned int ui_ConfigType;
        int i_ReturnValue = 0;
 
-       ui_BitsType = CR_CHAN(insn->chanspec);
-       devpriv->tsk_Current = current; /*  Save the current process task structure */
+       ui_ConfigType = CR_CHAN(insn->chanspec);
 
-       switch (ui_BitsType) {
-       case APCI1710_INCCPT_CLEARCOUNTERVALUE:
-               i_ReturnValue = i_APCI1710_ClearCounterValue(dev,
-                       (unsigned char) CR_AREF(insn->chanspec));
+       printk("\nINC_CPT");
+
+       devpriv->tsk_Current = current; /*  Save the current process task structure */
+       switch (ui_ConfigType) {
+       case APCI1710_INCCPT_INITCOUNTER:
+               i_ReturnValue = i_APCI1710_InitCounter(dev,
+                       CR_AREF(insn->chanspec),
+                       (unsigned char) data[0],
+                       (unsigned char) data[1],
+                       (unsigned char) data[2], (unsigned char) data[3], (unsigned char) data[4]);
                break;
 
-       case APCI1710_INCCPT_CLEARALLCOUNTERVALUE:
-               i_ReturnValue = i_APCI1710_ClearAllCounterValue(dev);
+       case APCI1710_INCCPT_COUNTERAUTOTEST:
+               i_ReturnValue = i_APCI1710_CounterAutoTest(dev,
+                       (unsigned char *) &data[0]);
                break;
 
-       case APCI1710_INCCPT_SETINPUTFILTER:
-               i_ReturnValue = i_APCI1710_SetInputFilter(dev,
-                       (unsigned char) CR_AREF(insn->chanspec),
-                       (unsigned char) data[0], (unsigned char) data[1]);
+       case APCI1710_INCCPT_INITINDEX:
+               i_ReturnValue = i_APCI1710_InitIndex(dev,
+                       CR_AREF(insn->chanspec),
+                       (unsigned char) data[0],
+                       (unsigned char) data[1], (unsigned char) data[2], (unsigned char) data[3]);
                break;
 
-       case APCI1710_INCCPT_LATCHCOUNTER:
-               i_ReturnValue = i_APCI1710_LatchCounter(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
+       case APCI1710_INCCPT_INITREFERENCE:
+               i_ReturnValue = i_APCI1710_InitReference(dev,
+                       CR_AREF(insn->chanspec), (unsigned char) data[0]);
                break;
 
-       case APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE:
-               i_ReturnValue = i_APCI1710_SetIndexAndReferenceSource(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
+       case APCI1710_INCCPT_INITEXTERNALSTROBE:
+               i_ReturnValue = i_APCI1710_InitExternalStrobe(dev,
+                       CR_AREF(insn->chanspec),
+                       (unsigned char) data[0], (unsigned char) data[1]);
                break;
 
-       case APCI1710_INCCPT_SETDIGITALCHLON:
-               i_ReturnValue = i_APCI1710_SetDigitalChlOn(dev,
-                       (unsigned char) CR_AREF(insn->chanspec));
+       case APCI1710_INCCPT_INITCOMPARELOGIC:
+               i_ReturnValue = i_APCI1710_InitCompareLogic(dev,
+                       CR_AREF(insn->chanspec), (unsigned int) data[0]);
                break;
 
-       case APCI1710_INCCPT_SETDIGITALCHLOFF:
-               i_ReturnValue = i_APCI1710_SetDigitalChlOff(dev,
-                       (unsigned char) CR_AREF(insn->chanspec));
+       case APCI1710_INCCPT_INITFREQUENCYMEASUREMENT:
+               i_ReturnValue = i_APCI1710_InitFrequencyMeasurement(dev,
+                       CR_AREF(insn->chanspec),
+                       (unsigned char) data[0],
+                       (unsigned char) data[1], (unsigned int) data[2], (unsigned int *) &data[0]);
                break;
 
        default:
-               printk("Bits Config Parameter Wrong\n");
+               printk("Insn Config : Config Parameter Wrong\n");
+
        }
 
        if (i_ReturnValue >= 0)
@@ -2101,8 +2125,8 @@ int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, struct comedi_subdevice
 |                         "i_APCI1710_InitCounter"                           |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_ClearCounterValue(struct comedi_device *dev, unsigned char b_ModulNbr)
+static int i_APCI1710_ClearCounterValue(struct comedi_device *dev,
+                                       unsigned char b_ModulNbr)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -2162,8 +2186,7 @@ int i_APCI1710_ClearCounterValue(struct comedi_device *dev, unsigned char b_Modu
 |                     -2: No counter module found                            |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev)
+static int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev)
 {
        struct addi_private *devpriv = dev->private;
        unsigned char b_ModulCpt = 0;
@@ -2309,9 +2332,10 @@ int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev)
 |                                        -6: 40MHz quartz not on board                          |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_SetInputFilter(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char b_PCIInputClock, unsigned char b_Filter)
+static int i_APCI1710_SetInputFilter(struct comedi_device *dev,
+                                    unsigned char b_ModulNbr,
+                                    unsigned char b_PCIInputClock,
+                                    unsigned char b_Filter)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -2574,9 +2598,9 @@ int i_APCI1710_SetInputFilter(struct comedi_device *dev,
 |                     -4: The selected latch register parameter is wrong     |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_LatchCounter(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char b_LatchReg)
+static int i_APCI1710_LatchCounter(struct comedi_device *dev,
+                                  unsigned char b_ModulNbr,
+                                  unsigned char b_LatchReg)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -2672,9 +2696,9 @@ int i_APCI1710_LatchCounter(struct comedi_device *dev,
 |                    -4: The source selection is wrong                      |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char b_SourceSelection)
+static int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev,
+                                                unsigned char b_ModulNbr,
+                                                unsigned char b_SourceSelection)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -2810,8 +2834,8 @@ int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev,
 |                        "i_APCI1710_InitCounter"                           |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, unsigned char b_ModulNbr)
+static int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev,
+                                     unsigned char b_ModulNbr)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -2891,8 +2915,8 @@ int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, unsigned char b_ModulN
 |                        "i_APCI1710_InitCounter"                           |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, unsigned char b_ModulNbr)
+static int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev,
+                                      unsigned char b_ModulNbr)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -2950,89 +2974,59 @@ int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, unsigned char b_Modul
        return i_ReturnValue;
 }
 
-/*########################################################################### */
-
-                                                       /*  INSN WRITE */
-/*########################################################################### */
-
 /*
-+----------------------------------------------------------------------------+
-| Function Name     :INT       i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev,struct comedi_subdevice *s,
-struct comedi_insn *insn,unsigned int *data)                   |
-+----------------------------------------------------------------------------+
-| Task              : Enable Disable functions for INC_CPT                                       |
-+----------------------------------------------------------------------------+
-| Input Parameters  :
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      :
-+----------------------------------------------------------------------------+
-*/
-int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+ * Set & Clear Functions for INC_CPT
+ */
+static int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_insn *insn,
+                                    unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
-       unsigned int ui_WriteType;
+       unsigned int ui_BitsType;
        int i_ReturnValue = 0;
 
-       ui_WriteType = CR_CHAN(insn->chanspec);
+       ui_BitsType = CR_CHAN(insn->chanspec);
        devpriv->tsk_Current = current; /*  Save the current process task structure */
 
-       switch (ui_WriteType) {
-       case APCI1710_INCCPT_ENABLELATCHINTERRUPT:
-               i_ReturnValue = i_APCI1710_EnableLatchInterrupt(dev,
+       switch (ui_BitsType) {
+       case APCI1710_INCCPT_CLEARCOUNTERVALUE:
+               i_ReturnValue = i_APCI1710_ClearCounterValue(dev,
                        (unsigned char) CR_AREF(insn->chanspec));
                break;
 
-       case APCI1710_INCCPT_DISABLELATCHINTERRUPT:
-               i_ReturnValue = i_APCI1710_DisableLatchInterrupt(dev,
-                       (unsigned char) CR_AREF(insn->chanspec));
+       case APCI1710_INCCPT_CLEARALLCOUNTERVALUE:
+               i_ReturnValue = i_APCI1710_ClearAllCounterValue(dev);
                break;
 
-       case APCI1710_INCCPT_WRITE16BITCOUNTERVALUE:
-               i_ReturnValue = i_APCI1710_Write16BitCounterValue(dev,
+       case APCI1710_INCCPT_SETINPUTFILTER:
+               i_ReturnValue = i_APCI1710_SetInputFilter(dev,
                        (unsigned char) CR_AREF(insn->chanspec),
-                       (unsigned char) data[0], (unsigned int) data[1]);
-               break;
-
-       case APCI1710_INCCPT_WRITE32BITCOUNTERVALUE:
-               i_ReturnValue = i_APCI1710_Write32BitCounterValue(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned int) data[0]);
-
-               break;
-
-       case APCI1710_INCCPT_ENABLEINDEX:
-               i_APCI1710_EnableIndex(dev, (unsigned char) CR_AREF(insn->chanspec));
+                       (unsigned char) data[0], (unsigned char) data[1]);
                break;
 
-       case APCI1710_INCCPT_DISABLEINDEX:
-               i_ReturnValue = i_APCI1710_DisableIndex(dev,
-                       (unsigned char) CR_AREF(insn->chanspec));
+       case APCI1710_INCCPT_LATCHCOUNTER:
+               i_ReturnValue = i_APCI1710_LatchCounter(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
                break;
 
-       case APCI1710_INCCPT_ENABLECOMPARELOGIC:
-               i_ReturnValue = i_APCI1710_EnableCompareLogic(dev,
-                       (unsigned char) CR_AREF(insn->chanspec));
+       case APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE:
+               i_ReturnValue = i_APCI1710_SetIndexAndReferenceSource(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
                break;
 
-       case APCI1710_INCCPT_DISABLECOMPARELOGIC:
-               i_ReturnValue = i_APCI1710_DisableCompareLogic(dev,
+       case APCI1710_INCCPT_SETDIGITALCHLON:
+               i_ReturnValue = i_APCI1710_SetDigitalChlOn(dev,
                        (unsigned char) CR_AREF(insn->chanspec));
                break;
 
-       case APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT:
-               i_ReturnValue = i_APCI1710_EnableFrequencyMeasurement(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
-               break;
-
-       case APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT:
-               i_ReturnValue = i_APCI1710_DisableFrequencyMeasurement(dev,
+       case APCI1710_INCCPT_SETDIGITALCHLOFF:
+               i_ReturnValue = i_APCI1710_SetDigitalChlOff(dev,
                        (unsigned char) CR_AREF(insn->chanspec));
                break;
 
        default:
-               printk("Write Config Parameter Wrong\n");
+               printk("Bits Config Parameter Wrong\n");
        }
 
        if (i_ReturnValue >= 0)
@@ -3065,8 +3059,8 @@ int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, struct comedi_subdevic
 |                         "i_APCI1710_SetBoardIntRoutine"                    |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr)
+static int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev,
+                                          unsigned char b_ModulNbr)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -3152,8 +3146,8 @@ int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, unsigned char b_M
 |                         "i_APCI1710_SetBoardIntRoutine"                    |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr)
+static int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev,
+                                           unsigned char b_ModulNbr)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -3251,9 +3245,10 @@ int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, unsigned char b_
 |                     -4: The selected 16-Bit counter parameter is wrong     |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char b_SelectedCounter, unsigned int ui_WriteValue)
+static int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev,
+                                            unsigned char b_ModulNbr,
+                                            unsigned char b_SelectedCounter,
+                                            unsigned int ui_WriteValue)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -3337,9 +3332,9 @@ int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev,
 |                         "i_APCI1710_InitCounter"                           |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned int ul_WriteValue)
+static int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev,
+                                            unsigned char b_ModulNbr,
+                                            unsigned int ul_WriteValue)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -3405,8 +3400,8 @@ int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev,
 |                         "i_APCI1710_InitIndex"                             |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_EnableIndex(struct comedi_device *dev, unsigned char b_ModulNbr)
+static int i_APCI1710_EnableIndex(struct comedi_device *dev,
+                                 unsigned char b_ModulNbr)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -3504,8 +3499,8 @@ int i_APCI1710_EnableIndex(struct comedi_device *dev, unsigned char b_ModulNbr)
 |                         "i_APCI1710_InitIndex"                             |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_DisableIndex(struct comedi_device *dev, unsigned char b_ModulNbr)
+static int i_APCI1710_DisableIndex(struct comedi_device *dev,
+                                  unsigned char b_ModulNbr)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -3604,8 +3599,8 @@ int i_APCI1710_DisableIndex(struct comedi_device *dev, unsigned char b_ModulNbr)
 |                         See function "i_APCI1710_SetBoardIntRoutineX"      |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_EnableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr)
+static int i_APCI1710_EnableCompareLogic(struct comedi_device *dev,
+                                        unsigned char b_ModulNbr)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -3705,8 +3700,8 @@ int i_APCI1710_EnableCompareLogic(struct comedi_device *dev, unsigned char b_Mod
 |                         See function "i_APCI1710_InitCompareLogic"         |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_DisableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr)
+static int i_APCI1710_DisableCompareLogic(struct comedi_device *dev,
+                                         unsigned char b_ModulNbr)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -3815,9 +3810,9 @@ int i_APCI1710_DisableCompareLogic(struct comedi_device *dev, unsigned char b_Mo
           |                     -6: Interrupt function not initialised.                |
           +----------------------------------------------------------------------------+
         */
-
-int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char b_InterruptEnable)
+static int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev,
+                                                unsigned char b_ModulNbr,
+                                                unsigned char b_InterruptEnable)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -3963,8 +3958,8 @@ int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev,
           |                      See function "i_APCI1710_InitFrequencyMeasurement" |
           +----------------------------------------------------------------------------+
         */
-
-int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev, unsigned char b_ModulNbr)
+static int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev,
+                                                 unsigned char b_ModulNbr)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -4058,135 +4053,80 @@ int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev, unsigned c
        return i_ReturnValue;
 }
 
-/*########################################################################### */
-
-                                                       /*  INSN READ */
-
-/*########################################################################### */
-
 /*
-+----------------------------------------------------------------------------+
-| Function Name     :INT       i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev,struct comedi_subdevice *s,
-struct comedi_insn *insn,unsigned int *data)                   |
-+----------------------------------------------------------------------------+
-| Task              : Read and Get functions for INC_CPT                                       |
-+----------------------------------------------------------------------------+
-| Input Parameters  :
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      :
-+----------------------------------------------------------------------------+
-*/
-int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+ * Enable Disable functions for INC_CPT
+ */
+static int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev,
+                                     struct comedi_subdevice *s,
+                                     struct comedi_insn *insn,
+                                     unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
-       unsigned int ui_ReadType;
+       unsigned int ui_WriteType;
        int i_ReturnValue = 0;
 
-       ui_ReadType = CR_CHAN(insn->chanspec);
-
+       ui_WriteType = CR_CHAN(insn->chanspec);
        devpriv->tsk_Current = current; /*  Save the current process task structure */
-       switch (ui_ReadType) {
-       case APCI1710_INCCPT_READLATCHREGISTERSTATUS:
-               i_ReturnValue = i_APCI1710_ReadLatchRegisterStatus(dev,
-                       (unsigned char) CR_AREF(insn->chanspec),
-                       (unsigned char) CR_RANGE(insn->chanspec), (unsigned char *) &data[0]);
-               break;
 
-       case APCI1710_INCCPT_READLATCHREGISTERVALUE:
-               i_ReturnValue = i_APCI1710_ReadLatchRegisterValue(dev,
-                       (unsigned char) CR_AREF(insn->chanspec),
-                       (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]);
-               printk("Latch Register Value %d\n", data[0]);
+       switch (ui_WriteType) {
+       case APCI1710_INCCPT_ENABLELATCHINTERRUPT:
+               i_ReturnValue = i_APCI1710_EnableLatchInterrupt(dev,
+                       (unsigned char) CR_AREF(insn->chanspec));
                break;
 
-       case APCI1710_INCCPT_READ16BITCOUNTERVALUE:
-               i_ReturnValue = i_APCI1710_Read16BitCounterValue(dev,
-                       (unsigned char) CR_AREF(insn->chanspec),
-                       (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]);
+       case APCI1710_INCCPT_DISABLELATCHINTERRUPT:
+               i_ReturnValue = i_APCI1710_DisableLatchInterrupt(dev,
+                       (unsigned char) CR_AREF(insn->chanspec));
                break;
 
-       case APCI1710_INCCPT_READ32BITCOUNTERVALUE:
-               i_ReturnValue = i_APCI1710_Read32BitCounterValue(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned int *) &data[0]);
+       case APCI1710_INCCPT_WRITE16BITCOUNTERVALUE:
+               i_ReturnValue = i_APCI1710_Write16BitCounterValue(dev,
+                       (unsigned char) CR_AREF(insn->chanspec),
+                       (unsigned char) data[0], (unsigned int) data[1]);
                break;
 
-       case APCI1710_INCCPT_GETINDEXSTATUS:
-               i_ReturnValue = i_APCI1710_GetIndexStatus(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
-               break;
+       case APCI1710_INCCPT_WRITE32BITCOUNTERVALUE:
+               i_ReturnValue = i_APCI1710_Write32BitCounterValue(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned int) data[0]);
 
-       case APCI1710_INCCPT_GETREFERENCESTATUS:
-               i_ReturnValue = i_APCI1710_GetReferenceStatus(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
                break;
 
-       case APCI1710_INCCPT_GETUASSTATUS:
-               i_ReturnValue = i_APCI1710_GetUASStatus(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
-               break;
-
-       case APCI1710_INCCPT_GETCBSTATUS:
-               i_ReturnValue = i_APCI1710_GetCBStatus(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
+       case APCI1710_INCCPT_ENABLEINDEX:
+               i_APCI1710_EnableIndex(dev, (unsigned char) CR_AREF(insn->chanspec));
                break;
 
-       case APCI1710_INCCPT_GET16BITCBSTATUS:
-               i_ReturnValue = i_APCI1710_Get16BitCBStatus(dev,
-                       (unsigned char) CR_AREF(insn->chanspec),
-                       (unsigned char *) &data[0], (unsigned char *) &data[1]);
+       case APCI1710_INCCPT_DISABLEINDEX:
+               i_ReturnValue = i_APCI1710_DisableIndex(dev,
+                       (unsigned char) CR_AREF(insn->chanspec));
                break;
 
-       case APCI1710_INCCPT_GETUDSTATUS:
-               i_ReturnValue = i_APCI1710_GetUDStatus(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
-
+       case APCI1710_INCCPT_ENABLECOMPARELOGIC:
+               i_ReturnValue = i_APCI1710_EnableCompareLogic(dev,
+                       (unsigned char) CR_AREF(insn->chanspec));
                break;
 
-       case APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS:
-               i_ReturnValue = i_APCI1710_GetInterruptUDLatchedStatus(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
+       case APCI1710_INCCPT_DISABLECOMPARELOGIC:
+               i_ReturnValue = i_APCI1710_DisableCompareLogic(dev,
+                       (unsigned char) CR_AREF(insn->chanspec));
                break;
 
-       case APCI1710_INCCPT_READFREQUENCYMEASUREMENT:
-               i_ReturnValue = i_APCI1710_ReadFrequencyMeasurement(dev,
-                       (unsigned char) CR_AREF(insn->chanspec),
-                       (unsigned char *) &data[0],
-                       (unsigned char *) &data[1], (unsigned int *) &data[2]);
+       case APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT:
+               i_ReturnValue = i_APCI1710_EnableFrequencyMeasurement(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
                break;
 
-       case APCI1710_INCCPT_READINTERRUPT:
-               data[0] = devpriv->s_InterruptParameters.
-                       s_FIFOInterruptParameters[devpriv->
-                       s_InterruptParameters.ui_Read].b_OldModuleMask;
-               data[1] = devpriv->s_InterruptParameters.
-                       s_FIFOInterruptParameters[devpriv->
-                       s_InterruptParameters.ui_Read].ul_OldInterruptMask;
-               data[2] = devpriv->s_InterruptParameters.
-                       s_FIFOInterruptParameters[devpriv->
-                       s_InterruptParameters.ui_Read].ul_OldCounterLatchValue;
-
-               /**************************/
-               /* Increment the read FIFO */
-               /***************************/
-
-               devpriv->
-                       s_InterruptParameters.
-                       ui_Read = (devpriv->s_InterruptParameters.
-                       ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
-
+       case APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT:
+               i_ReturnValue = i_APCI1710_DisableFrequencyMeasurement(dev,
+                       (unsigned char) CR_AREF(insn->chanspec));
                break;
 
        default:
-               printk("ReadType Parameter wrong\n");
+               printk("Write Config Parameter Wrong\n");
        }
 
        if (i_ReturnValue >= 0)
                i_ReturnValue = insn->n;
        return i_ReturnValue;
-
 }
 
 /*
@@ -4222,9 +4162,10 @@ int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, struct comedi_subdevice
 |                     -4: The selected latch register parameter is wrong     |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char b_LatchReg, unsigned char *pb_LatchStatus)
+static int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev,
+                                             unsigned char b_ModulNbr,
+                                             unsigned char b_LatchReg,
+                                             unsigned char *pb_LatchStatus)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -4310,9 +4251,10 @@ int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev,
 |                     -4: The selected latch register parameter is wrong     |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char b_LatchReg, unsigned int *pul_LatchValue)
+static int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev,
+                                            unsigned char b_ModulNbr,
+                                            unsigned char b_LatchReg,
+                                            unsigned int *pul_LatchValue)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -4395,9 +4337,10 @@ int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev,
 |                     -4: The selected 16-Bit counter parameter is wrong     |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char b_SelectedCounter, unsigned int *pui_CounterValue)
+static int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev,
+                                           unsigned char b_ModulNbr,
+                                           unsigned char b_SelectedCounter,
+                                           unsigned int *pui_CounterValue)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -4491,9 +4434,9 @@ int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev,
 |                         "i_APCI1710_InitCounter"                           |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned int *pul_CounterValue)
+static int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev,
+                                           unsigned char b_ModulNbr,
+                                           unsigned int *pul_CounterValue)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -4568,9 +4511,9 @@ int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev,
 |                         "i_APCI1710_InitIndex"                             |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_GetIndexStatus(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char *pb_IndexStatus)
+static int i_APCI1710_GetIndexStatus(struct comedi_device *dev,
+                                    unsigned char b_ModulNbr,
+                                    unsigned char *pb_IndexStatus)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -4653,9 +4596,9 @@ int i_APCI1710_GetIndexStatus(struct comedi_device *dev,
 |                         "i_APCI1710_InitReference"                         |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_GetReferenceStatus(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char *pb_ReferenceStatus)
+static int i_APCI1710_GetReferenceStatus(struct comedi_device *dev,
+                                        unsigned char b_ModulNbr,
+                                        unsigned char *pb_ReferenceStatus)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -4738,9 +4681,9 @@ int i_APCI1710_GetReferenceStatus(struct comedi_device *dev,
 |                         "i_APCI1710_InitCounter"                           |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_GetUASStatus(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char *pb_UASStatus)
+static int i_APCI1710_GetUASStatus(struct comedi_device *dev,
+                                  unsigned char b_ModulNbr,
+                                  unsigned char *pb_UASStatus)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -4807,9 +4750,9 @@ int i_APCI1710_GetUASStatus(struct comedi_device *dev,
 |                         "i_APCI1710_InitCounter"                           |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_GetCBStatus(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char *pb_CBStatus)
+static int i_APCI1710_GetCBStatus(struct comedi_device *dev,
+                                 unsigned char b_ModulNbr,
+                                 unsigned char *pb_CBStatus)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -4890,9 +4833,10 @@ int i_APCI1710_GetCBStatus(struct comedi_device *dev,
 |                     -5: Firmware revision error                            |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char *pb_CBStatusCounter0, unsigned char *pb_CBStatusCounter1)
+static int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev,
+                                      unsigned char b_ModulNbr,
+                                      unsigned char *pb_CBStatusCounter0,
+                                      unsigned char *pb_CBStatusCounter1)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -5004,9 +4948,9 @@ int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev,
 |                         "i_APCI1710_InitCounter"                           |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_GetUDStatus(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char *pb_UDStatus)
+static int i_APCI1710_GetUDStatus(struct comedi_device *dev,
+                                 unsigned char b_ModulNbr,
+                                 unsigned char *pb_UDStatus)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -5079,9 +5023,9 @@ int i_APCI1710_GetUDStatus(struct comedi_device *dev,
 |                         See function "i_APCI1710_SetBoardIntRoutineX"      |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev,
-       unsigned char b_ModulNbr, unsigned char *pb_UDStatus)
+static int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev,
+                                                 unsigned char b_ModulNbr,
+                                                 unsigned char *pb_UDStatus)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -5185,10 +5129,11 @@ int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev,
           |                      See function "i_APCI1710_InitFrequencyMeasurement" |
           +----------------------------------------------------------------------------+
         */
-
-int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev,
-       unsigned char b_ModulNbr,
-       unsigned char *pb_Status, unsigned char *pb_UDStatus, unsigned int *pul_ReadValue)
+static int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev,
+                                              unsigned char b_ModulNbr,
+                                              unsigned char *pb_Status,
+                                              unsigned char *pb_UDStatus,
+                                              unsigned int *pul_ReadValue)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -5403,3 +5348,118 @@ int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev,
 
        return i_ReturnValue;
 }
+/*
+ * Read and Get functions for INC_CPT
+ */
+static int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_insn *insn,
+                                    unsigned int *data)
+{
+       struct addi_private *devpriv = dev->private;
+       unsigned int ui_ReadType;
+       int i_ReturnValue = 0;
+
+       ui_ReadType = CR_CHAN(insn->chanspec);
+
+       devpriv->tsk_Current = current; /*  Save the current process task structure */
+       switch (ui_ReadType) {
+       case APCI1710_INCCPT_READLATCHREGISTERSTATUS:
+               i_ReturnValue = i_APCI1710_ReadLatchRegisterStatus(dev,
+                       (unsigned char) CR_AREF(insn->chanspec),
+                       (unsigned char) CR_RANGE(insn->chanspec), (unsigned char *) &data[0]);
+               break;
+
+       case APCI1710_INCCPT_READLATCHREGISTERVALUE:
+               i_ReturnValue = i_APCI1710_ReadLatchRegisterValue(dev,
+                       (unsigned char) CR_AREF(insn->chanspec),
+                       (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]);
+               printk("Latch Register Value %d\n", data[0]);
+               break;
+
+       case APCI1710_INCCPT_READ16BITCOUNTERVALUE:
+               i_ReturnValue = i_APCI1710_Read16BitCounterValue(dev,
+                       (unsigned char) CR_AREF(insn->chanspec),
+                       (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]);
+               break;
+
+       case APCI1710_INCCPT_READ32BITCOUNTERVALUE:
+               i_ReturnValue = i_APCI1710_Read32BitCounterValue(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned int *) &data[0]);
+               break;
+
+       case APCI1710_INCCPT_GETINDEXSTATUS:
+               i_ReturnValue = i_APCI1710_GetIndexStatus(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
+               break;
+
+       case APCI1710_INCCPT_GETREFERENCESTATUS:
+               i_ReturnValue = i_APCI1710_GetReferenceStatus(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
+               break;
+
+       case APCI1710_INCCPT_GETUASSTATUS:
+               i_ReturnValue = i_APCI1710_GetUASStatus(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
+               break;
+
+       case APCI1710_INCCPT_GETCBSTATUS:
+               i_ReturnValue = i_APCI1710_GetCBStatus(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
+               break;
+
+       case APCI1710_INCCPT_GET16BITCBSTATUS:
+               i_ReturnValue = i_APCI1710_Get16BitCBStatus(dev,
+                       (unsigned char) CR_AREF(insn->chanspec),
+                       (unsigned char *) &data[0], (unsigned char *) &data[1]);
+               break;
+
+       case APCI1710_INCCPT_GETUDSTATUS:
+               i_ReturnValue = i_APCI1710_GetUDStatus(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
+
+               break;
+
+       case APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS:
+               i_ReturnValue = i_APCI1710_GetInterruptUDLatchedStatus(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]);
+               break;
+
+       case APCI1710_INCCPT_READFREQUENCYMEASUREMENT:
+               i_ReturnValue = i_APCI1710_ReadFrequencyMeasurement(dev,
+                       (unsigned char) CR_AREF(insn->chanspec),
+                       (unsigned char *) &data[0],
+                       (unsigned char *) &data[1], (unsigned int *) &data[2]);
+               break;
+
+       case APCI1710_INCCPT_READINTERRUPT:
+               data[0] = devpriv->s_InterruptParameters.
+                       s_FIFOInterruptParameters[devpriv->
+                       s_InterruptParameters.ui_Read].b_OldModuleMask;
+               data[1] = devpriv->s_InterruptParameters.
+                       s_FIFOInterruptParameters[devpriv->
+                       s_InterruptParameters.ui_Read].ul_OldInterruptMask;
+               data[2] = devpriv->s_InterruptParameters.
+                       s_FIFOInterruptParameters[devpriv->
+                       s_InterruptParameters.ui_Read].ul_OldCounterLatchValue;
+
+               /**************************/
+               /* Increment the read FIFO */
+               /***************************/
+
+               devpriv->
+                       s_InterruptParameters.
+                       ui_Read = (devpriv->s_InterruptParameters.
+                       ui_Read + 1) % APCI1710_SAVE_INTERRUPT;
+
+               break;
+
+       default:
+               printk("ReadType Parameter wrong\n");
+       }
+
+       if (i_ReturnValue >= 0)
+               i_ReturnValue = insn->n;
+       return i_ReturnValue;
+
+}
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.h
deleted file mode 100644 (file)
index 358298b..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#define APCI1710_16BIT_COUNTER                 0x10
-#define APCI1710_32BIT_COUNTER                 0x0
-#define APCI1710_QUADRUPLE_MODE                        0x0
-#define APCI1710_DOUBLE_MODE                   0x3
-#define APCI1710_SIMPLE_MODE                   0xF
-#define APCI1710_DIRECT_MODE                   0x80
-#define APCI1710_HYSTERESIS_ON                 0x60
-#define APCI1710_HYSTERESIS_OFF                        0x0
-#define APCI1710_INCREMENT                     0x60
-#define APCI1710_DECREMENT                     0x0
-#define APCI1710_LATCH_COUNTER                 0x1
-#define APCI1710_CLEAR_COUNTER                 0x0
-#define APCI1710_LOW                           0x0
-#define APCI1710_HIGH                          0x1
-
-/*********************/
-/* Version 0600-0229 */
-/*********************/
-#define APCI1710_HIGH_EDGE_CLEAR_COUNTER               0x0
-#define APCI1710_HIGH_EDGE_LATCH_COUNTER               0x1
-#define APCI1710_LOW_EDGE_CLEAR_COUNTER                        0x2
-#define APCI1710_LOW_EDGE_LATCH_COUNTER                        0x3
-#define APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER     0x4
-#define APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER      0x5
-#define APCI1710_SOURCE_0                              0x0
-#define APCI1710_SOURCE_1                              0x1
-
-#define APCI1710_30MHZ                         30
-#define APCI1710_33MHZ                         33
-#define APCI1710_40MHZ                         40
-
-#define APCI1710_ENABLE_LATCH_INT              0x80
-#define APCI1710_DISABLE_LATCH_INT             (~APCI1710_ENABLE_LATCH_INT)
-
-#define APCI1710_INDEX_LATCH_COUNTER           0x10
-#define APCI1710_INDEX_AUTO_MODE               0x8
-#define APCI1710_ENABLE_INDEX                  0x4
-#define APCI1710_DISABLE_INDEX                 (~APCI1710_ENABLE_INDEX)
-#define APCI1710_ENABLE_LATCH_AND_CLEAR                0x8
-#define APCI1710_DISABLE_LATCH_AND_CLEAR       (~APCI1710_ENABLE_LATCH_AND_CLEAR)
-#define APCI1710_SET_LOW_INDEX_LEVEL           0x4
-#define APCI1710_SET_HIGH_INDEX_LEVEL          (~APCI1710_SET_LOW_INDEX_LEVEL)
-#define APCI1710_INVERT_INDEX_RFERENCE         0x2
-#define APCI1710_DEFAULT_INDEX_RFERENCE         (~APCI1710_INVERT_INDEX_RFERENCE)
-
-#define APCI1710_ENABLE_INDEX_INT              0x1
-#define APCI1710_DISABLE_INDEX_INT             (~APCI1710_ENABLE_INDEX_INT)
-
-#define APCI1710_ENABLE_FREQUENCY              0x4
-#define APCI1710_DISABLE_FREQUENCY             (~APCI1710_ENABLE_FREQUENCY)
-
-#define APCI1710_ENABLE_FREQUENCY_INT          0x8
-#define APCI1710_DISABLE_FREQUENCY_INT         (~APCI1710_ENABLE_FREQUENCY_INT)
-
-#define APCI1710_ENABLE_40MHZ_FREQUENCY                0x40
-#define APCI1710_DISABLE_40MHZ_FREQUENCY       (~APCI1710_ENABLE_40MHZ_FREQUENCY)
-
-#define APCI1710_ENABLE_40MHZ_FILTER           0x80
-#define APCI1710_DISABLE_40MHZ_FILTER          (~APCI1710_ENABLE_40MHZ_FILTER)
-
-#define APCI1710_ENABLE_COMPARE_INT            0x2
-#define APCI1710_DISABLE_COMPARE_INT           (~APCI1710_ENABLE_COMPARE_INT)
-
-#define APCI1710_ENABLE_INDEX_ACTION           0x20
-#define APCI1710_DISABLE_INDEX_ACTION          (~APCI1710_ENABLE_INDEX_ACTION)
-#define APCI1710_REFERENCE_HIGH                        0x40
-#define APCI1710_REFERENCE_LOW                 (~APCI1710_REFERENCE_HIGH)
-
-#define APCI1710_TOR_GATE_LOW                  0x40
-#define APCI1710_TOR_GATE_HIGH                 (~APCI1710_TOR_GATE_LOW)
-
-/* INSN CONFIG */
-#define        APCI1710_INCCPT_INITCOUNTER                             100
-#define APCI1710_INCCPT_COUNTERAUTOTEST                                101
-#define APCI1710_INCCPT_INITINDEX                              102
-#define APCI1710_INCCPT_INITREFERENCE                          103
-#define APCI1710_INCCPT_INITEXTERNALSTROBE                     104
-#define APCI1710_INCCPT_INITCOMPARELOGIC                       105
-#define APCI1710_INCCPT_INITFREQUENCYMEASUREMENT               106
-
-/* INSN READ */
-#define APCI1710_INCCPT_READLATCHREGISTERSTATUS                        200
-#define APCI1710_INCCPT_READLATCHREGISTERVALUE                 201
-#define APCI1710_INCCPT_READ16BITCOUNTERVALUE                  202
-#define APCI1710_INCCPT_READ32BITCOUNTERVALUE                  203
-#define APCI1710_INCCPT_GETINDEXSTATUS                         204
-#define APCI1710_INCCPT_GETREFERENCESTATUS                     205
-#define APCI1710_INCCPT_GETUASSTATUS                           206
-#define APCI1710_INCCPT_GETCBSTATUS                            207
-#define APCI1710_INCCPT_GET16BITCBSTATUS                       208
-#define APCI1710_INCCPT_GETUDSTATUS                            209
-#define APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS            210
-#define APCI1710_INCCPT_READFREQUENCYMEASUREMENT               211
-#define APCI1710_INCCPT_READINTERRUPT                          212
-
-/* INSN BITS */
-#define APCI1710_INCCPT_CLEARCOUNTERVALUE                      300
-#define APCI1710_INCCPT_CLEARALLCOUNTERVALUE                   301
-#define APCI1710_INCCPT_SETINPUTFILTER                         302
-#define APCI1710_INCCPT_LATCHCOUNTER                           303
-#define APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE             304
-#define APCI1710_INCCPT_SETDIGITALCHLON                                305
-#define APCI1710_INCCPT_SETDIGITALCHLOFF                       306
-
-/* INSN WRITE */
-#define APCI1710_INCCPT_ENABLELATCHINTERRUPT                   400
-#define APCI1710_INCCPT_DISABLELATCHINTERRUPT                  401
-#define APCI1710_INCCPT_WRITE16BITCOUNTERVALUE                 402
-#define APCI1710_INCCPT_WRITE32BITCOUNTERVALUE                 403
-#define APCI1710_INCCPT_ENABLEINDEX                            404
-#define APCI1710_INCCPT_DISABLEINDEX                           405
-#define APCI1710_INCCPT_ENABLECOMPARELOGIC                     406
-#define APCI1710_INCCPT_DISABLECOMPARELOGIC                    407
-#define APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT             408
-#define APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT            409
-
-/************ Main Functions *************/
-int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, struct comedi_subdevice *s,
-                               struct comedi_insn *insn, unsigned int * data);
-
-int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, struct comedi_subdevice * s,
-                             struct comedi_insn *insn, unsigned int * data);
-
-int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, struct comedi_subdevice * s,
-                              struct comedi_insn *insn, unsigned int * data);
-
-int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, struct comedi_subdevice * s,
-                             struct comedi_insn *insn, unsigned int * data);
-
-/*********** Supplementary Functions********/
-
-/* INSN CONFIG */
-int i_APCI1710_InitCounter(struct comedi_device *dev,
-                          unsigned char b_ModulNbr,
-                          unsigned char b_CounterRange,
-                          unsigned char b_FirstCounterModus,
-                          unsigned char b_FirstCounterOption,
-                          unsigned char b_SecondCounterModus,
-                          unsigned char b_SecondCounterOption);
-
-int i_APCI1710_CounterAutoTest(struct comedi_device *dev, unsigned char * pb_TestStatus);
-
-int i_APCI1710_InitIndex(struct comedi_device *dev,
-                        unsigned char b_ModulNbr,
-                        unsigned char b_ReferenceAction,
-                        unsigned char b_IndexOperation, unsigned char b_AutoMode,
-                        unsigned char b_InterruptEnable);
-
-int i_APCI1710_InitReference(struct comedi_device *dev,
-                            unsigned char b_ModulNbr, unsigned char b_ReferenceLevel);
-
-int i_APCI1710_InitExternalStrobe(struct comedi_device *dev,
-                                 unsigned char b_ModulNbr, unsigned char b_ExternalStrobe,
-                                 unsigned char b_ExternalStrobeLevel);
-
-int i_APCI1710_InitCompareLogic(struct comedi_device *dev,
-                               unsigned char b_ModulNbr, unsigned int ui_CompareValue);
-
-int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev,
-                                       unsigned char b_ModulNbr,
-                                       unsigned char b_PCIInputClock,
-                                       unsigned char b_TimingUnity,
-                                       unsigned int ul_TimingInterval,
-                                       unsigned int *pul_RealTimingInterval);
-
-/* INSN BITS */
-int i_APCI1710_ClearCounterValue(struct comedi_device *dev, unsigned char b_ModulNbr);
-
-int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev);
-
-int i_APCI1710_SetInputFilter(struct comedi_device *dev,
-                             unsigned char b_ModulNbr, unsigned char b_PCIInputClock,
-                             unsigned char b_Filter);
-
-int i_APCI1710_LatchCounter(struct comedi_device *dev,
-                           unsigned char b_ModulNbr, unsigned char b_LatchReg);
-
-int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev,
-                                         unsigned char b_ModulNbr,
-                                         unsigned char b_SourceSelection);
-
-int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, unsigned char b_ModulNbr);
-
-int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, unsigned char b_ModulNbr);
-
-/* INSN WRITE */
-int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr);
-
-int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, unsigned char b_ModulNbr);
-
-int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev,
-                                     unsigned char b_ModulNbr, unsigned char b_SelectedCounter,
-                                     unsigned int ui_WriteValue);
-
-int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev,
-                                     unsigned char b_ModulNbr, unsigned int ul_WriteValue);
-
-int i_APCI1710_EnableIndex(struct comedi_device *dev, unsigned char b_ModulNbr);
-
-int i_APCI1710_DisableIndex(struct comedi_device *dev, unsigned char b_ModulNbr);
-
-int i_APCI1710_EnableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr);
-
-int i_APCI1710_DisableCompareLogic(struct comedi_device *dev, unsigned char b_ModulNbr);
-
-int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev,
-                                         unsigned char b_ModulNbr,
-                                         unsigned char b_InterruptEnable);
-
-int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev,
-                                          unsigned char b_ModulNbr);
-
-/* INSN READ */
-int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev,
-                                      unsigned char b_ModulNbr, unsigned char b_LatchReg,
-                                      unsigned char *pb_LatchStatus);
-
-int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev,
-                                     unsigned char b_ModulNbr, unsigned char b_LatchReg,
-                                     unsigned int *pul_LatchValue);
-
-int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev,
-                                    unsigned char b_ModulNbr, unsigned char b_SelectedCounter,
-                                    unsigned int *pui_CounterValue);
-
-int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev,
-                                    unsigned char b_ModulNbr, unsigned int *pul_CounterValue);
-
-int i_APCI1710_GetIndexStatus(struct comedi_device *dev,
-                             unsigned char b_ModulNbr, unsigned char *pb_IndexStatus);
-
-int i_APCI1710_GetReferenceStatus(struct comedi_device *dev,
-                                 unsigned char b_ModulNbr, unsigned char *pb_ReferenceStatus);
-
-int i_APCI1710_GetUASStatus(struct comedi_device *dev,
-                           unsigned char b_ModulNbr, unsigned char *pb_UASStatus);
-
-int i_APCI1710_GetCBStatus(struct comedi_device *dev,
-                          unsigned char b_ModulNbr, unsigned char *pb_CBStatus);
-
-int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev,
-                               unsigned char b_ModulNbr, unsigned char *pb_CBStatusCounter0,
-                               unsigned char *pb_CBStatusCounter1);
-
-int i_APCI1710_GetUDStatus(struct comedi_device *dev,
-                          unsigned char b_ModulNbr, unsigned char *pb_UDStatus);
-
-int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev,
-                                          unsigned char b_ModulNbr, unsigned char *pb_UDStatus);
-
-int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev,
-                                       unsigned char b_ModulNbr,
-                                       unsigned char *pb_Status, unsigned char *pb_UDStatus,
-                                       unsigned int *pul_ReadValue);
index c892d0c569e5cd3f7f00c9459b881b6f22a09b55..be0c6adbdc94158fba17d98cb326cb3768afc33d 100644 (file)
@@ -49,13 +49,11 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +-----------------------------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
+#define APCI1710_SINGLE                        0
+#define APCI1710_CONTINUOUS            1
 
-#include "APCI1710_Inp_cpt.h"
+#define APCI1710_PULSEENCODER_READ     0
+#define APCI1710_PULSEENCODER_WRITE    1
 
 /*
 +----------------------------------------------------------------------------+
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.h
deleted file mode 100644 (file)
index c8b90b4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#define APCI1710_SINGLE                        0
-#define APCI1710_CONTINUOUS            1
-
-#define APCI1710_PULSEENCODER_READ     0
-#define APCI1710_PULSEENCODER_WRITE    1
index 9a01ea05b40efb89a8c26b938d5667e7ce6550af..a211e78dd3ba244b23784aaa87114a53b9c1c417 100644 (file)
@@ -47,72 +47,16 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +-----------------------------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
-
-#include "APCI1710_Pwm.h"
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     :INT i_APCI1710_InsnConfigPWM(struct comedi_device *dev,
-struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)                        |
-+----------------------------------------------------------------------------+
-| Task              : Pwm Init and Get Pwm Initialisation                    |
-+----------------------------------------------------------------------------+
-| Input Parameters  :
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      :
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI1710_InsnConfigPWM(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
-{
-       unsigned char b_ConfigType;
-       int i_ReturnValue = 0;
-       b_ConfigType = CR_CHAN(insn->chanspec);
-
-       switch (b_ConfigType) {
-       case APCI1710_PWM_INIT:
-               i_ReturnValue = i_APCI1710_InitPWM(dev, (unsigned char) CR_AREF(insn->chanspec),        /*   b_ModulNbr */
-                       (unsigned char) data[0],        /* b_PWM */
-                       (unsigned char) data[1],        /*  b_ClockSelection */
-                       (unsigned char) data[2],        /*  b_TimingUnit */
-                       (unsigned int) data[3], /* ul_LowTiming */
-                       (unsigned int) data[4], /* ul_HighTiming */
-                       (unsigned int *) &data[0],      /* pul_RealLowTiming */
-                       (unsigned int *) &data[1]       /* pul_RealHighTiming */
-                       );
-               break;
-
-       case APCI1710_PWM_GETINITDATA:
-               i_ReturnValue = i_APCI1710_GetPWMInitialisation(dev, (unsigned char) CR_AREF(insn->chanspec),   /*  b_ModulNbr */
-                       (unsigned char) data[0],        /* b_PWM */
-                       (unsigned char *) &data[0],     /* pb_TimingUnit */
-                       (unsigned int *) &data[1],      /* pul_LowTiming */
-                       (unsigned int *) &data[2],      /* pul_HighTiming */
-                       (unsigned char *) &data[3],     /*  pb_StartLevel */
-                       (unsigned char *) &data[4],     /*  pb_StopMode */
-                       (unsigned char *) &data[5],     /*  pb_StopLevel */
-                       (unsigned char *) &data[6],     /*  pb_ExternGate */
-                       (unsigned char *) &data[7],     /*  pb_InterruptEnable */
-                       (unsigned char *) &data[8]      /*  pb_Enable */
-                       );
-               break;
+#define APCI1710_30MHZ                 30
+#define APCI1710_33MHZ                 33
+#define APCI1710_40MHZ                 40
 
-       default:
-               printk(" Config Parameter Wrong\n");
-       }
+#define APCI1710_PWM_INIT              0
+#define APCI1710_PWM_GETINITDATA       1
 
-       if (i_ReturnValue >= 0)
-               i_ReturnValue = insn->n;
-       return i_ReturnValue;
-}
+#define APCI1710_PWM_DISABLE           0
+#define APCI1710_PWM_ENABLE            1
+#define APCI1710_PWM_NEWTIMING         2
 
 /*
 +----------------------------------------------------------------------------+
@@ -178,15 +122,15 @@ int i_APCI1710_InsnConfigPWM(struct comedi_device *dev, struct comedi_subdevice
 |                        this board                                          |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InitPWM(struct comedi_device *dev,
-       unsigned char b_ModulNbr,
-       unsigned char b_PWM,
-       unsigned char b_ClockSelection,
-       unsigned char b_TimingUnit,
-       unsigned int ul_LowTiming,
-       unsigned int ul_HighTiming,
-       unsigned int *pul_RealLowTiming, unsigned int *pul_RealHighTiming)
+static int i_APCI1710_InitPWM(struct comedi_device *dev,
+                             unsigned char b_ModulNbr,
+                             unsigned char b_PWM,
+                             unsigned char b_ClockSelection,
+                             unsigned char b_TimingUnit,
+                             unsigned int ul_LowTiming,
+                             unsigned int ul_HighTiming,
+                             unsigned int *pul_RealLowTiming,
+                             unsigned int *pul_RealHighTiming)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1534,17 +1478,18 @@ int i_APCI1710_InitPWM(struct comedi_device *dev,
 |                         "i_APCI1710_InitPWM"                               |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_GetPWMInitialisation(struct comedi_device *dev,
-       unsigned char b_ModulNbr,
-       unsigned char b_PWM,
-       unsigned char *pb_TimingUnit,
-       unsigned int *pul_LowTiming,
-       unsigned int *pul_HighTiming,
-       unsigned char *pb_StartLevel,
-       unsigned char *pb_StopMode,
-       unsigned char *pb_StopLevel,
-       unsigned char *pb_ExternGate, unsigned char *pb_InterruptEnable, unsigned char *pb_Enable)
+static int i_APCI1710_GetPWMInitialisation(struct comedi_device *dev,
+                                          unsigned char b_ModulNbr,
+                                          unsigned char b_PWM,
+                                          unsigned char *pb_TimingUnit,
+                                          unsigned int *pul_LowTiming,
+                                          unsigned int *pul_HighTiming,
+                                          unsigned char *pb_StartLevel,
+                                          unsigned char *pb_StopMode,
+                                          unsigned char *pb_StopLevel,
+                                          unsigned char *pb_ExternGate,
+                                          unsigned char *pb_InterruptEnable,
+                                          unsigned char *pb_Enable)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -1671,51 +1616,47 @@ int i_APCI1710_GetPWMInitialisation(struct comedi_device *dev,
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function Name     :INT i_APCI1710_InsnWritePWM(struct comedi_device *dev,
-struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)                        |
-+----------------------------------------------------------------------------+
-| Task              : Pwm Enable Disable and Set New Timing                  |
-+----------------------------------------------------------------------------+
-| Input Parameters  :
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      :
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI1710_InsnWritePWM(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+ * Pwm Init and Get Pwm Initialisation
+ */
+static int i_APCI1710_InsnConfigPWM(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct comedi_insn *insn,
+                                   unsigned int *data)
 {
-       unsigned char b_WriteType;
+       unsigned char b_ConfigType;
        int i_ReturnValue = 0;
-       b_WriteType = CR_CHAN(insn->chanspec);
-
-       switch (b_WriteType) {
-       case APCI1710_PWM_ENABLE:
-               i_ReturnValue = i_APCI1710_EnablePWM(dev,
-                       (unsigned char) CR_AREF(insn->chanspec),
-                       (unsigned char) data[0],
-                       (unsigned char) data[1],
-                       (unsigned char) data[2],
-                       (unsigned char) data[3], (unsigned char) data[4], (unsigned char) data[5]);
-               break;
+       b_ConfigType = CR_CHAN(insn->chanspec);
 
-       case APCI1710_PWM_DISABLE:
-               i_ReturnValue = i_APCI1710_DisablePWM(dev,
-                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
+       switch (b_ConfigType) {
+       case APCI1710_PWM_INIT:
+               i_ReturnValue = i_APCI1710_InitPWM(dev, (unsigned char) CR_AREF(insn->chanspec),        /*   b_ModulNbr */
+                       (unsigned char) data[0],        /* b_PWM */
+                       (unsigned char) data[1],        /*  b_ClockSelection */
+                       (unsigned char) data[2],        /*  b_TimingUnit */
+                       (unsigned int) data[3], /* ul_LowTiming */
+                       (unsigned int) data[4], /* ul_HighTiming */
+                       (unsigned int *) &data[0],      /* pul_RealLowTiming */
+                       (unsigned int *) &data[1]       /* pul_RealHighTiming */
+                       );
                break;
 
-       case APCI1710_PWM_NEWTIMING:
-               i_ReturnValue = i_APCI1710_SetNewPWMTiming(dev,
-                       (unsigned char) CR_AREF(insn->chanspec),
-                       (unsigned char) data[0],
-                       (unsigned char) data[1], (unsigned int) data[2], (unsigned int) data[3]);
+       case APCI1710_PWM_GETINITDATA:
+               i_ReturnValue = i_APCI1710_GetPWMInitialisation(dev, (unsigned char) CR_AREF(insn->chanspec),   /*  b_ModulNbr */
+                       (unsigned char) data[0],        /* b_PWM */
+                       (unsigned char *) &data[0],     /* pb_TimingUnit */
+                       (unsigned int *) &data[1],      /* pul_LowTiming */
+                       (unsigned int *) &data[2],      /* pul_HighTiming */
+                       (unsigned char *) &data[3],     /*  pb_StartLevel */
+                       (unsigned char *) &data[4],     /*  pb_StopMode */
+                       (unsigned char *) &data[5],     /*  pb_StopLevel */
+                       (unsigned char *) &data[6],     /*  pb_ExternGate */
+                       (unsigned char *) &data[7],     /*  pb_InterruptEnable */
+                       (unsigned char *) &data[8]      /*  pb_Enable */
+                       );
                break;
 
        default:
-               printk("Write Config Parameter Wrong\n");
+               printk(" Config Parameter Wrong\n");
        }
 
        if (i_ReturnValue >= 0)
@@ -1807,13 +1748,14 @@ int i_APCI1710_InsnWritePWM(struct comedi_device *dev, struct comedi_subdevice *
 |                         See function "i_APCI1710_SetBoardIntRoutineX"      |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_EnablePWM(struct comedi_device *dev,
-       unsigned char b_ModulNbr,
-       unsigned char b_PWM,
-       unsigned char b_StartLevel,
-       unsigned char b_StopMode,
-       unsigned char b_StopLevel, unsigned char b_ExternGate, unsigned char b_InterruptEnable)
+static int i_APCI1710_EnablePWM(struct comedi_device *dev,
+                               unsigned char b_ModulNbr,
+                               unsigned char b_PWM,
+                               unsigned char b_StartLevel,
+                               unsigned char b_StopMode,
+                               unsigned char b_StopLevel,
+                               unsigned char b_ExternGate,
+                               unsigned char b_InterruptEnable)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -2064,8 +2006,9 @@ int i_APCI1710_EnablePWM(struct comedi_device *dev,
 |                         "i_APCI1710_EnablePWM"                             |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_DisablePWM(struct comedi_device *dev, unsigned char b_ModulNbr, unsigned char b_PWM)
+static int i_APCI1710_DisablePWM(struct comedi_device *dev,
+                                unsigned char b_ModulNbr,
+                                unsigned char b_PWM)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -2192,10 +2135,12 @@ int i_APCI1710_DisablePWM(struct comedi_device *dev, unsigned char b_ModulNbr, u
 |                    -8: High base timing selection is wrong                 |
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_SetNewPWMTiming(struct comedi_device *dev,
-       unsigned char b_ModulNbr,
-       unsigned char b_PWM, unsigned char b_TimingUnit, unsigned int ul_LowTiming, unsigned int ul_HighTiming)
+static int i_APCI1710_SetNewPWMTiming(struct comedi_device *dev,
+                                     unsigned char b_ModulNbr,
+                                     unsigned char b_PWM,
+                                     unsigned char b_TimingUnit,
+                                     unsigned int ul_LowTiming,
+                                     unsigned int ul_HighTiming)
 {
        struct addi_private *devpriv = dev->private;
        unsigned char b_ClockSelection;
@@ -3419,6 +3364,49 @@ int i_APCI1710_SetNewPWMTiming(struct comedi_device *dev,
        return i_ReturnValue;
 }
 
+/*
+ * Pwm Enable Disable and Set New Timing
+ */
+static int i_APCI1710_InsnWritePWM(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_insn *insn,
+                                  unsigned int *data)
+{
+       unsigned char b_WriteType;
+       int i_ReturnValue = 0;
+       b_WriteType = CR_CHAN(insn->chanspec);
+
+       switch (b_WriteType) {
+       case APCI1710_PWM_ENABLE:
+               i_ReturnValue = i_APCI1710_EnablePWM(dev,
+                       (unsigned char) CR_AREF(insn->chanspec),
+                       (unsigned char) data[0],
+                       (unsigned char) data[1],
+                       (unsigned char) data[2],
+                       (unsigned char) data[3], (unsigned char) data[4], (unsigned char) data[5]);
+               break;
+
+       case APCI1710_PWM_DISABLE:
+               i_ReturnValue = i_APCI1710_DisablePWM(dev,
+                       (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]);
+               break;
+
+       case APCI1710_PWM_NEWTIMING:
+               i_ReturnValue = i_APCI1710_SetNewPWMTiming(dev,
+                       (unsigned char) CR_AREF(insn->chanspec),
+                       (unsigned char) data[0],
+                       (unsigned char) data[1], (unsigned int) data[2], (unsigned int) data[3]);
+               break;
+
+       default:
+               printk("Write Config Parameter Wrong\n");
+       }
+
+       if (i_ReturnValue >= 0)
+               i_ReturnValue = insn->n;
+       return i_ReturnValue;
+}
+
 /*
 +----------------------------------------------------------------------------+
 | Function Name     : _INT_ i_APCI1710_GetPWMStatus                          |
@@ -3464,9 +3452,10 @@ int i_APCI1710_SetNewPWMTiming(struct comedi_device *dev,
 |                     -6: PWM not enabled see function "i_APCI1710_EnablePWM"|
 +----------------------------------------------------------------------------+
 */
-
-int i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+static int i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev,
+                                          struct comedi_subdevice *s,
+                                          struct comedi_insn *insn,
+                                          unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        int i_ReturnValue = 0;
@@ -3566,8 +3555,10 @@ int i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev, struct comedi_sub
        return i_ReturnValue;
 }
 
-int i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device *dev,
-       struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+static int i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device *dev,
+                                              struct comedi_subdevice *s,
+                                              struct comedi_insn *insn,
+                                              unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
 
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.h
deleted file mode 100644 (file)
index d8ad0b9..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#define APCI1710_30MHZ         30
-#define APCI1710_33MHZ         33
-#define APCI1710_40MHZ         40
-
-#define APCI1710_PWM_INIT              0
-#define APCI1710_PWM_GETINITDATA       1
-
-#define APCI1710_PWM_DISABLE           0
-#define APCI1710_PWM_ENABLE            1
-#define APCI1710_PWM_NEWTIMING         2
-
-int i_APCI1710_InsnConfigPWM(struct comedi_device *dev, struct comedi_subdevice *s,
-                            struct comedi_insn *insn, unsigned int *data);
-
-int i_APCI1710_InitPWM(struct comedi_device *dev,
-                      unsigned char b_ModulNbr,
-                      unsigned char b_PWM,
-                      unsigned char b_ClockSelection,
-                      unsigned char b_TimingUnit,
-                      unsigned int ul_LowTiming,
-                      unsigned int ul_HighTiming,
-                      unsigned int *pul_RealLowTiming, unsigned int *pul_RealHighTiming);
-
-int i_APCI1710_GetPWMInitialisation(struct comedi_device *dev,
-                                   unsigned char b_ModulNbr,
-                                   unsigned char b_PWM,
-                                   unsigned char *pb_TimingUnit,
-                                   unsigned int *pul_LowTiming,
-                                   unsigned int *pul_HighTiming,
-                                   unsigned char *pb_StartLevel,
-                                   unsigned char *pb_StopMode,
-                                   unsigned char *pb_StopLevel,
-                                   unsigned char *pb_ExternGate,
-                                   unsigned char *pb_InterruptEnable, unsigned char *pb_Enable);
-
-int i_APCI1710_InsnWritePWM(struct comedi_device *dev, struct comedi_subdevice *s,
-                           struct comedi_insn *insn, unsigned int *data);
-
-int i_APCI1710_EnablePWM(struct comedi_device *dev,
-                        unsigned char b_ModulNbr,
-                        unsigned char b_PWM,
-                        unsigned char b_StartLevel,
-                        unsigned char b_StopMode,
-                        unsigned char b_StopLevel, unsigned char b_ExternGate,
-                        unsigned char b_InterruptEnable);
-
-int i_APCI1710_SetNewPWMTiming(struct comedi_device *dev,
-                              unsigned char b_ModulNbr,
-                              unsigned char b_PWM, unsigned char b_TimingUnit,
-                              unsigned int ul_LowTiming, unsigned int ul_HighTiming);
-
-int i_APCI1710_DisablePWM(struct comedi_device *dev, unsigned char b_ModulNbr, unsigned char b_PWM);
-
-int i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev, struct comedi_subdevice *s,
-                                   struct comedi_insn *insn, unsigned int *data);
-
-int i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device *dev,
-                                       struct comedi_subdevice *s,
-                                       struct comedi_insn *insn, unsigned int *data);
index 00f8dc38186e2e97ea90335ec54fd80d21185369..1e05732e9f3d52d9aac5b499d93d6b68128327be 100644 (file)
@@ -40,13 +40,20 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +-----------------------------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
+#define APCI1710_30MHZ                 30
+#define APCI1710_33MHZ                 33
+#define APCI1710_40MHZ                 40
+
+#define APCI1710_BINARY_MODE           0x1
+#define APCI1710_GRAY_MODE             0x0
+
+#define APCI1710_SSI_READ1VALUE                1
+#define APCI1710_SSI_READALLVALUE      2
 
-#include "APCI1710_Ssi.h"
+#define APCI1710_SSI_SET_CHANNELON     0
+#define APCI1710_SSI_SET_CHANNELOFF    1
+#define APCI1710_SSI_READ_1CHANNEL     2
+#define APCI1710_SSI_READ_ALLCHANNEL   3
 
 /*
 +----------------------------------------------------------------------------+
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.h
deleted file mode 100644 (file)
index c4f6565..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#define APCI1710_30MHZ         30
-#define APCI1710_33MHZ         33
-#define APCI1710_40MHZ         40
-
-#define APCI1710_BINARY_MODE   0x1
-#define APCI1710_GRAY_MODE     0x0
-
-#define APCI1710_SSI_READ1VALUE                1
-#define APCI1710_SSI_READALLVALUE      2
-
-#define APCI1710_SSI_SET_CHANNELON     0
-#define APCI1710_SSI_SET_CHANNELOFF    1
-#define APCI1710_SSI_READ_1CHANNEL     2
-#define APCI1710_SSI_READ_ALLCHANNEL   3
index 3594a0487f70860ea8774cf36e1877ec991012c0..3bc9826ce40bbcacec42383c9b397422372da25d 100644 (file)
@@ -52,13 +52,22 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +-----------------------------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
+#define APCI1710_30MHZ                 30
+#define APCI1710_33MHZ                 33
+#define APCI1710_40MHZ                 40
+
+#define APCI1710_GATE_INPUT            10
+
+#define APCI1710_TOR_SIMPLE_MODE       2
+#define APCI1710_TOR_DOUBLE_MODE       3
+#define APCI1710_TOR_QUADRUPLE_MODE    4
+
+#define APCI1710_SINGLE                        0
+#define APCI1710_CONTINUOUS            1
 
-#include "APCI1710_Tor.h"
+#define APCI1710_TOR_GETPROGRESSSTATUS 0
+#define APCI1710_TOR_GETCOUNTERVALUE   1
+#define APCI1710_TOR_READINTERRUPT     2
 
 /*
 +----------------------------------------------------------------------------+
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.h
deleted file mode 100644 (file)
index c6eb9d1..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#define APCI1710_30MHZ         30
-#define APCI1710_33MHZ         33
-#define APCI1710_40MHZ         40
-
-#define APCI1710_GATE_INPUT    10
-
-#define APCI1710_TOR_SIMPLE_MODE       2
-#define APCI1710_TOR_DOUBLE_MODE       3
-#define APCI1710_TOR_QUADRUPLE_MODE    4
-
-#define APCI1710_SINGLE                        0
-#define APCI1710_CONTINUOUS            1
-
-#define APCI1710_TOR_GETPROGRESSSTATUS 0
-#define APCI1710_TOR_GETCOUNTERVALUE   1
-#define APCI1710_TOR_READINTERRUPT     2
index 3bf6929c2185731a2dcf8a86f7822d8b4180e14a..c8238b8921cd64a691b4c6ca4c785588cb06a0e0 100644 (file)
@@ -52,13 +52,11 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +-----------------------------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
+#define APCI1710_TTL_INIT              0
+#define APCI1710_TTL_INITDIRECTION     1
 
-#include "APCI1710_Ttl.h"
+#define APCI1710_TTL_READCHANNEL       0
+#define APCI1710_TTL_READPORT          1
 
 /*
 +----------------------------------------------------------------------------+
diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.h
deleted file mode 100644 (file)
index 2f6a392..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#define APCI1710_TTL_INIT              0
-#define APCI1710_TTL_INITDIRECTION     1
-
-#define APCI1710_TTL_READCHANNEL       0
-#define APCI1710_TTL_READPORT          1
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h b/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h
deleted file mode 100644 (file)
index 95f7dc6..0000000
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- *  Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-/* Header file for AMCC  s 5933 */
-
-#ifndef _AMCC_S5933_H_
-#define _AMCC_S5933_H_
-
-#include "../../comedidev.h"
-
-/* written on base0 */
-#define FIFO_ADVANCE_ON_BYTE_2 0x20000000
-
-/* added for step 6 dma written on base2 */
-#define AMWEN_ENABLE           0x02
-
-#define A2P_FIFO_WRITE_ENABLE  0x01
-
-/* for transfer count enable bit */
-#define AGCSTS_TC_ENABLE       0x10000000
-
-/*
- * ADDON RELATED ADDITIONS
- */
-/* Constant */
-#define APCI3120_ENABLE_TRANSFER_ADD_ON_LOW            0x00
-#define APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH           0x1200
-#define APCI3120_A2P_FIFO_MANAGEMENT                   0x04000400L
-#define APCI3120_AMWEN_ENABLE                          0x02
-#define APCI3120_A2P_FIFO_WRITE_ENABLE                 0x01
-#define APCI3120_FIFO_ADVANCE_ON_BYTE_2                        0x20000000L
-#define APCI3120_ENABLE_WRITE_TC_INT                   0x00004000L
-#define APCI3120_CLEAR_WRITE_TC_INT                    0x00040000L
-#define APCI3120_DISABLE_AMWEN_AND_A2P_FIFO_WRITE      0x0
-#define APCI3120_DISABLE_BUS_MASTER_ADD_ON             0x0
-#define APCI3120_DISABLE_BUS_MASTER_PCI                        0x0
-
-/* ADD_ON ::: this needed since apci supports 16 bit interface to add on */
-#define APCI3120_ADD_ON_AGCSTS_LOW     0x3C
-#define APCI3120_ADD_ON_AGCSTS_HIGH    (APCI3120_ADD_ON_AGCSTS_LOW + 2)
-#define APCI3120_ADD_ON_MWAR_LOW       0x24
-#define APCI3120_ADD_ON_MWAR_HIGH      (APCI3120_ADD_ON_MWAR_LOW + 2)
-#define APCI3120_ADD_ON_MWTC_LOW       0x058
-#define APCI3120_ADD_ON_MWTC_HIGH      (APCI3120_ADD_ON_MWTC_LOW + 2)
-
-/* AMCC */
-#define APCI3120_AMCC_OP_MCSR          0x3C
-#define APCI3120_AMCC_OP_REG_INTCSR    0x38
-
-/*
- * AMCC Operation Register Offsets - PCI
- */
-#define AMCC_OP_REG_OMB1               0x00
-#define AMCC_OP_REG_OMB2               0x04
-#define AMCC_OP_REG_OMB3               0x08
-#define AMCC_OP_REG_OMB4               0x0c
-#define AMCC_OP_REG_IMB1               0x10
-#define AMCC_OP_REG_IMB2               0x14
-#define AMCC_OP_REG_IMB3               0x18
-#define AMCC_OP_REG_IMB4               0x1c
-#define AMCC_OP_REG_FIFO               0x20
-#define AMCC_OP_REG_MWAR               0x24
-#define AMCC_OP_REG_MWTC               0x28
-#define AMCC_OP_REG_MRAR               0x2c
-#define AMCC_OP_REG_MRTC               0x30
-#define AMCC_OP_REG_MBEF               0x34
-#define AMCC_OP_REG_INTCSR             0x38
-/* int source */
-#define  AMCC_OP_REG_INTCSR_SRC                (AMCC_OP_REG_INTCSR + 2)
-/* FIFO ctrl */
-#define  AMCC_OP_REG_INTCSR_FEC                (AMCC_OP_REG_INTCSR + 3)
-#define AMCC_OP_REG_MCSR               0x3c
-/* Data in byte 2 */
-#define  AMCC_OP_REG_MCSR_NVDATA       (AMCC_OP_REG_MCSR + 2)
-/* Command in byte 3 */
-#define  AMCC_OP_REG_MCSR_NVCMD                (AMCC_OP_REG_MCSR + 3)
-
-#define AMCC_FIFO_DEPTH_DWORD  8
-#define AMCC_FIFO_DEPTH_BYTES  (8 * sizeof(u32))
-
-/*
- * AMCC Operation Registers Size - PCI
- */
-#define AMCC_OP_REG_SIZE        64     /* in bytes */
-
-/*
- * AMCC Operation Register Offsets - Add-on
- */
-#define AMCC_OP_REG_AIMB1      0x00
-#define AMCC_OP_REG_AIMB2      0x04
-#define AMCC_OP_REG_AIMB3      0x08
-#define AMCC_OP_REG_AIMB4      0x0c
-#define AMCC_OP_REG_AOMB1      0x10
-#define AMCC_OP_REG_AOMB2      0x14
-#define AMCC_OP_REG_AOMB3      0x18
-#define AMCC_OP_REG_AOMB4      0x1c
-#define AMCC_OP_REG_AFIFO      0x20
-#define AMCC_OP_REG_AMWAR      0x24
-#define AMCC_OP_REG_APTA       0x28
-#define AMCC_OP_REG_APTD       0x2c
-#define AMCC_OP_REG_AMRAR      0x30
-#define AMCC_OP_REG_AMBEF      0x34
-#define AMCC_OP_REG_AINT       0x38
-#define AMCC_OP_REG_AGCSTS     0x3c
-#define AMCC_OP_REG_AMWTC      0x58
-#define AMCC_OP_REG_AMRTC      0x5c
-
-/*
- * AMCC - Add-on General Control/Status Register
- */
-#define AGCSTS_CONTROL_MASK    0xfffff000
-#define  AGCSTS_NV_ACC_MASK    0xe0000000
-#define  AGCSTS_RESET_MASK     0x0e000000
-#define  AGCSTS_NV_DA_MASK     0x00ff0000
-#define  AGCSTS_BIST_MASK      0x0000f000
-#define AGCSTS_STATUS_MASK     0x000000ff
-#define  AGCSTS_TCZERO_MASK    0x000000c0
-#define  AGCSTS_FIFO_ST_MASK   0x0000003f
-
-#define AGCSTS_RESET_MBFLAGS   0x08000000
-#define AGCSTS_RESET_P2A_FIFO  0x04000000
-#define AGCSTS_RESET_A2P_FIFO  0x02000000
-#define AGCSTS_RESET_FIFOS     (AGCSTS_RESET_A2P_FIFO | AGCSTS_RESET_P2A_FIFO)
-
-#define AGCSTS_A2P_TCOUNT      0x00000080
-#define AGCSTS_P2A_TCOUNT      0x00000040
-
-#define AGCSTS_FS_P2A_EMPTY    0x00000020
-#define AGCSTS_FS_P2A_HALF     0x00000010
-#define AGCSTS_FS_P2A_FULL     0x00000008
-
-#define AGCSTS_FS_A2P_EMPTY    0x00000004
-#define AGCSTS_FS_A2P_HALF     0x00000002
-#define AGCSTS_FS_A2P_FULL     0x00000001
-
-/*
- * AMCC - Add-on Interrupt Control/Status Register
- */
-#define AINT_INT_MASK          0x00ff0000
-#define AINT_SEL_MASK          0x0000ffff
-#define  AINT_IS_ENSEL_MASK    0x00001f1f
-
-#define AINT_INT_ASSERTED      0x00800000
-#define AINT_BM_ERROR          0x00200000
-#define AINT_BIST_INT          0x00100000
-
-#define AINT_RT_COMPLETE       0x00080000
-#define AINT_WT_COMPLETE       0x00040000
-
-#define AINT_OUT_MB_INT                0x00020000
-#define AINT_IN_MB_INT         0x00010000
-
-#define AINT_READ_COMPL                0x00008000
-#define AINT_WRITE_COMPL       0x00004000
-
-#define AINT_OMB_ENABLE        0x00001000
-#define AINT_OMB_SELECT        0x00000c00
-#define AINT_OMB_BYTE          0x00000300
-
-#define AINT_IMB_ENABLE        0x00000010
-#define AINT_IMB_SELECT        0x0000000c
-#define AINT_IMB_BYTE          0x00000003
-
-/* Enable Bus Mastering */
-#define EN_A2P_TRANSFERS       0x00000400
-/* FIFO Flag Reset */
-#define RESET_A2P_FLAGS                0x04000000L
-/* FIFO Relative Priority */
-#define A2P_HI_PRIORITY                0x00000100L
-/* Identify Interrupt Sources */
-#define ANY_S593X_INT          0x00800000L
-#define READ_TC_INT            0x00080000L
-#define WRITE_TC_INT           0x00040000L
-#define IN_MB_INT              0x00020000L
-#define MASTER_ABORT_INT       0x00100000L
-#define TARGET_ABORT_INT       0x00200000L
-#define BUS_MASTER_INT         0x00200000L
-
-/****************************************************************************/
-
-struct pcilst_struct {
-       struct pcilst_struct *next;
-       int used;
-       struct pci_dev *pcidev;
-       unsigned short vendor;
-       unsigned short device;
-       unsigned char pci_bus;
-       unsigned char pci_slot;
-       unsigned char pci_func;
-       resource_size_t io_addr[5];
-       unsigned int irq;
-};
-
-/* ptr to root list of all amcc devices */
-static struct pcilst_struct *amcc_devices;
-
-static const int i_ADDIDATADeviceID[] = { 0x15B8, 0x10E8 };
-
-/****************************************************************************/
-
-void v_pci_card_list_init(unsigned short pci_vendor, char display);
-void v_pci_card_list_cleanup(unsigned short pci_vendor);
-struct pcilst_struct *ptr_find_free_pci_card_by_device(unsigned short vendor_id,
-                                                      unsigned short
-                                                      device_id);
-int i_find_free_pci_card_by_position(unsigned short vendor_id,
-                                    unsigned short device_id,
-                                    unsigned short pci_bus,
-                                    unsigned short pci_slot,
-                                    struct pcilst_struct **card);
-struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
-                                                   unsigned short device_id,
-                                                   unsigned short pci_bus,
-                                                   unsigned short pci_slot,
-                                                   int i_Master);
-
-int pci_card_alloc(struct pcilst_struct *amcc, int master);
-int i_pci_card_free(struct pcilst_struct *amcc);
-void v_pci_card_list_display(void);
-int i_pci_card_data(struct pcilst_struct *amcc,
-                   unsigned char *pci_bus, unsigned char *pci_slot,
-                   unsigned char *pci_func, resource_size_t * io_addr,
-                   unsigned int *irq);
-
-/****************************************************************************/
-
-/* build list of amcc cards in this system */
-void v_pci_card_list_init(unsigned short pci_vendor, char display)
-{
-       struct pci_dev *pcidev = NULL;
-       struct pcilst_struct *amcc, *last;
-       int i;
-       int i_Count = 0;
-       amcc_devices = NULL;
-       last = NULL;
-
-       for_each_pci_dev(pcidev) {
-               for (i_Count = 0; i_Count < 2; i_Count++) {
-                       pci_vendor = i_ADDIDATADeviceID[i_Count];
-                       if (pcidev->vendor == pci_vendor) {
-                               amcc = kzalloc(sizeof(*amcc), GFP_KERNEL);
-                               if (amcc == NULL)
-                                       continue;
-
-                               amcc->pcidev = pcidev;
-                               if (last)
-                                       last->next = amcc;
-                               else
-                                       amcc_devices = amcc;
-                               last = amcc;
-
-                               amcc->vendor = pcidev->vendor;
-                               amcc->device = pcidev->device;
-                               amcc->pci_bus = pcidev->bus->number;
-                               amcc->pci_slot = PCI_SLOT(pcidev->devfn);
-                               amcc->pci_func = PCI_FUNC(pcidev->devfn);
-                               /* Note: resources may be invalid if PCI device
-                                * not enabled, but they are corrected in
-                                * pci_card_alloc. */
-                               for (i = 0; i < 5; i++)
-                                       amcc->io_addr[i] =
-                                           pci_resource_start(pcidev, i);
-                               amcc->irq = pcidev->irq;
-
-                       }
-               }
-       }
-
-       if (display)
-               v_pci_card_list_display();
-}
-
-/****************************************************************************/
-/* free up list of amcc cards in this system */
-void v_pci_card_list_cleanup(unsigned short pci_vendor)
-{
-       struct pcilst_struct *amcc, *next;
-
-       for (amcc = amcc_devices; amcc; amcc = next) {
-               next = amcc->next;
-               kfree(amcc);
-       }
-
-       amcc_devices = NULL;
-}
-
-/****************************************************************************/
-/* find first unused card with this device_id */
-struct pcilst_struct *ptr_find_free_pci_card_by_device(unsigned short vendor_id,
-                                                      unsigned short device_id)
-{
-       struct pcilst_struct *amcc, *next;
-
-       for (amcc = amcc_devices; amcc; amcc = next) {
-               next = amcc->next;
-               if ((!amcc->used) && (amcc->device == device_id)
-                   && (amcc->vendor == vendor_id))
-                       return amcc;
-
-       }
-
-       return NULL;
-}
-
-/****************************************************************************/
-/* find card on requested position */
-int i_find_free_pci_card_by_position(unsigned short vendor_id,
-                                    unsigned short device_id,
-                                    unsigned short pci_bus,
-                                    unsigned short pci_slot,
-                                    struct pcilst_struct **card)
-{
-       struct pcilst_struct *amcc, *next;
-
-       *card = NULL;
-       for (amcc = amcc_devices; amcc; amcc = next) {
-               next = amcc->next;
-               if ((amcc->vendor == vendor_id) && (amcc->device == device_id)
-                   && (amcc->pci_bus == pci_bus)
-                   && (amcc->pci_slot == pci_slot)) {
-                       if (!(amcc->used)) {
-                               *card = amcc;
-                               return 0;       /* ok, card is found */
-                       } else {
-                               printk(" - \nCard on requested position is used b:s %d:%d!\n",
-                                         pci_bus, pci_slot);
-                               return 2;       /* card exist but is used */
-                       }
-               }
-       }
-
-       /* no card found */
-       return 1;
-}
-
-/****************************************************************************/
-/* mark card as used */
-int pci_card_alloc(struct pcilst_struct *amcc, int master)
-{
-       int i;
-
-       if (!amcc)
-               return -1;
-
-       if (amcc->used)
-               return 1;
-       if (comedi_pci_enable(amcc->pcidev, "addi_amcc_s5933"))
-               return -1;
-       /* Resources will be accurate now. */
-       for (i = 0; i < 5; i++)
-               amcc->io_addr[i] = pci_resource_start(amcc->pcidev, i);
-       if (master)
-               pci_set_master(amcc->pcidev);
-       amcc->used = 1;
-
-       return 0;
-}
-
-/****************************************************************************/
-/* mark card as free */
-int i_pci_card_free(struct pcilst_struct *amcc)
-{
-       if (!amcc)
-               return -1;
-
-       if (!amcc->used)
-               return 1;
-       amcc->used = 0;
-       comedi_pci_disable(amcc->pcidev);
-       return 0;
-}
-
-/****************************************************************************/
-/* display list of found cards */
-void v_pci_card_list_display(void)
-{
-       struct pcilst_struct *amcc, *next;
-
-       printk(KERN_DEBUG "List of pci cards\n");
-       printk(KERN_DEBUG "bus:slot:func vendor device io_amcc io_daq irq used\n");
-
-       for (amcc = amcc_devices; amcc; amcc = next) {
-               next = amcc->next;
-               printk
-                   ("%2d   %2d   %2d  0x%4x 0x%4x   0x%8llx 0x%8llx  %2u  %2d\n",
-                    amcc->pci_bus, amcc->pci_slot, amcc->pci_func,
-                    amcc->vendor, amcc->device,
-                    (unsigned long long)amcc->io_addr[0],
-                    (unsigned long long)amcc->io_addr[2], amcc->irq,
-                    amcc->used);
-
-       }
-}
-
-/****************************************************************************/
-/* return all card information for driver */
-int i_pci_card_data(struct pcilst_struct *amcc,
-                   unsigned char *pci_bus, unsigned char *pci_slot,
-                   unsigned char *pci_func, resource_size_t * io_addr,
-                   unsigned int *irq)
-{
-       int i;
-
-       if (!amcc)
-               return -1;
-       *pci_bus = amcc->pci_bus;
-       *pci_slot = amcc->pci_slot;
-       *pci_func = amcc->pci_func;
-       for (i = 0; i < 5; i++)
-               io_addr[i] = amcc->io_addr[i];
-       *irq = amcc->irq;
-       return 0;
-}
-
-/****************************************************************************/
-/* select and alloc card */
-struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
-                                                   unsigned short device_id,
-                                                   unsigned short pci_bus,
-                                                   unsigned short pci_slot,
-                                                   int i_Master)
-{
-       struct pcilst_struct *card;
-
-       if ((pci_bus < 1) & (pci_slot < 1)) {
-               /* use autodetection */
-               card = ptr_find_free_pci_card_by_device(vendor_id, device_id);
-               if (card == NULL) {
-                       printk(" - Unused card not found in system!\n");
-                       return NULL;
-               }
-       } else {
-               switch (i_find_free_pci_card_by_position(vendor_id, device_id,
-                                                        pci_bus, pci_slot,
-                                                        &card)) {
-               case 1:
-                       printk(" - Card not found on requested position b:s %d:%d!\n",
-                                 pci_bus, pci_slot);
-                       return NULL;
-               case 2:
-                       printk(" - Card on requested position is used b:s %d:%d!\n",
-                                 pci_bus, pci_slot);
-                       return NULL;
-               }
-       }
-
-       if (pci_card_alloc(card, i_Master) != 0) {
-               printk(" - Can't allocate card!\n");
-               return NULL;
-
-       }
-
-       return card;
-}
-#endif
index 79beff15d68c0304734262e6faf591d58960ab8d..75f3dbdbed665006587d53142418b9f8af55d18f 100644 (file)
@@ -36,14 +36,6 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +-----------------------------------------------------------------------+
   | Description : ADDI COMMON Main Module                                 |
   +-----------------------------------------------------------------------+
-  | CONFIG OPTIONS                                                        |
-  |    option[0] - PCI bus number - if bus number and slot number are 0, |
-  |                             then driver search for first unused card |
-  |    option[1] - PCI slot number                                       |
-  |                                                                      |
-  |    option[2] = 0  - DMA ENABLE                                       |
-  |               = 1  - DMA DISABLE                                      |
-  +----------+-----------+------------------------------------------------+
 */
 
 #ifndef COMEDI_SUBD_TTLIO
@@ -84,87 +76,66 @@ static int i_ADDI_Reset(struct comedi_device *dev)
        return 0;
 }
 
-static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static const void *addi_find_boardinfo(struct comedi_device *dev,
+                                      struct pci_dev *pcidev)
 {
-       const struct addi_board *this_board = comedi_board(dev);
+       const void *p = dev->driver->board_name;
+       const struct addi_board *this_board;
+       int i;
+
+       for (i = 0; i < dev->driver->num_names; i++) {
+               this_board = p;
+               if (this_board->i_VendorId == pcidev->vendor &&
+                   this_board->i_DeviceId == pcidev->device)
+                       return this_board;
+               p += dev->driver->offset;
+       }
+       return NULL;
+}
+
+static int addi_attach_pci(struct comedi_device *dev,
+                          struct pci_dev *pcidev)
+{
+       const struct addi_board *this_board;
        struct addi_private *devpriv;
        struct comedi_subdevice *s;
        int ret, pages, i, n_subdevices;
        unsigned int dw_Dummy;
-       resource_size_t io_addr[5];
-       unsigned int irq;
-       resource_size_t iobase_a, iobase_main, iobase_addon, iobase_reserved;
-       struct pcilst_struct *card = NULL;
-       unsigned char pci_bus, pci_slot, pci_func;
-       int i_Dma = 0;
+
+       this_board = addi_find_boardinfo(dev, pcidev);
+       if (!this_board)
+               return -ENODEV;
+       dev->board_ptr = this_board;
+       dev->board_name = this_board->pc_DriverName;
 
        devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
        if (!devpriv)
                return -ENOMEM;
        dev->private = devpriv;
 
-       if (!pci_list_builded) {
-               v_pci_card_list_init(this_board->i_VendorId, 1);        /* 1 for displaying the list.. */
-               pci_list_builded = 1;
-       }
-       /* printk("comedi%d: "ADDIDATA_DRIVER_NAME": board=%s",dev->minor,this_board->pc_DriverName); */
-
-       if ((this_board->i_Dma) && (it->options[2] == 0)) {
-               i_Dma = 1;
-       }
-
-       card = ptr_select_and_alloc_pci_card(this_board->i_VendorId,
-                                            this_board->i_DeviceId,
-                                            it->options[0],
-                                            it->options[1], i_Dma);
-
-       if (card == NULL)
-               return -EIO;
-
-       devpriv->allocated = 1;
-
-       if ((i_pci_card_data(card, &pci_bus, &pci_slot, &pci_func, &io_addr[0],
-                               &irq)) < 0) {
-               i_pci_card_free(card);
-               printk(" - Can't get AMCC data!\n");
-               return -EIO;
-       }
-
-       iobase_a = io_addr[0];
-       iobase_main = io_addr[1];
-       iobase_addon = io_addr[2];
-       iobase_reserved = io_addr[3];
-       printk("\nBus %d: Slot %d: Funct%d\nBase0: 0x%8llx\nBase1: 0x%8llx\nBase2: 0x%8llx\nBase3: 0x%8llx\n", pci_bus, pci_slot, pci_func, (unsigned long long)io_addr[0], (unsigned long long)io_addr[1], (unsigned long long)io_addr[2], (unsigned long long)io_addr[3]);
-
-       if ((this_board->pc_EepromChip == NULL)
-               || (strcmp(this_board->pc_EepromChip, ADDIDATA_9054) != 0)) {
-          /************************************/
-               /* Test if more that 1 address used */
-          /************************************/
-
-               if (this_board->i_IorangeBase1 != 0) {
-                       dev->iobase = (unsigned long)iobase_main;       /*  DAQ base address... */
-               } else {
-                       dev->iobase = (unsigned long)iobase_a;  /*  DAQ base address... */
-               }
-
-               dev->board_name = this_board->pc_DriverName;
-               devpriv->amcc = card;
-               devpriv->iobase = (int) dev->iobase;
-               devpriv->i_IobaseAmcc = (int) iobase_a; /* AMCC base address... */
-               devpriv->i_IobaseAddon = (int) iobase_addon;    /* ADD ON base address.... */
-               devpriv->i_IobaseReserved = (int) iobase_reserved;
+       ret = comedi_pci_enable(pcidev, dev->board_name);
+       if (ret)
+               return ret;
+       if (this_board->i_Dma)
+               pci_set_master(pcidev);
+
+       if (!this_board->pc_EepromChip ||
+           !strcmp(this_board->pc_EepromChip, ADDIDATA_9054)) {
+               if (this_board->i_IorangeBase1)
+                       dev->iobase = pci_resource_start(pcidev, 1);
+               else
+                       dev->iobase = pci_resource_start(pcidev, 0);
+
+               devpriv->iobase = dev->iobase;
+               devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0);
+               devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2);
        } else {
-               dev->board_name = this_board->pc_DriverName;
-               dev->iobase = (unsigned long)io_addr[2];
-               devpriv->amcc = card;
-               devpriv->iobase = (int) io_addr[2];
-               devpriv->i_IobaseReserved = (int) io_addr[3];
-               printk("\nioremap begin");
-               devpriv->dw_AiBase = ioremap(io_addr[3],
+               dev->iobase = pci_resource_start(pcidev, 2);
+               devpriv->iobase = pci_resource_start(pcidev, 2);
+               devpriv->dw_AiBase = ioremap(pci_resource_start(pcidev, 3),
                                             this_board->i_IorangeBase3);
-               printk("\nioremap end");
        }
+       devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3);
 
        /* Initialize parameters that can be overridden in EEPROM */
        devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel;
@@ -183,30 +154,19 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
        /* ## */
 
-       if (irq > 0) {
-               if (request_irq(irq, v_ADDI_Interrupt, IRQF_SHARED,
-                               this_board->pc_DriverName, dev) < 0) {
-                       printk(", unable to allocate IRQ %u, DISABLING IT",
-                               irq);
-                       irq = 0;        /* Can't use IRQ */
-               } else {
-                       printk("\nirq=%u", irq);
-               }
-       } else {
-               printk(", IRQ disabled");
+       if (pcidev->irq > 0) {
+               ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED,
+                                 dev->board_name, dev);
+               if (ret == 0)
+                       dev->irq = pcidev->irq;
        }
 
-       printk("\nOption %d %d %d\n", it->options[0], it->options[1],
-               it->options[2]);
-       dev->irq = irq;
-
        /*  Read eepeom and fill addi_board Structure */
 
        if (this_board->i_PCIEeprom) {
-               printk("\nPCI Eeprom used");
                if (!(strcmp(this_board->pc_EepromChip, "S5920"))) {
                        /*  Set 3 wait stait */
-                       if (!(strcmp(this_board->pc_DriverName, "apci035"))) {
+                       if (!(strcmp(dev->board_name, "apci035"))) {
                                outl(0x80808082, devpriv->i_IobaseAmcc + 0x60);
                        } else {
                                outl(0x83838383, devpriv->i_IobaseAmcc + 0x60);
@@ -214,22 +174,13 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
                        /*  Enable the interrupt for the controller */
                        dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38);
                        outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38);
-                       printk("\nEnable the interrupt for the controller");
                }
-               printk("\nRead Eeprom");
-               addi_eeprom_read_info(dev, io_addr[0]);
-       } else {
-               printk("\nPCI Eeprom unused");
+               addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0));
        }
 
-       if (it->options[2] > 0) {
-               devpriv->us_UseDma = ADDI_DISABLE;
-       } else {
-               devpriv->us_UseDma = ADDI_ENABLE;
-       }
+       devpriv->us_UseDma = ADDI_ENABLE;
 
        if (devpriv->s_EeParameters.i_Dma) {
-               printk("\nDMA used");
                if (devpriv->us_UseDma == ADDI_ENABLE) {
                        /*  alloc DMA buffers */
                        devpriv->b_DmaDoubleBuffer = 0;
@@ -253,198 +204,176 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
                                                ul_DmaBufferVirtual[i]);
                                }
                        }
-                       if (!devpriv->ul_DmaBufferVirtual[0]) {
-                               printk
-                                       (", Can't allocate DMA buffer, DMA disabled!");
+                       if (!devpriv->ul_DmaBufferVirtual[0])
                                devpriv->us_UseDma = ADDI_DISABLE;
-                       }
 
-                       if (devpriv->ul_DmaBufferVirtual[1]) {
+                       if (devpriv->ul_DmaBufferVirtual[1])
                                devpriv->b_DmaDoubleBuffer = 1;
-                       }
                }
+       }
 
-               if ((devpriv->us_UseDma == ADDI_ENABLE)) {
-                       printk("\nDMA ENABLED\n");
+       n_subdevices = 7;
+       ret = comedi_alloc_subdevices(dev, n_subdevices);
+       if (ret)
+               return ret;
+
+       /*  Allocate and Initialise AI Subdevice Structures */
+       s = &dev->subdevices[0];
+       if ((devpriv->s_EeParameters.i_NbrAiChannel)
+               || (this_board->i_NbrAiChannelDiff)) {
+               dev->read_subdev = s;
+               s->type = COMEDI_SUBD_AI;
+               s->subdev_flags =
+                       SDF_READABLE | SDF_COMMON | SDF_GROUND
+                       | SDF_DIFF;
+               if (devpriv->s_EeParameters.i_NbrAiChannel) {
+                       s->n_chan =
+                               devpriv->s_EeParameters.i_NbrAiChannel;
+                       devpriv->b_SingelDiff = 0;
                } else {
-                       printk("\nDMA DISABLED\n");
+                       s->n_chan = this_board->i_NbrAiChannelDiff;
+                       devpriv->b_SingelDiff = 1;
                }
-       }
-
-       if (!strcmp(this_board->pc_DriverName, "apci1710")) {
-#ifdef CONFIG_APCI_1710
-               i_ADDI_AttachPCI1710(dev);
-
-               /*  save base address */
-               devpriv->s_BoardInfos.ui_Address = io_addr[2];
-#endif
-       } else {
-               n_subdevices = 7;
-               ret = comedi_alloc_subdevices(dev, n_subdevices);
-               if (ret)
-                       return ret;
-
-               /*  Allocate and Initialise AI Subdevice Structures */
-               s = &dev->subdevices[0];
-               if ((devpriv->s_EeParameters.i_NbrAiChannel)
-                       || (this_board->i_NbrAiChannelDiff)) {
-                       dev->read_subdev = s;
-                       s->type = COMEDI_SUBD_AI;
-                       s->subdev_flags =
-                               SDF_READABLE | SDF_COMMON | SDF_GROUND
-                               | SDF_DIFF;
-                       if (devpriv->s_EeParameters.i_NbrAiChannel) {
-                               s->n_chan =
-                                       devpriv->s_EeParameters.i_NbrAiChannel;
-                               devpriv->b_SingelDiff = 0;
-                       } else {
-                               s->n_chan = this_board->i_NbrAiChannelDiff;
-                               devpriv->b_SingelDiff = 1;
-                       }
-                       s->maxdata = devpriv->s_EeParameters.i_AiMaxdata;
-                       s->len_chanlist = this_board->i_AiChannelList;
-                       s->range_table = this_board->pr_AiRangelist;
+               s->maxdata = devpriv->s_EeParameters.i_AiMaxdata;
+               s->len_chanlist = this_board->i_AiChannelList;
+               s->range_table = this_board->pr_AiRangelist;
 
-                       /* Set the initialisation flag */
-                       devpriv->b_AiInitialisation = 1;
+               /* Set the initialisation flag */
+               devpriv->b_AiInitialisation = 1;
 
-                       s->insn_config = this_board->ai_config;
-                       s->insn_read = this_board->ai_read;
-                       s->insn_write = this_board->ai_write;
-                       s->insn_bits = this_board->ai_bits;
-                       s->do_cmdtest = this_board->ai_cmdtest;
-                       s->do_cmd = this_board->ai_cmd;
-                       s->cancel = this_board->ai_cancel;
+               s->insn_config = this_board->ai_config;
+               s->insn_read = this_board->ai_read;
+               s->insn_write = this_board->ai_write;
+               s->insn_bits = this_board->ai_bits;
+               s->do_cmdtest = this_board->ai_cmdtest;
+               s->do_cmd = this_board->ai_cmd;
+               s->cancel = this_board->ai_cancel;
 
-               } else {
-                       s->type = COMEDI_SUBD_UNUSED;
-               }
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
 
-               /*  Allocate and Initialise AO Subdevice Structures */
-               s = &dev->subdevices[1];
-               if (devpriv->s_EeParameters.i_NbrAoChannel) {
-                       s->type = COMEDI_SUBD_AO;
-                       s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-                       s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel;
-                       s->maxdata = devpriv->s_EeParameters.i_AoMaxdata;
-                       s->len_chanlist =
-                               devpriv->s_EeParameters.i_NbrAoChannel;
-                       s->range_table = this_board->pr_AoRangelist;
-                       s->insn_config = this_board->ao_config;
-                       s->insn_write = this_board->ao_write;
-               } else {
-                       s->type = COMEDI_SUBD_UNUSED;
-               }
-               /*  Allocate and Initialise DI Subdevice Structures */
-               s = &dev->subdevices[2];
-               if (devpriv->s_EeParameters.i_NbrDiChannel) {
-                       s->type = COMEDI_SUBD_DI;
-                       s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
-                       s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel;
-                       s->maxdata = 1;
-                       s->len_chanlist =
-                               devpriv->s_EeParameters.i_NbrDiChannel;
-                       s->range_table = &range_digital;
-                       s->io_bits = 0; /* all bits input */
-                       s->insn_config = this_board->di_config;
-                       s->insn_read = this_board->di_read;
-                       s->insn_write = this_board->di_write;
-                       s->insn_bits = this_board->di_bits;
-               } else {
-                       s->type = COMEDI_SUBD_UNUSED;
-               }
-               /*  Allocate and Initialise DO Subdevice Structures */
-               s = &dev->subdevices[3];
-               if (devpriv->s_EeParameters.i_NbrDoChannel) {
-                       s->type = COMEDI_SUBD_DO;
-                       s->subdev_flags =
-                               SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-                       s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel;
-                       s->maxdata = devpriv->s_EeParameters.i_DoMaxdata;
-                       s->len_chanlist =
-                               devpriv->s_EeParameters.i_NbrDoChannel;
-                       s->range_table = &range_digital;
-                       s->io_bits = 0xf;       /* all bits output */
-
-                       /* insn_config - for digital output memory */
-                       s->insn_config = this_board->do_config;
-                       s->insn_write = this_board->do_write;
-                       s->insn_bits = this_board->do_bits;
-                       s->insn_read = this_board->do_read;
-               } else {
-                       s->type = COMEDI_SUBD_UNUSED;
-               }
+       /*  Allocate and Initialise AO Subdevice Structures */
+       s = &dev->subdevices[1];
+       if (devpriv->s_EeParameters.i_NbrAoChannel) {
+               s->type = COMEDI_SUBD_AO;
+               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel;
+               s->maxdata = devpriv->s_EeParameters.i_AoMaxdata;
+               s->len_chanlist =
+                       devpriv->s_EeParameters.i_NbrAoChannel;
+               s->range_table = this_board->pr_AoRangelist;
+               s->insn_config = this_board->ao_config;
+               s->insn_write = this_board->ao_write;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+       /*  Allocate and Initialise DI Subdevice Structures */
+       s = &dev->subdevices[2];
+       if (devpriv->s_EeParameters.i_NbrDiChannel) {
+               s->type = COMEDI_SUBD_DI;
+               s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel;
+               s->maxdata = 1;
+               s->len_chanlist =
+                       devpriv->s_EeParameters.i_NbrDiChannel;
+               s->range_table = &range_digital;
+               s->io_bits = 0; /* all bits input */
+               s->insn_config = this_board->di_config;
+               s->insn_read = this_board->di_read;
+               s->insn_write = this_board->di_write;
+               s->insn_bits = this_board->di_bits;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+       /*  Allocate and Initialise DO Subdevice Structures */
+       s = &dev->subdevices[3];
+       if (devpriv->s_EeParameters.i_NbrDoChannel) {
+               s->type = COMEDI_SUBD_DO;
+               s->subdev_flags =
+                       SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel;
+               s->maxdata = devpriv->s_EeParameters.i_DoMaxdata;
+               s->len_chanlist =
+                       devpriv->s_EeParameters.i_NbrDoChannel;
+               s->range_table = &range_digital;
+               s->io_bits = 0xf;       /* all bits output */
+
+               /* insn_config - for digital output memory */
+               s->insn_config = this_board->do_config;
+               s->insn_write = this_board->do_write;
+               s->insn_bits = this_board->do_bits;
+               s->insn_read = this_board->do_read;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
 
-               /*  Allocate and Initialise Timer Subdevice Structures */
-               s = &dev->subdevices[4];
-               if (devpriv->s_EeParameters.i_Timer) {
-                       s->type = COMEDI_SUBD_TIMER;
-                       s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-                       s->n_chan = 1;
-                       s->maxdata = 0;
-                       s->len_chanlist = 1;
-                       s->range_table = &range_digital;
-
-                       s->insn_write = this_board->timer_write;
-                       s->insn_read = this_board->timer_read;
-                       s->insn_config = this_board->timer_config;
-                       s->insn_bits = this_board->timer_bits;
-               } else {
-                       s->type = COMEDI_SUBD_UNUSED;
-               }
+       /*  Allocate and Initialise Timer Subdevice Structures */
+       s = &dev->subdevices[4];
+       if (devpriv->s_EeParameters.i_Timer) {
+               s->type = COMEDI_SUBD_TIMER;
+               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = 1;
+               s->maxdata = 0;
+               s->len_chanlist = 1;
+               s->range_table = &range_digital;
+
+               s->insn_write = this_board->timer_write;
+               s->insn_read = this_board->timer_read;
+               s->insn_config = this_board->timer_config;
+               s->insn_bits = this_board->timer_bits;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
 
-               /*  Allocate and Initialise TTL */
-               s = &dev->subdevices[5];
-               if (this_board->i_NbrTTLChannel) {
-                       s->type = COMEDI_SUBD_TTLIO;
-                       s->subdev_flags =
-                               SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON;
-                       s->n_chan = this_board->i_NbrTTLChannel;
-                       s->maxdata = 1;
-                       s->io_bits = 0; /* all bits input */
-                       s->len_chanlist = this_board->i_NbrTTLChannel;
-                       s->range_table = &range_digital;
-                       s->insn_config = this_board->ttl_config;
-                       s->insn_bits = this_board->ttl_bits;
-                       s->insn_read = this_board->ttl_read;
-                       s->insn_write = this_board->ttl_write;
-               } else {
-                       s->type = COMEDI_SUBD_UNUSED;
-               }
+       /*  Allocate and Initialise TTL */
+       s = &dev->subdevices[5];
+       if (this_board->i_NbrTTLChannel) {
+               s->type = COMEDI_SUBD_TTLIO;
+               s->subdev_flags =
+                       SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = this_board->i_NbrTTLChannel;
+               s->maxdata = 1;
+               s->io_bits = 0; /* all bits input */
+               s->len_chanlist = this_board->i_NbrTTLChannel;
+               s->range_table = &range_digital;
+               s->insn_config = this_board->ttl_config;
+               s->insn_bits = this_board->ttl_bits;
+               s->insn_read = this_board->ttl_read;
+               s->insn_write = this_board->ttl_write;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
 
-               /* EEPROM */
-               s = &dev->subdevices[6];
-               if (this_board->i_PCIEeprom) {
-                       s->type = COMEDI_SUBD_MEMORY;
-                       s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
-                       s->n_chan = 256;
-                       s->maxdata = 0xffff;
-                       s->insn_read = i_ADDIDATA_InsnReadEeprom;
-               } else {
-                       s->type = COMEDI_SUBD_UNUSED;
-               }
+       /* EEPROM */
+       s = &dev->subdevices[6];
+       if (this_board->i_PCIEeprom) {
+               s->type = COMEDI_SUBD_MEMORY;
+               s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
+               s->n_chan = 256;
+               s->maxdata = 0xffff;
+               s->insn_read = i_ADDIDATA_InsnReadEeprom;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
        }
 
-       printk("\ni_ADDI_Attach end\n");
        i_ADDI_Reset(dev);
-       devpriv->b_ValidDriver = 1;
        return 0;
 }
 
 static void i_ADDI_Detach(struct comedi_device *dev)
 {
        const struct addi_board *this_board = comedi_board(dev);
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct addi_private *devpriv = dev->private;
 
        if (devpriv) {
-               if (devpriv->b_ValidDriver)
+               if (dev->iobase)
                        i_ADDI_Reset(dev);
                if (dev->irq)
                        free_irq(dev->irq, dev);
                if ((this_board->pc_EepromChip == NULL) ||
                    (strcmp(this_board->pc_EepromChip, ADDIDATA_9054) != 0)) {
-                       if (devpriv->allocated)
-                               i_pci_card_free(devpriv->amcc);
                        if (devpriv->ul_DmaBufferVirtual[0]) {
                                free_pages((unsigned long)devpriv->
                                        ul_DmaBufferVirtual[0],
@@ -457,41 +386,10 @@ static void i_ADDI_Detach(struct comedi_device *dev)
                        }
                } else {
                        iounmap(devpriv->dw_AiBase);
-                       if (devpriv->allocated)
-                               i_pci_card_free(devpriv->amcc);
-               }
-               if (pci_list_builded) {
-                       v_pci_card_list_cleanup(this_board->i_VendorId);
-                       pci_list_builded = 0;
                }
        }
+       if (pcidev) {
+               if (dev->iobase)
+                       comedi_pci_disable(pcidev);
+       }
 }
-
-static struct comedi_driver addi_driver = {
-       .driver_name    = ADDIDATA_DRIVER_NAME,
-       .module         = THIS_MODULE,
-       .attach         = i_ADDI_Attach,
-       .detach         = i_ADDI_Detach,
-       .num_names      = ARRAY_SIZE(boardtypes),
-       .board_name     = &boardtypes[0].pc_DriverName,
-       .offset         = sizeof(struct addi_board),
-};
-
-static int __devinit addi_pci_probe(struct pci_dev *dev,
-                                   const struct pci_device_id *ent)
-{
-       return comedi_pci_auto_config(dev, &addi_driver);
-}
-
-static void __devexit addi_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver addi_pci_driver = {
-       .name           = ADDIDATA_DRIVER_NAME,
-       .id_table       = addi_apci_tbl,
-       .probe          = &addi_pci_probe,
-       .remove         = __devexit_p(&addi_pci_remove),
-};
-module_comedi_pci_driver(addi_driver, addi_pci_driver);
index 6b71dbbfb22b0cc93ad50d222994e3c72c748ae3..6d8b29f945d5b7a1dd77be99fe3bcfb6ebe317bd 100644 (file)
  * any later version.
  */
 
-#include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
 #include <linux/interrupt.h>
-#include <linux/timex.h>
-#include <linux/timer.h>
-#include <linux/pci.h>
-#include <linux/io.h>
-#include <linux/kmod.h>
-#include <linux/uaccess.h>
-#include "../../comedidev.h"
-#include "addi_amcc_s5933.h"
-
-#define ERROR  -1
-#define SUCCESS        1
 
 #define LOBYTE(W)      (unsigned char)((W) & 0xFF)
 #define HIBYTE(W)      (unsigned char)(((W) >> 8) & 0xFF)
@@ -312,9 +294,6 @@ struct addi_private {
        int i_IobaseAddon;      /* addon base address */
        int i_IobaseReserved;
        void __iomem *dw_AiBase;
-       struct pcilst_struct *amcc;     /*  ptr too AMCC data */
-       unsigned char allocated;                /*  we have blocked card */
-       unsigned char b_ValidDriver;    /*  driver is ok */
        unsigned char b_AiContinuous;   /*  we do unlimited AI */
        unsigned char b_AiInitialisation;
        unsigned int ui_AiActualScan;   /* how many scans we finished */
@@ -410,5 +389,3 @@ struct addi_private {
                                        /*  Minimum Delay in Nano secs */
        } s_EeParameters;
 };
-
-static unsigned short pci_list_builded;        /* set to 1 when list of card is known */
index f28c737a173d2ee5c0236e86f0e1b0f1d2b23f4b..b05f8505c894fa69af48ae2955df3dcb1963021f 100644 (file)
@@ -44,7 +44,35 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   |          |           |                                                |
   +----------+-----------+------------------------------------------------+
 */
-#include "hwdrv_APCI1710.h"
+
+#define COMEDI_SUBD_TTLIO              11      /* Digital Input Output But TTL */
+#define COMEDI_SUBD_PWM                        12      /* Pulse width Measurement */
+#define COMEDI_SUBD_SSI                        13      /* Synchronous serial interface */
+#define COMEDI_SUBD_TOR                        14      /* Tor counter */
+#define COMEDI_SUBD_CHRONO             15      /* Chrono meter */
+#define COMEDI_SUBD_PULSEENCODER       16      /* Pulse Encoder INP CPT */
+#define COMEDI_SUBD_INCREMENTALCOUNTER 17      /* Incremental Counter */
+
+#define APCI1710_BOARD_NAME            "apci1710"
+#define APCI1710_BOARD_DEVICE_ID       0x818F
+#define APCI1710_ADDRESS_RANGE         256
+#define APCI1710_CONFIG_ADDRESS_RANGE  8
+#define APCI1710_INCREMENTAL_COUNTER   0x53430000UL
+#define APCI1710_SSI_COUNTER           0x53490000UL
+#define APCI1710_TTL_IO                        0x544C0000UL
+#define APCI1710_DIGITAL_IO            0x44490000UL
+#define APCI1710_82X54_TIMER           0x49430000UL
+#define APCI1710_CHRONOMETER           0x43480000UL
+#define APCI1710_PULSE_ENCODER         0x495A0000UL
+#define APCI1710_TOR_COUNTER           0x544F0000UL
+#define APCI1710_PWM                   0x50570000UL
+#define APCI1710_ETM                   0x45540000UL
+#define APCI1710_CDA                   0x43440000UL
+#define APCI1710_DISABLE               0
+#define APCI1710_ENABLE                        1
+#define APCI1710_SYNCHRONOUS_MODE      1
+#define APCI1710_ASYNCHRONOUS_MODE     0
+
 #include "APCI1710_Inp_cpt.c"
 
 #include "APCI1710_Ssi.c"
@@ -56,6 +84,33 @@ You should also find the complete GPL in the COPYING file accompanying this sour
 #include "APCI1710_Pwm.c"
 #include "APCI1710_INCCPT.c"
 
+static const struct comedi_lrange range_apci1710_ttl = {
+       4, {
+               BIP_RANGE(10),
+               BIP_RANGE(5),
+               BIP_RANGE(2),
+               BIP_RANGE(1)
+       }
+};
+
+static const struct comedi_lrange range_apci1710_ssi = {
+       4, {
+               BIP_RANGE(10),
+               BIP_RANGE(5),
+               BIP_RANGE(2),
+               BIP_RANGE(1)
+       }
+};
+
+static const struct comedi_lrange range_apci1710_inccpt = {
+       4, {
+               BIP_RANGE(10),
+               BIP_RANGE(5),
+               BIP_RANGE(2),
+               BIP_RANGE(1)
+       }
+};
+
 static void i_ADDI_AttachPCI1710(struct comedi_device *dev)
 {
        struct comedi_subdevice *s;
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.h
deleted file mode 100644 (file)
index dab528e..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#define COMEDI_SUBD_TTLIO              11      /* Digital Input Output But TTL */
-#define COMEDI_SUBD_PWM                        12      /* Pulse width Measurement */
-#define COMEDI_SUBD_SSI                        13      /* Synchronous serial interface */
-#define COMEDI_SUBD_TOR                        14      /* Tor counter */
-#define COMEDI_SUBD_CHRONO             15      /* Chrono meter */
-#define COMEDI_SUBD_PULSEENCODER       16      /* Pulse Encoder INP CPT */
-#define COMEDI_SUBD_INCREMENTALCOUNTER 17      /* Incremental Counter */
-
-#define APCI1710_BOARD_NAME            "apci1710"
-#define APCI1710_BOARD_DEVICE_ID       0x818F
-#define APCI1710_ADDRESS_RANGE         256
-#define APCI1710_CONFIG_ADDRESS_RANGE  8
-#define APCI1710_INCREMENTAL_COUNTER   0x53430000UL
-#define APCI1710_SSI_COUNTER           0x53490000UL
-#define APCI1710_TTL_IO                        0x544C0000UL
-#define APCI1710_DIGITAL_IO            0x44490000UL
-#define APCI1710_82X54_TIMER           0x49430000UL
-#define APCI1710_CHRONOMETER           0x43480000UL
-#define APCI1710_PULSE_ENCODER         0x495A0000UL
-#define APCI1710_TOR_COUNTER           0x544F0000UL
-#define APCI1710_PWM                   0x50570000UL
-#define APCI1710_ETM                   0x45540000UL
-#define APCI1710_CDA                   0x43440000UL
-#define APCI1710_DISABLE               0
-#define APCI1710_ENABLE                        1
-#define APCI1710_SYNCHRONOUS_MODE      1
-#define APCI1710_ASYNCHRONOUS_MODE     0
-
-/* MODULE INFO STRUCTURE */
-
-static const struct comedi_lrange range_apci1710_ttl = { 4, {
-                                                     BIP_RANGE(10),
-                                                     BIP_RANGE(5),
-                                                     BIP_RANGE(2),
-                                                     BIP_RANGE(1)
-                                                     }
-};
-
-static const struct comedi_lrange range_apci1710_ssi = { 4, {
-                                                     BIP_RANGE(10),
-                                                     BIP_RANGE(5),
-                                                     BIP_RANGE(2),
-                                                     BIP_RANGE(1)
-                                                     }
-};
-
-static const struct comedi_lrange range_apci1710_inccpt = { 4, {
-                                                        BIP_RANGE(10),
-                                                        BIP_RANGE(5),
-                                                        BIP_RANGE(2),
-                                                        BIP_RANGE(1)
-                                                        }
-};
index 6d81575c78db8c50a2ec8fa193b5ae295cafae2d..3d66e48e0cf7b4417f0381877e280cff538daf24 100644 (file)
@@ -46,12 +46,70 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +----------+-----------+------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
-#include "hwdrv_apci035.h"
+/* Card Specific information */
+#define APCI035_ADDRESS_RANGE          255
+
+/* Timer / Watchdog Related Defines */
+#define APCI035_TCW_SYNC_ENABLEDISABLE 0
+#define APCI035_TCW_RELOAD_VALUE       4
+#define APCI035_TCW_TIMEBASE           8
+#define APCI035_TCW_PROG               12
+#define APCI035_TCW_TRIG_STATUS                16
+#define APCI035_TCW_IRQ                        20
+#define APCI035_TCW_WARN_TIMEVAL       24
+#define APCI035_TCW_WARN_TIMEBASE      28
+
+#define ADDIDATA_TIMER                 0
+/* #define ADDIDATA_WATCHDOG           1 */
+
+#define APCI035_TW1                    0
+#define APCI035_TW2                    32
+#define APCI035_TW3                    64
+#define APCI035_TW4                    96
+
+#define APCI035_AI_OFFSET              0
+#define APCI035_TEMP                   128
+#define APCI035_ALR_SEQ                        4
+#define APCI035_START_STOP_INDEX       8
+#define APCI035_ALR_START_STOP         12
+#define APCI035_ALR_IRQ                        16
+#define APCI035_EOS                    20
+#define APCI035_CHAN_NO                        24
+#define APCI035_CHAN_VAL               28
+#define APCI035_CONV_TIME_TIME_BASE    36
+#define APCI035_RELOAD_CONV_TIME_VAL   32
+#define APCI035_DELAY_TIME_TIME_BASE   44
+#define APCI035_RELOAD_DELAY_TIME_VAL  40
+#define ENABLE_EXT_TRIG                        1
+#define ENABLE_EXT_GATE                        2
+#define ENABLE_EXT_TRIG_GATE           3
+
+#define ANALOG_INPUT                   0
+#define TEMPERATURE                    1
+#define RESISTANCE                     2
+
+#define ADDIDATA_GREATER_THAN_TEST     0
+#define ADDIDATA_LESS_THAN_TEST                1
+
+#define APCI035_MAXVOLT                        2.5
+
+#define ADDIDATA_UNIPOLAR              1
+#define ADDIDATA_BIPOLAR               2
+
+/* ANALOG INPUT RANGE */
+static struct comedi_lrange range_apci035_ai = {
+       8, {
+               BIP_RANGE(10),
+               BIP_RANGE(5),
+               BIP_RANGE(2),
+               BIP_RANGE(1),
+               UNI_RANGE(10),
+               UNI_RANGE(5),
+               UNI_RANGE(2),
+               UNI_RANGE(1)
+       }
+};
+
 static int i_WatchdogNbr = 0;
 static int i_Temp = 0;
 static int i_Flag = 1;
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci035.h
deleted file mode 100644 (file)
index 5b5c4a3..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-/* Card Specific information */
-#define APCI035_ADDRESS_RANGE          255
-
-/* ANALOG INPUT RANGE */
-static struct comedi_lrange range_apci035_ai = { 8, {
-                                      BIP_RANGE(10),
-                                      BIP_RANGE(5),
-                                      BIP_RANGE(2),
-                                      BIP_RANGE(1),
-                                      UNI_RANGE(10),
-                                      UNI_RANGE(5),
-                                      UNI_RANGE(2),
-                                      UNI_RANGE(1)
-                                      }
-};
-
-/* Timer / Watchdog Related Defines */
-#define APCI035_TCW_SYNC_ENABLEDISABLE 0
-#define APCI035_TCW_RELOAD_VALUE       4
-#define APCI035_TCW_TIMEBASE           8
-#define APCI035_TCW_PROG               12
-#define APCI035_TCW_TRIG_STATUS                16
-#define APCI035_TCW_IRQ                        20
-#define APCI035_TCW_WARN_TIMEVAL       24
-#define APCI035_TCW_WARN_TIMEBASE      28
-
-#define ADDIDATA_TIMER                 0
-/* #define ADDIDATA_WATCHDOG           1 */
-
-#define APCI035_TW1                               0
-#define APCI035_TW2                               32
-#define APCI035_TW3                               64
-#define APCI035_TW4                               96
-
-#define APCI035_AI_OFFSET                        0
-#define APCI035_TEMP                             128
-#define APCI035_ALR_SEQ                          4
-#define APCI035_START_STOP_INDEX                 8
-#define APCI035_ALR_START_STOP                   12
-#define APCI035_ALR_IRQ                          16
-#define APCI035_EOS                              20
-#define APCI035_CHAN_NO                          24
-#define APCI035_CHAN_VAL                         28
-#define APCI035_CONV_TIME_TIME_BASE    36
-#define APCI035_RELOAD_CONV_TIME_VAL   32
-#define APCI035_DELAY_TIME_TIME_BASE   44
-#define APCI035_RELOAD_DELAY_TIME_VAL  40
-#define ENABLE_EXT_TRIG                        1
-#define ENABLE_EXT_GATE                        2
-#define ENABLE_EXT_TRIG_GATE           3
-
-#define ANALOG_INPUT                   0
-#define TEMPERATURE                    1
-#define RESISTANCE                     2
-
-#define ADDIDATA_GREATER_THAN_TEST     0
-#define ADDIDATA_LESS_THAN_TEST                1
-
-#define APCI035_MAXVOLT                         2.5
-
-#define ADDIDATA_UNIPOLAR                        1
-#define ADDIDATA_BIPOLAR                         2
-
-/* ADDIDATA Enable Disable */
-#define ADDIDATA_ENABLE                                1
-#define ADDIDATA_DISABLE                       0
index e4e85f472f0f9955dea861162776911f1c574dbc..30a44aea0c2f0d472f9a6890d37548b464ab4c55 100644 (file)
@@ -46,13 +46,26 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +----------+-----------+------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
-#include "hwdrv_apci1032.h"
-#include <linux/delay.h>
+/*********      Definitions for APCI-1032 card  *****/
+
+#define APCI1032_ADDRESS_RANGE                 20
+/* DIGITAL INPUT DEFINE */
+
+#define APCI1032_DIGITAL_IP                    0
+#define APCI1032_DIGITAL_IP_INTERRUPT_MODE1    4
+#define APCI1032_DIGITAL_IP_INTERRUPT_MODE2    8
+#define APCI1032_DIGITAL_IP_IRQ                        16
+
+/* Digital Input IRQ Function Selection */
+#define ADDIDATA_OR                            0
+#define ADDIDATA_AND                           1
+
+/* Digital Input Interrupt Status */
+#define APCI1032_DIGITAL_IP_INTERRUPT_STATUS   12
+
+/* Digital Input Interrupt Enable Disable. */
+#define APCI1032_DIGITAL_IP_INTERRUPT_ENABLE   0x4
+#define APCI1032_DIGITAL_IP_INTERRUPT_DISABLE  0xfffffffb
 
 static unsigned int ui_InterruptStatus;
 
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.h
deleted file mode 100644 (file)
index f0b32e8..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-/*********      Definitions for APCI-1032 card  *****/
-
-#define APCI1032_ADDRESS_RANGE  20
-/* DIGITAL INPUT DEFINE */
-
-#define APCI1032_DIGITAL_IP                     0
-#define APCI1032_DIGITAL_IP_INTERRUPT_MODE1     4
-#define APCI1032_DIGITAL_IP_INTERRUPT_MODE2     8
-#define APCI1032_DIGITAL_IP_IRQ                 16
-
-/* Digital Input IRQ Function Selection */
-#define ADDIDATA_OR                  0
-#define ADDIDATA_AND                 1
-
-/* Digital Input Interrupt Status */
-#define APCI1032_DIGITAL_IP_INTERRUPT_STATUS    12
-
-/* Digital Input Interrupt Enable Disable. */
-#define APCI1032_DIGITAL_IP_INTERRUPT_ENABLE    0x4
-#define APCI1032_DIGITAL_IP_INTERRUPT_DISABLE   0xFFFFFFFB
-
-/* ADDIDATA Enable Disable */
-
-#define ADDIDATA_ENABLE                            1
-#define ADDIDATA_DISABLE                           0
index cc47821a7457b64c6200a0bdf2016ef976dcec40..771a3054f926ad58e92f3773fccfcade58d3cf70 100644 (file)
@@ -45,7 +45,105 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   |          |           |                                                |
   +----------+-----------+------------------------------------------------+
 */
-#include "hwdrv_apci1500.h"
+
+/*********      Definitions for APCI-1500 card  *****/
+
+/* Card Specific information */
+#define APCI1500_ADDRESS_RANGE         4
+
+/* DIGITAL INPUT-OUTPUT DEFINE */
+
+#define APCI1500_DIGITAL_OP            2
+#define APCI1500_DIGITAL_IP            0
+#define APCI1500_AND                   2
+#define APCI1500_OR                    4
+#define APCI1500_OR_PRIORITY           6
+#define APCI1500_CLK_SELECT            0
+#define COUNTER1                       0
+#define COUNTER2                       1
+#define COUNTER3                       2
+#define APCI1500_COUNTER               0x20
+#define APCI1500_TIMER                 0
+#define APCI1500_WATCHDOG              0
+#define APCI1500_SINGLE                        0
+#define APCI1500_CONTINUOUS            0x80
+#define APCI1500_DISABLE               0
+#define APCI1500_ENABLE                        1
+#define APCI1500_SOFTWARE_TRIGGER      0x4
+#define APCI1500_HARDWARE_TRIGGER      0x10
+#define APCI1500_SOFTWARE_GATE         0
+#define APCI1500_HARDWARE_GATE         0x8
+#define START                          0
+#define STOP                           1
+#define TRIGGER                                2
+
+/*
+ * Zillog I/O enumeration
+ */
+enum {
+       APCI1500_Z8536_PORT_C,
+       APCI1500_Z8536_PORT_B,
+       APCI1500_Z8536_PORT_A,
+       APCI1500_Z8536_CONTROL_REGISTER
+};
+
+/*
+ * Z8536 CIO Internal Address
+ */
+enum {
+       APCI1500_RW_MASTER_INTERRUPT_CONTROL,
+       APCI1500_RW_MASTER_CONFIGURATION_CONTROL,
+       APCI1500_RW_PORT_A_INTERRUPT_CONTROL,
+       APCI1500_RW_PORT_B_INTERRUPT_CONTROL,
+       APCI1500_RW_TIMER_COUNTER_INTERRUPT_VECTOR,
+       APCI1500_RW_PORT_C_DATA_PCITCH_POLARITY,
+       APCI1500_RW_PORT_C_DATA_DIRECTION,
+       APCI1500_RW_PORT_C_SPECIAL_IO_CONTROL,
+
+       APCI1500_RW_PORT_A_COMMAND_AND_STATUS,
+       APCI1500_RW_PORT_B_COMMAND_AND_STATUS,
+       APCI1500_RW_CPT_TMR1_CMD_STATUS,
+       APCI1500_RW_CPT_TMR2_CMD_STATUS,
+       APCI1500_RW_CPT_TMR3_CMD_STATUS,
+       APCI1500_RW_PORT_A_DATA,
+       APCI1500_RW_PORT_B_DATA,
+       APCI1500_RW_PORT_C_DATA,
+
+       APCI1500_R_CPT_TMR1_VALUE_HIGH,
+       APCI1500_R_CPT_TMR1_VALUE_LOW,
+       APCI1500_R_CPT_TMR2_VALUE_HIGH,
+       APCI1500_R_CPT_TMR2_VALUE_LOW,
+       APCI1500_R_CPT_TMR3_VALUE_HIGH,
+       APCI1500_R_CPT_TMR3_VALUE_LOW,
+       APCI1500_RW_CPT_TMR1_TIME_CST_HIGH,
+       APCI1500_RW_CPT_TMR1_TIME_CST_LOW,
+       APCI1500_RW_CPT_TMR2_TIME_CST_HIGH,
+       APCI1500_RW_CPT_TMR2_TIME_CST_LOW,
+       APCI1500_RW_CPT_TMR3_TIME_CST_HIGH,
+       APCI1500_RW_CPT_TMR3_TIME_CST_LOW,
+       APCI1500_RW_CPT_TMR1_MODE_SPECIFICATION,
+       APCI1500_RW_CPT_TMR2_MODE_SPECIFICATION,
+       APCI1500_RW_CPT_TMR3_MODE_SPECIFICATION,
+       APCI1500_R_CURRENT_VECTOR,
+
+       APCI1500_RW_PORT_A_SPECIFICATION,
+       APCI1500_RW_PORT_A_HANDSHAKE_SPECIFICATION,
+       APCI1500_RW_PORT_A_DATA_PCITCH_POLARITY,
+       APCI1500_RW_PORT_A_DATA_DIRECTION,
+       APCI1500_RW_PORT_A_SPECIAL_IO_CONTROL,
+       APCI1500_RW_PORT_A_PATTERN_POLARITY,
+       APCI1500_RW_PORT_A_PATTERN_TRANSITION,
+       APCI1500_RW_PORT_A_PATTERN_MASK,
+
+       APCI1500_RW_PORT_B_SPECIFICATION,
+       APCI1500_RW_PORT_B_HANDSHAKE_SPECIFICATION,
+       APCI1500_RW_PORT_B_DATA_PCITCH_POLARITY,
+       APCI1500_RW_PORT_B_DATA_DIRECTION,
+       APCI1500_RW_PORT_B_SPECIAL_IO_CONTROL,
+       APCI1500_RW_PORT_B_PATTERN_POLARITY,
+       APCI1500_RW_PORT_B_PATTERN_TRANSITION,
+       APCI1500_RW_PORT_B_PATTERN_MASK
+};
 
 static int i_TimerCounter1Init = 0;
 static int i_TimerCounter2Init = 0;
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.h
deleted file mode 100644 (file)
index 989e880..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-/*********      Definitions for APCI-1500 card  *****/
-
-/* Card Specific information */
-#define APCI1500_ADDRESS_RANGE              4
-
-/* DIGITAL INPUT-OUTPUT DEFINE */
-
-#define  APCI1500_DIGITAL_OP                   2
-#define  APCI1500_DIGITAL_IP                    0
-#define  APCI1500_AND                              2
-#define  APCI1500_OR                               4
-#define  APCI1500_OR_PRIORITY                      6
-#define  APCI1500_CLK_SELECT                    0
-#define  COUNTER1                               0
-#define  COUNTER2                               1
-#define  COUNTER3                               2
-#define  APCI1500_COUNTER                              0x20
-#define  APCI1500_TIMER                                0
-#define  APCI1500_WATCHDOG                         0
-#define  APCI1500_SINGLE                           0
-#define  APCI1500_CONTINUOUS                       0x80
-#define  APCI1500_DISABLE                              0
-#define  APCI1500_ENABLE                               1
-#define  APCI1500_SOFTWARE_TRIGGER                 0x4
-#define  APCI1500_HARDWARE_TRIGGER                 0x10
-#define  APCI1500_SOFTWARE_GATE                    0
-#define  APCI1500_HARDWARE_GATE                    0x8
-#define  START                                     0
-#define  STOP                                      1
-#define  TRIGGER                                           2
-
-/*
- * Zillog I/O enumeration
- */
-enum {
-       APCI1500_Z8536_PORT_C,
-       APCI1500_Z8536_PORT_B,
-       APCI1500_Z8536_PORT_A,
-       APCI1500_Z8536_CONTROL_REGISTER
-};
-
-/*
- * Z8536 CIO Internal Address
- */
-enum {
-       APCI1500_RW_MASTER_INTERRUPT_CONTROL,
-       APCI1500_RW_MASTER_CONFIGURATION_CONTROL,
-       APCI1500_RW_PORT_A_INTERRUPT_CONTROL,
-       APCI1500_RW_PORT_B_INTERRUPT_CONTROL,
-       APCI1500_RW_TIMER_COUNTER_INTERRUPT_VECTOR,
-       APCI1500_RW_PORT_C_DATA_PCITCH_POLARITY,
-       APCI1500_RW_PORT_C_DATA_DIRECTION,
-       APCI1500_RW_PORT_C_SPECIAL_IO_CONTROL,
-
-       APCI1500_RW_PORT_A_COMMAND_AND_STATUS,
-       APCI1500_RW_PORT_B_COMMAND_AND_STATUS,
-       APCI1500_RW_CPT_TMR1_CMD_STATUS,
-       APCI1500_RW_CPT_TMR2_CMD_STATUS,
-       APCI1500_RW_CPT_TMR3_CMD_STATUS,
-       APCI1500_RW_PORT_A_DATA,
-       APCI1500_RW_PORT_B_DATA,
-       APCI1500_RW_PORT_C_DATA,
-
-       APCI1500_R_CPT_TMR1_VALUE_HIGH,
-       APCI1500_R_CPT_TMR1_VALUE_LOW,
-       APCI1500_R_CPT_TMR2_VALUE_HIGH,
-       APCI1500_R_CPT_TMR2_VALUE_LOW,
-       APCI1500_R_CPT_TMR3_VALUE_HIGH,
-       APCI1500_R_CPT_TMR3_VALUE_LOW,
-       APCI1500_RW_CPT_TMR1_TIME_CST_HIGH,
-       APCI1500_RW_CPT_TMR1_TIME_CST_LOW,
-       APCI1500_RW_CPT_TMR2_TIME_CST_HIGH,
-       APCI1500_RW_CPT_TMR2_TIME_CST_LOW,
-       APCI1500_RW_CPT_TMR3_TIME_CST_HIGH,
-       APCI1500_RW_CPT_TMR3_TIME_CST_LOW,
-       APCI1500_RW_CPT_TMR1_MODE_SPECIFICATION,
-       APCI1500_RW_CPT_TMR2_MODE_SPECIFICATION,
-       APCI1500_RW_CPT_TMR3_MODE_SPECIFICATION,
-       APCI1500_R_CURRENT_VECTOR,
-
-       APCI1500_RW_PORT_A_SPECIFICATION,
-       APCI1500_RW_PORT_A_HANDSHAKE_SPECIFICATION,
-       APCI1500_RW_PORT_A_DATA_PCITCH_POLARITY,
-       APCI1500_RW_PORT_A_DATA_DIRECTION,
-       APCI1500_RW_PORT_A_SPECIAL_IO_CONTROL,
-       APCI1500_RW_PORT_A_PATTERN_POLARITY,
-       APCI1500_RW_PORT_A_PATTERN_TRANSITION,
-       APCI1500_RW_PORT_A_PATTERN_MASK,
-
-       APCI1500_RW_PORT_B_SPECIFICATION,
-       APCI1500_RW_PORT_B_HANDSHAKE_SPECIFICATION,
-       APCI1500_RW_PORT_B_DATA_PCITCH_POLARITY,
-       APCI1500_RW_PORT_B_DATA_DIRECTION,
-       APCI1500_RW_PORT_B_SPECIAL_IO_CONTROL,
-       APCI1500_RW_PORT_B_PATTERN_POLARITY,
-       APCI1500_RW_PORT_B_PATTERN_TRANSITION,
-       APCI1500_RW_PORT_B_PATTERN_MASK
-};
index a3045f85513e1016bc8e65cfe0c5409ce3da6c46..7504c520600c180ebdaee4a07c90403be2673e39 100644 (file)
@@ -46,12 +46,24 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +----------+-----------+------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
-#include "hwdrv_apci1516.h"
+/*********      Definitions for APCI-1516 card  *****/
+
+/* Card Specific information */
+#define APCI1516_ADDRESS_RANGE                 8
+
+/* DIGITAL INPUT-OUTPUT DEFINE */
+
+#define APCI1516_DIGITAL_OP                    4
+#define APCI1516_DIGITAL_OP_RW                 4
+#define APCI1516_DIGITAL_IP                    0
+
+/* TIMER COUNTER WATCHDOG DEFINES */
+
+#define ADDIDATA_WATCHDOG                      2
+#define APCI1516_DIGITAL_OP_WATCHDOG           0
+#define APCI1516_WATCHDOG_ENABLEDISABLE                12
+#define APCI1516_WATCHDOG_RELOAD_VALUE         4
+#define APCI1516_WATCHDOG_STATUS               16
 
 /*
 +----------------------------------------------------------------------------+
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1516.h
deleted file mode 100644 (file)
index aaf564f..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-/*********      Definitions for APCI-1516 card  *****/
-
-/* Card Specific information */
-#define APCI1516_ADDRESS_RANGE                   8
-
-/* DIGITAL INPUT-OUTPUT DEFINE */
-
-#define APCI1516_DIGITAL_OP                    4
-#define APCI1516_DIGITAL_OP_RW                         4
-#define APCI1516_DIGITAL_IP                     0
-
-/* TIMER COUNTER WATCHDOG DEFINES */
-
-#define ADDIDATA_WATCHDOG                          2
-#define APCI1516_DIGITAL_OP_WATCHDOG               0
-#define APCI1516_WATCHDOG_ENABLEDISABLE            12
-#define APCI1516_WATCHDOG_RELOAD_VALUE             4
-#define APCI1516_WATCHDOG_STATUS                   16
index 5fbd03db3ba6989b74a7a87dcfc0d7f1baac9d4f..0f734d5be4cbe8c15a8e3b836f796756ec4d3fa6 100644 (file)
@@ -46,14 +46,62 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +----------+-----------+------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
-
-#include <linux/delay.h>
-#include "hwdrv_apci1564.h"
+/*********      Definitions for APCI-1564 card  *****/
+
+#define APCI1564_ADDRESS_RANGE                         128
+
+/* DIGITAL INPUT-OUTPUT DEFINE */
+/* Input defines */
+#define APCI1564_DIGITAL_IP                            0x04
+#define APCI1564_DIGITAL_IP_INTERRUPT_MODE1            4
+#define APCI1564_DIGITAL_IP_INTERRUPT_MODE2            8
+#define APCI1564_DIGITAL_IP_IRQ                                16
+
+/* Output defines */
+#define APCI1564_DIGITAL_OP                            0x18
+#define APCI1564_DIGITAL_OP_RW                         0
+#define APCI1564_DIGITAL_OP_INTERRUPT                  4
+#define APCI1564_DIGITAL_OP_IRQ                                12
+
+/* Digital Input IRQ Function Selection */
+#define ADDIDATA_OR                                    0
+#define ADDIDATA_AND                                   1
+
+/* Digital Input Interrupt Status */
+#define APCI1564_DIGITAL_IP_INTERRUPT_STATUS           12
+
+/* Digital Output Interrupt Status */
+#define APCI1564_DIGITAL_OP_INTERRUPT_STATUS           8
+
+/* Digital Input Interrupt Enable Disable. */
+#define APCI1564_DIGITAL_IP_INTERRUPT_ENABLE           0x4
+#define APCI1564_DIGITAL_IP_INTERRUPT_DISABLE          0xfffffffb
+
+/* Digital Output Interrupt Enable Disable. */
+#define APCI1564_DIGITAL_OP_VCC_INTERRUPT_ENABLE       0x1
+#define APCI1564_DIGITAL_OP_VCC_INTERRUPT_DISABLE      0xfffffffe
+#define APCI1564_DIGITAL_OP_CC_INTERRUPT_ENABLE                0x2
+#define APCI1564_DIGITAL_OP_CC_INTERRUPT_DISABLE       0xfffffffd
+
+/* TIMER COUNTER WATCHDOG DEFINES */
+
+#define ADDIDATA_TIMER                                 0
+#define ADDIDATA_COUNTER                               1
+#define ADDIDATA_WATCHDOG                              2
+#define APCI1564_DIGITAL_OP_WATCHDOG                   0x28
+#define APCI1564_TIMER                                 0x48
+#define APCI1564_COUNTER1                              0x0
+#define APCI1564_COUNTER2                              0x20
+#define APCI1564_COUNTER3                              0x40
+#define APCI1564_COUNTER4                              0x60
+#define APCI1564_TCW_SYNC_ENABLEDISABLE                        0
+#define APCI1564_TCW_RELOAD_VALUE                      4
+#define APCI1564_TCW_TIMEBASE                          8
+#define APCI1564_TCW_PROG                              12
+#define APCI1564_TCW_TRIG_STATUS                       16
+#define APCI1564_TCW_IRQ                               20
+#define APCI1564_TCW_WARN_TIMEVAL                      24
+#define APCI1564_TCW_WARN_TIMEBASE                     28
 
 /* Global variables */
 static unsigned int ui_InterruptStatus_1564 = 0;
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.h
deleted file mode 100644 (file)
index df69fd0..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-/*********      Definitions for APCI-1564 card  *****/
-
-#define APCI1564_ADDRESS_RANGE                  128
-
-/* DIGITAL INPUT-OUTPUT DEFINE */
-/* Input defines */
-#define APCI1564_DIGITAL_IP                     0x04
-#define APCI1564_DIGITAL_IP_INTERRUPT_MODE1     4
-#define APCI1564_DIGITAL_IP_INTERRUPT_MODE2     8
-#define APCI1564_DIGITAL_IP_IRQ                 16
-
-/* Output defines */
-#define APCI1564_DIGITAL_OP                    0x18
-#define APCI1564_DIGITAL_OP_RW                 0
-#define APCI1564_DIGITAL_OP_INTERRUPT           4
-#define APCI1564_DIGITAL_OP_IRQ                 12
-
-/* Digital Input IRQ Function Selection */
-#define ADDIDATA_OR                             0
-#define ADDIDATA_AND                            1
-
-/* Digital Input Interrupt Status */
-#define APCI1564_DIGITAL_IP_INTERRUPT_STATUS    12
-
-/* Digital Output Interrupt Status */
-#define APCI1564_DIGITAL_OP_INTERRUPT_STATUS    8
-
-/* Digital Input Interrupt Enable Disable. */
-#define APCI1564_DIGITAL_IP_INTERRUPT_ENABLE    0x4
-#define APCI1564_DIGITAL_IP_INTERRUPT_DISABLE   0xFFFFFFFB
-
-/* Digital Output Interrupt Enable Disable. */
-#define APCI1564_DIGITAL_OP_VCC_INTERRUPT_ENABLE   0x1
-#define APCI1564_DIGITAL_OP_VCC_INTERRUPT_DISABLE  0xFFFFFFFE
-#define APCI1564_DIGITAL_OP_CC_INTERRUPT_ENABLE    0x2
-#define APCI1564_DIGITAL_OP_CC_INTERRUPT_DISABLE   0xFFFFFFFD
-
-/* ADDIDATA Enable Disable */
-
-#define ADDIDATA_ENABLE                            1
-#define ADDIDATA_DISABLE                           0
-
-/* TIMER COUNTER WATCHDOG DEFINES */
-
-#define ADDIDATA_TIMER                             0
-#define ADDIDATA_COUNTER                           1
-#define ADDIDATA_WATCHDOG                          2
-#define APCI1564_DIGITAL_OP_WATCHDOG               0x28
-#define APCI1564_TIMER                             0x48
-#define APCI1564_COUNTER1                          0x0
-#define APCI1564_COUNTER2                          0x20
-#define APCI1564_COUNTER3                          0x40
-#define APCI1564_COUNTER4                          0x60
-#define APCI1564_TCW_SYNC_ENABLEDISABLE            0
-#define APCI1564_TCW_RELOAD_VALUE                  4
-#define APCI1564_TCW_TIMEBASE                      8
-#define APCI1564_TCW_PROG                          12
-#define APCI1564_TCW_TRIG_STATUS                   16
-#define APCI1564_TCW_IRQ                           20
-#define APCI1564_TCW_WARN_TIMEVAL                  24
-#define APCI1564_TCW_WARN_TIMEBASE                 28
index 722832b8dc2f80f4797e91cafd99674eb0bc8778..5958a9cb2a38325435c6e0beea97300a085695d8 100644 (file)
@@ -47,13 +47,24 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +-----------------------------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
+#ifndef COMEDI_SUBD_TTLIO
+#define COMEDI_SUBD_TTLIO              11 /* Digital Input Output But TTL */
+#endif
+
+#define APCI16XX_TTL_INIT              0
+#define APCI16XX_TTL_INITDIRECTION     1
+#define APCI16XX_TTL_OUTPUTMEMORY      2
+
+#define APCI16XX_TTL_READCHANNEL       0
+#define APCI16XX_TTL_READPORT          1
+
+#define APCI16XX_TTL_WRITECHANNEL_ON   0
+#define APCI16XX_TTL_WRITECHANNEL_OFF  1
+#define APCI16XX_TTL_WRITEPORT_ON      2
+#define APCI16XX_TTL_WRITEPORT_OFF     3
 
-#include "hwdrv_apci16xx.h"
+#define APCI16XX_TTL_READ_ALL_INPUTS   0
+#define APCI16XX_TTL_READ_ALL_OUTPUTS  1
 
 /*
 +----------------------------------------------------------------------------+
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.h
deleted file mode 100644 (file)
index 6293633..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data-com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#ifndef COMEDI_SUBD_TTLIO
-#define COMEDI_SUBD_TTLIO   11 /* Digital Input Output But TTL */
-#endif
-
-#ifndef ADDIDATA_ENABLE
-#define ADDIDATA_ENABLE  1
-#define ADDIDATA_DISABLE 0
-#endif
-
-#define APCI16XX_TTL_INIT           0
-#define APCI16XX_TTL_INITDIRECTION  1
-#define APCI16XX_TTL_OUTPUTMEMORY   2
-
-#define APCI16XX_TTL_READCHANNEL            0
-#define APCI16XX_TTL_READPORT               1
-
-#define APCI16XX_TTL_WRITECHANNEL_ON        0
-#define APCI16XX_TTL_WRITECHANNEL_OFF       1
-#define APCI16XX_TTL_WRITEPORT_ON           2
-#define APCI16XX_TTL_WRITEPORT_OFF          3
-
-#define APCI16XX_TTL_READ_ALL_INPUTS        0
-#define APCI16XX_TTL_READ_ALL_OUTPUTS       1
index d42bd62e803ccc6a121a6dd7cb33e3e607a73504..b7192875b0098e886ab75b8b5aa90bd8b914996e 100644 (file)
@@ -46,12 +46,22 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +----------+-----------+------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
-#include "hwdrv_apci2016.h"
+/*********      Definitions for APCI-2016 card  *****/
+
+#define APCI2016_ADDRESS_RANGE         8
+
+/* DIGITAL INPUT-OUTPUT DEFINE */
+
+#define APCI2016_DIGITAL_OP            0x04
+#define APCI2016_DIGITAL_OP_RW         4
+
+/* TIMER COUNTER WATCHDOG DEFINES */
+
+#define ADDIDATA_WATCHDOG              2
+#define APCI2016_DIGITAL_OP_WATCHDOG   0
+#define APCI2016_WATCHDOG_ENABLEDISABLE        12
+#define APCI2016_WATCHDOG_RELOAD_VALUE 4
+#define APCI2016_WATCHDOG_STATUS       16
 
 /*
 +----------------------------------------------------------------------------+
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2016.h
deleted file mode 100644 (file)
index 635295e..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-/*********      Definitions for APCI-2016 card  *****/
-
-#define APCI2016_ADDRESS_RANGE   8
-
-/* DIGITAL INPUT-OUTPUT DEFINE */
-
-#define APCI2016_DIGITAL_OP                    0x04
-#define APCI2016_DIGITAL_OP_RW                         4
-
-/* ADDIDATA Enable Disable */
-
-#define ADDIDATA_ENABLE                            1
-#define ADDIDATA_DISABLE                           0
-
-/* TIMER COUNTER WATCHDOG DEFINES */
-
-#define ADDIDATA_WATCHDOG                          2
-#define APCI2016_DIGITAL_OP_WATCHDOG               0
-#define APCI2016_WATCHDOG_ENABLEDISABLE            12
-#define APCI2016_WATCHDOG_RELOAD_VALUE             4
-#define APCI2016_WATCHDOG_STATUS                   16
index a198e5df21010dbc8925054ecbc50f297e44ea34..ebe6d1d4fe64de723e897a02a322c7f656d492cd 100644 (file)
@@ -46,14 +46,39 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +----------+-----------+------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
+/*********      Definitions for APCI-2032 card  *****/
+
+/* Card Specific information */
+#define APCI2032_ADDRESS_RANGE                         63
+
+/* DIGITAL INPUT-OUTPUT DEFINE */
+
+#define APCI2032_DIGITAL_OP                            0
+#define APCI2032_DIGITAL_OP_RW                         0
+#define APCI2032_DIGITAL_OP_INTERRUPT                  4
+#define APCI2032_DIGITAL_OP_IRQ                                12
+
+/* Digital Output Interrupt Status */
+#define APCI2032_DIGITAL_OP_INTERRUPT_STATUS           8
+
+/* Digital Output Interrupt Enable Disable. */
+#define APCI2032_DIGITAL_OP_VCC_INTERRUPT_ENABLE       0x1
+#define APCI2032_DIGITAL_OP_VCC_INTERRUPT_DISABLE      0xfffffffe
+#define APCI2032_DIGITAL_OP_CC_INTERRUPT_ENABLE                0x2
+#define APCI2032_DIGITAL_OP_CC_INTERRUPT_DISABLE       0xfffffffd
+
+/* TIMER COUNTER WATCHDOG DEFINES */
+
+#define ADDIDATA_WATCHDOG                              2
+#define APCI2032_DIGITAL_OP_WATCHDOG                   16
+#define APCI2032_TCW_RELOAD_VALUE                      4
+#define APCI2032_TCW_TIMEBASE                          8
+#define APCI2032_TCW_PROG                              12
+#define APCI2032_TCW_TRIG_STATUS                       16
+#define APCI2032_TCW_IRQ                               20
 
-#include "hwdrv_apci2032.h"
 static unsigned int ui_InterruptData, ui_Type;
+
 /*
 +----------------------------------------------------------------------------+
 | Function   Name   : int i_APCI2032_ConfigDigitalOutput                     |
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2032.h
deleted file mode 100644 (file)
index a156a65..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-/*********      Definitions for APCI-2032 card  *****/
-
-/* Card Specific information */
-#define APCI2032_ADDRESS_RANGE                   63
-
-/* DIGITAL INPUT-OUTPUT DEFINE */
-
-#define APCI2032_DIGITAL_OP                    0
-#define APCI2032_DIGITAL_OP_RW                         0
-#define APCI2032_DIGITAL_OP_INTERRUPT           4
-#define APCI2032_DIGITAL_OP_IRQ                 12
-
-/* Digital Output Interrupt Status */
-#define APCI2032_DIGITAL_OP_INTERRUPT_STATUS    8
-
-/* Digital Output Interrupt Enable Disable. */
-#define APCI2032_DIGITAL_OP_VCC_INTERRUPT_ENABLE   0x1
-#define APCI2032_DIGITAL_OP_VCC_INTERRUPT_DISABLE  0xFFFFFFFE
-#define APCI2032_DIGITAL_OP_CC_INTERRUPT_ENABLE    0x2
-#define APCI2032_DIGITAL_OP_CC_INTERRUPT_DISABLE   0xFFFFFFFD
-
-/* ADDIDATA Enable Disable */
-
-#define ADDIDATA_ENABLE                            1
-#define ADDIDATA_DISABLE                           0
-
-/* TIMER COUNTER WATCHDOG DEFINES */
-
-#define ADDIDATA_WATCHDOG                          2
-#define APCI2032_DIGITAL_OP_WATCHDOG               16
-#define APCI2032_TCW_RELOAD_VALUE                  4
-#define APCI2032_TCW_TIMEBASE                      8
-#define APCI2032_TCW_PROG                          12
-#define APCI2032_TCW_TRIG_STATUS                   16
-#define APCI2032_TCW_IRQ                           20
index 4453ceaca6d2cc810854a7fe369c26e9dfd49f16..94c884d31b1daf2faf79f21846bd99200003541f 100644 (file)
@@ -46,12 +46,22 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +----------+-----------+------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
-#include "hwdrv_apci2200.h"
+/*********      Definitions for APCI-2200 card  *****/
+
+/* Card Specific information */
+#define APCI2200_ADDRESS_RANGE         64
+
+/* DIGITAL INPUT-OUTPUT DEFINE */
+
+#define APCI2200_DIGITAL_OP            4
+#define APCI2200_DIGITAL_IP            0
+
+/* TIMER COUNTER WATCHDOG DEFINES */
+
+#define APCI2200_WATCHDOG              0x08
+#define APCI2200_WATCHDOG_ENABLEDISABLE        12
+#define APCI2200_WATCHDOG_RELOAD_VALUE 4
+#define APCI2200_WATCHDOG_STATUS       16
 
 /*
 +----------------------------------------------------------------------------+
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.h
deleted file mode 100644 (file)
index 6267c8f..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-/*********      Definitions for APCI-2200 card  *****/
-
-/* Card Specific information */
-#define APCI2200_ADDRESS_RANGE                   64
-
-/* DIGITAL INPUT-OUTPUT DEFINE */
-
-#define APCI2200_DIGITAL_OP                    4
-#define APCI2200_DIGITAL_IP                     0
-
-/* TIMER COUNTER WATCHDOG DEFINES */
-
-#define APCI2200_WATCHDOG                          0x08
-#define APCI2200_WATCHDOG_ENABLEDISABLE            12
-#define APCI2200_WATCHDOG_RELOAD_VALUE             4
-#define APCI2200_WATCHDOG_STATUS                   16
index 0cbe915a5ce9b52522400513eb7f872f3b7a8157..47ec2083c58d8c8a3c886ecfc321ee8d711d6ad0 100644 (file)
@@ -44,7 +44,204 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +----------+-----------+------------------------------------------------+
 */
 
-#include "hwdrv_apci3120.h"
+/*
+ * ADDON RELATED ADDITIONS
+ */
+/* Constant */
+#define APCI3120_ENABLE_TRANSFER_ADD_ON_LOW            0x00
+#define APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH           0x1200
+#define APCI3120_A2P_FIFO_MANAGEMENT                   0x04000400L
+#define APCI3120_AMWEN_ENABLE                          0x02
+#define APCI3120_A2P_FIFO_WRITE_ENABLE                 0x01
+#define APCI3120_FIFO_ADVANCE_ON_BYTE_2                        0x20000000L
+#define APCI3120_ENABLE_WRITE_TC_INT                   0x00004000L
+#define APCI3120_CLEAR_WRITE_TC_INT                    0x00040000L
+#define APCI3120_DISABLE_AMWEN_AND_A2P_FIFO_WRITE      0x0
+#define APCI3120_DISABLE_BUS_MASTER_ADD_ON             0x0
+#define APCI3120_DISABLE_BUS_MASTER_PCI                        0x0
+
+/* ADD_ON ::: this needed since apci supports 16 bit interface to add on */
+#define APCI3120_ADD_ON_AGCSTS_LOW     0x3C
+#define APCI3120_ADD_ON_AGCSTS_HIGH    (APCI3120_ADD_ON_AGCSTS_LOW + 2)
+#define APCI3120_ADD_ON_MWAR_LOW       0x24
+#define APCI3120_ADD_ON_MWAR_HIGH      (APCI3120_ADD_ON_MWAR_LOW + 2)
+#define APCI3120_ADD_ON_MWTC_LOW       0x058
+#define APCI3120_ADD_ON_MWTC_HIGH      (APCI3120_ADD_ON_MWTC_LOW + 2)
+
+/* AMCC */
+#define APCI3120_AMCC_OP_MCSR          0x3C
+#define APCI3120_AMCC_OP_REG_INTCSR    0x38
+
+/* for transfer count enable bit */
+#define AGCSTS_TC_ENABLE       0x10000000
+
+/* used for test on mixture of BIP/UNI ranges */
+#define APCI3120_BIPOLAR_RANGES                4
+
+#define APCI3120_ADDRESS_RANGE         16
+
+#define APCI3120_DISABLE               0
+#define APCI3120_ENABLE                        1
+
+#define APCI3120_START                 1
+#define APCI3120_STOP                  0
+
+#define APCI3120_EOC_MODE              1
+#define APCI3120_EOS_MODE              2
+#define APCI3120_DMA_MODE              3
+
+/* DIGITAL INPUT-OUTPUT DEFINE */
+
+#define APCI3120_DIGITAL_OUTPUT                0x0d
+#define APCI3120_RD_STATUS             0x02
+#define APCI3120_RD_FIFO               0x00
+
+/* digital output insn_write ON /OFF selection */
+#define        APCI3120_SET4DIGITALOUTPUTON    1
+#define APCI3120_SET4DIGITALOUTPUTOFF  0
+
+/* analog output SELECT BIT */
+#define APCI3120_ANALOG_OP_CHANNEL_1   0x0000
+#define APCI3120_ANALOG_OP_CHANNEL_2   0x4000
+#define APCI3120_ANALOG_OP_CHANNEL_3   0x8000
+#define APCI3120_ANALOG_OP_CHANNEL_4   0xc000
+#define APCI3120_ANALOG_OP_CHANNEL_5   0x0000
+#define APCI3120_ANALOG_OP_CHANNEL_6   0x4000
+#define APCI3120_ANALOG_OP_CHANNEL_7   0x8000
+#define APCI3120_ANALOG_OP_CHANNEL_8   0xc000
+
+/* Enable external trigger bit in nWrAddress */
+#define APCI3120_ENABLE_EXT_TRIGGER    0x8000
+
+/* ANALOG OUTPUT AND INPUT DEFINE */
+#define APCI3120_UNIPOLAR              0x80
+#define APCI3120_BIPOLAR               0x00
+#define APCI3120_ANALOG_OUTPUT_1       0x08
+#define APCI3120_ANALOG_OUTPUT_2       0x0a
+#define APCI3120_1_GAIN                        0x00
+#define APCI3120_2_GAIN                        0x10
+#define APCI3120_5_GAIN                        0x20
+#define APCI3120_10_GAIN               0x30
+#define APCI3120_SEQ_RAM_ADDRESS       0x06
+#define APCI3120_RESET_FIFO            0x0c
+#define APCI3120_TIMER_0_MODE_2                0x01
+#define APCI3120_TIMER_0_MODE_4                0x2
+#define APCI3120_SELECT_TIMER_0_WORD   0x00
+#define APCI3120_ENABLE_TIMER0         0x1000
+#define APCI3120_CLEAR_PR              0xf0ff
+#define APCI3120_CLEAR_PA              0xfff0
+#define APCI3120_CLEAR_PA_PR           (APCI3120_CLEAR_PR & APCI3120_CLEAR_PA)
+
+/* nWrMode_Select */
+#define APCI3120_ENABLE_SCAN           0x8
+#define APCI3120_DISABLE_SCAN          (~APCI3120_ENABLE_SCAN)
+#define APCI3120_ENABLE_EOS_INT                0x2
+
+#define APCI3120_DISABLE_EOS_INT       (~APCI3120_ENABLE_EOS_INT)
+#define APCI3120_ENABLE_EOC_INT                0x1
+#define APCI3120_DISABLE_EOC_INT       (~APCI3120_ENABLE_EOC_INT)
+#define APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER   \
+       (APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT)
+#define APCI3120_DISABLE_ALL_INTERRUPT                 \
+       (APCI3120_DISABLE_TIMER_INT & APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT)
+
+/* status register bits */
+#define APCI3120_EOC                   0x8000
+#define APCI3120_EOS                   0x2000
+
+/* software trigger dummy register */
+#define APCI3120_START_CONVERSION      0x02
+
+/* TIMER DEFINE */
+#define APCI3120_QUARTZ_A              70
+#define APCI3120_QUARTZ_B              50
+#define APCI3120_TIMER                 1
+#define APCI3120_WATCHDOG              2
+#define APCI3120_TIMER_DISABLE         0
+#define APCI3120_TIMER_ENABLE          1
+#define APCI3120_ENABLE_TIMER2         0x4000
+#define APCI3120_DISABLE_TIMER2                (~APCI3120_ENABLE_TIMER2)
+#define APCI3120_ENABLE_TIMER_INT      0x04
+#define APCI3120_DISABLE_TIMER_INT     (~APCI3120_ENABLE_TIMER_INT)
+#define APCI3120_WRITE_MODE_SELECT     0x0e
+#define APCI3120_SELECT_TIMER_0_WORD   0x00
+#define APCI3120_SELECT_TIMER_1_WORD   0x01
+#define APCI3120_TIMER_1_MODE_2                0x4
+
+/* $$ BIT FOR MODE IN nCsTimerCtr1 */
+#define APCI3120_TIMER_2_MODE_0                0x0
+#define APCI3120_TIMER_2_MODE_2                0x10
+#define APCI3120_TIMER_2_MODE_5                0x30
+
+/* $$ BIT FOR MODE IN nCsTimerCtr0 */
+#define APCI3120_SELECT_TIMER_2_LOW_WORD       0x02
+#define APCI3120_SELECT_TIMER_2_HIGH_WORD      0x03
+
+#define APCI3120_TIMER_CRT0            0x0d
+#define APCI3120_TIMER_CRT1            0x0c
+
+#define APCI3120_TIMER_VALUE           0x04
+#define APCI3120_TIMER_STATUS_REGISTER 0x0d
+#define APCI3120_RD_STATUS             0x02
+#define APCI3120_WR_ADDRESS            0x00
+#define APCI3120_ENABLE_WATCHDOG       0x20
+#define APCI3120_DISABLE_WATCHDOG      (~APCI3120_ENABLE_WATCHDOG)
+#define APCI3120_ENABLE_TIMER_COUNTER  0x10
+#define APCI3120_DISABLE_TIMER_COUNTER (~APCI3120_ENABLE_TIMER_COUNTER)
+#define APCI3120_FC_TIMER              0x1000
+#define APCI3120_ENABLE_TIMER0         0x1000
+#define APCI3120_ENABLE_TIMER1         0x2000
+#define APCI3120_ENABLE_TIMER2         0x4000
+#define APCI3120_DISABLE_TIMER0                (~APCI3120_ENABLE_TIMER0)
+#define APCI3120_DISABLE_TIMER1                (~APCI3120_ENABLE_TIMER1)
+#define APCI3120_DISABLE_TIMER2                (~APCI3120_ENABLE_TIMER2)
+
+#define APCI3120_TIMER2_SELECT_EOS     0xc0
+#define APCI3120_COUNTER               3
+#define APCI3120_DISABLE_ALL_TIMER     (APCI3120_DISABLE_TIMER0 &      \
+                                        APCI3120_DISABLE_TIMER1 &      \
+                                        APCI3120_DISABLE_TIMER2)
+
+#define MAX_ANALOGINPUT_CHANNELS       32
+
+struct str_AnalogReadInformation {
+       /* EOC or EOS */
+       unsigned char b_Type;
+       /* Interrupt use or not */
+       unsigned char b_InterruptFlag;
+       /* Selection of the conversion time */
+       unsigned int ui_ConvertTiming;
+       /* Number of channel to read */
+       unsigned char b_NbrOfChannel;
+       /* Number of the channel to be read */
+       unsigned int ui_ChannelList[MAX_ANALOGINPUT_CHANNELS];
+       /* Gain of each channel */
+       unsigned int ui_RangeList[MAX_ANALOGINPUT_CHANNELS];
+};
+
+/* ANALOG INPUT RANGE */
+static const struct comedi_lrange range_apci3120_ai = {
+       8, {
+               BIP_RANGE(10),
+               BIP_RANGE(5),
+               BIP_RANGE(2),
+               BIP_RANGE(1),
+               UNI_RANGE(10),
+               UNI_RANGE(5),
+               UNI_RANGE(2),
+               UNI_RANGE(1)
+       }
+};
+
+/* ANALOG OUTPUT RANGE */
+static const struct comedi_lrange range_apci3120_ao = {
+       2, {
+               BIP_RANGE(10),
+               UNI_RANGE(10)
+       }
+};
+
+
 static unsigned int ui_Temp;
 
 /* FUNCTION DEFINITIONS */
@@ -55,27 +252,10 @@ static unsigned int ui_Temp;
 +----------------------------------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev,|
-|  struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)                                      |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : Calls card specific function                                          |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_insn *insn                                      |
-|                     unsigned int *data                                                                |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+static int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev,
+                                           struct comedi_subdevice *s,
+                                           struct comedi_insn *insn,
+                                           unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int i;
@@ -122,30 +302,69 @@ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_su
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev,  |
-|                      struct comedi_subdevice *s,struct comedi_insn *insn, unsigned int *data)         |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              :  card specific function                                                           |
-|                              Reads analog input in synchronous mode               |
-|                        EOC and EOS is selected as per configured              |
-|                     if no conversion time is set uses default conversion   |
-|                        time 10 microsec.                                                                      |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_insn *insn                                      |
-|                     unsigned int *data                                                                        |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
+ * This function will first check channel list is ok or not and then
+ * initialize the sequence RAM with the polarity, Gain,Channel number.
+ * If the last argument of function "check"is 1 then it only checks
+ * the channel list is ok or not.
+ */
+static int i_APCI3120_SetupChannelList(struct comedi_device *dev,
+                                      struct comedi_subdevice *s,
+                                      int n_chan,
+                                      unsigned int *chanlist,
+                                      char check)
+{
+       struct addi_private *devpriv = dev->private;
+       unsigned int i;         /* , differencial=0, bipolar=0; */
+       unsigned int gain;
+       unsigned short us_TmpValue;
+
+       /* correct channel and range number check itself comedi/range.c */
+       if (n_chan < 1) {
+               if (!check)
+                       comedi_error(dev, "range/channel list is empty!");
+               return 0;
+       }
+       /*  All is ok, so we can setup channel/range list */
+       if (check)
+               return 1;
+
+       /* Code  to set the PA and PR...Here it set PA to 0.. */
+       devpriv->us_OutputRegister =
+               devpriv->us_OutputRegister & APCI3120_CLEAR_PA_PR;
+       devpriv->us_OutputRegister = ((n_chan - 1) & 0xf) << 8;
+       outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
+
+       for (i = 0; i < n_chan; i++) {
+               /*  store range list to card */
+               us_TmpValue = CR_CHAN(chanlist[i]);     /*  get channel number; */
+
+               if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES)
+                       us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff);   /*  set bipolar */
+               else
+                       us_TmpValue |= APCI3120_UNIPOLAR;       /*  enable unipolar...... */
+
+               gain = CR_RANGE(chanlist[i]);   /*  get gain number */
+               us_TmpValue |= ((gain & 0x03) << 4);    /* <<4 for G0 and G1 bit in RAM */
+               us_TmpValue |= i << 8;  /* To select the RAM LOCATION.... */
+               outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS);
+
+               printk("\n Gain = %i",
+                       (((unsigned char)CR_RANGE(chanlist[i]) & 0x03) << 2));
+               printk("\n Channel = %i", CR_CHAN(chanlist[i]));
+               printk("\n Polarity = %i", us_TmpValue & APCI3120_UNIPOLAR);
+       }
+       return 1;               /*  we can serve this with scan logic */
+}
 
-int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+/*
+ * Reads analog input in synchronous mode EOC and EOS is selected
+ * as per configured if no conversion time is set uses default
+ * conversion time 10 microsec.
+ */
+static int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev,
+                                         struct comedi_subdevice *s,
+                                         struct comedi_insn *insn,
+                                         unsigned int *data)
 {
        const struct addi_board *this_board = comedi_board(dev);
        struct addi_private *devpriv = dev->private;
@@ -390,25 +609,83 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subd
 
 }
 
+static int i_APCI3120_Reset(struct comedi_device *dev)
+{
+       struct addi_private *devpriv = dev->private;
+       unsigned int i;
+       unsigned short us_TmpValue;
+
+       devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
+       devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
+       devpriv->b_InterruptMode = APCI3120_EOC_MODE;
+       devpriv->ui_EocEosConversionTime = 0;   /*  set eoc eos conv time to 0 */
+       devpriv->b_OutputMemoryStatus = 0;
+
+       /*  variables used in timer subdevice */
+       devpriv->b_Timer2Mode = 0;
+       devpriv->b_Timer2Interrupt = 0;
+       devpriv->b_ExttrigEnable = 0;   /*  Disable ext trigger */
+
+       /* Disable all interrupts, watchdog for the anolog output */
+       devpriv->b_ModeSelectRegister = 0;
+       outb(devpriv->b_ModeSelectRegister,
+               dev->iobase + APCI3120_WRITE_MODE_SELECT);
+
+       /*  Disables all counters, ext trigger and clears PA, PR */
+       devpriv->us_OutputRegister = 0;
+       outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
+
 /*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev,|
-|                                                                                           struct comedi_subdevice *s)|
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : Stops Cyclic acquisition                                                      |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :0                                                                      |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
+ * Code to set the all anolog o/p channel to 0v 8191 is decimal
+ * value for zero(0 v)volt in bipolar mode(default)
+ */
+       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_1, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 1 */
+       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_2, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 2 */
+       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_3, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 3 */
+       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_4, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 4 */
+
+       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_5, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 5 */
+       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_6, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 6 */
+       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_7, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 7 */
+       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_8, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 8 */
+
+       /*   Reset digital output to L0W */
+
+/* ES05  outb(0x0,dev->iobase+APCI3120_DIGITAL_OUTPUT); */
+       udelay(10);
+
+       inw(dev->iobase + 0);   /* make a dummy read */
+       inb(dev->iobase + APCI3120_RESET_FIFO); /*  flush FIFO */
+       inw(dev->iobase + APCI3120_RD_STATUS);  /*  flush A/D status register */
+
+       /* code to reset the RAM sequence */
+       for (i = 0; i < 16; i++) {
+               us_TmpValue = i << 8;   /* select the location */
+               outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS);
+       }
+       return 0;
+}
+
+static int i_APCI3120_ExttrigEnable(struct comedi_device *dev)
+{
+       struct addi_private *devpriv = dev->private;
+
+       devpriv->us_OutputRegister |= APCI3120_ENABLE_EXT_TRIGGER;
+       outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
+       return 0;
+}
+
+static int i_APCI3120_ExttrigDisable(struct comedi_device *dev)
+{
+       struct addi_private *devpriv = dev->private;
+
+       devpriv->us_OutputRegister &= ~APCI3120_ENABLE_EXT_TRIGGER;
+       outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
+       return 0;
+}
 
-int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s)
+static int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev,
+                                           struct comedi_subdevice *s)
 {
        struct addi_private *devpriv = dev->private;
 
@@ -461,27 +738,9 @@ int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_su
        return 0;
 }
 
-/*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev|
-|                      ,struct comedi_subdevice *s,struct comedi_cmd *cmd)                                      |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : Test validity for a command for cyclic anlog input     |
-|                       acquisition                                                                     |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_cmd *cmd                                                            |
-+----------------------------------------------------------------------------+
-| Return Value      :0                                                                      |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_cmd *cmd)
+static int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev,
+                                            struct comedi_subdevice *s,
+                                            struct comedi_cmd *cmd)
 {
        const struct addi_board *this_board = comedi_board(dev);
        struct addi_private *devpriv = dev->private;
@@ -591,100 +850,14 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function name     : int i_APCI3120_CommandAnalogInput(struct comedi_device *dev,  |
-|                                                                                              struct comedi_subdevice *s) |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : Does asynchronous acquisition                          |
-|                     Determines the mode 1 or 2.                                                   |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                                                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s)
-{
-       struct addi_private *devpriv = dev->private;
-       struct comedi_cmd *cmd = &s->async->cmd;
-
-       /* loading private structure with cmd structure inputs */
-       devpriv->ui_AiFlags = cmd->flags;
-       devpriv->ui_AiNbrofChannels = cmd->chanlist_len;
-       devpriv->ui_AiScanLength = cmd->scan_end_arg;
-       devpriv->pui_AiChannelList = cmd->chanlist;
-
-       /* UPDATE-0.7.57->0.7.68devpriv->AiData=s->async->data; */
-       devpriv->AiData = s->async->prealloc_buf;
-       /* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */
-       devpriv->ui_AiDataLength = s->async->prealloc_bufsz;
-
-       if (cmd->stop_src == TRIG_COUNT)
-               devpriv->ui_AiNbrofScans = cmd->stop_arg;
-       else
-               devpriv->ui_AiNbrofScans = 0;
-
-       devpriv->ui_AiTimer0 = 0;       /*  variables changed to timer0,timer1 */
-       devpriv->ui_AiTimer1 = 0;
-       if ((devpriv->ui_AiNbrofScans == 0) || (devpriv->ui_AiNbrofScans == -1))
-               devpriv->b_AiContinuous = 1;    /*  user want neverending analog acquisition */
-       /*  stopped using cancel */
-
-       if (cmd->start_src == TRIG_EXT)
-               devpriv->b_ExttrigEnable = APCI3120_ENABLE;
-       else
-               devpriv->b_ExttrigEnable = APCI3120_DISABLE;
-
-       if (cmd->scan_begin_src == TRIG_FOLLOW) {
-               /*  mode 1 or 3 */
-               if (cmd->convert_src == TRIG_TIMER) {
-                       /*  mode 1 */
-
-                       devpriv->ui_AiTimer0 = cmd->convert_arg;        /*  timer constant in nano seconds */
-                       /* return this_board->ai_cmd(1,dev,s); */
-                       return i_APCI3120_CyclicAnalogInput(1, dev, s);
-               }
-
-       }
-       if ((cmd->scan_begin_src == TRIG_TIMER)
-               && (cmd->convert_src == TRIG_TIMER)) {
-               /*  mode 2 */
-               devpriv->ui_AiTimer1 = cmd->scan_begin_arg;
-               devpriv->ui_AiTimer0 = cmd->convert_arg;        /*  variable changed timer2 to timer0 */
-               /* return this_board->ai_cmd(2,dev,s); */
-               return i_APCI3120_CyclicAnalogInput(2, dev, s);
-       }
-       return -1;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function name     :  int i_APCI3120_CyclicAnalogInput(int mode,            |
-|                         struct comedi_device * dev,struct comedi_subdevice * s)                       |
-+----------------------------------------------------------------------------+
-| Task              : This is used for analog input cyclic acquisition       |
-|                        Performs the command operations.                       |
-|                        If DMA is configured does DMA initialization           |
-|                        otherwise does the acquisition with EOS interrupt.     |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  :                                                                                                           |
-|                                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
-       struct comedi_subdevice *s)
+ * This is used for analog input cyclic acquisition.
+ * Performs the command operations.
+ * If DMA is configured does DMA initialization otherwise does the
+ * acquisition with EOS interrupt.
+ */
+static int i_APCI3120_CyclicAnalogInput(int mode,
+                                       struct comedi_device *dev,
+                                       struct comedi_subdevice *s)
 {
        const struct addi_board *this_board = comedi_board(dev);
        struct addi_private *devpriv = dev->private;
@@ -1196,491 +1369,89 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
 }
 
 /*
-+----------------------------------------------------------------------------+
-|                      intERNAL FUNCTIONS                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-/*
-+----------------------------------------------------------------------------+
-| Function name     : int i_APCI3120_Reset(struct comedi_device *dev)               |
-|                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : Hardware reset function                                                       |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  :  struct comedi_device *dev                                                                        |
-|                                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_Reset(struct comedi_device *dev)
+ * Does asynchronous acquisition.
+ * Determines the mode 1 or 2.
+ */
+static int i_APCI3120_CommandAnalogInput(struct comedi_device *dev,
+                                        struct comedi_subdevice *s)
 {
        struct addi_private *devpriv = dev->private;
-       unsigned int i;
-       unsigned short us_TmpValue;
+       struct comedi_cmd *cmd = &s->async->cmd;
 
-       devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
-       devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
-       devpriv->b_InterruptMode = APCI3120_EOC_MODE;
-       devpriv->ui_EocEosConversionTime = 0;   /*  set eoc eos conv time to 0 */
-       devpriv->b_OutputMemoryStatus = 0;
+       /* loading private structure with cmd structure inputs */
+       devpriv->ui_AiFlags = cmd->flags;
+       devpriv->ui_AiNbrofChannels = cmd->chanlist_len;
+       devpriv->ui_AiScanLength = cmd->scan_end_arg;
+       devpriv->pui_AiChannelList = cmd->chanlist;
 
-       /*  variables used in timer subdevice */
-       devpriv->b_Timer2Mode = 0;
-       devpriv->b_Timer2Interrupt = 0;
-       devpriv->b_ExttrigEnable = 0;   /*  Disable ext trigger */
+       /* UPDATE-0.7.57->0.7.68devpriv->AiData=s->async->data; */
+       devpriv->AiData = s->async->prealloc_buf;
+       /* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */
+       devpriv->ui_AiDataLength = s->async->prealloc_bufsz;
 
-       /* Disable all interrupts, watchdog for the anolog output */
-       devpriv->b_ModeSelectRegister = 0;
-       outb(devpriv->b_ModeSelectRegister,
-               dev->iobase + APCI3120_WRITE_MODE_SELECT);
-
-       /*  Disables all counters, ext trigger and clears PA, PR */
-       devpriv->us_OutputRegister = 0;
-       outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
-
-/*
- * Code to set the all anolog o/p channel to 0v 8191 is decimal
- * value for zero(0 v)volt in bipolar mode(default)
- */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_1, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 1 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_2, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 2 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_3, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 3 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_4, dev->iobase + APCI3120_ANALOG_OUTPUT_1);      /* channel 4 */
-
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_5, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 5 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_6, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 6 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_7, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 7 */
-       outw(8191 | APCI3120_ANALOG_OP_CHANNEL_8, dev->iobase + APCI3120_ANALOG_OUTPUT_2);      /* channel 8 */
-
-       /*   Reset digital output to L0W */
-
-/* ES05  outb(0x0,dev->iobase+APCI3120_DIGITAL_OUTPUT); */
-       udelay(10);
-
-       inw(dev->iobase + 0);   /* make a dummy read */
-       inb(dev->iobase + APCI3120_RESET_FIFO); /*  flush FIFO */
-       inw(dev->iobase + APCI3120_RD_STATUS);  /*  flush A/D status register */
-
-       /* code to reset the RAM sequence */
-       for (i = 0; i < 16; i++) {
-               us_TmpValue = i << 8;   /* select the location */
-               outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS);
-       }
-       return 0;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function name     : int i_APCI3120_SetupChannelList(struct comedi_device * dev,   |
-|                     struct comedi_subdevice * s, int n_chan,unsigned int *chanlist|
-|                        ,char check)                                                                                   |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              :This function will first check channel list is ok or not|
-|and then initialize the sequence RAM with the polarity, Gain,Channel number |
-|If the last argument of function "check"is 1 then it only checks the channel|
-|list is ok or not.                                                                                                             |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device * dev                                                                        |
-|                     struct comedi_subdevice * s                                                                       |
-|                     int n_chan                                                                |
-                         unsigned int *chanlist
-                         char check
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevice *s,
-       int n_chan, unsigned int *chanlist, char check)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int i;         /* , differencial=0, bipolar=0; */
-       unsigned int gain;
-       unsigned short us_TmpValue;
-
-       /* correct channel and range number check itself comedi/range.c */
-       if (n_chan < 1) {
-               if (!check)
-                       comedi_error(dev, "range/channel list is empty!");
-               return 0;
-       }
-       /*  All is ok, so we can setup channel/range list */
-       if (check)
-               return 1;
-
-       /* Code  to set the PA and PR...Here it set PA to 0.. */
-       devpriv->us_OutputRegister =
-               devpriv->us_OutputRegister & APCI3120_CLEAR_PA_PR;
-       devpriv->us_OutputRegister = ((n_chan - 1) & 0xf) << 8;
-       outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
-
-       for (i = 0; i < n_chan; i++) {
-               /*  store range list to card */
-               us_TmpValue = CR_CHAN(chanlist[i]);     /*  get channel number; */
-
-               if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES)
-                       us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff);   /*  set bipolar */
-               else
-                       us_TmpValue |= APCI3120_UNIPOLAR;       /*  enable unipolar...... */
-
-               gain = CR_RANGE(chanlist[i]);   /*  get gain number */
-               us_TmpValue |= ((gain & 0x03) << 4);    /* <<4 for G0 and G1 bit in RAM */
-               us_TmpValue |= i << 8;  /* To select the RAM LOCATION.... */
-               outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS);
-
-               printk("\n Gain = %i",
-                       (((unsigned char)CR_RANGE(chanlist[i]) & 0x03) << 2));
-               printk("\n Channel = %i", CR_CHAN(chanlist[i]));
-               printk("\n Polarity = %i", us_TmpValue & APCI3120_UNIPOLAR);
-       }
-       return 1;               /*  we can serve this with scan logic */
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function name     :  int i_APCI3120_ExttrigEnable(struct comedi_device * dev)    |
-|                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              :  Enable the external trigger                                                  |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  :  struct comedi_device * dev                                                                       |
-|                                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :      0                                                                    |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_ExttrigEnable(struct comedi_device *dev)
-{
-       struct addi_private *devpriv = dev->private;
-
-       devpriv->us_OutputRegister |= APCI3120_ENABLE_EXT_TRIGGER;
-       outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
-       return 0;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function name     :  int i_APCI3120_ExttrigDisable(struct comedi_device * dev)   |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              :  Disables the external trigger                                        |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  :  struct comedi_device * dev                                                                       |
-|                                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :    0                                                                      |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_ExttrigDisable(struct comedi_device *dev)
-{
-       struct addi_private *devpriv = dev->private;
-
-       devpriv->us_OutputRegister &= ~APCI3120_ENABLE_EXT_TRIGGER;
-       outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
-       return 0;
-}
-
-/*
-+----------------------------------------------------------------------------+
-|                    intERRUPT FUNCTIONS                                                |
-+----------------------------------------------------------------------------+
-*/
-
-/*
-+----------------------------------------------------------------------------+
-| Function name     : void v_APCI3120_Interrupt(int irq, void *d)                                                               |
-|                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              :Interrupt handler for APCI3120                             |
-|                       When interrupt occurs this gets called.                 |
-|                       First it finds which interrupt has been generated and   |
-|                       handles  corresponding interrupt                        |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  :  int irq                                                                                          |
-|                        void *d                                                                                        |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      : void                                                                      |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-void v_APCI3120_Interrupt(int irq, void *d)
-{
-       struct comedi_device *dev = d;
-       struct addi_private *devpriv = dev->private;
-       unsigned short int_daq;
-       unsigned int int_amcc, ui_Check, i;
-       unsigned short us_TmpValue;
-       unsigned char b_DummyRead;
-       struct comedi_subdevice *s = &dev->subdevices[0];
-
-       ui_Check = 1;
-
-       int_daq = inw(dev->iobase + APCI3120_RD_STATUS) & 0xf000;       /*  get IRQ reasons */
-       int_amcc = inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);     /*  get AMCC int register */
-
-       if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) {
-               comedi_error(dev, "IRQ from unknown source");
-               return;
-       }
-
-       outl(int_amcc | 0x00ff0000, devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);        /*  shutdown IRQ reasons in AMCC */
-
-       int_daq = (int_daq >> 12) & 0xF;
-
-       if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) {
-               /* Disable ext trigger */
-               i_APCI3120_ExttrigDisable(dev);
-               devpriv->b_ExttrigEnable = APCI3120_DISABLE;
-       }
-       /* clear the timer 2 interrupt */
-       inb(devpriv->i_IobaseAmcc + APCI3120_TIMER_STATUS_REGISTER);
-
-       if (int_amcc & MASTER_ABORT_INT)
-               comedi_error(dev, "AMCC IRQ - MASTER DMA ABORT!");
-       if (int_amcc & TARGET_ABORT_INT)
-               comedi_error(dev, "AMCC IRQ - TARGET DMA ABORT!");
-
-       /*  Ckeck if EOC interrupt */
-       if (((int_daq & 0x8) == 0)
-               && (devpriv->b_InterruptMode == APCI3120_EOC_MODE)) {
-               if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) {
-
-                       /*  Read the AI Value */
-
-                       devpriv->ui_AiReadData[0] =
-                               (unsigned int) inw(devpriv->iobase + 0);
-                       devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
-                       send_sig(SIGIO, devpriv->tsk_Current, 0);       /*  send signal to the sample */
-               } else {
-                       /* Disable EOC Interrupt */
-                       devpriv->b_ModeSelectRegister =
-                               devpriv->
-                               b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT;
-                       outb(devpriv->b_ModeSelectRegister,
-                               devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
-
-               }
-       }
-
-       /*  Check If EOS interrupt */
-       if ((int_daq & 0x2) && (devpriv->b_InterruptMode == APCI3120_EOS_MODE)) {
-
-               if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) {    /*  enable this in without DMA ??? */
-
-                       if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
-                               ui_Check = 0;
-                               i_APCI3120_InterruptHandleEos(dev);
-                               devpriv->ui_AiActualScan++;
-                               devpriv->b_ModeSelectRegister =
-                                       devpriv->
-                                       b_ModeSelectRegister |
-                                       APCI3120_ENABLE_EOS_INT;
-                               outb(devpriv->b_ModeSelectRegister,
-                                       dev->iobase +
-                                       APCI3120_WRITE_MODE_SELECT);
-                       } else {
-                               ui_Check = 0;
-                               for (i = 0; i < devpriv->ui_AiNbrofChannels;
-                                       i++) {
-                                       us_TmpValue = inw(devpriv->iobase + 0);
-                                       devpriv->ui_AiReadData[i] =
-                                               (unsigned int) us_TmpValue;
-                               }
-                               devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
-                               devpriv->b_InterruptMode = APCI3120_EOC_MODE;
-
-                               send_sig(SIGIO, devpriv->tsk_Current, 0);       /*  send signal to the sample */
-
-                       }
-
-               } else {
-                       devpriv->b_ModeSelectRegister =
-                               devpriv->
-                               b_ModeSelectRegister & APCI3120_DISABLE_EOS_INT;
-                       outb(devpriv->b_ModeSelectRegister,
-                               dev->iobase + APCI3120_WRITE_MODE_SELECT);
-                       devpriv->b_EocEosInterrupt = APCI3120_DISABLE;  /* Default settings */
-                       devpriv->b_InterruptMode = APCI3120_EOC_MODE;
-               }
-
-       }
-       /* Timer2 interrupt */
-       if (int_daq & 0x1) {
-
-               switch (devpriv->b_Timer2Mode) {
-               case APCI3120_COUNTER:
-
-                       devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
-                       devpriv->b_ModeSelectRegister =
-                               devpriv->
-                               b_ModeSelectRegister & APCI3120_DISABLE_EOS_INT;
-                       outb(devpriv->b_ModeSelectRegister,
-                               dev->iobase + APCI3120_WRITE_MODE_SELECT);
-
-                       /*  stop timer 2 */
-                       devpriv->us_OutputRegister =
-                               devpriv->
-                               us_OutputRegister & APCI3120_DISABLE_ALL_TIMER;
-                       outw(devpriv->us_OutputRegister,
-                               dev->iobase + APCI3120_WR_ADDRESS);
-
-                       /* stop timer 0 and timer 1 */
-                       i_APCI3120_StopCyclicAcquisition(dev, s);
-                       devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
-
-                       /* UPDATE-0.7.57->0.7.68comedi_done(dev,s); */
-                       s->async->events |= COMEDI_CB_EOA;
-                       comedi_event(dev, s);
-
-                       break;
-
-               case APCI3120_TIMER:
-
-                       /* Send a signal to from kernel to user space */
-                       send_sig(SIGIO, devpriv->tsk_Current, 0);
-                       break;
-
-               case APCI3120_WATCHDOG:
-
-                       /* Send a signal to from kernel to user space */
-                       send_sig(SIGIO, devpriv->tsk_Current, 0);
-                       break;
-
-               default:
-
-                       /*  disable Timer Interrupt */
-
-                       devpriv->b_ModeSelectRegister =
-                               devpriv->
-                               b_ModeSelectRegister &
-                               APCI3120_DISABLE_TIMER_INT;
-
-                       outb(devpriv->b_ModeSelectRegister,
-                               dev->iobase + APCI3120_WRITE_MODE_SELECT);
-
-               }
-
-               b_DummyRead = inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
-
-       }
+       if (cmd->stop_src == TRIG_COUNT)
+               devpriv->ui_AiNbrofScans = cmd->stop_arg;
+       else
+               devpriv->ui_AiNbrofScans = 0;
 
-       if ((int_daq & 0x4) && (devpriv->b_InterruptMode == APCI3120_DMA_MODE)) {
-               if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
+       devpriv->ui_AiTimer0 = 0;       /*  variables changed to timer0,timer1 */
+       devpriv->ui_AiTimer1 = 0;
+       if ((devpriv->ui_AiNbrofScans == 0) || (devpriv->ui_AiNbrofScans == -1))
+               devpriv->b_AiContinuous = 1;    /*  user want neverending analog acquisition */
+       /*  stopped using cancel */
 
-                       /****************************/
-                       /* Clear Timer Write TC int */
-                       /****************************/
+       if (cmd->start_src == TRIG_EXT)
+               devpriv->b_ExttrigEnable = APCI3120_ENABLE;
+       else
+               devpriv->b_ExttrigEnable = APCI3120_DISABLE;
 
-                       outl(APCI3120_CLEAR_WRITE_TC_INT,
-                               devpriv->i_IobaseAmcc +
-                               APCI3120_AMCC_OP_REG_INTCSR);
+       if (cmd->scan_begin_src == TRIG_FOLLOW) {
+               /*  mode 1 or 3 */
+               if (cmd->convert_src == TRIG_TIMER) {
+                       /*  mode 1 */
 
-                       /************************************/
-                       /* Clears the timer status register */
-                       /************************************/
-                       inw(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
-                       v_APCI3120_InterruptDma(irq, d);        /*  do some data transfer */
-               } else {
-                       /* Stops the Timer */
-                       outw(devpriv->
-                               us_OutputRegister & APCI3120_DISABLE_TIMER0 &
-                               APCI3120_DISABLE_TIMER1,
-                               dev->iobase + APCI3120_WR_ADDRESS);
+                       devpriv->ui_AiTimer0 = cmd->convert_arg;        /*  timer constant in nano seconds */
+                       /* return this_board->ai_cmd(1,dev,s); */
+                       return i_APCI3120_CyclicAnalogInput(1, dev, s);
                }
 
        }
-
-       return;
+       if ((cmd->scan_begin_src == TRIG_TIMER)
+               && (cmd->convert_src == TRIG_TIMER)) {
+               /*  mode 2 */
+               devpriv->ui_AiTimer1 = cmd->scan_begin_arg;
+               devpriv->ui_AiTimer0 = cmd->convert_arg;        /*  variable changed timer2 to timer0 */
+               /* return this_board->ai_cmd(2,dev,s); */
+               return i_APCI3120_CyclicAnalogInput(2, dev, s);
+       }
+       return -1;
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_InterruptHandleEos(struct comedi_device *dev)   |
-|                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : This function handles EOS interrupt.                   |
-|                     This function copies the acquired data(from FIFO)      |
-|                              to Comedi buffer.                                                                        |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      : 0                                                                         |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-
-int i_APCI3120_InterruptHandleEos(struct comedi_device *dev)
+ * This function copies the data from DMA buffer to the Comedi buffer.
+ */
+static void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,
+                                                 struct comedi_subdevice *s,
+                                                 short *dma_buffer,
+                                                 unsigned int num_samples)
 {
        struct addi_private *devpriv = dev->private;
-       int n_chan, i;
-       struct comedi_subdevice *s = &dev->subdevices[0];
-       int err = 1;
-
-       n_chan = devpriv->ui_AiNbrofChannels;
 
-       s->async->events = 0;
-
-       for (i = 0; i < n_chan; i++)
-               err &= comedi_buf_put(s->async, inw(dev->iobase + 0));
-
-       s->async->events |= COMEDI_CB_EOS;
-
-       if (err == 0)
-               s->async->events |= COMEDI_CB_OVERFLOW;
-
-       comedi_event(dev, s);
+       devpriv->ui_AiActualScan +=
+               (s->async->cur_chan + num_samples) / devpriv->ui_AiScanLength;
+       s->async->cur_chan += num_samples;
+       s->async->cur_chan %= devpriv->ui_AiScanLength;
 
-       return 0;
+       cfc_write_array_to_buffer(s, dma_buffer, num_samples * sizeof(short));
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function name     : void v_APCI3120_InterruptDma(int irq, void *d)                                                                    |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : This is a handler for the DMA interrupt                |
-|                        This function copies the data to Comedi Buffer.        |
-|                        For continuous DMA it reinitializes the DMA operation. |
-|                        For single mode DMA it stop the acquisition.           |
-|                                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : int irq, void *d                          |
-|                                                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :  void                                                                     |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-void v_APCI3120_InterruptDma(int irq, void *d)
+ * This is a handler for the DMA interrupt.
+ * This function copies the data to Comedi Buffer.
+ * For continuous DMA it reinitializes the DMA operation.
+ * For single mode DMA it stop the acquisition.
+ */
+static void v_APCI3120_InterruptDma(int irq, void *d)
 {
        struct comedi_device *dev = d;
        struct addi_private *devpriv = dev->private;
@@ -1767,136 +1538,300 @@ void v_APCI3120_InterruptDma(int irq, void *d)
                        comedi_event(dev, s);
                }
        }
-       if (!devpriv->b_AiContinuous)
-               if (devpriv->ui_AiActualScan >= devpriv->ui_AiNbrofScans) {
-                       /*  all data sampled */
+       if (!devpriv->b_AiContinuous)
+               if (devpriv->ui_AiActualScan >= devpriv->ui_AiNbrofScans) {
+                       /*  all data sampled */
+                       i_APCI3120_StopCyclicAcquisition(dev, s);
+                       devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
+                       s->async->events |= COMEDI_CB_EOA;
+                       comedi_event(dev, s);
+                       return;
+               }
+
+       if (devpriv->b_DmaDoubleBuffer) {       /*  switch dma buffers */
+               devpriv->ui_DmaActualBuffer = 1 - devpriv->ui_DmaActualBuffer;
+       } else {
+/*
+ * restart DMA if is not used double buffering
+ * ADDED REINITIALISE THE DMA
+ */
+               ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
+               outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS);
+
+               /*  changed  since 16 bit interface for add on */
+               outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
+               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,
+                       devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
+               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /*  */
+/*
+ * A2P FIFO MANAGEMENT
+ * A2P fifo reset & transfer control enable
+ */
+               outl(APCI3120_A2P_FIFO_MANAGEMENT,
+                       devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR);
+
+               var = devpriv->ul_DmaBufferHw[0];
+               low_word = var & 0xffff;
+               var = devpriv->ul_DmaBufferHw[0];
+               high_word = var / 65536;
+               outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0);
+               outw(low_word, devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
+               outw(high_word, devpriv->i_IobaseAddon + 2);
+
+               var = devpriv->ui_DmaBufferUsesize[0];
+               low_word = var & 0xffff;        /* changed */
+               var = devpriv->ui_DmaBufferUsesize[0];
+               high_word = var / 65536;
+               outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0);
+               outw(low_word, devpriv->i_IobaseAddon + 2);
+               outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
+               outw(high_word, devpriv->i_IobaseAddon + 2);
+
+/*
+ * To configure A2P FIFO
+ * ENABLE A2P FIFO WRITE AND ENABLE AMWEN
+ * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
+ */
+               outw(3, devpriv->i_IobaseAddon + 4);
+               /* initialise end of dma interrupt  AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */
+               outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
+                               APCI3120_ENABLE_WRITE_TC_INT),
+                       devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
+       }
+}
+
+/*
+ * This function handles EOS interrupt.
+ * This function copies the acquired data(from FIFO) to Comedi buffer.
+ */
+static int i_APCI3120_InterruptHandleEos(struct comedi_device *dev)
+{
+       struct addi_private *devpriv = dev->private;
+       int n_chan, i;
+       struct comedi_subdevice *s = &dev->subdevices[0];
+       int err = 1;
+
+       n_chan = devpriv->ui_AiNbrofChannels;
+
+       s->async->events = 0;
+
+       for (i = 0; i < n_chan; i++)
+               err &= comedi_buf_put(s->async, inw(dev->iobase + 0));
+
+       s->async->events |= COMEDI_CB_EOS;
+
+       if (err == 0)
+               s->async->events |= COMEDI_CB_OVERFLOW;
+
+       comedi_event(dev, s);
+
+       return 0;
+}
+
+static void v_APCI3120_Interrupt(int irq, void *d)
+{
+       struct comedi_device *dev = d;
+       struct addi_private *devpriv = dev->private;
+       unsigned short int_daq;
+       unsigned int int_amcc, ui_Check, i;
+       unsigned short us_TmpValue;
+       unsigned char b_DummyRead;
+       struct comedi_subdevice *s = &dev->subdevices[0];
+
+       ui_Check = 1;
+
+       int_daq = inw(dev->iobase + APCI3120_RD_STATUS) & 0xf000;       /*  get IRQ reasons */
+       int_amcc = inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);     /*  get AMCC int register */
+
+       if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) {
+               comedi_error(dev, "IRQ from unknown source");
+               return;
+       }
+
+       outl(int_amcc | 0x00ff0000, devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);        /*  shutdown IRQ reasons in AMCC */
+
+       int_daq = (int_daq >> 12) & 0xF;
+
+       if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) {
+               /* Disable ext trigger */
+               i_APCI3120_ExttrigDisable(dev);
+               devpriv->b_ExttrigEnable = APCI3120_DISABLE;
+       }
+       /* clear the timer 2 interrupt */
+       inb(devpriv->i_IobaseAmcc + APCI3120_TIMER_STATUS_REGISTER);
+
+       if (int_amcc & MASTER_ABORT_INT)
+               comedi_error(dev, "AMCC IRQ - MASTER DMA ABORT!");
+       if (int_amcc & TARGET_ABORT_INT)
+               comedi_error(dev, "AMCC IRQ - TARGET DMA ABORT!");
+
+       /*  Ckeck if EOC interrupt */
+       if (((int_daq & 0x8) == 0)
+               && (devpriv->b_InterruptMode == APCI3120_EOC_MODE)) {
+               if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) {
+
+                       /*  Read the AI Value */
+
+                       devpriv->ui_AiReadData[0] =
+                               (unsigned int) inw(devpriv->iobase + 0);
+                       devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
+                       send_sig(SIGIO, devpriv->tsk_Current, 0);       /*  send signal to the sample */
+               } else {
+                       /* Disable EOC Interrupt */
+                       devpriv->b_ModeSelectRegister =
+                               devpriv->
+                               b_ModeSelectRegister & APCI3120_DISABLE_EOC_INT;
+                       outb(devpriv->b_ModeSelectRegister,
+                               devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
+
+               }
+       }
+
+       /*  Check If EOS interrupt */
+       if ((int_daq & 0x2) && (devpriv->b_InterruptMode == APCI3120_EOS_MODE)) {
+
+               if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) {    /*  enable this in without DMA ??? */
+
+                       if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
+                               ui_Check = 0;
+                               i_APCI3120_InterruptHandleEos(dev);
+                               devpriv->ui_AiActualScan++;
+                               devpriv->b_ModeSelectRegister =
+                                       devpriv->
+                                       b_ModeSelectRegister |
+                                       APCI3120_ENABLE_EOS_INT;
+                               outb(devpriv->b_ModeSelectRegister,
+                                       dev->iobase +
+                                       APCI3120_WRITE_MODE_SELECT);
+                       } else {
+                               ui_Check = 0;
+                               for (i = 0; i < devpriv->ui_AiNbrofChannels;
+                                       i++) {
+                                       us_TmpValue = inw(devpriv->iobase + 0);
+                                       devpriv->ui_AiReadData[i] =
+                                               (unsigned int) us_TmpValue;
+                               }
+                               devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
+                               devpriv->b_InterruptMode = APCI3120_EOC_MODE;
+
+                               send_sig(SIGIO, devpriv->tsk_Current, 0);       /*  send signal to the sample */
+
+                       }
+
+               } else {
+                       devpriv->b_ModeSelectRegister =
+                               devpriv->
+                               b_ModeSelectRegister & APCI3120_DISABLE_EOS_INT;
+                       outb(devpriv->b_ModeSelectRegister,
+                               dev->iobase + APCI3120_WRITE_MODE_SELECT);
+                       devpriv->b_EocEosInterrupt = APCI3120_DISABLE;  /* Default settings */
+                       devpriv->b_InterruptMode = APCI3120_EOC_MODE;
+               }
+
+       }
+       /* Timer2 interrupt */
+       if (int_daq & 0x1) {
+
+               switch (devpriv->b_Timer2Mode) {
+               case APCI3120_COUNTER:
+
+                       devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
+                       devpriv->b_ModeSelectRegister =
+                               devpriv->
+                               b_ModeSelectRegister & APCI3120_DISABLE_EOS_INT;
+                       outb(devpriv->b_ModeSelectRegister,
+                               dev->iobase + APCI3120_WRITE_MODE_SELECT);
+
+                       /*  stop timer 2 */
+                       devpriv->us_OutputRegister =
+                               devpriv->
+                               us_OutputRegister & APCI3120_DISABLE_ALL_TIMER;
+                       outw(devpriv->us_OutputRegister,
+                               dev->iobase + APCI3120_WR_ADDRESS);
+
+                       /* stop timer 0 and timer 1 */
                        i_APCI3120_StopCyclicAcquisition(dev, s);
                        devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
+
+                       /* UPDATE-0.7.57->0.7.68comedi_done(dev,s); */
                        s->async->events |= COMEDI_CB_EOA;
                        comedi_event(dev, s);
-                       return;
-               }
 
-       if (devpriv->b_DmaDoubleBuffer) {       /*  switch dma buffers */
-               devpriv->ui_DmaActualBuffer = 1 - devpriv->ui_DmaActualBuffer;
-       } else {
-/*
- * restart DMA if is not used double buffering
- * ADDED REINITIALISE THE DMA
- */
-               ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
-               outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS);
+                       break;
 
-               /*  changed  since 16 bit interface for add on */
-               outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
-               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,
-                       devpriv->i_IobaseAddon + 2);
-               outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
-               outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /*  */
-/*
- * A2P FIFO MANAGEMENT
- * A2P fifo reset & transfer control enable
- */
-               outl(APCI3120_A2P_FIFO_MANAGEMENT,
-                       devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR);
+               case APCI3120_TIMER:
 
-               var = devpriv->ul_DmaBufferHw[0];
-               low_word = var & 0xffff;
-               var = devpriv->ul_DmaBufferHw[0];
-               high_word = var / 65536;
-               outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0);
-               outw(low_word, devpriv->i_IobaseAddon + 2);
-               outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
-               outw(high_word, devpriv->i_IobaseAddon + 2);
+                       /* Send a signal to from kernel to user space */
+                       send_sig(SIGIO, devpriv->tsk_Current, 0);
+                       break;
 
-               var = devpriv->ui_DmaBufferUsesize[0];
-               low_word = var & 0xffff;        /* changed */
-               var = devpriv->ui_DmaBufferUsesize[0];
-               high_word = var / 65536;
-               outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0);
-               outw(low_word, devpriv->i_IobaseAddon + 2);
-               outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
-               outw(high_word, devpriv->i_IobaseAddon + 2);
+               case APCI3120_WATCHDOG:
+
+                       /* Send a signal to from kernel to user space */
+                       send_sig(SIGIO, devpriv->tsk_Current, 0);
+                       break;
+
+               default:
+
+                       /*  disable Timer Interrupt */
+
+                       devpriv->b_ModeSelectRegister =
+                               devpriv->
+                               b_ModeSelectRegister &
+                               APCI3120_DISABLE_TIMER_INT;
+
+                       outb(devpriv->b_ModeSelectRegister,
+                               dev->iobase + APCI3120_WRITE_MODE_SELECT);
+
+               }
+
+               b_DummyRead = inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
 
-/*
- * To configure A2P FIFO
- * ENABLE A2P FIFO WRITE AND ENABLE AMWEN
- * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
- */
-               outw(3, devpriv->i_IobaseAddon + 4);
-               /* initialise end of dma interrupt  AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */
-               outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
-                               APCI3120_ENABLE_WRITE_TC_INT),
-                       devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
        }
-}
 
-/*
-+----------------------------------------------------------------------------+
-| Function name     :void v_APCI3120_InterruptDmaMoveBlock16bit(comedi_device|
-|*dev,struct comedi_subdevice *s,short *dma,short *data,int n)                              |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : This function copies the data from DMA buffer to the   |
-|                               Comedi buffer                                                                           |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                     short *dma                                                                                        |
-|                     short *data,int n                                                         |
-+----------------------------------------------------------------------------+
-| Return Value      : void                                                                      |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
+       if ((int_daq & 0x4) && (devpriv->b_InterruptMode == APCI3120_DMA_MODE)) {
+               if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
 
-void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,
-       struct comedi_subdevice *s, short *dma_buffer, unsigned int num_samples)
-{
-       struct addi_private *devpriv = dev->private;
+                       /****************************/
+                       /* Clear Timer Write TC int */
+                       /****************************/
 
-       devpriv->ui_AiActualScan +=
-               (s->async->cur_chan + num_samples) / devpriv->ui_AiScanLength;
-       s->async->cur_chan += num_samples;
-       s->async->cur_chan %= devpriv->ui_AiScanLength;
+                       outl(APCI3120_CLEAR_WRITE_TC_INT,
+                               devpriv->i_IobaseAmcc +
+                               APCI3120_AMCC_OP_REG_INTCSR);
 
-       cfc_write_array_to_buffer(s, dma_buffer, num_samples * sizeof(short));
-}
+                       /************************************/
+                       /* Clears the timer status register */
+                       /************************************/
+                       inw(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
+                       v_APCI3120_InterruptDma(irq, d);        /*  do some data transfer */
+               } else {
+                       /* Stops the Timer */
+                       outw(devpriv->
+                               us_OutputRegister & APCI3120_DISABLE_TIMER0 &
+                               APCI3120_DISABLE_TIMER1,
+                               dev->iobase + APCI3120_WR_ADDRESS);
+               }
 
-/*
-+----------------------------------------------------------------------------+
-|                           TIMER SUBDEVICE                                     |
-+----------------------------------------------------------------------------+
-*/
+       }
 
-/*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_InsnConfigTimer(struct comedi_device *dev,          |
-|      struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)                              |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              :Configure Timer 2                                                                      |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_insn *insn                                      |
-|                     unsigned int *data                                                                                |
-|                                                                                                                               |
-|                      data[0]= TIMER  configure as timer                    |
-|                                               = WATCHDOG configure as watchdog                                |
-|                                data[1] = Timer constant                                                       |
-|                                data[2] = Timer2 interrupt (1)enable or(0) disable |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
+       return;
+}
 
-int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+/*
+ * Configure Timer 2
+ *
+ * data[0] = TIMER configure as timer
+ *        = WATCHDOG configure as watchdog
+ * data[1] = Timer constant
+ * data[2] = Timer2 interrupt (1)enable or(0) disable
+ */
+static int i_APCI3120_InsnConfigTimer(struct comedi_device *dev,
+                                     struct comedi_subdevice *s,
+                                     struct comedi_insn *insn,
+                                     unsigned int *data)
 {
        const struct addi_board *this_board = comedi_board(dev);
        struct addi_private *devpriv = dev->private;
@@ -2027,35 +1962,21 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevic
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_InsnWriteTimer(struct comedi_device *dev,           |
-|                    struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data)  |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              :    To start and stop the timer                            |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_insn *insn                                      |
-|                     unsigned int *data                                         |
-|                                                                            |
-|                              data[0] = 1 (start)                                  |
-|                              data[0] = 0 (stop )                                  |
-|                              data[0] = 2  (write new value)                       |
-|                              data[1]= new value                                   |
-|                                                                            |
-|                              devpriv->b_Timer2Mode =  0 DISABLE                   |
-|                                                               1 Timer                     |
-|                                                                               2 Watch dog                         |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+ * To start and stop the timer
+ *
+ * data[0] = 1 (start)
+ *        = 0 (stop)
+ *        = 2 (write new value)
+ * data[1] = new value
+ *
+ * devpriv->b_Timer2Mode = 0 DISABLE
+ *                      = 1 Timer
+ *                      = 2 Watch dog
+ */
+static int i_APCI3120_InsnWriteTimer(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_insn *insn,
+                                    unsigned int *data)
 {
        const struct addi_board *this_board = comedi_board(dev);
        struct addi_private *devpriv = dev->private;
@@ -2217,30 +2138,17 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function name     : int i_APCI3120_InsnReadTimer(struct comedi_device *dev,           |
-|              struct comedi_subdevice *s,struct comedi_insn *insn, unsigned int *data)                 |
-|                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : read the Timer value                                                      |
-+----------------------------------------------------------------------------+
-| Input Parameters  :  struct comedi_device *dev                                                                        |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_insn *insn                                      |
-|                     unsigned int *data                                                                                |
-|                                                                                                                               |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                                                           |
-|                      for Timer:      data[0]= Timer constant                                          |
-|                                                                                                                                       |
-|                      for watchdog: data[0]=0 (still running)                  |
-|                                        data[0]=1  (run down)                                  |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+ * Read the Timer value
+ *
+ * for Timer: data[0]= Timer constant
+ *
+ * for watchdog: data[0] = 0 (still running)
+ *                      = 1 (run down)
+ */
+static int i_APCI3120_InsnReadTimer(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct comedi_insn *insn,
+                                   unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned char b_Tmp;
@@ -2288,35 +2196,12 @@ int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice
 }
 
 /*
-+----------------------------------------------------------------------------+
-|                           DIGITAL INPUT SUBDEVICE                             |
-+----------------------------------------------------------------------------+
-*/
-
-/*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,     |
-|                      struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data)   |
-|                                                                                                               |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : Reads the value of the specified  Digital input channel|
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_insn *insn                                      |
-|                     unsigned int *data                                                                                |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,
-                                   struct comedi_subdevice *s,
-                                   struct comedi_insn *insn,
-                                   unsigned int *data)
+ * Reads the value of the specified Digital input channel
+ */
+static int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,
+                                          struct comedi_subdevice *s,
+                                          struct comedi_insn *insn,
+                                          unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int ui_Chan, ui_TmpValue;
@@ -2342,26 +2227,13 @@ int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, |
-|struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data)                      |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : Reads the value of the Digital input Port i.e.4channels|
-|   value is returned in data[0]                                                                                        |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_insn *insn                                      |
-|                     unsigned int *data                                                                                |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+ * Reads the value of the Digital input Port i.e.4channels
+ * value is returned in data[0]
+ */
+static int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev,
+                                          struct comedi_subdevice *s,
+                                          struct comedi_insn *insn,
+                                          unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int ui_TmpValue;
@@ -2378,31 +2250,12 @@ int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_sub
 }
 
 /*
-+----------------------------------------------------------------------------+
-|                           DIGITAL OUTPUT SUBDEVICE                                    |
-+----------------------------------------------------------------------------+
-*/
-/*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device    |
-| *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)                          |
-|                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              :Configure the output memory ON or OFF                                  |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  :struct comedi_device *dev                                                                          |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_insn *insn                                      |
-|                     unsigned int *data                                                                                |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
-       struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+ * Configure the output memory ON or OFF
+ */
+static int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
+                                             struct comedi_subdevice *s,
+                                             struct comedi_insn *insn,
+                                             unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
 
@@ -2426,31 +2279,16 @@ int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,    |
-|              struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data)                 |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : write diatal output port                                                      |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_insn *insn                                      |
-|                     unsigned int *data                                                                                |
-|                      data[0]     Value to be written
-|                      data[1]    :1 Set digital o/p ON
-|                      data[1]     2 Set digital o/p OFF with memory ON
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,
-                                    struct comedi_subdevice *s,
-                                    struct comedi_insn *insn,
-                                    unsigned int *data)
+ * Write diatal output port
+ *
+ * data[0] = Value to be written
+ * data[1] = 1 Set digital o/p ON
+ *        = 2 Set digital o/p OFF with memory ON
+ */
+static int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,
+                                           struct comedi_subdevice *s,
+                                           struct comedi_insn *insn,
+                                           unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
 
@@ -2481,31 +2319,16 @@ int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function name                :int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,|
-|struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)       |
-|                                                                              |
-+----------------------------------------------------------------------------+
-| Task                 : Write digiatl output                                  |
-|                                                                              |
-+----------------------------------------------------------------------------+
-| Input Parameters     : struct comedi_device *dev                             |
-|                      struct comedi_subdevice *s                              |
-|                      struct comedi_insn *insn                                |
-|                      unsigned int *data                                      |
-                       data[0]     Value to be written
-                       data[1]    :1 Set digital o/p ON
-                       data[1]     2 Set digital o/p OFF with memory ON
-+----------------------------------------------------------------------------+
-| Return Value         :                                                       |
-|                                                                              |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
-                                     struct comedi_subdevice *s,
-                                     struct comedi_insn *insn,
-                                     unsigned int *data)
+ * Write digital output
+ *
+ * data[0] = Value to be written
+ * data[1] = 1 Set digital o/p ON
+ *        = 2 Set digital o/p OFF with memory ON
+ */
+static int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
+                                            struct comedi_subdevice *s,
+                                            struct comedi_insn *insn,
+                                            unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int ui_Temp1;
@@ -2555,35 +2378,11 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
 
 }
 
-/*
-+----------------------------------------------------------------------------+
-|                            ANALOG OUTPUT SUBDEVICE                         |
-+----------------------------------------------------------------------------+
-*/
-
-/*
-+----------------------------------------------------------------------------+
-| Function name     :int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,|
-|struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data)                                   |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Task              : Write  analog output                                                          |
-|                                                                                                               |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                                                         |
-|                     struct comedi_subdevice *s                                                                        |
-|                     struct comedi_insn *insn                                      |
-|                     unsigned int *data                                                                                |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                                           |
-|                                                                                                                           |
-+----------------------------------------------------------------------------+
-*/
-
-int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
-                                    struct comedi_subdevice *s,
-                                    struct comedi_insn *insn,
-                                    unsigned int *data)
+#ifdef CONFIG_APCI_3120
+static int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
+                                           struct comedi_subdevice *s,
+                                           struct comedi_insn *insn,
+                                           unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int ui_Range, ui_Channel;
@@ -2638,3 +2437,4 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
 
        return insn->n;
 }
+#endif
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.h
deleted file mode 100644 (file)
index 0cd1e3d..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-
-/* hwdrv_apci3120.h */
-
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-/* comedi related defines */
-
-/* ANALOG INPUT RANGE */
-static const struct comedi_lrange range_apci3120_ai = { 8, {
-                                                    BIP_RANGE(10),
-                                                    BIP_RANGE(5),
-                                                    BIP_RANGE(2),
-                                                    BIP_RANGE(1),
-                                                    UNI_RANGE(10),
-                                                    UNI_RANGE(5),
-                                                    UNI_RANGE(2),
-                                                    UNI_RANGE(1)
-                                                    }
-};
-
-/* ANALOG OUTPUT RANGE */
-static const struct comedi_lrange range_apci3120_ao = { 2, {
-                                                    BIP_RANGE(10),
-                                                    UNI_RANGE(10)
-                                                    }
-};
-
-#define APCI3120_BIPOLAR_RANGES        4       /*  used for test on mixture of BIP/UNI ranges */
-
-#define APCI3120_ADDRESS_RANGE                                 16
-
-#define APCI3120_DISABLE                         0
-#define APCI3120_ENABLE                          1
-
-#define APCI3120_START                           1
-#define APCI3120_STOP                            0
-
-#define     APCI3120_EOC_MODE         1
-#define     APCI3120_EOS_MODE         2
-#define     APCI3120_DMA_MODE         3
-
-/* DIGITAL INPUT-OUTPUT DEFINE */
-
-#define APCI3120_DIGITAL_OUTPUT                        0x0D
-#define APCI3120_RD_STATUS                             0x02
-#define APCI3120_RD_FIFO                               0x00
-
-/* digital output insn_write ON /OFF selection */
-#define        APCI3120_SET4DIGITALOUTPUTON                            1
-#define APCI3120_SET4DIGITALOUTPUTOFF                          0
-
-/* analog output SELECT BIT */
-#define APCI3120_ANALOG_OP_CHANNEL_1   0x0000
-#define APCI3120_ANALOG_OP_CHANNEL_2   0x4000
-#define APCI3120_ANALOG_OP_CHANNEL_3   0x8000
-#define APCI3120_ANALOG_OP_CHANNEL_4   0xC000
-#define APCI3120_ANALOG_OP_CHANNEL_5   0x0000
-#define APCI3120_ANALOG_OP_CHANNEL_6   0x4000
-#define APCI3120_ANALOG_OP_CHANNEL_7   0x8000
-#define APCI3120_ANALOG_OP_CHANNEL_8   0xC000
-
-/* Enable external trigger bit in nWrAddress */
-#define APCI3120_ENABLE_EXT_TRIGGER    0x8000
-
-/* ANALOG OUTPUT AND INPUT DEFINE */
-#define APCI3120_UNIPOLAR 0x80 /* $$ RAM sequence polarity BIT */
-#define APCI3120_BIPOLAR  0x00 /* $$ RAM sequence polarity BIT */
-#define APCI3120_ANALOG_OUTPUT_1 0x08  /*  (ADDRESS ) */
-#define APCI3120_ANALOG_OUTPUT_2 0x0A  /*  (ADDRESS ) */
-#define APCI3120_1_GAIN              0x00      /* $$ RAM sequence Gain Bits for gain 1 */
-#define APCI3120_2_GAIN              0x10      /* $$ RAM sequence Gain Bits for gain 2 */
-#define APCI3120_5_GAIN              0x20      /* $$ RAM sequence Gain Bits for gain 5 */
-#define APCI3120_10_GAIN             0x30      /* $$ RAM sequence Gain Bits for gain 10 */
-#define APCI3120_SEQ_RAM_ADDRESS        0x06   /* $$ EARLIER NAMED APCI3120_FIFO_ADDRESS */
-#define APCI3120_RESET_FIFO          0x0C      /* (ADDRESS) */
-#define APCI3120_TIMER_0_MODE_2      0x01      /* $$ Bits for timer mode */
-#define APCI3120_TIMER_0_MODE_4       0x2
-#define APCI3120_SELECT_TIMER_0_WORD 0x00
-#define APCI3120_ENABLE_TIMER0     0x1000      /* $$Gatebit 0 in nWrAddress */
-#define APCI3120_CLEAR_PR          0xF0FF
-#define APCI3120_CLEAR_PA          0xFFF0
-#define APCI3120_CLEAR_PA_PR       (APCI3120_CLEAR_PR & APCI3120_CLEAR_PA)
-
-/* nWrMode_Select */
-#define APCI3120_ENABLE_SCAN          0x8      /* $$ bit in nWrMode_Select */
-#define APCI3120_DISABLE_SCAN      (~APCI3120_ENABLE_SCAN)
-#define APCI3120_ENABLE_EOS_INT       0x2      /* $$ bit in nWrMode_Select */
-
-#define APCI3120_DISABLE_EOS_INT   (~APCI3120_ENABLE_EOS_INT)
-#define APCI3120_ENABLE_EOC_INT       0x1
-#define APCI3120_DISABLE_EOC_INT   (~APCI3120_ENABLE_EOC_INT)
-#define APCI3120_DISABLE_ALL_INTERRUPT_WITHOUT_TIMER   (APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT)
-#define APCI3120_DISABLE_ALL_INTERRUPT   (APCI3120_DISABLE_TIMER_INT & APCI3120_DISABLE_EOS_INT & APCI3120_DISABLE_EOC_INT)
-
-/* status register bits */
-#define APCI3120_EOC                     0x8000
-#define APCI3120_EOS                     0x2000
-
-/* software trigger dummy register */
-#define APCI3120_START_CONVERSION        0x02  /* (ADDRESS) */
-
-/* TIMER DEFINE */
-#define APCI3120_QUARTZ_A                                70
-#define APCI3120_QUARTZ_B                                50
-#define APCI3120_TIMER                            1
-#define APCI3120_WATCHDOG                         2
-#define APCI3120_TIMER_DISABLE                    0
-#define APCI3120_TIMER_ENABLE                     1
-#define APCI3120_ENABLE_TIMER2                    0x4000       /* $$ gatebit 2 in nWrAddress */
-#define APCI3120_DISABLE_TIMER2                   (~APCI3120_ENABLE_TIMER2)
-#define APCI3120_ENABLE_TIMER_INT                 0x04 /* $$ ENAIRQ_FC_Bit in nWrModeSelect */
-#define APCI3120_DISABLE_TIMER_INT                (~APCI3120_ENABLE_TIMER_INT)
-#define APCI3120_WRITE_MODE_SELECT                0x0E /*  (ADDRESS) */
-#define APCI3120_SELECT_TIMER_0_WORD  0x00
-#define APCI3120_SELECT_TIMER_1_WORD  0x01
-#define APCI3120_TIMER_1_MODE_2       0x4
-
-/* $$ BIT FOR MODE IN nCsTimerCtr1 */
-#define APCI3120_TIMER_2_MODE_0                   0x0
-#define APCI3120_TIMER_2_MODE_2                   0x10
-#define APCI3120_TIMER_2_MODE_5                   0x30
-
-/* $$ BIT FOR MODE IN nCsTimerCtr0 */
-#define APCI3120_SELECT_TIMER_2_LOW_WORD          0x02
-#define APCI3120_SELECT_TIMER_2_HIGH_WORD         0x03
-
-#define APCI3120_TIMER_CRT0                       0x0D /* (ADDRESS for cCsTimerCtr0) */
-#define APCI3120_TIMER_CRT1                       0x0C /* (ADDRESS for cCsTimerCtr1) */
-
-#define APCI3120_TIMER_VALUE                      0x04 /* ADDRESS for nCsTimerWert */
-#define APCI3120_TIMER_STATUS_REGISTER            0x0D /* ADDRESS for delete timer 2 interrupt */
-#define APCI3120_RD_STATUS                        0x02 /* ADDRESS */
-#define APCI3120_WR_ADDRESS                       0x00 /* ADDRESS */
-#define APCI3120_ENABLE_WATCHDOG                  0x20 /* $$BIT in nWrMode_Select */
-#define APCI3120_DISABLE_WATCHDOG                 (~APCI3120_ENABLE_WATCHDOG)
-#define APCI3120_ENABLE_TIMER_COUNTER                    0x10  /* $$BIT in nWrMode_Select */
-#define APCI3120_DISABLE_TIMER_COUNTER            (~APCI3120_ENABLE_TIMER_COUNTER)
-#define APCI3120_FC_TIMER                         0x1000       /* bit in  status register */
-#define APCI3120_ENABLE_TIMER0                    0x1000
-#define APCI3120_ENABLE_TIMER1                    0x2000
-#define APCI3120_ENABLE_TIMER2                    0x4000
-#define APCI3120_DISABLE_TIMER0                                  (~APCI3120_ENABLE_TIMER0)
-#define APCI3120_DISABLE_TIMER1                              (~APCI3120_ENABLE_TIMER1)
-#define APCI3120_DISABLE_TIMER2                          (~APCI3120_ENABLE_TIMER2)
-
-#define APCI3120_TIMER2_SELECT_EOS                0xC0 /*  ADDED on 20-6 */
-#define APCI3120_COUNTER                          3    /*  on 20-6 */
-#define APCI3120_DISABLE_ALL_TIMER                (APCI3120_DISABLE_TIMER0 & APCI3120_DISABLE_TIMER1 & APCI3120_DISABLE_TIMER2)        /*  on 20-6 */
-
-#define MAX_ANALOGINPUT_CHANNELS    32
-
-struct str_AnalogReadInformation {
-
-       unsigned char b_Type;           /* EOC or EOS */
-       unsigned char b_InterruptFlag;  /* Interrupt use or not                    */
-       unsigned int ui_ConvertTiming;  /* Selection of the conversion time        */
-       unsigned char b_NbrOfChannel;   /* Number of channel to read               */
-       unsigned int ui_ChannelList[MAX_ANALOGINPUT_CHANNELS];  /* Number of the channel to be read        */
-       unsigned int ui_RangeList[MAX_ANALOGINPUT_CHANNELS];    /* Gain of each channel                    */
-
-};
-
-
-/* Function Declaration For APCI-3120 */
-
-/* Internal functions */
-int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevice *s,
-                               int n_chan, unsigned int *chanlist, char check);
-int i_APCI3120_ExttrigEnable(struct comedi_device *dev);
-int i_APCI3120_ExttrigDisable(struct comedi_device *dev);
-int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s);
-int i_APCI3120_Reset(struct comedi_device *dev);
-int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
-                                struct comedi_subdevice *s);
-/* Interrupt functions */
-void v_APCI3120_Interrupt(int irq, void *d);
-/* UPDATE-0.7.57->0.7.68 void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,struct comedi_subdevice *s,short *dma,short *data,int n); */
-void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,
-                                          struct comedi_subdevice *s,
-                                          short *dma_buffer,
-                                          unsigned int num_samples);
-int i_APCI3120_InterruptHandleEos(struct comedi_device *dev);
-void v_APCI3120_InterruptDma(int irq, void *d);
-
-/* TIMER */
-
-int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevice *s,
-                              struct comedi_insn *insn, unsigned int *data);
-int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice *s,
-                             struct comedi_insn *insn, unsigned int *data);
-int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice *s,
-                            struct comedi_insn *insn, unsigned int *data);
-
-/*
-* DI for di read
-*/
-
-int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
-                                   struct comedi_insn *insn, unsigned int *data);
-int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
-                                   struct comedi_insn *insn, unsigned int *data);
-
-/* DO */
-/* int i_APCI3120_WriteDigitalOutput(struct comedi_device *dev,
- * unsigned char data);
- */
-int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
-                                      struct comedi_subdevice *s, struct comedi_insn *insn,
-                                      unsigned int *data);
-int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
-                                    struct comedi_insn *insn, unsigned int *data);
-int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
-                                     struct comedi_insn *insn, unsigned int *data);
-
-/* AO */
-/* int i_APCI3120_Write1AnalogValue(struct comedi_device *dev,UINT ui_Range,
- * UINT ui_Channel,UINT data );
- */
-
-int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s,
-                                    struct comedi_insn *insn, unsigned int *data);
-
-/* AI HArdware layer */
-
-int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-                                    struct comedi_insn *insn, unsigned int *data);
-int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-                                  struct comedi_insn *insn, unsigned int *data);
-int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-                                     struct comedi_cmd *cmd);
-int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s);
-/* int i_APCI3120_CancelAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s); */
-int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s);
index 7f5efa39cb76987d1b700836b72c8a55ac895f68..f2330774a6ff859d9ab6b77ed328bc76828d1329 100644 (file)
@@ -51,15 +51,131 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +----------+-----------+------------------------------------------------+
 */
 
-/*
-  +----------------------------------------------------------------------------+
-  |                               Included files                               |
-  +----------------------------------------------------------------------------+
-*/
-#include "hwdrv_apci3200.h"
-
 /* #define PRINT_INFO */
 
+/* Card Specific information */
+/* #define APCI3200_ADDRESS_RANGE      264 */
+
+/* Analog Input related Defines */
+#define APCI3200_AI_OFFSET_GAIN                0
+#define APCI3200_AI_SC_TEST            4
+#define APCI3200_AI_IRQ                        8
+#define APCI3200_AI_AUTOCAL            12
+#define APCI3200_RELOAD_CONV_TIME_VAL  32
+#define APCI3200_CONV_TIME_TIME_BASE   36
+#define APCI3200_RELOAD_DELAY_TIME_VAL 40
+#define APCI3200_DELAY_TIME_TIME_BASE  44
+#define APCI3200_AI_MODULE1            0
+#define APCI3200_AI_MODULE2            64
+#define APCI3200_AI_MODULE3            128
+#define APCI3200_AI_MODULE4            192
+#define TRUE                           1
+#define FALSE                          0
+#define APCI3200_AI_EOSIRQ             16
+#define APCI3200_AI_EOS                        20
+#define APCI3200_AI_CHAN_ID            24
+#define APCI3200_AI_CHAN_VAL           28
+#define ANALOG_INPUT                   0
+#define TEMPERATURE                    1
+#define RESISTANCE                     2
+
+#define ENABLE_EXT_TRIG                        1
+#define ENABLE_EXT_GATE                        2
+#define ENABLE_EXT_TRIG_GATE           3
+
+#define APCI3200_MAXVOLT               2.5
+#define ADDIDATA_GREATER_THAN_TEST     0
+#define ADDIDATA_LESS_THAN_TEST                1
+
+#define ADDIDATA_UNIPOLAR              1
+#define ADDIDATA_BIPOLAR               2
+
+#define MAX_MODULE                     4
+
+/* ANALOG INPUT RANGE */
+static const struct comedi_lrange range_apci3200_ai = {
+       8, {
+               BIP_RANGE(10),
+               BIP_RANGE(5),
+               BIP_RANGE(2),
+               BIP_RANGE(1),
+               UNI_RANGE(10),
+               UNI_RANGE(5),
+               UNI_RANGE(2),
+               UNI_RANGE(1)
+       }
+};
+
+static const struct comedi_lrange range_apci3300_ai = {
+       4, {
+               UNI_RANGE(10),
+               UNI_RANGE(5),
+               UNI_RANGE(2),
+               UNI_RANGE(1)
+       }
+};
+
+int MODULE_NO;
+struct {
+       int i_Gain;
+       int i_Polarity;
+       int i_OffsetRange;
+       int i_Coupling;
+       int i_SingleDiff;
+       int i_AutoCalibration;
+       unsigned int ui_ReloadValue;
+       unsigned int ui_TimeUnitReloadVal;
+       int i_Interrupt;
+       int i_ModuleSelection;
+} Config_Parameters_Module1, Config_Parameters_Module2,
+    Config_Parameters_Module3, Config_Parameters_Module4;
+
+
+struct str_ADDIDATA_RTDStruct {
+       unsigned int ul_NumberOfValue;
+       unsigned int *pul_ResistanceValue;
+       unsigned int *pul_TemperatureValue;
+};
+
+struct str_Module {
+       unsigned long ul_CurrentSourceCJC;
+       unsigned long ul_CurrentSource[5];
+       unsigned long ul_GainFactor[8]; /*  Gain Factor */
+       unsigned int w_GainValue[10];
+};
+
+struct str_BoardInfos {
+
+       int i_CJCAvailable;
+       int i_CJCPolarity;
+       int i_CJCGain;
+       int i_InterruptFlag;
+       int i_ADDIDATAPolarity;
+       int i_ADDIDATAGain;
+       int i_AutoCalibration;
+       int i_ADDIDATAConversionTime;
+       int i_ADDIDATAConversionTimeUnit;
+       int i_ADDIDATAType;
+       int i_ChannelNo;
+       int i_ChannelCount;
+       int i_ScanType;
+       int i_FirstChannel;
+       int i_LastChannel;
+       int i_Sum;
+       int i_Offset;
+       unsigned int ui_Channel_num;
+       int i_Count;
+       int i_Initialised;
+       unsigned int ui_InterruptChannelValue[144];     /* Buffer */
+       unsigned char b_StructInitialized;
+       /* 7 is the maximal number of channels */
+       unsigned int ui_ScanValueArray[7 + 12]; 
+
+       int i_ConnectionType;
+       int i_NbrOfModule;
+       struct str_Module s_Module[MAX_MODULE];
+};
+
 /* BEGIN JK 06.07.04: Management of sevrals boards */
 /*
   int i_CJCAvailable=1;
@@ -94,27 +210,10 @@ struct str_BoardInfos s_BoardInfos[100];   /*  100 will be the max number of board
 #define NVCMD_BEGIN_READ       (0x7 << 5)      /* nvRam begin read command */
 #define NVCMD_BEGIN_WRITE      (0x6 << 5)      /* EEPROM begin write command */
 
-/*+----------------------------------------------------------------------------+*/
-/*| Function   Name   : int i_AddiHeaderRW_ReadEeprom                          |*/
-/*|                               (int    i_NbOfWordsToRead,                   |*/
-/*|                                unsigned int dw_PCIBoardEepromAddress,             |*/
-/*|                                unsigned short   w_EepromStartAddress,                |*/
-/*|                                unsigned short * pw_DataRead)                          |*/
-/*+----------------------------------------------------------------------------+*/
-/*| Task              : Read word from the 5920 eeprom.                        |*/
-/*+----------------------------------------------------------------------------+*/
-/*| Input Parameters  : int    i_NbOfWordsToRead : Nbr. of word to read        |*/
-/*|                     unsigned int dw_PCIBoardEepromAddress : Address of the eeprom |*/
-/*|                     unsigned short   w_EepromStartAddress : Eeprom start address     |*/
-/*+----------------------------------------------------------------------------+*/
-/*| Output Parameters : unsigned short * pw_DataRead : Read data                          |*/
-/*+----------------------------------------------------------------------------+*/
-/*| Return Value      : -                                                      |*/
-/*+----------------------------------------------------------------------------+*/
-
-int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead,
-       unsigned int dw_PCIBoardEepromAddress,
-       unsigned short w_EepromStartAddress, unsigned short *pw_DataRead)
+static int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead,
+                                    unsigned int dw_PCIBoardEepromAddress,
+                                    unsigned short w_EepromStartAddress,
+                                    unsigned short *pw_DataRead)
 {
        unsigned int dw_eeprom_busy = 0;
        int i_Counter = 0;
@@ -241,20 +340,8 @@ int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead,
        return 0;
 }
 
-/*+----------------------------------------------------------------------------+*/
-/*| Function   Name   : void v_GetAPCI3200EepromCalibrationValue (void)        |*/
-/*+----------------------------------------------------------------------------+*/
-/*| Task              : Read calibration value from the APCI-3200 eeprom.      |*/
-/*+----------------------------------------------------------------------------+*/
-/*| Input Parameters  : -                                                      |*/
-/*+----------------------------------------------------------------------------+*/
-/*| Output Parameters : -                                                      |*/
-/*+----------------------------------------------------------------------------+*/
-/*| Return Value      : -                                                      |*/
-/*+----------------------------------------------------------------------------+*/
-
-void v_GetAPCI3200EepromCalibrationValue(unsigned int dw_PCIBoardEepromAddress,
-       struct str_BoardInfos *BoardInformations)
+static void v_GetAPCI3200EepromCalibrationValue(unsigned int dw_PCIBoardEepromAddress,
+                                               struct str_BoardInfos *BoardInformations)
 {
        unsigned short w_AnalogInputMainHeaderAddress;
        unsigned short w_AnalogInputComponentAddress;
@@ -448,9 +535,11 @@ void v_GetAPCI3200EepromCalibrationValue(unsigned int dw_PCIBoardEepromAddress,
        }
 }
 
-int i_APCI3200_GetChannelCalibrationValue(struct comedi_device *dev,
-       unsigned int ui_Channel_num, unsigned int *CJCCurrentSource,
-       unsigned int *ChannelCurrentSource, unsigned int *ChannelGainFactor)
+static int i_APCI3200_GetChannelCalibrationValue(struct comedi_device *dev,
+                                                unsigned int ui_Channel_num,
+                                                unsigned int *CJCCurrentSource,
+                                                unsigned int *ChannelCurrentSource,
+                                                unsigned int *ChannelGainFactor)
 {
        int i_DiffChannel = 0;
        int i_Module = 0;
@@ -520,33 +609,19 @@ int i_APCI3200_GetChannelCalibrationValue(struct comedi_device *dev,
        return 0;
 }
 
-/* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
 /*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_ReadDigitalInput                       |
-  |                      (struct comedi_device *dev,struct comedi_subdevice *s,               |
-  |                      struct comedi_insn *insn,unsigned int *data)                     |
-  +----------------------------------------------------------------------------+
-  | Task              : Read  value  of the selected channel or port           |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     unsigned int ui_NoOfChannels    : No Of Channels To read  for Port
-  Channel Numberfor single channel
-  |                     unsigned int data[0]            : 0: Read single channel
-  1: Read port value
-  data[1]              Port number
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --      data[0] :Read status value
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-
-int i_APCI3200_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+ * Read  value  of the selected channel or port
+ *
+ * data[0] = 0: Read single channel
+ *        = 1 Read port value
+ * data[1] = Port number
+ *
+ * data[0] : Read status value
+ */
+static int i_APCI3200_ReadDigitalInput(struct comedi_device *dev,
+                                      struct comedi_subdevice *s,
+                                      struct comedi_insn *insn,
+                                      unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int ui_Temp = 0;
@@ -587,26 +662,15 @@ int i_APCI3200_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevi
 }
 
 /*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_ConfigDigitalOutput                     |
-  |                      (struct comedi_device *dev,struct comedi_subdevice *s,                                 |
-  |                      struct comedi_insn *insn,unsigned int *data)                     |
-  +----------------------------------------------------------------------------+
-  | Task              : Configures The Digital Output Subdevice.               |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev : Driver handle                     |
-  |                      data[0]  :1  Memory enable
-  0  Memory Disable
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error                      |
-  |                                                                                                                                     |
-  +----------------------------------------------------------------------------+
-*/
-int i_APCI3200_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+ * Configures The Digital Output Subdevice.
+ *
+ * data[0] = 1  Memory enable
+ *        = 0  Memory Disable
+ */
+static int i_APCI3200_ConfigDigitalOutput(struct comedi_device *dev,
+                                         struct comedi_subdevice *s,
+                                         struct comedi_insn *insn,
+                                         unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
 
@@ -625,34 +689,19 @@ int i_APCI3200_ConfigDigitalOutput(struct comedi_device *dev, struct comedi_subd
 }
 
 /*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_WriteDigitalOutput                      |
-  |                      (struct comedi_device *dev,struct comedi_subdevice *s,                                 |
-  |                      struct comedi_insn *insn,unsigned int *data)                     |
-  +----------------------------------------------------------------------------+
-  | Task              : writes To the digital Output Subdevice                 |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     struct comedi_subdevice *s     : Subdevice Pointer            |
-  |                     struct comedi_insn *insn       : Insn Structure Pointer       |
-  |                     unsigned int *data          : Data Pointer contains        |
-  |                                          configuration parameters as below |
-  |                     data[0]             :Value to output
-  data[1]             : 0 o/p single channel
-  1 o/p port
-  data[2]             : port no
-  data[3]             :0 set the digital o/p on
-  1 set the digital o/p off
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error              |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-int i_APCI3200_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+ * Writes To the digital Output Subdevice
+ *
+ * data[0] = Value to output
+ * data[1] = 0  o/p single channel
+ *        = 1  o/p port
+ * data[2] = port no
+ * data[3] = 0  set the digital o/p on
+ *        = 1  set the digital o/p off
+ */
+static int i_APCI3200_WriteDigitalOutput(struct comedi_device *dev,
+                                        struct comedi_subdevice *s,
+                                        struct comedi_insn *insn,
+                                        unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int ui_Temp = 0, ui_Temp1 = 0;
@@ -744,30 +793,16 @@ int i_APCI3200_WriteDigitalOutput(struct comedi_device *dev, struct comedi_subde
 }
 
 /*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_ReadDigitalOutput                       |
-  |                      (struct comedi_device *dev,struct comedi_subdevice *s,               |
-  |                      struct comedi_insn *insn,unsigned int *data)                     |
-  +----------------------------------------------------------------------------+
-  | Task              : Read  value  of the selected channel or port           |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     unsigned int ui_NoOfChannels    : No Of Channels To read       |
-  |                     unsigned int *data              : Data Pointer to read status  |
-  data[0]                 :0 read single channel
-  1 read port value
-  data[1]                  port no
-
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-int i_APCI3200_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+ * Read  value  of the selected channel or port
+ *
+ * data[0] = 0  read single channel
+ *        = 1  read port value
+ * data[1] = port no
+ */
+static int i_APCI3200_ReadDigitalOutput(struct comedi_device *dev,
+                                       struct comedi_subdevice *s,
+                                       struct comedi_insn *insn,
+                                       unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int ui_Temp;
@@ -806,881 +841,360 @@ int i_APCI3200_ReadDigitalOutput(struct comedi_device *dev, struct comedi_subdev
        return insn->n;
 }
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_ConfigAnalogInput                       |
-  |                      (struct comedi_device *dev,struct comedi_subdevice *s,               |
-  |                      struct comedi_insn *insn,unsigned int *data)                     |
-  +----------------------------------------------------------------------------+
-  | Task              : Configures The Analog Input Subdevice                  |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     struct comedi_subdevice *s     : Subdevice Pointer            |
-  |                     struct comedi_insn *insn       : Insn Structure Pointer       |
-  |                     unsigned int *data          : Data Pointer contains        |
-  |                                          configuration parameters as below |
-  |                                                                            |
-  |                                    data[0]
-  |                                               0:Normal AI                  |
-  |                                               1:RTD                        |
-  |                                               2:THERMOCOUPLE               |
-  |                                data[1]            : Gain To Use                 |
-  |                                                                            |
-  |                           data[2]            : Polarity
-  |                                                0:Bipolar                   |
-  |                                                1:Unipolar                  |
-  |                                                                                                                             |
-  |                           data[3]            : Offset Range
-  |                                                                            |
-  |                           data[4]            : Coupling
-  |                                                0:DC Coupling               |
-  |                                                1:AC Coupling               |
-  |                                                                            |
-  |                           data[5]            :Differential/Single
-  |                                                0:Single                    |
-  |                                                1:Differential              |
-  |                                                                            |
-  |                           data[6]            :TimerReloadValue
-  |                                                                            |
-  |                           data[7]            :ConvertingTimeUnit
-  |                                                                            |
-  |                           data[8]             :0 Analog voltage measurement
-  1 Resistance measurement
-  2 Temperature measurement
-  |                           data[9]            :Interrupt
-  |                                              0:Disable
-  |                                              1:Enable
-  data[10]           :Type of Thermocouple
-  |                          data[11]           : 0: single channel
-  Module Number
-  |
-  |                          data[12]
-  |                                             0:Single Read
-  |                                             1:Read more channel
-  2:Single scan
-  |                                             3:Continuous Scan
-  data[13]          :Number of channels to read
-  |                          data[14]          :RTD connection type
-  :0:RTD not used
-  1:RTD 2 wire connection
-  2:RTD 3 wire connection
-  3:RTD 4 wire connection
-  |                                                                            |
-  |                                                                            |
-  |                                                                            |
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-int i_APCI3200_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
+static int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev,
+                                             struct comedi_subdevice *s,
+                                             struct comedi_insn *insn,
+                                             unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
-       unsigned int ul_Config = 0, ul_Temp = 0;
+       unsigned int ui_EOC = 0;
        unsigned int ui_ChannelNo = 0;
-       unsigned int ui_Dummy = 0;
-       int i_err = 0;
+       unsigned int ui_CommandRegister = 0;
 
-       /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /* ui_ChannelNo=i_ChannelNo; */
+       ui_ChannelNo = s_BoardInfos[dev->minor].i_ChannelNo;
 
-#ifdef PRINT_INFO
-       int i = 0, i2 = 0;
-#endif
-       /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
+  /*********************************/
+       /* Write the channel to configure */
+  /*********************************/
+       /* Begin JK 20.10.2004: Bad channel value is used when using differential mode */
+       /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
+       /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
+       outl(0 | s_BoardInfos[dev->minor].i_ChannelNo,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4);
+       /* End JK 20.10.2004: Bad channel value is used when using differential mode */
 
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /*  Initialize the structure */
-       if (s_BoardInfos[dev->minor].b_StructInitialized != 1) {
-               s_BoardInfos[dev->minor].i_CJCAvailable = 1;
-               s_BoardInfos[dev->minor].i_CJCPolarity = 0;
-               s_BoardInfos[dev->minor].i_CJCGain = 2; /* changed from 0 to 2 */
-               s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-               s_BoardInfos[dev->minor].i_AutoCalibration = 0; /* : auto calibration */
-               s_BoardInfos[dev->minor].i_ChannelCount = 0;
-               s_BoardInfos[dev->minor].i_Sum = 0;
-               s_BoardInfos[dev->minor].ui_Channel_num = 0;
-               s_BoardInfos[dev->minor].i_Count = 0;
-               s_BoardInfos[dev->minor].i_Initialised = 0;
-               s_BoardInfos[dev->minor].b_StructInitialized = 1;
+  /*******************************/
+       /* Set the convert timing unit */
+  /*******************************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
 
-               /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               s_BoardInfos[dev->minor].i_ConnectionType = 0;
-               /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
+       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
 
-               /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               memset(s_BoardInfos[dev->minor].s_Module, 0,
-                       sizeof(s_BoardInfos[dev->minor].s_Module[MAX_MODULE]));
+  /**************************/
+       /* Set the convert timing */
+  /**************************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
 
-               v_GetAPCI3200EepromCalibrationValue(devpriv->i_IobaseAmcc,
-                       &s_BoardInfos[dev->minor]);
+       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
+       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
 
-#ifdef PRINT_INFO
-               for (i = 0; i < MAX_MODULE; i++) {
-                       printk("\n s_Module[%i].ul_CurrentSourceCJC = %lu", i,
-                               s_BoardInfos[dev->minor].s_Module[i].
-                               ul_CurrentSourceCJC);
+  /**************************************************************************/
+       /* Set the start end stop index to the selected channel and set the start */
+  /**************************************************************************/
 
-                       for (i2 = 0; i2 < 5; i2++) {
-                               printk("\n s_Module[%i].ul_CurrentSource [%i] = %lu", i, i2, s_BoardInfos[dev->minor].s_Module[i].ul_CurrentSource[i2]);
-                       }
+       ui_CommandRegister = ui_ChannelNo | (ui_ChannelNo << 8) | 0x80000;
 
-                       for (i2 = 0; i2 < 8; i2++) {
-                               printk("\n s_Module[%i].ul_GainFactor [%i] = %lu", i, i2, s_BoardInfos[dev->minor].s_Module[i].ul_GainFactor[i2]);
-                       }
+  /*********************************/
+       /*Test if the interrupt is enable */
+  /*********************************/
 
-                       for (i2 = 0; i2 < 8; i2++) {
-                               printk("\n s_Module[%i].w_GainValue [%i] = %u",
-                                       i, i2,
-                                       s_BoardInfos[dev->minor].s_Module[i].
-                                       w_GainValue[i2]);
-                       }
-               }
-#endif
-               /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-       }
+       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
+       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
+      /************************/
+               /* Enable the interrupt */
+      /************************/
+               ui_CommandRegister = ui_CommandRegister | 0x00100000;
+       }                       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
 
-       if (data[0] != 0 && data[0] != 1 && data[0] != 2) {
-               printk("\nThe selection of acquisition type is in error\n");
-               i_err++;
-       }                       /* if(data[0]!=0 && data[0]!=1 && data[0]!=2) */
-       if (data[0] == 1) {
-               if (data[14] != 0 && data[14] != 1 && data[14] != 2
-                       && data[14] != 4) {
-                       printk("\n Error in selection of RTD connection type\n");
-                       i_err++;
-               }               /* if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4) */
-       }                       /* if(data[0]==1 ) */
-       if (data[1] < 0 || data[1] > 7) {
-               printk("\nThe selection of gain is in error\n");
-               i_err++;
-       }                       /*  if(data[1]<0 || data[1]>7) */
-       if (data[2] != 0 && data[2] != 1) {
-               printk("\nThe selection of polarity is in error\n");
-               i_err++;
-       }                       /* if(data[2]!=0 &&  data[2]!=1) */
-       if (data[3] != 0) {
-               printk("\nThe selection of offset range  is in error\n");
-               i_err++;
-       }                       /*  if(data[3]!=0) */
-       if (data[4] != 0 && data[4] != 1) {
-               printk("\nThe selection of coupling is in error\n");
-               i_err++;
-       }                       /* if(data[4]!=0 &&  data[4]!=1) */
-       if (data[5] != 0 && data[5] != 1) {
-               printk("\nThe selection of single/differential mode is in error\n");
-               i_err++;
-       }                       /* if(data[5]!=0 &&  data[5]!=1) */
-       if (data[8] != 0 && data[8] != 1 && data[2] != 2) {
-               printk("\nError in selection of functionality\n");
-       }                       /* if(data[8]!=0 && data[8]!=1 && data[2]!=2) */
-       if (data[12] == 0 || data[12] == 1) {
-               if (data[6] != 20 && data[6] != 40 && data[6] != 80
-                       && data[6] != 160) {
-                       printk("\nThe selection of conversion time reload value is in error\n");
-                       i_err++;
-               }               /*  if (data[6]!=20 && data[6]!=40 && data[6]!=80 && data[6]!=160 ) */
-               if (data[7] != 2) {
-                       printk("\nThe selection of conversion time unit  is in error\n");
-                       i_err++;
-               }               /*  if(data[7]!=2) */
-       }
-       if (data[9] != 0 && data[9] != 1) {
-               printk("\nThe selection of interrupt enable is in error\n");
-               i_err++;
-       }                       /* if(data[9]!=0 &&  data[9]!=1) */
-       if (data[11] < 0 || data[11] > 4) {
-               printk("\nThe selection of module is in error\n");
-               i_err++;
-       }                       /* if(data[11] <0 ||  data[11]>1) */
-       if (data[12] < 0 || data[12] > 3) {
-               printk("\nThe selection of singlechannel/scan selection is in error\n");
-               i_err++;
-       }                       /* if(data[12] < 0 ||  data[12]> 3) */
-       if (data[13] < 0 || data[13] > 16) {
-               printk("\nThe selection of number of channels is in error\n");
-               i_err++;
-       }                       /*  if(data[13] <0 ||data[13] >15) */
+  /******************************/
+       /* Write the command register */
+  /******************************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
 
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /*
-          i_ChannelCount=data[13];
-          i_ScanType=data[12];
-          i_ADDIDATAPolarity = data[2];
-          i_ADDIDATAGain=data[1];
-          i_ADDIDATAConversionTime=data[6];
-          i_ADDIDATAConversionTimeUnit=data[7];
-          i_ADDIDATAType=data[0];
-        */
+       /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */
+       outl(ui_CommandRegister,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
 
-       /*  Save acquisition configuration for the actual board */
-       s_BoardInfos[dev->minor].i_ChannelCount = data[13];
-       s_BoardInfos[dev->minor].i_ScanType = data[12];
-       s_BoardInfos[dev->minor].i_ADDIDATAPolarity = data[2];
-       s_BoardInfos[dev->minor].i_ADDIDATAGain = data[1];
-       s_BoardInfos[dev->minor].i_ADDIDATAConversionTime = data[6];
-       s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit = data[7];
-       s_BoardInfos[dev->minor].i_ADDIDATAType = data[0];
-       /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-       s_BoardInfos[dev->minor].i_ConnectionType = data[5];
-       /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-       /* END JK 06.07.04: Management of sevrals boards */
+  /*****************************/
+       /*Test if interrupt is enable */
+  /*****************************/
+       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
+       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
+               do {
+         /*************************/
+                       /*Read the EOC Status bit */
+         /*************************/
 
-       /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-       memset(s_BoardInfos[dev->minor].ui_ScanValueArray, 0, (7 + 12) * sizeof(unsigned int)); /*  7 is the maximal number of channels */
-       /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+                       /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
+                       ui_EOC = inl(devpriv->iobase +
+                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
 
-       /* BEGIN JK 02.07.04 : This while can't be do, it block the process when using severals boards */
-       /* while(i_InterruptFlag==1) */
-       while (s_BoardInfos[dev->minor].i_InterruptFlag == 1) {
-#ifndef MSXBOX
-               udelay(1);
-#else
-               /*  In the case where the driver is compiled for the MSX-Box */
-               /*  we used a printk to have a little delay because udelay */
-               /*  seems to be broken under the MSX-Box. */
-               /*  This solution hat to be studied. */
-               printk("");
-#endif
-       }
-       /* END JK 02.07.04 : This while can't be do, it block the process when using severals boards */
+               } while (ui_EOC != 1);
 
-       ui_ChannelNo = CR_CHAN(insn->chanspec); /*  get the channel */
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* i_ChannelNo=ui_ChannelNo; */
-       /* ui_Channel_num =ui_ChannelNo; */
+      /***************************************/
+               /* Read the digital value of the input */
+      /***************************************/
 
-       s_BoardInfos[dev->minor].i_ChannelNo = ui_ChannelNo;
-       s_BoardInfos[dev->minor].ui_Channel_num = ui_ChannelNo;
+               /* data[0] = inl (devpriv->iobase+i_Offset + 28); */
+               data[0] =
+                       inl(devpriv->iobase +
+                       s_BoardInfos[dev->minor].i_Offset + 28);
+               /* END JK 06.07.04: Management of sevrals boards */
 
-       /* END JK 06.07.04: Management of sevrals boards */
+       }                       /*  if (i_InterruptFlag == ADDIDATA_DISABLE) */
+       return 0;
+}
 
-       if (data[5] == 0) {
-               if (ui_ChannelNo < 0 || ui_ChannelNo > 15) {
-                       printk("\nThe Selection of the channel is in error\n");
-                       i_err++;
-               }               /*  if(ui_ChannelNo<0 || ui_ChannelNo>15) */
-       }                       /* if(data[5]==0) */
-       else {
-               if (data[14] == 2) {
-                       if (ui_ChannelNo < 0 || ui_ChannelNo > 3) {
-                               printk("\nThe Selection of the channel is in error\n");
-                               i_err++;
-                       }       /*  if(ui_ChannelNo<0 || ui_ChannelNo>3) */
-               }               /* if(data[14]==2) */
-               else {
-                       if (ui_ChannelNo < 0 || ui_ChannelNo > 7) {
-                               printk("\nThe Selection of the channel is in error\n");
-                               i_err++;
-                       }       /*  if(ui_ChannelNo<0 || ui_ChannelNo>7) */
-               }               /* elseif(data[14]==2) */
-       }                       /* elseif(data[5]==0) */
-       if (data[12] == 0 || data[12] == 1) {
-               switch (data[5]) {
-               case 0:
-                       if (ui_ChannelNo >= 0 && ui_ChannelNo <= 3) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_Offset=0; */
-                               s_BoardInfos[dev->minor].i_Offset = 0;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(ui_ChannelNo >=0 && ui_ChannelNo <=3) */
-                       if (ui_ChannelNo >= 4 && ui_ChannelNo <= 7) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_Offset=64; */
-                               s_BoardInfos[dev->minor].i_Offset = 64;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(ui_ChannelNo >=4 && ui_ChannelNo <=7) */
-                       if (ui_ChannelNo >= 8 && ui_ChannelNo <= 11) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_Offset=128; */
-                               s_BoardInfos[dev->minor].i_Offset = 128;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(ui_ChannelNo >=8 && ui_ChannelNo <=11) */
-                       if (ui_ChannelNo >= 12 && ui_ChannelNo <= 15) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_Offset=192; */
-                               s_BoardInfos[dev->minor].i_Offset = 192;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(ui_ChannelNo >=12 && ui_ChannelNo <=15) */
-                       break;
-               case 1:
-                       if (data[14] == 2) {
-                               if (ui_ChannelNo == 0) {
-                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                                       /* i_Offset=0; */
-                                       s_BoardInfos[dev->minor].i_Offset = 0;
-                                       /* END JK 06.07.04: Management of sevrals boards */
-                               }       /* if(ui_ChannelNo ==0 ) */
-                               if (ui_ChannelNo == 1) {
-                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                                       /* i_Offset=0; */
-                                       s_BoardInfos[dev->minor].i_Offset = 64;
-                                       /* END JK 06.07.04: Management of sevrals boards */
-                               }       /*  if(ui_ChannelNo ==1) */
-                               if (ui_ChannelNo == 2) {
-                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                                       /* i_Offset=128; */
-                                       s_BoardInfos[dev->minor].i_Offset = 128;
-                                       /* END JK 06.07.04: Management of sevrals boards */
-                               }       /* if(ui_ChannelNo ==2 ) */
-                               if (ui_ChannelNo == 3) {
-                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                                       /* i_Offset=192; */
-                                       s_BoardInfos[dev->minor].i_Offset = 192;
-                                       /* END JK 06.07.04: Management of sevrals boards */
-                               }       /* if(ui_ChannelNo ==3) */
-
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_ChannelNo=0; */
-                               s_BoardInfos[dev->minor].i_ChannelNo = 0;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                               ui_ChannelNo = 0;
-                               break;
-                       }       /* if(data[14]==2) */
-                       if (ui_ChannelNo >= 0 && ui_ChannelNo <= 1) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_Offset=0; */
-                               s_BoardInfos[dev->minor].i_Offset = 0;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(ui_ChannelNo >=0 && ui_ChannelNo <=1) */
-                       if (ui_ChannelNo >= 2 && ui_ChannelNo <= 3) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_ChannelNo=i_ChannelNo-2; */
-                               /* i_Offset=64; */
-                               s_BoardInfos[dev->minor].i_ChannelNo =
-                                       s_BoardInfos[dev->minor].i_ChannelNo -
-                                       2;
-                               s_BoardInfos[dev->minor].i_Offset = 64;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                               ui_ChannelNo = ui_ChannelNo - 2;
-                       }       /* if(ui_ChannelNo >=2 && ui_ChannelNo <=3) */
-                       if (ui_ChannelNo >= 4 && ui_ChannelNo <= 5) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_ChannelNo=i_ChannelNo-4; */
-                               /* i_Offset=128; */
-                               s_BoardInfos[dev->minor].i_ChannelNo =
-                                       s_BoardInfos[dev->minor].i_ChannelNo -
-                                       4;
-                               s_BoardInfos[dev->minor].i_Offset = 128;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                               ui_ChannelNo = ui_ChannelNo - 4;
-                       }       /* if(ui_ChannelNo >=4 && ui_ChannelNo <=5) */
-                       if (ui_ChannelNo >= 6 && ui_ChannelNo <= 7) {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* i_ChannelNo=i_ChannelNo-6; */
-                               /* i_Offset=192; */
-                               s_BoardInfos[dev->minor].i_ChannelNo =
-                                       s_BoardInfos[dev->minor].i_ChannelNo -
-                                       6;
-                               s_BoardInfos[dev->minor].i_Offset = 192;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                               ui_ChannelNo = ui_ChannelNo - 6;
-                       }       /* if(ui_ChannelNo >=6 && ui_ChannelNo <=7) */
-                       break;
-
-               default:
-                       printk("\n This selection of polarity does not exist\n");
-                       i_err++;
-               }               /* switch(data[2]) */
-       }                       /* if(data[12]==0 || data[12]==1) */
-       else {
-               switch (data[11]) {
-               case 1:
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* i_Offset=0; */
-                       s_BoardInfos[dev->minor].i_Offset = 0;
-                       /* END JK 06.07.04: Management of sevrals boards */
-                       break;
-               case 2:
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* i_Offset=64; */
-                       s_BoardInfos[dev->minor].i_Offset = 64;
-                       /* END JK 06.07.04: Management of sevrals boards */
-                       break;
-               case 3:
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* i_Offset=128; */
-                       s_BoardInfos[dev->minor].i_Offset = 128;
-                       /* END JK 06.07.04: Management of sevrals boards */
-                       break;
-               case 4:
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* i_Offset=192; */
-                       s_BoardInfos[dev->minor].i_Offset = 192;
-                       /* END JK 06.07.04: Management of sevrals boards */
-                       break;
-               default:
-                       printk("\nError in module selection\n");
-                       i_err++;
-               }               /*  switch(data[11]) */
-       }                       /*  elseif(data[12]==0 || data[12]==1) */
-       if (i_err) {
-               i_APCI3200_Reset(dev);
-               return -EINVAL;
-       }
-       /* if(i_ScanType!=1) */
-       if (s_BoardInfos[dev->minor].i_ScanType != 1) {
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* i_Count=0; */
-               /* i_Sum=0; */
-               s_BoardInfos[dev->minor].i_Count = 0;
-               s_BoardInfos[dev->minor].i_Sum = 0;
-               /* END JK 06.07.04: Management of sevrals boards */
-       }                       /* if(i_ScanType!=1) */
+static int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev,
+                                                unsigned int *data)
+{
+       struct addi_private *devpriv = dev->private;
+       unsigned int ui_Temp = 0, ui_EOC = 0;
+       unsigned int ui_CommandRegister = 0;
 
-       ul_Config =
-               data[1] | (data[2] << 6) | (data[5] << 7) | (data[3] << 8) |
-               (data[4] << 9);
        /* BEGIN JK 06.07.04: Management of sevrals boards */
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* END JK 06.07.04: Management of sevrals boards */
   /*********************************/
        /* Write the channel to configure */
   /*********************************/
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* outl(0 | ui_ChannelNo , devpriv->iobase+i_Offset + 0x4); */
-       outl(0 | ui_ChannelNo,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4);
-       /* END JK 06.07.04: Management of sevrals boards */
+       /* Begin JK 20.10.2004: This seems not necessary ! */
+       /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
+       /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
+       /* End JK 20.10.2004: This seems not necessary ! */
 
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
+  /*******************************/
+       /* Set the convert timing unit */
+  /*******************************/
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* END JK 06.07.04: Management of sevrals boards */
+       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
+       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
   /**************************/
-       /* Reset the configuration */
+       /* Set the convert timing */
   /**************************/
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* outl(0 , devpriv->iobase+i_Offset + 0x0); */
-       outl(0, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0);
-       /* END JK 06.07.04: Management of sevrals boards */
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* END JK 06.07.04: Management of sevrals boards */
-
-  /***************************/
-       /* Write the configuration */
-  /***************************/
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* outl(ul_Config , devpriv->iobase+i_Offset + 0x0); */
-       outl(ul_Config,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0);
-       /* END JK 06.07.04: Management of sevrals boards */
-
-  /***************************/
-       /*Reset the calibration bit */
-  /***************************/
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* ul_Temp = inl(devpriv->iobase+i_Offset + 12); */
-       ul_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-       /* END JK 06.07.04: Management of sevrals boards */
+       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
+       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
+  /*****************************/
+       /*Read the calibration offset */
+  /*****************************/
+       /* ui_Temp = inl(devpriv->iobase+i_Offset + 12); */
+       ui_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
 
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
+  /*********************************/
+       /*Configure the Offset Conversion */
+  /*********************************/
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* END JK 06.07.04: Management of sevrals boards */
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* outl((ul_Temp & 0xFFF9FFFF) , devpriv->iobase+.i_Offset + 12); */
-       outl((ul_Temp & 0xFFF9FFFF),
+       /* outl((ui_Temp | 0x00020000), devpriv->iobase+i_Offset + 12); */
+       outl((ui_Temp | 0x00020000),
                devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-       /* END JK 06.07.04: Management of sevrals boards */
+  /*******************************/
+       /*Initialise ui_CommandRegister */
+  /*******************************/
 
-       if (data[9] == 1) {
-               devpriv->tsk_Current = current;
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* i_InterruptFlag=1; */
-               s_BoardInfos[dev->minor].i_InterruptFlag = 1;
-               /* END JK 06.07.04: Management of sevrals boards */
-       }                       /*  if(data[9]==1) */
-       else {
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* i_InterruptFlag=0; */
-               s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-               /* END JK 06.07.04: Management of sevrals boards */
-       }                       /* else  if(data[9]==1) */
+       ui_CommandRegister = 0;
 
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* i_Initialised=1; */
-       s_BoardInfos[dev->minor].i_Initialised = 1;
-       /* END JK 06.07.04: Management of sevrals boards */
+  /*********************************/
+       /*Test if the interrupt is enable */
+  /*********************************/
 
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* if(i_ScanType==1) */
-       if (s_BoardInfos[dev->minor].i_ScanType == 1)
-               /* END JK 06.07.04: Management of sevrals boards */
-       {
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* i_Sum=i_Sum+1; */
-               s_BoardInfos[dev->minor].i_Sum =
-                       s_BoardInfos[dev->minor].i_Sum + 1;
-               /* END JK 06.07.04: Management of sevrals boards */
+       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
+       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
 
-               insn->unused[0] = 0;
-               i_APCI3200_ReadAnalogInput(dev, s, insn, &ui_Dummy);
-       }
+      /**********************/
+               /*Enable the interrupt */
+      /**********************/
 
-       return insn->n;
-}
+               ui_CommandRegister = ui_CommandRegister | 0x00100000;
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_ReadAnalogInput                         |
-  |                              (struct comedi_device *dev,struct comedi_subdevice *s,       |
-  |                     struct comedi_insn *insn,unsigned int *data)                      |
-  +----------------------------------------------------------------------------+
-  | Task              : Read  value  of the selected channel                            |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     unsigned int ui_NoOfChannels    : No Of Channels To read       |
-  |                     unsigned int *data              : Data Pointer to read status  |
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  |                            data[0]  : Digital Value Of Input             |
-  |                            data[1]  : Calibration Offset Value           |
-  |                            data[2]  : Calibration Gain Value
-  |                            data[3]  : CJC value
-  |                            data[4]  : CJC offset value
-  |                            data[5]  : CJC gain value
-  | Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
-  |                            data[6] : CJC current source from eeprom
-  |                            data[7] : Channel current source from eeprom
-  |                            data[8] : Channle gain factor from eeprom
-  | End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-int i_APCI3200_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_insn *insn, unsigned int *data)
-{
-       unsigned int ui_DummyValue = 0;
-       int i_ConvertCJCCalibration;
-       int i = 0;
+       }                       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
 
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* if(i_Initialised==0) */
-       if (s_BoardInfos[dev->minor].i_Initialised == 0)
-               /* END JK 06.07.04: Management of sevrals boards */
-       {
-               i_APCI3200_Reset(dev);
-               return -EINVAL;
-       }                       /* if(i_Initialised==0); */
+  /**********************/
+       /*Start the conversion */
+  /**********************/
+       ui_CommandRegister = ui_CommandRegister | 0x00080000;
 
-#ifdef PRINT_INFO
-       printk("\n insn->unused[0] = %i", insn->unused[0]);
-#endif
+  /***************************/
+       /*Write the command regiter */
+  /***************************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
+       /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */
+       outl(ui_CommandRegister,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
 
-       switch (insn->unused[0]) {
-       case 0:
+  /*****************************/
+       /*Test if interrupt is enable */
+  /*****************************/
 
-               i_APCI3200_Read1AnalogInputChannel(dev, s, insn,
-                       &ui_DummyValue);
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* ui_InterruptChannelValue[i_Count+0]=ui_DummyValue; */
-               s_BoardInfos[dev->minor].
-                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
-                       i_Count + 0] = ui_DummyValue;
-               /* END JK 06.07.04: Management of sevrals boards */
+       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
+       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
 
-               /* Begin JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               i_APCI3200_GetChannelCalibrationValue(dev,
-                       s_BoardInfos[dev->minor].ui_Channel_num,
-                       &s_BoardInfos[dev->minor].
-                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
-                               i_Count + 6],
-                       &s_BoardInfos[dev->minor].
-                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
-                               i_Count + 7],
-                       &s_BoardInfos[dev->minor].
-                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
-                               i_Count + 8]);
+               do {
+         /*******************/
+                       /*Read the EOC flag */
+         /*******************/
 
-#ifdef PRINT_INFO
-               printk("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+6] = %lu", s_BoardInfos[dev->minor].ui_InterruptChannelValue[s_BoardInfos[dev->minor].i_Count + 6]);
+                       /* ui_EOC = inl (devpriv->iobase+i_Offset + 20) & 1; */
+                       ui_EOC = inl(devpriv->iobase +
+                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
 
-               printk("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+7] = %lu", s_BoardInfos[dev->minor].ui_InterruptChannelValue[s_BoardInfos[dev->minor].i_Count + 7]);
+               } while (ui_EOC != 1);
 
-               printk("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+8] = %lu", s_BoardInfos[dev->minor].ui_InterruptChannelValue[s_BoardInfos[dev->minor].i_Count + 8]);
-#endif
+      /**************************************************/
+               /*Read the digital value of the calibration Offset */
+      /**************************************************/
 
-               /* End JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+               /* data[0] = inl(devpriv->iobase+i_Offset+ 28); */
+               data[0] =
+                       inl(devpriv->iobase +
+                       s_BoardInfos[dev->minor].i_Offset + 28);
+       }                       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
+       return 0;
+}
 
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */
-               if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2)
-                       && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE)
-                       && (s_BoardInfos[dev->minor].i_CJCAvailable == 1))
-                       /* END JK 06.07.04: Management of sevrals boards */
-               {
-                       i_APCI3200_ReadCJCValue(dev, &ui_DummyValue);
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* ui_InterruptChannelValue[i_Count + 3]=ui_DummyValue; */
-                       s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[s_BoardInfos[dev->
-                                       minor].i_Count + 3] = ui_DummyValue;
-                       /* END JK 06.07.04: Management of sevrals boards */
-               }               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */
-               else {
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* ui_InterruptChannelValue[i_Count + 3]=0; */
-                       s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[s_BoardInfos[dev->
-                                       minor].i_Count + 3] = 0;
-                       /* END JK 06.07.04: Management of sevrals boards */
-               }               /* elseif((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */
+static int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev,
+                                              unsigned int *data)
+{
+       struct addi_private *devpriv = dev->private;
+       unsigned int ui_EOC = 0;
+       int ui_CommandRegister = 0;
 
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */
-               if ((s_BoardInfos[dev->minor].i_AutoCalibration == FALSE)
-                       && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE))
-                       /* END JK 06.07.04: Management of sevrals boards */
-               {
-                       i_APCI3200_ReadCalibrationOffsetValue(dev,
-                               &ui_DummyValue);
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* ui_InterruptChannelValue[i_Count + 1]=ui_DummyValue; */
-                       s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[s_BoardInfos[dev->
-                                       minor].i_Count + 1] = ui_DummyValue;
-                       /* END JK 06.07.04: Management of sevrals boards */
-                       i_APCI3200_ReadCalibrationGainValue(dev,
-                               &ui_DummyValue);
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* ui_InterruptChannelValue[i_Count + 2]=ui_DummyValue; */
-                       s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[s_BoardInfos[dev->
-                                       minor].i_Count + 2] = ui_DummyValue;
-                       /* END JK 06.07.04: Management of sevrals boards */
-               }               /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
+  /*********************************/
+       /* Write the channel to configure */
+  /*********************************/
+       /* Begin JK 20.10.2004: This seems not necessary ! */
+       /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
+       /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
+       /* End JK 20.10.2004: This seems not necessary ! */
 
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)&& (i_CJCAvailable==1)) */
-               if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2)
-                       && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE)
-                       && (s_BoardInfos[dev->minor].i_CJCAvailable == 1))
-                       /* END JK 06.07.04: Management of sevrals boards */
-               {
-         /**********************************************************/
-                       /*Test if the Calibration channel must be read for the CJC */
-         /**********************************************************/
-         /**********************************/
-                       /*Test if the polarity is the same */
-         /**********************************/
-                       /* BEGIN JK 06.07.04: Management of sevrals boards */
-                       /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
-                       if (s_BoardInfos[dev->minor].i_CJCPolarity !=
-                               s_BoardInfos[dev->minor].i_ADDIDATAPolarity)
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       {
-                               i_ConvertCJCCalibration = 1;
-                       }       /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
-                       else {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* if(i_CJCGain==i_ADDIDATAGain) */
-                               if (s_BoardInfos[dev->minor].i_CJCGain ==
-                                       s_BoardInfos[dev->minor].i_ADDIDATAGain)
-                                       /* END JK 06.07.04: Management of sevrals boards */
-                               {
-                                       i_ConvertCJCCalibration = 0;
-                               }       /* if(i_CJCGain==i_ADDIDATAGain) */
-                               else {
-                                       i_ConvertCJCCalibration = 1;
-                               }       /* elseif(i_CJCGain==i_ADDIDATAGain) */
-                       }       /* elseif(i_CJCPolarity!=i_ADDIDATAPolarity) */
-                       if (i_ConvertCJCCalibration == 1) {
-                               i_APCI3200_ReadCJCCalOffset(dev,
-                                       &ui_DummyValue);
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* ui_InterruptChannelValue[i_Count+4]=ui_DummyValue; */
-                               s_BoardInfos[dev->minor].
-                                       ui_InterruptChannelValue[s_BoardInfos
-                                       [dev->minor].i_Count + 4] =
-                                       ui_DummyValue;
-                               /* END JK 06.07.04: Management of sevrals boards */
+  /***************************/
+       /*Read the calibration gain */
+  /***************************/
+  /*******************************/
+       /* Set the convert timing unit */
+  /*******************************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
+       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
+       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
+  /**************************/
+       /* Set the convert timing */
+  /**************************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
+       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
+       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
+  /*******************************/
+       /*Configure the Gain Conversion */
+  /*******************************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
+       /* outl(0x00040000 , devpriv->iobase+i_Offset + 12); */
+       outl(0x00040000,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
 
-                               i_APCI3200_ReadCJCCalGain(dev, &ui_DummyValue);
+  /*******************************/
+       /*Initialise ui_CommandRegister */
+  /*******************************/
 
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* ui_InterruptChannelValue[i_Count+5]=ui_DummyValue; */
-                               s_BoardInfos[dev->minor].
-                                       ui_InterruptChannelValue[s_BoardInfos
-                                       [dev->minor].i_Count + 5] =
-                                       ui_DummyValue;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* if(i_ConvertCJCCalibration==1) */
-                       else {
-                               /* BEGIN JK 06.07.04: Management of sevrals boards */
-                               /* ui_InterruptChannelValue[i_Count+4]=0; */
-                               /* ui_InterruptChannelValue[i_Count+5]=0; */
+       ui_CommandRegister = 0;
 
-                               s_BoardInfos[dev->minor].
-                                       ui_InterruptChannelValue[s_BoardInfos
-                                       [dev->minor].i_Count + 4] = 0;
-                               s_BoardInfos[dev->minor].
-                                       ui_InterruptChannelValue[s_BoardInfos
-                                       [dev->minor].i_Count + 5] = 0;
-                               /* END JK 06.07.04: Management of sevrals boards */
-                       }       /* elseif(i_ConvertCJCCalibration==1) */
-               }               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */
+  /*********************************/
+       /*Test if the interrupt is enable */
+  /*********************************/
 
-               /* BEGIN JK 06.07.04: Management of sevrals boards */
-               /* if(i_ScanType!=1) */
-               if (s_BoardInfos[dev->minor].i_ScanType != 1) {
-                       /* i_Count=0; */
-                       s_BoardInfos[dev->minor].i_Count = 0;
-               }               /* if(i_ScanType!=1) */
-               else {
-                       /* i_Count=i_Count +6; */
-                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                       /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count +6; */
-                       s_BoardInfos[dev->minor].i_Count =
-                               s_BoardInfos[dev->minor].i_Count + 9;
-                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               }               /* else if(i_ScanType!=1) */
+       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
+       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
 
-               /* if((i_ScanType==1) &&(i_InterruptFlag==1)) */
-               if ((s_BoardInfos[dev->minor].i_ScanType == 1)
-                       && (s_BoardInfos[dev->minor].i_InterruptFlag == 1)) {
-                       /* i_Count=i_Count-6; */
-                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                       /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count-6; */
-                       s_BoardInfos[dev->minor].i_Count =
-                               s_BoardInfos[dev->minor].i_Count - 9;
-                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               }
-               /* if(i_ScanType==0) */
-               if (s_BoardInfos[dev->minor].i_ScanType == 0) {
-                       /*
-                          data[0]= ui_InterruptChannelValue[0];
-                          data[1]= ui_InterruptChannelValue[1];
-                          data[2]= ui_InterruptChannelValue[2];
-                          data[3]= ui_InterruptChannelValue[3];
-                          data[4]= ui_InterruptChannelValue[4];
-                          data[5]= ui_InterruptChannelValue[5];
-                        */
-#ifdef PRINT_INFO
-                       printk("\n data[0]= s_BoardInfos [dev->minor].ui_InterruptChannelValue[0];");
-#endif
-                       data[0] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[0];
-                       data[1] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[1];
-                       data[2] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[2];
-                       data[3] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[3];
-                       data[4] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[4];
-                       data[5] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[5];
+      /**********************/
+               /*Enable the interrupt */
+      /**********************/
 
-                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                       /* printk("\n 0 - i_APCI3200_GetChannelCalibrationValue data [6] = %lu, data [7] = %lu, data [8] = %lu", data [6], data [7], data [8]); */
-                       i_APCI3200_GetChannelCalibrationValue(dev,
-                               s_BoardInfos[dev->minor].ui_Channel_num,
-                               &data[6], &data[7], &data[8]);
-                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-               }
-               break;
-       case 1:
+               ui_CommandRegister = ui_CommandRegister | 0x00100000;
 
-               for (i = 0; i < insn->n; i++) {
-                       /* data[i]=ui_InterruptChannelValue[i]; */
-                       data[i] =
-                               s_BoardInfos[dev->minor].
-                               ui_InterruptChannelValue[i];
-               }
+       }                       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
 
-               /* i_Count=0; */
-               /* i_Sum=0; */
-               /* if(i_ScanType==1) */
-               s_BoardInfos[dev->minor].i_Count = 0;
-               s_BoardInfos[dev->minor].i_Sum = 0;
-               if (s_BoardInfos[dev->minor].i_ScanType == 1) {
-                       /* i_Initialised=0; */
-                       /* i_InterruptFlag=0; */
-                       s_BoardInfos[dev->minor].i_Initialised = 0;
-                       s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-                       /* END JK 06.07.04: Management of sevrals boards */
-               }
-               break;
-       default:
-               printk("\nThe parameters passed are in error\n");
-               i_APCI3200_Reset(dev);
-               return -EINVAL;
-       }                       /* switch(insn->unused[0]) */
+  /**********************/
+       /*Start the conversion */
+  /**********************/
 
-       return insn->n;
+       ui_CommandRegister = ui_CommandRegister | 0x00080000;
+  /***************************/
+       /*Write the command regiter */
+  /***************************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
+       /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */
+       outl(ui_CommandRegister,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
+
+  /*****************************/
+       /*Test if interrupt is enable */
+  /*****************************/
+
+       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
+       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
+
+               do {
+
+         /*******************/
+                       /*Read the EOC flag */
+         /*******************/
+
+                       /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
+                       ui_EOC = inl(devpriv->iobase +
+                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
+
+               } while (ui_EOC != 1);
+
+      /************************************************/
+               /*Read the digital value of the calibration Gain */
+      /************************************************/
+
+               /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
+               data[0] =
+                       inl(devpriv->iobase +
+                       s_BoardInfos[dev->minor].i_Offset + 28);
+
+       }                       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
+       return 0;
 }
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_Read1AnalogInputChannel                 |
-  |                              (struct comedi_device *dev,struct comedi_subdevice *s,       |
-  |                     struct comedi_insn *insn,unsigned int *data)                      |
-  +----------------------------------------------------------------------------+
-  | Task              : Read  value  of the selected channel                            |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     unsigned int ui_NoOfChannel    : Channel No to read            |
-  |                     unsigned int *data              : Data Pointer to read status  |
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  |                              data[0]  : Digital Value read                   |
-  |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev,
-       struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+static int i_APCI3200_ReadCJCValue(struct comedi_device *dev,
+                                  unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int ui_EOC = 0;
-       unsigned int ui_ChannelNo = 0;
-       unsigned int ui_CommandRegister = 0;
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* ui_ChannelNo=i_ChannelNo; */
-       ui_ChannelNo = s_BoardInfos[dev->minor].i_ChannelNo;
+       int ui_CommandRegister = 0;
 
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-  /*********************************/
-       /* Write the channel to configure */
-  /*********************************/
-       /* Begin JK 20.10.2004: Bad channel value is used when using differential mode */
-       /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
-       /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
-       outl(0 | s_BoardInfos[dev->minor].i_ChannelNo,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4);
-       /* End JK 20.10.2004: Bad channel value is used when using differential mode */
+  /******************************/
+       /*Set the converting time unit */
+  /******************************/
 
-  /*******************************/
-       /* Set the convert timing unit */
-  /*******************************/
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
@@ -1688,7 +1202,6 @@ int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev,
        /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
        outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
                devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
-
   /**************************/
        /* Set the convert timing */
   /**************************/
@@ -1700,44 +1213,58 @@ int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev,
        outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
                devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
 
-  /**************************************************************************/
-       /* Set the start end stop index to the selected channel and set the start */
-  /**************************************************************************/
-
-       ui_CommandRegister = ui_ChannelNo | (ui_ChannelNo << 8) | 0x80000;
+  /******************************/
+       /*Configure the CJC Conversion */
+  /******************************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
 
+       /* outl( 0x00000400 , devpriv->iobase+i_Offset + 4); */
+       outl(0x00000400,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
+  /*******************************/
+       /*Initialise dw_CommandRegister */
+  /*******************************/
+       ui_CommandRegister = 0;
   /*********************************/
        /*Test if the interrupt is enable */
   /*********************************/
-
        /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
        if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
-      /************************/
-               /* Enable the interrupt */
-      /************************/
+      /**********************/
+               /*Enable the interrupt */
+      /**********************/
                ui_CommandRegister = ui_CommandRegister | 0x00100000;
-       }                       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
+       }
 
-  /******************************/
-       /* Write the command register */
-  /******************************/
+  /**********************/
+       /*Start the conversion */
+  /**********************/
+
+       ui_CommandRegister = ui_CommandRegister | 0x00080000;
+
+  /***************************/
+       /*Write the command regiter */
+  /***************************/
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-
-       /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */
+       /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */
        outl(ui_CommandRegister,
                devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
 
   /*****************************/
        /*Test if interrupt is enable */
   /*****************************/
+
        /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
        if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
                do {
-         /*************************/
-                       /*Read the EOC Status bit */
-         /*************************/
+
+         /*******************/
+                       /*Read the EOC flag */
+         /*******************/
 
                        /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
                        ui_EOC = inl(devpriv->iobase +
@@ -1745,58 +1272,29 @@ int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev,
 
                } while (ui_EOC != 1);
 
-      /***************************************/
-               /* Read the digital value of the input */
-      /***************************************/
+      /***********************************/
+               /*Read the digital value of the CJC */
+      /***********************************/
 
-               /* data[0] = inl (devpriv->iobase+i_Offset + 28); */
+               /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
                data[0] =
                        inl(devpriv->iobase +
                        s_BoardInfos[dev->minor].i_Offset + 28);
-               /* END JK 06.07.04: Management of sevrals boards */
 
-       }                       /*  if (i_InterruptFlag == ADDIDATA_DISABLE) */
+       }                       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
        return 0;
 }
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_ReadCalibrationOffsetValue              |
-  |                              (struct comedi_device *dev,struct comedi_subdevice *s,       |
-  |                     struct comedi_insn *insn,unsigned int *data)                      |
-  +----------------------------------------------------------------------------+
-  | Task              : Read calibration offset  value  of the selected channel|
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     unsigned int *data              : Data Pointer to read status  |
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  |                              data[0]  : Calibration offset Value   |
-  |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, unsigned int *data)
+static int i_APCI3200_ReadCJCCalOffset(struct comedi_device *dev,
+                                      unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
-       unsigned int ui_Temp = 0, ui_EOC = 0;
-       unsigned int ui_CommandRegister = 0;
-
-       /* BEGIN JK 06.07.04: Management of sevrals boards */
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-  /*********************************/
-       /* Write the channel to configure */
-  /*********************************/
-       /* Begin JK 20.10.2004: This seems not necessary ! */
-       /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
-       /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
-       /* End JK 20.10.2004: This seems not necessary ! */
+       unsigned int ui_EOC = 0;
+       int ui_CommandRegister = 0;
 
+  /*******************************************/
+       /*Read calibration offset value for the CJC */
+  /*******************************************/
   /*******************************/
        /* Set the convert timing unit */
   /*******************************/
@@ -1815,80 +1313,69 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, unsigned in
        /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
        outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
                devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
-  /*****************************/
-       /*Read the calibration offset */
-  /*****************************/
-       /* ui_Temp = inl(devpriv->iobase+i_Offset + 12); */
-       ui_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-
+  /******************************/
+       /*Configure the CJC Conversion */
+  /******************************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
+       /* outl(0x00000400 , devpriv->iobase+i_Offset + 4); */
+       outl(0x00000400,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
   /*********************************/
        /*Configure the Offset Conversion */
   /*********************************/
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* outl((ui_Temp | 0x00020000), devpriv->iobase+i_Offset + 12); */
-       outl((ui_Temp | 0x00020000),
+       /* outl(0x00020000, devpriv->iobase+i_Offset + 12); */
+       outl(0x00020000,
                devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
   /*******************************/
        /*Initialise ui_CommandRegister */
   /*******************************/
-
        ui_CommandRegister = 0;
-
   /*********************************/
        /*Test if the interrupt is enable */
   /*********************************/
 
        /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
        if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
-
       /**********************/
                /*Enable the interrupt */
       /**********************/
-
                ui_CommandRegister = ui_CommandRegister | 0x00100000;
 
-       }                       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
+       }
 
   /**********************/
        /*Start the conversion */
   /**********************/
        ui_CommandRegister = ui_CommandRegister | 0x00080000;
-
   /***************************/
        /*Write the command regiter */
   /***************************/
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* outl(ui_CommandRegister, devpriv->iobase+i_Offset + 8); */
+       /* outl(ui_CommandRegister,devpriv->iobase+i_Offset + 8); */
        outl(ui_CommandRegister,
                devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-
-  /*****************************/
-       /*Test if interrupt is enable */
-  /*****************************/
-
        /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
        if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
-
                do {
          /*******************/
                        /*Read the EOC flag */
          /*******************/
-
-                       /* ui_EOC = inl (devpriv->iobase+i_Offset + 20) & 1; */
+                       /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
                        ui_EOC = inl(devpriv->iobase +
                                s_BoardInfos[dev->minor].i_Offset + 20) & 1;
-
                } while (ui_EOC != 1);
 
       /**************************************************/
                /*Read the digital value of the calibration Offset */
       /**************************************************/
-
-               /* data[0] = inl(devpriv->iobase+i_Offset+ 28); */
+               /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
                data[0] =
                        inl(devpriv->iobase +
                        s_BoardInfos[dev->minor].i_Offset + 28);
@@ -1896,46 +1383,13 @@ int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, unsigned in
        return 0;
 }
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_ReadCalibrationGainValue                |
-  |                              (struct comedi_device *dev,struct comedi_subdevice *s,       |
-  |                     struct comedi_insn *insn,unsigned int *data)                      |
-  +----------------------------------------------------------------------------+
-  | Task              : Read calibration gain  value  of the selected channel  |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     unsigned int *data              : Data Pointer to read status  |
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  |                              data[0]  : Calibration gain Value Of Input     |
-  |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, unsigned int *data)
+static int i_APCI3200_ReadCJCCalGain(struct comedi_device *dev,
+                                    unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int ui_EOC = 0;
        int ui_CommandRegister = 0;
 
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-  /*********************************/
-       /* Write the channel to configure */
-  /*********************************/
-       /* Begin JK 20.10.2004: This seems not necessary ! */
-       /* outl(0 | ui_Channel_num , devpriv->iobase+i_Offset + 0x4); */
-       /* outl(0 | s_BoardInfos [dev->minor].ui_Channel_num , devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 0x4); */
-       /* End JK 20.10.2004: This seems not necessary ! */
-
-  /***************************/
-       /*Read the calibration gain */
-  /***************************/
   /*******************************/
        /* Set the convert timing unit */
   /*******************************/
@@ -1954,41 +1408,42 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, unsigned int
        /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
        outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
                devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
+  /******************************/
+       /*Configure the CJC Conversion */
+  /******************************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
+       /* outl(0x00000400,devpriv->iobase+i_Offset + 4); */
+       outl(0x00000400,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
   /*******************************/
        /*Configure the Gain Conversion */
   /*******************************/
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* outl(0x00040000 , devpriv->iobase+i_Offset + 12); */
+       /* outl(0x00040000,devpriv->iobase+i_Offset + 12); */
        outl(0x00040000,
                devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
 
   /*******************************/
-       /*Initialise ui_CommandRegister */
+       /*Initialise dw_CommandRegister */
   /*******************************/
-
        ui_CommandRegister = 0;
-
   /*********************************/
        /*Test if the interrupt is enable */
   /*********************************/
-
        /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
        if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
-
       /**********************/
                /*Enable the interrupt */
       /**********************/
-
                ui_CommandRegister = ui_CommandRegister | 0x00100000;
-
-       }                       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
-
+       }
   /**********************/
        /*Start the conversion */
   /**********************/
-
        ui_CommandRegister = ui_CommandRegister | 0x00080000;
   /***************************/
        /*Write the command regiter */
@@ -1996,426 +1451,861 @@ int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, unsigned int
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */
+       /* outl(ui_CommandRegister ,devpriv->iobase+i_Offset + 8); */
        outl(ui_CommandRegister,
                devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-
-  /*****************************/
-       /*Test if interrupt is enable */
-  /*****************************/
-
        /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
        if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
-
                do {
-
          /*******************/
                        /*Read the EOC flag */
          /*******************/
-
                        /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
                        ui_EOC = inl(devpriv->iobase +
                                s_BoardInfos[dev->minor].i_Offset + 20) & 1;
-
                } while (ui_EOC != 1);
-
       /************************************************/
                /*Read the digital value of the calibration Gain */
       /************************************************/
-
-               /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
+               /* data[0] = inl (devpriv->iobase+i_Offset + 28); */
                data[0] =
                        inl(devpriv->iobase +
                        s_BoardInfos[dev->minor].i_Offset + 28);
-
        }                       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
        return 0;
 }
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_ReadCJCValue                            |
-  |                              (struct comedi_device *dev,struct comedi_subdevice *s,       |
-  |                     struct comedi_insn *insn,unsigned int *data)                      |
-  +----------------------------------------------------------------------------+
-  | Task              : Read CJC  value  of the selected channel               |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     unsigned int *data              : Data Pointer to read status  |
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  |                              data[0]  : CJC Value                           |
-  |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-
-int i_APCI3200_ReadCJCValue(struct comedi_device *dev, unsigned int *data)
+static int i_APCI3200_Reset(struct comedi_device *dev)
 {
        struct addi_private *devpriv = dev->private;
-       unsigned int ui_EOC = 0;
-       int ui_CommandRegister = 0;
+       int i_Temp;
+       unsigned int dw_Dummy;
 
-  /******************************/
-       /*Set the converting time unit */
-  /******************************/
+       /* i_InterruptFlag=0; */
+       /* i_Initialised==0; */
+       /* i_Count=0; */
+       /* i_Sum=0; */
 
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
+       s_BoardInfos[dev->minor].i_InterruptFlag = 0;
+       s_BoardInfos[dev->minor].i_Initialised = 0;
+       s_BoardInfos[dev->minor].i_Count = 0;
+       s_BoardInfos[dev->minor].i_Sum = 0;
+       s_BoardInfos[dev->minor].b_StructInitialized = 0;
 
-       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
-  /**************************/
-       /* Set the convert timing */
-  /**************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
+       outl(0x83838383, devpriv->i_IobaseAmcc + 0x60);
 
-       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
+       /*  Enable the interrupt for the controller */
+       dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38);
+       outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38);
+       outl(0, devpriv->i_IobaseAddon);        /* Resets the output */
+  /***************/
+       /*Empty the buffer */
+  /**************/
+       for (i_Temp = 0; i_Temp <= 95; i_Temp++) {
+               /* ui_InterruptChannelValue[i_Temp]=0; */
+               s_BoardInfos[dev->minor].ui_InterruptChannelValue[i_Temp] = 0;
+       }                       /* for(i_Temp=0;i_Temp<=95;i_Temp++) */
+  /*****************************/
+       /*Reset the START and IRQ bit */
+  /*****************************/
+       for (i_Temp = 0; i_Temp <= 192;) {
+               while (((inl(devpriv->iobase + i_Temp + 12) >> 19) & 1) != 1) ;
+               outl(0, devpriv->iobase + i_Temp + 8);
+               i_Temp = i_Temp + 64;
+       }                       /* for(i_Temp=0;i_Temp<=192;i_Temp+64) */
+       return 0;
+}
 
-  /******************************/
-       /*Configure the CJC Conversion */
-  /******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
+/*
+ * Read value of the selected channel
+ *
+ * data[0]  : Digital Value Of Input
+ * data[1]  : Calibration Offset Value
+ * data[2]  : Calibration Gain Value
+ * data[3]  : CJC value
+ * data[4]  : CJC offset value
+ * data[5]  : CJC gain value
+ * data[6] : CJC current source from eeprom
+ * data[7] : Channel current source from eeprom
+ * data[8] : Channle gain factor from eeprom
+ */
+static int i_APCI3200_ReadAnalogInput(struct comedi_device *dev,
+                                     struct comedi_subdevice *s,
+                                     struct comedi_insn *insn,
+                                     unsigned int *data)
+{
+       unsigned int ui_DummyValue = 0;
+       int i_ConvertCJCCalibration;
+       int i = 0;
 
-       /* outl( 0x00000400 , devpriv->iobase+i_Offset + 4); */
-       outl(0x00000400,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
-  /*******************************/
-       /*Initialise dw_CommandRegister */
-  /*******************************/
-       ui_CommandRegister = 0;
-  /*********************************/
-       /*Test if the interrupt is enable */
-  /*********************************/
-       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
-      /**********************/
-               /*Enable the interrupt */
-      /**********************/
-               ui_CommandRegister = ui_CommandRegister | 0x00100000;
-       }
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /* if(i_Initialised==0) */
+       if (s_BoardInfos[dev->minor].i_Initialised == 0)
+               /* END JK 06.07.04: Management of sevrals boards */
+       {
+               i_APCI3200_Reset(dev);
+               return -EINVAL;
+       }                       /* if(i_Initialised==0); */
 
-  /**********************/
-       /*Start the conversion */
-  /**********************/
+#ifdef PRINT_INFO
+       printk("\n insn->unused[0] = %i", insn->unused[0]);
+#endif
 
-       ui_CommandRegister = ui_CommandRegister | 0x00080000;
+       switch (insn->unused[0]) {
+       case 0:
 
-  /***************************/
-       /*Write the command regiter */
-  /***************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(ui_CommandRegister , devpriv->iobase+i_Offset + 8); */
-       outl(ui_CommandRegister,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
+               i_APCI3200_Read1AnalogInputChannel(dev, s, insn,
+                       &ui_DummyValue);
+               /* BEGIN JK 06.07.04: Management of sevrals boards */
+               /* ui_InterruptChannelValue[i_Count+0]=ui_DummyValue; */
+               s_BoardInfos[dev->minor].
+                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
+                       i_Count + 0] = ui_DummyValue;
+               /* END JK 06.07.04: Management of sevrals boards */
 
-  /*****************************/
-       /*Test if interrupt is enable */
-  /*****************************/
+               /* Begin JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+               i_APCI3200_GetChannelCalibrationValue(dev,
+                       s_BoardInfos[dev->minor].ui_Channel_num,
+                       &s_BoardInfos[dev->minor].
+                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
+                               i_Count + 6],
+                       &s_BoardInfos[dev->minor].
+                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
+                               i_Count + 7],
+                       &s_BoardInfos[dev->minor].
+                       ui_InterruptChannelValue[s_BoardInfos[dev->minor].
+                               i_Count + 8]);
 
-       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
-               do {
+#ifdef PRINT_INFO
+               printk("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+6] = %lu", s_BoardInfos[dev->minor].ui_InterruptChannelValue[s_BoardInfos[dev->minor].i_Count + 6]);
 
-         /*******************/
-                       /*Read the EOC flag */
-         /*******************/
+               printk("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+7] = %lu", s_BoardInfos[dev->minor].ui_InterruptChannelValue[s_BoardInfos[dev->minor].i_Count + 7]);
 
-                       /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
-                       ui_EOC = inl(devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
+               printk("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+8] = %lu", s_BoardInfos[dev->minor].ui_InterruptChannelValue[s_BoardInfos[dev->minor].i_Count + 8]);
+#endif
 
-               } while (ui_EOC != 1);
+               /* End JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
 
-      /***********************************/
-               /*Read the digital value of the CJC */
-      /***********************************/
+               /* BEGIN JK 06.07.04: Management of sevrals boards */
+               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */
+               if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2)
+                       && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE)
+                       && (s_BoardInfos[dev->minor].i_CJCAvailable == 1))
+                       /* END JK 06.07.04: Management of sevrals boards */
+               {
+                       i_APCI3200_ReadCJCValue(dev, &ui_DummyValue);
+                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                       /* ui_InterruptChannelValue[i_Count + 3]=ui_DummyValue; */
+                       s_BoardInfos[dev->minor].
+                               ui_InterruptChannelValue[s_BoardInfos[dev->
+                                       minor].i_Count + 3] = ui_DummyValue;
+                       /* END JK 06.07.04: Management of sevrals boards */
+               }               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */
+               else {
+                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                       /* ui_InterruptChannelValue[i_Count + 3]=0; */
+                       s_BoardInfos[dev->minor].
+                               ui_InterruptChannelValue[s_BoardInfos[dev->
+                                       minor].i_Count + 3] = 0;
+                       /* END JK 06.07.04: Management of sevrals boards */
+               }               /* elseif((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE) && (i_CJCAvailable==1)) */
 
-               /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
-               data[0] =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 28);
+               /* BEGIN JK 06.07.04: Management of sevrals boards */
+               /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */
+               if ((s_BoardInfos[dev->minor].i_AutoCalibration == FALSE)
+                       && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE))
+                       /* END JK 06.07.04: Management of sevrals boards */
+               {
+                       i_APCI3200_ReadCalibrationOffsetValue(dev,
+                               &ui_DummyValue);
+                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                       /* ui_InterruptChannelValue[i_Count + 1]=ui_DummyValue; */
+                       s_BoardInfos[dev->minor].
+                               ui_InterruptChannelValue[s_BoardInfos[dev->
+                                       minor].i_Count + 1] = ui_DummyValue;
+                       /* END JK 06.07.04: Management of sevrals boards */
+                       i_APCI3200_ReadCalibrationGainValue(dev,
+                               &ui_DummyValue);
+                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                       /* ui_InterruptChannelValue[i_Count + 2]=ui_DummyValue; */
+                       s_BoardInfos[dev->minor].
+                               ui_InterruptChannelValue[s_BoardInfos[dev->
+                                       minor].i_Count + 2] = ui_DummyValue;
+                       /* END JK 06.07.04: Management of sevrals boards */
+               }               /* if (( i_AutoCalibration == FALSE) && (i_InterruptFlag == FALSE)) */
 
-       }                       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
-       return 0;
+               /* BEGIN JK 06.07.04: Management of sevrals boards */
+               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)&& (i_CJCAvailable==1)) */
+               if ((s_BoardInfos[dev->minor].i_ADDIDATAType == 2)
+                       && (s_BoardInfos[dev->minor].i_InterruptFlag == FALSE)
+                       && (s_BoardInfos[dev->minor].i_CJCAvailable == 1))
+                       /* END JK 06.07.04: Management of sevrals boards */
+               {
+         /**********************************************************/
+                       /*Test if the Calibration channel must be read for the CJC */
+         /**********************************************************/
+         /**********************************/
+                       /*Test if the polarity is the same */
+         /**********************************/
+                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                       /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
+                       if (s_BoardInfos[dev->minor].i_CJCPolarity !=
+                               s_BoardInfos[dev->minor].i_ADDIDATAPolarity)
+                               /* END JK 06.07.04: Management of sevrals boards */
+                       {
+                               i_ConvertCJCCalibration = 1;
+                       }       /* if(i_CJCPolarity!=i_ADDIDATAPolarity) */
+                       else {
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* if(i_CJCGain==i_ADDIDATAGain) */
+                               if (s_BoardInfos[dev->minor].i_CJCGain ==
+                                       s_BoardInfos[dev->minor].i_ADDIDATAGain)
+                                       /* END JK 06.07.04: Management of sevrals boards */
+                               {
+                                       i_ConvertCJCCalibration = 0;
+                               }       /* if(i_CJCGain==i_ADDIDATAGain) */
+                               else {
+                                       i_ConvertCJCCalibration = 1;
+                               }       /* elseif(i_CJCGain==i_ADDIDATAGain) */
+                       }       /* elseif(i_CJCPolarity!=i_ADDIDATAPolarity) */
+                       if (i_ConvertCJCCalibration == 1) {
+                               i_APCI3200_ReadCJCCalOffset(dev,
+                                       &ui_DummyValue);
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* ui_InterruptChannelValue[i_Count+4]=ui_DummyValue; */
+                               s_BoardInfos[dev->minor].
+                                       ui_InterruptChannelValue[s_BoardInfos
+                                       [dev->minor].i_Count + 4] =
+                                       ui_DummyValue;
+                               /* END JK 06.07.04: Management of sevrals boards */
+
+                               i_APCI3200_ReadCJCCalGain(dev, &ui_DummyValue);
+
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* ui_InterruptChannelValue[i_Count+5]=ui_DummyValue; */
+                               s_BoardInfos[dev->minor].
+                                       ui_InterruptChannelValue[s_BoardInfos
+                                       [dev->minor].i_Count + 5] =
+                                       ui_DummyValue;
+                               /* END JK 06.07.04: Management of sevrals boards */
+                       }       /* if(i_ConvertCJCCalibration==1) */
+                       else {
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* ui_InterruptChannelValue[i_Count+4]=0; */
+                               /* ui_InterruptChannelValue[i_Count+5]=0; */
+
+                               s_BoardInfos[dev->minor].
+                                       ui_InterruptChannelValue[s_BoardInfos
+                                       [dev->minor].i_Count + 4] = 0;
+                               s_BoardInfos[dev->minor].
+                                       ui_InterruptChannelValue[s_BoardInfos
+                                       [dev->minor].i_Count + 5] = 0;
+                               /* END JK 06.07.04: Management of sevrals boards */
+                       }       /* elseif(i_ConvertCJCCalibration==1) */
+               }               /* if((i_ADDIDATAType==2) && (i_InterruptFlag == FALSE)) */
+
+               /* BEGIN JK 06.07.04: Management of sevrals boards */
+               /* if(i_ScanType!=1) */
+               if (s_BoardInfos[dev->minor].i_ScanType != 1) {
+                       /* i_Count=0; */
+                       s_BoardInfos[dev->minor].i_Count = 0;
+               }               /* if(i_ScanType!=1) */
+               else {
+                       /* i_Count=i_Count +6; */
+                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+                       /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count +6; */
+                       s_BoardInfos[dev->minor].i_Count =
+                               s_BoardInfos[dev->minor].i_Count + 9;
+                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+               }               /* else if(i_ScanType!=1) */
+
+               /* if((i_ScanType==1) &&(i_InterruptFlag==1)) */
+               if ((s_BoardInfos[dev->minor].i_ScanType == 1)
+                       && (s_BoardInfos[dev->minor].i_InterruptFlag == 1)) {
+                       /* i_Count=i_Count-6; */
+                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+                       /* s_BoardInfos [dev->minor].i_Count=s_BoardInfos [dev->minor].i_Count-6; */
+                       s_BoardInfos[dev->minor].i_Count =
+                               s_BoardInfos[dev->minor].i_Count - 9;
+                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+               }
+               /* if(i_ScanType==0) */
+               if (s_BoardInfos[dev->minor].i_ScanType == 0) {
+                       /*
+                          data[0]= ui_InterruptChannelValue[0];
+                          data[1]= ui_InterruptChannelValue[1];
+                          data[2]= ui_InterruptChannelValue[2];
+                          data[3]= ui_InterruptChannelValue[3];
+                          data[4]= ui_InterruptChannelValue[4];
+                          data[5]= ui_InterruptChannelValue[5];
+                        */
+#ifdef PRINT_INFO
+                       printk("\n data[0]= s_BoardInfos [dev->minor].ui_InterruptChannelValue[0];");
+#endif
+                       data[0] =
+                               s_BoardInfos[dev->minor].
+                               ui_InterruptChannelValue[0];
+                       data[1] =
+                               s_BoardInfos[dev->minor].
+                               ui_InterruptChannelValue[1];
+                       data[2] =
+                               s_BoardInfos[dev->minor].
+                               ui_InterruptChannelValue[2];
+                       data[3] =
+                               s_BoardInfos[dev->minor].
+                               ui_InterruptChannelValue[3];
+                       data[4] =
+                               s_BoardInfos[dev->minor].
+                               ui_InterruptChannelValue[4];
+                       data[5] =
+                               s_BoardInfos[dev->minor].
+                               ui_InterruptChannelValue[5];
+
+                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+                       /* printk("\n 0 - i_APCI3200_GetChannelCalibrationValue data [6] = %lu, data [7] = %lu, data [8] = %lu", data [6], data [7], data [8]); */
+                       i_APCI3200_GetChannelCalibrationValue(dev,
+                               s_BoardInfos[dev->minor].ui_Channel_num,
+                               &data[6], &data[7], &data[8]);
+                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+               }
+               break;
+       case 1:
+
+               for (i = 0; i < insn->n; i++) {
+                       /* data[i]=ui_InterruptChannelValue[i]; */
+                       data[i] =
+                               s_BoardInfos[dev->minor].
+                               ui_InterruptChannelValue[i];
+               }
+
+               /* i_Count=0; */
+               /* i_Sum=0; */
+               /* if(i_ScanType==1) */
+               s_BoardInfos[dev->minor].i_Count = 0;
+               s_BoardInfos[dev->minor].i_Sum = 0;
+               if (s_BoardInfos[dev->minor].i_ScanType == 1) {
+                       /* i_Initialised=0; */
+                       /* i_InterruptFlag=0; */
+                       s_BoardInfos[dev->minor].i_Initialised = 0;
+                       s_BoardInfos[dev->minor].i_InterruptFlag = 0;
+                       /* END JK 06.07.04: Management of sevrals boards */
+               }
+               break;
+       default:
+               printk("\nThe parameters passed are in error\n");
+               i_APCI3200_Reset(dev);
+               return -EINVAL;
+       }                       /* switch(insn->unused[0]) */
+
+       return insn->n;
 }
 
 /*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_ReadCJCCalOffset                        |
-  |                              (struct comedi_device *dev,struct comedi_subdevice *s,       |
-  |                     struct comedi_insn *insn,unsigned int *data)                      |
-  +----------------------------------------------------------------------------+
-  | Task              : Read CJC calibration offset  value  of the selected channel
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     unsigned int *data              : Data Pointer to read status  |
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  |                              data[0]  : CJC calibration offset Value
-  |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-int i_APCI3200_ReadCJCCalOffset(struct comedi_device *dev, unsigned int *data)
+ * Configures The Analog Input Subdevice
+ *
+ * data[0]  = 0  Normal AI
+ *         = 1  RTD
+ *         = 2  THERMOCOUPLE
+ * data[1]  = Gain To Use
+ * data[2]  = 0  Bipolar
+ *         = 1  Unipolar
+ * data[3]  = Offset Range
+ * data[4]  = 0  DC Coupling
+ *         = 1  AC Coupling
+ * data[5]  = 0  Single
+ *         = 1  Differential
+ * data[6]  = TimerReloadValue
+ * data[7]  = ConvertingTimeUnit
+ * data[8]  = 0  Analog voltage measurement
+ *         = 1  Resistance measurement
+ *         = 2  Temperature measurement
+ * data[9]  = 0  Interrupt Disable
+ *         = 1  INterrupt Enable
+ * data[10] = Type of Thermocouple
+ * data[11] = single channel Module Number
+ * data[12] = 0  Single Read
+ *         = 1  Read more channel
+ *         = 2  Single scan
+ *         = 3  Continuous Scan
+ * data[13] = Number of channels to read
+ * data[14] = 0  RTD not used
+ *         = 1  RTD 2 wire connection
+ *         = 2  RTD 3 wire connection
+ *         = 3  RTD 4 wire connection
+ */
+static int i_APCI3200_ConfigAnalogInput(struct comedi_device *dev,
+                                       struct comedi_subdevice *s,
+                                       struct comedi_insn *insn,
+                                       unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
-       unsigned int ui_EOC = 0;
-       int ui_CommandRegister = 0;
+       unsigned int ul_Config = 0, ul_Temp = 0;
+       unsigned int ui_ChannelNo = 0;
+       unsigned int ui_Dummy = 0;
+       int i_err = 0;
 
-  /*******************************************/
-       /*Read calibration offset value for the CJC */
-  /*******************************************/
-  /*******************************/
-       /* Set the convert timing unit */
-  /*******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
-  /**************************/
-       /* Set the convert timing */
-  /**************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
-  /******************************/
-       /*Configure the CJC Conversion */
-  /******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(0x00000400 , devpriv->iobase+i_Offset + 4); */
-       outl(0x00000400,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
-  /*********************************/
-       /*Configure the Offset Conversion */
-  /*********************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(0x00020000, devpriv->iobase+i_Offset + 12); */
-       outl(0x00020000,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
-  /*******************************/
-       /*Initialise ui_CommandRegister */
-  /*******************************/
-       ui_CommandRegister = 0;
-  /*********************************/
-       /*Test if the interrupt is enable */
-  /*********************************/
+       /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
 
-       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
-      /**********************/
-               /*Enable the interrupt */
-      /**********************/
-               ui_CommandRegister = ui_CommandRegister | 0x00100000;
+#ifdef PRINT_INFO
+       int i = 0, i2 = 0;
+#endif
+       /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /*  Initialize the structure */
+       if (s_BoardInfos[dev->minor].b_StructInitialized != 1) {
+               s_BoardInfos[dev->minor].i_CJCAvailable = 1;
+               s_BoardInfos[dev->minor].i_CJCPolarity = 0;
+               s_BoardInfos[dev->minor].i_CJCGain = 2; /* changed from 0 to 2 */
+               s_BoardInfos[dev->minor].i_InterruptFlag = 0;
+               s_BoardInfos[dev->minor].i_AutoCalibration = 0; /* : auto calibration */
+               s_BoardInfos[dev->minor].i_ChannelCount = 0;
+               s_BoardInfos[dev->minor].i_Sum = 0;
+               s_BoardInfos[dev->minor].ui_Channel_num = 0;
+               s_BoardInfos[dev->minor].i_Count = 0;
+               s_BoardInfos[dev->minor].i_Initialised = 0;
+               s_BoardInfos[dev->minor].b_StructInitialized = 1;
+
+               /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+               s_BoardInfos[dev->minor].i_ConnectionType = 0;
+               /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+
+               /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+               memset(s_BoardInfos[dev->minor].s_Module, 0,
+                       sizeof(s_BoardInfos[dev->minor].s_Module[MAX_MODULE]));
 
+               v_GetAPCI3200EepromCalibrationValue(devpriv->i_IobaseAmcc,
+                       &s_BoardInfos[dev->minor]);
+
+#ifdef PRINT_INFO
+               for (i = 0; i < MAX_MODULE; i++) {
+                       printk("\n s_Module[%i].ul_CurrentSourceCJC = %lu", i,
+                               s_BoardInfos[dev->minor].s_Module[i].
+                               ul_CurrentSourceCJC);
+
+                       for (i2 = 0; i2 < 5; i2++) {
+                               printk("\n s_Module[%i].ul_CurrentSource [%i] = %lu", i, i2, s_BoardInfos[dev->minor].s_Module[i].ul_CurrentSource[i2]);
+                       }
+
+                       for (i2 = 0; i2 < 8; i2++) {
+                               printk("\n s_Module[%i].ul_GainFactor [%i] = %lu", i, i2, s_BoardInfos[dev->minor].s_Module[i].ul_GainFactor[i2]);
+                       }
+
+                       for (i2 = 0; i2 < 8; i2++) {
+                               printk("\n s_Module[%i].w_GainValue [%i] = %u",
+                                       i, i2,
+                                       s_BoardInfos[dev->minor].s_Module[i].
+                                       w_GainValue[i2]);
+                       }
+               }
+#endif
+               /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
        }
 
-  /**********************/
-       /*Start the conversion */
-  /**********************/
-       ui_CommandRegister = ui_CommandRegister | 0x00080000;
-  /***************************/
-       /*Write the command regiter */
-  /***************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(ui_CommandRegister,devpriv->iobase+i_Offset + 8); */
-       outl(ui_CommandRegister,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
-               do {
-         /*******************/
-                       /*Read the EOC flag */
-         /*******************/
-                       /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
-                       ui_EOC = inl(devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
-               } while (ui_EOC != 1);
+       if (data[0] != 0 && data[0] != 1 && data[0] != 2) {
+               printk("\nThe selection of acquisition type is in error\n");
+               i_err++;
+       }                       /* if(data[0]!=0 && data[0]!=1 && data[0]!=2) */
+       if (data[0] == 1) {
+               if (data[14] != 0 && data[14] != 1 && data[14] != 2
+                       && data[14] != 4) {
+                       printk("\n Error in selection of RTD connection type\n");
+                       i_err++;
+               }               /* if(data[14]!=0 && data[14]!=1 && data[14]!=2 && data[14]!=4) */
+       }                       /* if(data[0]==1 ) */
+       if (data[1] < 0 || data[1] > 7) {
+               printk("\nThe selection of gain is in error\n");
+               i_err++;
+       }                       /*  if(data[1]<0 || data[1]>7) */
+       if (data[2] != 0 && data[2] != 1) {
+               printk("\nThe selection of polarity is in error\n");
+               i_err++;
+       }                       /* if(data[2]!=0 &&  data[2]!=1) */
+       if (data[3] != 0) {
+               printk("\nThe selection of offset range  is in error\n");
+               i_err++;
+       }                       /*  if(data[3]!=0) */
+       if (data[4] != 0 && data[4] != 1) {
+               printk("\nThe selection of coupling is in error\n");
+               i_err++;
+       }                       /* if(data[4]!=0 &&  data[4]!=1) */
+       if (data[5] != 0 && data[5] != 1) {
+               printk("\nThe selection of single/differential mode is in error\n");
+               i_err++;
+       }                       /* if(data[5]!=0 &&  data[5]!=1) */
+       if (data[8] != 0 && data[8] != 1 && data[2] != 2) {
+               printk("\nError in selection of functionality\n");
+       }                       /* if(data[8]!=0 && data[8]!=1 && data[2]!=2) */
+       if (data[12] == 0 || data[12] == 1) {
+               if (data[6] != 20 && data[6] != 40 && data[6] != 80
+                       && data[6] != 160) {
+                       printk("\nThe selection of conversion time reload value is in error\n");
+                       i_err++;
+               }               /*  if (data[6]!=20 && data[6]!=40 && data[6]!=80 && data[6]!=160 ) */
+               if (data[7] != 2) {
+                       printk("\nThe selection of conversion time unit  is in error\n");
+                       i_err++;
+               }               /*  if(data[7]!=2) */
+       }
+       if (data[9] != 0 && data[9] != 1) {
+               printk("\nThe selection of interrupt enable is in error\n");
+               i_err++;
+       }                       /* if(data[9]!=0 &&  data[9]!=1) */
+       if (data[11] < 0 || data[11] > 4) {
+               printk("\nThe selection of module is in error\n");
+               i_err++;
+       }                       /* if(data[11] <0 ||  data[11]>1) */
+       if (data[12] < 0 || data[12] > 3) {
+               printk("\nThe selection of singlechannel/scan selection is in error\n");
+               i_err++;
+       }                       /* if(data[12] < 0 ||  data[12]> 3) */
+       if (data[13] < 0 || data[13] > 16) {
+               printk("\nThe selection of number of channels is in error\n");
+               i_err++;
+       }                       /*  if(data[13] <0 ||data[13] >15) */
 
-      /**************************************************/
-               /*Read the digital value of the calibration Offset */
-      /**************************************************/
-               /* data[0] = inl(devpriv->iobase+i_Offset + 28); */
-               data[0] =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 28);
-       }                       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
-       return 0;
-}
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /*
+          i_ChannelCount=data[13];
+          i_ScanType=data[12];
+          i_ADDIDATAPolarity = data[2];
+          i_ADDIDATAGain=data[1];
+          i_ADDIDATAConversionTime=data[6];
+          i_ADDIDATAConversionTimeUnit=data[7];
+          i_ADDIDATAType=data[0];
+        */
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_ReadCJCGainValue                        |
-  |                              (struct comedi_device *dev,struct comedi_subdevice *s,       |
-  |                     struct comedi_insn *insn,unsigned int *data)                      |
-  +----------------------------------------------------------------------------+
-  | Task              : Read CJC calibration gain value
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     unsigned int ui_NoOfChannels    : No Of Channels To read       |
-  |                     unsigned int *data              : Data Pointer to read status  |
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  |                              data[0]  : CJC calibration gain value
-  |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-int i_APCI3200_ReadCJCCalGain(struct comedi_device *dev, unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_EOC = 0;
-       int ui_CommandRegister = 0;
+       /*  Save acquisition configuration for the actual board */
+       s_BoardInfos[dev->minor].i_ChannelCount = data[13];
+       s_BoardInfos[dev->minor].i_ScanType = data[12];
+       s_BoardInfos[dev->minor].i_ADDIDATAPolarity = data[2];
+       s_BoardInfos[dev->minor].i_ADDIDATAGain = data[1];
+       s_BoardInfos[dev->minor].i_ADDIDATAConversionTime = data[6];
+       s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit = data[7];
+       s_BoardInfos[dev->minor].i_ADDIDATAType = data[0];
+       /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+       s_BoardInfos[dev->minor].i_ConnectionType = data[5];
+       /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+       /* END JK 06.07.04: Management of sevrals boards */
 
-  /*******************************/
-       /* Set the convert timing unit */
-  /*******************************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTimeUnit , devpriv->iobase+i_Offset + 36); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTimeUnit,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 36);
-  /**************************/
-       /* Set the convert timing */
-  /**************************/
+       /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+       memset(s_BoardInfos[dev->minor].ui_ScanValueArray, 0, (7 + 12) * sizeof(unsigned int)); /*  7 is the maximal number of channels */
+       /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+
+       /* BEGIN JK 02.07.04 : This while can't be do, it block the process when using severals boards */
+       /* while(i_InterruptFlag==1) */
+       while (s_BoardInfos[dev->minor].i_InterruptFlag == 1) {
+#ifndef MSXBOX
+               udelay(1);
+#else
+               /*  In the case where the driver is compiled for the MSX-Box */
+               /*  we used a printk to have a little delay because udelay */
+               /*  seems to be broken under the MSX-Box. */
+               /*  This solution hat to be studied. */
+               printk("");
+#endif
+       }
+       /* END JK 02.07.04 : This while can't be do, it block the process when using severals boards */
+
+       ui_ChannelNo = CR_CHAN(insn->chanspec); /*  get the channel */
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /* i_ChannelNo=ui_ChannelNo; */
+       /* ui_Channel_num =ui_ChannelNo; */
+
+       s_BoardInfos[dev->minor].i_ChannelNo = ui_ChannelNo;
+       s_BoardInfos[dev->minor].ui_Channel_num = ui_ChannelNo;
+
+       /* END JK 06.07.04: Management of sevrals boards */
+
+       if (data[5] == 0) {
+               if (ui_ChannelNo < 0 || ui_ChannelNo > 15) {
+                       printk("\nThe Selection of the channel is in error\n");
+                       i_err++;
+               }               /*  if(ui_ChannelNo<0 || ui_ChannelNo>15) */
+       }                       /* if(data[5]==0) */
+       else {
+               if (data[14] == 2) {
+                       if (ui_ChannelNo < 0 || ui_ChannelNo > 3) {
+                               printk("\nThe Selection of the channel is in error\n");
+                               i_err++;
+                       }       /*  if(ui_ChannelNo<0 || ui_ChannelNo>3) */
+               }               /* if(data[14]==2) */
+               else {
+                       if (ui_ChannelNo < 0 || ui_ChannelNo > 7) {
+                               printk("\nThe Selection of the channel is in error\n");
+                               i_err++;
+                       }       /*  if(ui_ChannelNo<0 || ui_ChannelNo>7) */
+               }               /* elseif(data[14]==2) */
+       }                       /* elseif(data[5]==0) */
+       if (data[12] == 0 || data[12] == 1) {
+               switch (data[5]) {
+               case 0:
+                       if (ui_ChannelNo >= 0 && ui_ChannelNo <= 3) {
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* i_Offset=0; */
+                               s_BoardInfos[dev->minor].i_Offset = 0;
+                               /* END JK 06.07.04: Management of sevrals boards */
+                       }       /* if(ui_ChannelNo >=0 && ui_ChannelNo <=3) */
+                       if (ui_ChannelNo >= 4 && ui_ChannelNo <= 7) {
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* i_Offset=64; */
+                               s_BoardInfos[dev->minor].i_Offset = 64;
+                               /* END JK 06.07.04: Management of sevrals boards */
+                       }       /* if(ui_ChannelNo >=4 && ui_ChannelNo <=7) */
+                       if (ui_ChannelNo >= 8 && ui_ChannelNo <= 11) {
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* i_Offset=128; */
+                               s_BoardInfos[dev->minor].i_Offset = 128;
+                               /* END JK 06.07.04: Management of sevrals boards */
+                       }       /* if(ui_ChannelNo >=8 && ui_ChannelNo <=11) */
+                       if (ui_ChannelNo >= 12 && ui_ChannelNo <= 15) {
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* i_Offset=192; */
+                               s_BoardInfos[dev->minor].i_Offset = 192;
+                               /* END JK 06.07.04: Management of sevrals boards */
+                       }       /* if(ui_ChannelNo >=12 && ui_ChannelNo <=15) */
+                       break;
+               case 1:
+                       if (data[14] == 2) {
+                               if (ui_ChannelNo == 0) {
+                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                                       /* i_Offset=0; */
+                                       s_BoardInfos[dev->minor].i_Offset = 0;
+                                       /* END JK 06.07.04: Management of sevrals boards */
+                               }       /* if(ui_ChannelNo ==0 ) */
+                               if (ui_ChannelNo == 1) {
+                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                                       /* i_Offset=0; */
+                                       s_BoardInfos[dev->minor].i_Offset = 64;
+                                       /* END JK 06.07.04: Management of sevrals boards */
+                               }       /*  if(ui_ChannelNo ==1) */
+                               if (ui_ChannelNo == 2) {
+                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                                       /* i_Offset=128; */
+                                       s_BoardInfos[dev->minor].i_Offset = 128;
+                                       /* END JK 06.07.04: Management of sevrals boards */
+                               }       /* if(ui_ChannelNo ==2 ) */
+                               if (ui_ChannelNo == 3) {
+                                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                                       /* i_Offset=192; */
+                                       s_BoardInfos[dev->minor].i_Offset = 192;
+                                       /* END JK 06.07.04: Management of sevrals boards */
+                               }       /* if(ui_ChannelNo ==3) */
+
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* i_ChannelNo=0; */
+                               s_BoardInfos[dev->minor].i_ChannelNo = 0;
+                               /* END JK 06.07.04: Management of sevrals boards */
+                               ui_ChannelNo = 0;
+                               break;
+                       }       /* if(data[14]==2) */
+                       if (ui_ChannelNo >= 0 && ui_ChannelNo <= 1) {
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* i_Offset=0; */
+                               s_BoardInfos[dev->minor].i_Offset = 0;
+                               /* END JK 06.07.04: Management of sevrals boards */
+                       }       /* if(ui_ChannelNo >=0 && ui_ChannelNo <=1) */
+                       if (ui_ChannelNo >= 2 && ui_ChannelNo <= 3) {
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* i_ChannelNo=i_ChannelNo-2; */
+                               /* i_Offset=64; */
+                               s_BoardInfos[dev->minor].i_ChannelNo =
+                                       s_BoardInfos[dev->minor].i_ChannelNo -
+                                       2;
+                               s_BoardInfos[dev->minor].i_Offset = 64;
+                               /* END JK 06.07.04: Management of sevrals boards */
+                               ui_ChannelNo = ui_ChannelNo - 2;
+                       }       /* if(ui_ChannelNo >=2 && ui_ChannelNo <=3) */
+                       if (ui_ChannelNo >= 4 && ui_ChannelNo <= 5) {
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* i_ChannelNo=i_ChannelNo-4; */
+                               /* i_Offset=128; */
+                               s_BoardInfos[dev->minor].i_ChannelNo =
+                                       s_BoardInfos[dev->minor].i_ChannelNo -
+                                       4;
+                               s_BoardInfos[dev->minor].i_Offset = 128;
+                               /* END JK 06.07.04: Management of sevrals boards */
+                               ui_ChannelNo = ui_ChannelNo - 4;
+                       }       /* if(ui_ChannelNo >=4 && ui_ChannelNo <=5) */
+                       if (ui_ChannelNo >= 6 && ui_ChannelNo <= 7) {
+                               /* BEGIN JK 06.07.04: Management of sevrals boards */
+                               /* i_ChannelNo=i_ChannelNo-6; */
+                               /* i_Offset=192; */
+                               s_BoardInfos[dev->minor].i_ChannelNo =
+                                       s_BoardInfos[dev->minor].i_ChannelNo -
+                                       6;
+                               s_BoardInfos[dev->minor].i_Offset = 192;
+                               /* END JK 06.07.04: Management of sevrals boards */
+                               ui_ChannelNo = ui_ChannelNo - 6;
+                       }       /* if(ui_ChannelNo >=6 && ui_ChannelNo <=7) */
+                       break;
+
+               default:
+                       printk("\n This selection of polarity does not exist\n");
+                       i_err++;
+               }               /* switch(data[2]) */
+       }                       /* if(data[12]==0 || data[12]==1) */
+       else {
+               switch (data[11]) {
+               case 1:
+                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                       /* i_Offset=0; */
+                       s_BoardInfos[dev->minor].i_Offset = 0;
+                       /* END JK 06.07.04: Management of sevrals boards */
+                       break;
+               case 2:
+                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                       /* i_Offset=64; */
+                       s_BoardInfos[dev->minor].i_Offset = 64;
+                       /* END JK 06.07.04: Management of sevrals boards */
+                       break;
+               case 3:
+                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                       /* i_Offset=128; */
+                       s_BoardInfos[dev->minor].i_Offset = 128;
+                       /* END JK 06.07.04: Management of sevrals boards */
+                       break;
+               case 4:
+                       /* BEGIN JK 06.07.04: Management of sevrals boards */
+                       /* i_Offset=192; */
+                       s_BoardInfos[dev->minor].i_Offset = 192;
+                       /* END JK 06.07.04: Management of sevrals boards */
+                       break;
+               default:
+                       printk("\nError in module selection\n");
+                       i_err++;
+               }               /*  switch(data[11]) */
+       }                       /*  elseif(data[12]==0 || data[12]==1) */
+       if (i_err) {
+               i_APCI3200_Reset(dev);
+               return -EINVAL;
+       }
+       /* if(i_ScanType!=1) */
+       if (s_BoardInfos[dev->minor].i_ScanType != 1) {
+               /* BEGIN JK 06.07.04: Management of sevrals boards */
+               /* i_Count=0; */
+               /* i_Sum=0; */
+               s_BoardInfos[dev->minor].i_Count = 0;
+               s_BoardInfos[dev->minor].i_Sum = 0;
+               /* END JK 06.07.04: Management of sevrals boards */
+       }                       /* if(i_ScanType!=1) */
+
+       ul_Config =
+               data[1] | (data[2] << 6) | (data[5] << 7) | (data[3] << 8) |
+               (data[4] << 9);
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* outl(i_ADDIDATAConversionTime , devpriv->iobase+i_Offset + 32); */
-       outl(s_BoardInfos[dev->minor].i_ADDIDATAConversionTime,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 32);
-  /******************************/
-       /*Configure the CJC Conversion */
-  /******************************/
+       /* END JK 06.07.04: Management of sevrals boards */
+  /*********************************/
+       /* Write the channel to configure */
+  /*********************************/
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /* outl(0 | ui_ChannelNo , devpriv->iobase+i_Offset + 0x4); */
+       outl(0 | ui_ChannelNo,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x4);
+       /* END JK 06.07.04: Management of sevrals boards */
+
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* outl(0x00000400,devpriv->iobase+i_Offset + 4); */
-       outl(0x00000400,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
-  /*******************************/
-       /*Configure the Gain Conversion */
-  /*******************************/
+       /* END JK 06.07.04: Management of sevrals boards */
+  /**************************/
+       /* Reset the configuration */
+  /**************************/
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /* outl(0 , devpriv->iobase+i_Offset + 0x0); */
+       outl(0, devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0);
+       /* END JK 06.07.04: Management of sevrals boards */
+
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* outl(0x00040000,devpriv->iobase+i_Offset + 12); */
-       outl(0x00040000,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
+       /* END JK 06.07.04: Management of sevrals boards */
 
-  /*******************************/
-       /*Initialise dw_CommandRegister */
-  /*******************************/
-       ui_CommandRegister = 0;
-  /*********************************/
-       /*Test if the interrupt is enable */
-  /*********************************/
-       /* if (i_InterruptFlag == ADDIDATA_ENABLE) */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_ENABLE) {
-      /**********************/
-               /*Enable the interrupt */
-      /**********************/
-               ui_CommandRegister = ui_CommandRegister | 0x00100000;
-       }
-  /**********************/
-       /*Start the conversion */
-  /**********************/
-       ui_CommandRegister = ui_CommandRegister | 0x00080000;
   /***************************/
-       /*Write the command regiter */
+       /* Write the configuration */
+  /***************************/
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /* outl(ul_Config , devpriv->iobase+i_Offset + 0x0); */
+       outl(ul_Config,
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 0x0);
+       /* END JK 06.07.04: Management of sevrals boards */
+
   /***************************/
+       /*Reset the calibration bit */
+  /***************************/
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /* ul_Temp = inl(devpriv->iobase+i_Offset + 12); */
+       ul_Temp = inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
+       /* END JK 06.07.04: Management of sevrals boards */
+
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
        /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
-       /* outl(ui_CommandRegister ,devpriv->iobase+i_Offset + 8); */
-       outl(ui_CommandRegister,
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
-       if (s_BoardInfos[dev->minor].i_InterruptFlag == ADDIDATA_DISABLE) {
-               do {
-         /*******************/
-                       /*Read the EOC flag */
-         /*******************/
-                       /* ui_EOC = inl(devpriv->iobase+i_Offset + 20) & 1; */
-                       ui_EOC = inl(devpriv->iobase +
-                               s_BoardInfos[dev->minor].i_Offset + 20) & 1;
-               } while (ui_EOC != 1);
-      /************************************************/
-               /*Read the digital value of the calibration Gain */
-      /************************************************/
-               /* data[0] = inl (devpriv->iobase+i_Offset + 28); */
-               data[0] =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 28);
-       }                       /* if (i_InterruptFlag == ADDIDATA_DISABLE) */
-       return 0;
+       /* END JK 06.07.04: Management of sevrals boards */
+
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /* outl((ul_Temp & 0xFFF9FFFF) , devpriv->iobase+.i_Offset + 12); */
+       outl((ul_Temp & 0xFFF9FFFF),
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
+       /* END JK 06.07.04: Management of sevrals boards */
+
+       if (data[9] == 1) {
+               devpriv->tsk_Current = current;
+               /* BEGIN JK 06.07.04: Management of sevrals boards */
+               /* i_InterruptFlag=1; */
+               s_BoardInfos[dev->minor].i_InterruptFlag = 1;
+               /* END JK 06.07.04: Management of sevrals boards */
+       }                       /*  if(data[9]==1) */
+       else {
+               /* BEGIN JK 06.07.04: Management of sevrals boards */
+               /* i_InterruptFlag=0; */
+               s_BoardInfos[dev->minor].i_InterruptFlag = 0;
+               /* END JK 06.07.04: Management of sevrals boards */
+       }                       /* else  if(data[9]==1) */
+
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /* i_Initialised=1; */
+       s_BoardInfos[dev->minor].i_Initialised = 1;
+       /* END JK 06.07.04: Management of sevrals boards */
+
+       /* BEGIN JK 06.07.04: Management of sevrals boards */
+       /* if(i_ScanType==1) */
+       if (s_BoardInfos[dev->minor].i_ScanType == 1)
+               /* END JK 06.07.04: Management of sevrals boards */
+       {
+               /* BEGIN JK 06.07.04: Management of sevrals boards */
+               /* i_Sum=i_Sum+1; */
+               s_BoardInfos[dev->minor].i_Sum =
+                       s_BoardInfos[dev->minor].i_Sum + 1;
+               /* END JK 06.07.04: Management of sevrals boards */
+
+               insn->unused[0] = 0;
+               i_APCI3200_ReadAnalogInput(dev, s, insn, &ui_Dummy);
+       }
+
+       return insn->n;
 }
 
 /*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_InsnBits_AnalogInput_Test               |
-  |                      (struct comedi_device *dev,struct comedi_subdevice *s,               |
-  |                      struct comedi_insn *insn,unsigned int *data)                     |
-  +----------------------------------------------------------------------------+
-  | Task              : Tests the Selected Anlog Input Channel                 |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     struct comedi_subdevice *s     : Subdevice Pointer            |
-  |                     struct comedi_insn *insn       : Insn Structure Pointer       |
-  |                     unsigned int *data          : Data Pointer contains        |
-  |                                          configuration parameters as below |
-  |
-  |
-  |                           data[0]            : 0 TestAnalogInputShortCircuit
-  |                                                                         1 TestAnalogInputConnection                                                                                                                                                                                                |
-
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  |                            data[0]            : Digital value obtained      |
-  |                           data[1]            : calibration offset          |
-  |                           data[2]            : calibration gain            |
-  |                                                                             |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-
-int i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device *dev,
-       struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+ * Tests the Selected Anlog Input Channel
+ *
+ * data[0] = 0  TestAnalogInputShortCircuit
+ *        = 1  TestAnalogInputConnection
+ *
+ * data[0] : Digital value obtained
+ * data[1] : calibration offset
+ * data[2] : calibration gain
+ */
+static int i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device *dev,
+                                               struct comedi_subdevice *s,
+                                               struct comedi_insn *insn,
+                                               unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int ui_Configuration = 0;
@@ -2519,61 +2409,18 @@ int i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device *dev,
        return insn->n;
 }
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : int i_APCI3200_InsnWriteReleaseAnalogInput             |
-  |                      (struct comedi_device *dev,struct comedi_subdevice *s,               |
-  |                      struct comedi_insn *insn,unsigned int *data)                     |
-  +----------------------------------------------------------------------------+
-  | Task              :  Resets the channels                                                      |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-  |                     struct comedi_subdevice *s     : Subdevice Pointer            |
-  |                     struct comedi_insn *insn       : Insn Structure Pointer       |
-  |                     unsigned int *data          : Data Pointer
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error          |
-  |                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-
-int i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device *dev,
-       struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+static int i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device *dev,
+                                                 struct comedi_subdevice *s,
+                                                 struct comedi_insn *insn,
+                                                 unsigned int *data)
 {
        i_APCI3200_Reset(dev);
        return insn->n;
 }
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function name     :int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev|
-  |                    ,struct comedi_subdevice *s,struct comedi_cmd *cmd)                              |
-  |                                                                                                             |
-  +----------------------------------------------------------------------------+
-  | Task              : Test validity for a command for cyclic anlog input     |
-  |                       acquisition                                                                           |
-  |                                                                                                                     |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev                                                                       |
-  |                     struct comedi_subdevice *s                                                                      |
-  |                     struct comedi_cmd *cmd                                                          |
-  |                                                                                                                     |
-  |
-  |                                                                                                                     |
-  |                                                                                                                     |
-  |                                                                                                                     |
-  +----------------------------------------------------------------------------+
-  | Return Value      :0                                                                    |
-  |                                                                                                                                 |
-  +----------------------------------------------------------------------------+
-*/
-
-int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-       struct comedi_cmd *cmd)
+static int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev,
+                                            struct comedi_subdevice *s,
+                                            struct comedi_cmd *cmd)
 {
 
        int err = 0;
@@ -2733,25 +2580,8 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
        return 0;
 }
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function name     :int i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev,|
-  |                                                                                         struct comedi_subdevice *s)|
-  |                                                                                                             |
-  +----------------------------------------------------------------------------+
-  | Task              : Stop the  acquisition                                                       |
-  |                                                                                                                     |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev                                                                       |
-  |                     struct comedi_subdevice *s                                                                      |
-  |                                                                                             |
-  +----------------------------------------------------------------------------+
-  | Return Value      :0                                                                    |
-  |                                                                                                                                 |
-  +----------------------------------------------------------------------------+
-*/
-
-int i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s)
+static int i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev,
+                                           struct comedi_subdevice *s)
 {
        struct addi_private *devpriv = dev->private;
        unsigned int ui_Configuration = 0;
@@ -2784,26 +2614,11 @@ int i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_su
 }
 
 /*
-  +----------------------------------------------------------------------------+
-  | Function name     : int i_APCI3200_CommandAnalogInput(struct comedi_device *dev,  |
-  |                                                                                            struct comedi_subdevice *s) |
-  |                                                                                                             |
-  +----------------------------------------------------------------------------+
-  | Task              : Does asynchronous acquisition                          |
-  |                     Determines the mode 1 or 2.                                                 |
-  |                                                                                                                     |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev                                                                       |
-  |                     struct comedi_subdevice *s                                                                      |
-  |                                                                                                                                     |
-  |                                                                                                                                     |
-  +----------------------------------------------------------------------------+
-  | Return Value      :                                                                         |
-  |                                                                                                                                 |
-  +----------------------------------------------------------------------------+
-*/
-
-int i_APCI3200_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s)
+ * Does asynchronous acquisition
+ * Determines the mode 1 or 2.
+ */
+static int i_APCI3200_CommandAnalogInput(struct comedi_device *dev,
+                                        struct comedi_subdevice *s)
 {
        struct addi_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
@@ -2953,104 +2768,176 @@ int i_APCI3200_CommandAnalogInput(struct comedi_device *dev, struct comedi_subde
        while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
                                        12) >> 19) & 1) != 1) ;
 
-       /* outl(((ui_Configuration & 0x1E0FF) | 0x00002000),devpriv->iobase+i_Offset + 4); */
-       outl(((ui_Configuration & 0x1E0FF) | 0x00002000),
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
-  /*******************/
-       /*Read the register */
-  /*******************/
-       ui_Configuration = 0;
-       /* ui_Configuration = inl(devpriv->iobase+i_Offset + 8); */
-       ui_Configuration =
-               inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
+       /* outl(((ui_Configuration & 0x1E0FF) | 0x00002000),devpriv->iobase+i_Offset + 4); */
+       outl(((ui_Configuration & 0x1E0FF) | 0x00002000),
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 4);
+  /*******************/
+       /*Read the register */
+  /*******************/
+       ui_Configuration = 0;
+       /* ui_Configuration = inl(devpriv->iobase+i_Offset + 8); */
+       ui_Configuration =
+               inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
+
+  /*******************/
+       /*Set the START bit */
+  /*******************/
+       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
+       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
+                                       12) >> 19) & 1) != 1) ;
+       /* outl((ui_Configuration | 0x00080000),devpriv->iobase+i_Offset + 8); */
+       outl((ui_Configuration | 0x00080000),
+               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
+       return 0;
+}
+
+/*
+ * This function copies the acquired data(from FIFO) to Comedi buffer.
+ */
+static int i_APCI3200_InterruptHandleEos(struct comedi_device *dev)
+{
+       struct addi_private *devpriv = dev->private;
+       unsigned int ui_StatusRegister = 0;
+       struct comedi_subdevice *s = &dev->subdevices[0];
+
+       /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+       /* comedi_async *async = s->async; */
+       /* UINT *data; */
+       /* data=async->data+async->buf_int_ptr;//new samples added from here onwards */
+       int n = 0, i = 0;
+       /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+
+  /************************************/
+       /*Read the interrupt status register */
+  /************************************/
+       /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */
+       ui_StatusRegister =
+               inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 16);
+
+  /*************************/
+       /*Test if interrupt occur */
+  /*************************/
+
+       if ((ui_StatusRegister & 0x2) == 0x2) {
+      /*************************/
+               /*Read the channel number */
+      /*************************/
+               /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */
+               /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+               /* This value is not used */
+               /* ui_ChannelNumber = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 24); */
+               s->async->events = 0;
+               /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+
+      /*************************************/
+               /*Read the digital Analog Input value */
+      /*************************************/
+
+               /* data[i_Count] = inl(devpriv->iobase+i_Offset + 28); */
+               /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+               /* data[s_BoardInfos [dev->minor].i_Count] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28); */
+               s_BoardInfos[dev->minor].ui_ScanValueArray[s_BoardInfos[dev->
+                               minor].i_Count] =
+                       inl(devpriv->iobase +
+                       s_BoardInfos[dev->minor].i_Offset + 28);
+               /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+
+               /* if((i_Count == (i_LastChannel-i_FirstChannel+3))) */
+               if ((s_BoardInfos[dev->minor].i_Count ==
+                               (s_BoardInfos[dev->minor].i_LastChannel -
+                                       s_BoardInfos[dev->minor].
+                                       i_FirstChannel + 3))) {
+
+                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
+                       s_BoardInfos[dev->minor].i_Count++;
+
+                       for (i = s_BoardInfos[dev->minor].i_FirstChannel;
+                               i <= s_BoardInfos[dev->minor].i_LastChannel;
+                               i++) {
+                               i_APCI3200_GetChannelCalibrationValue(dev, i,
+                                       &s_BoardInfos[dev->minor].
+                                       ui_ScanValueArray[s_BoardInfos[dev->
+                                                       minor].i_Count + ((i -
+                                                               s_BoardInfos
+                                                               [dev->minor].
+                                                               i_FirstChannel)
+                                                       * 3)],
+                                       &s_BoardInfos[dev->minor].
+                                       ui_ScanValueArray[s_BoardInfos[dev->
+                                                       minor].i_Count + ((i -
+                                                               s_BoardInfos
+                                                               [dev->minor].
+                                                               i_FirstChannel)
+                                                       * 3) + 1],
+                                       &s_BoardInfos[dev->minor].
+                                       ui_ScanValueArray[s_BoardInfos[dev->
+                                                       minor].i_Count + ((i -
+                                                               s_BoardInfos
+                                                               [dev->minor].
+                                                               i_FirstChannel)
+                                                       * 3) + 2]);
+                       }
+
+                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
 
-  /*******************/
-       /*Set the START bit */
-  /*******************/
-       /* while (((inl(devpriv->iobase+i_Offset+12)>>19) & 1) != 1); */
-       while (((inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset +
-                                       12) >> 19) & 1) != 1) ;
-       /* outl((ui_Configuration | 0x00080000),devpriv->iobase+i_Offset + 8); */
-       outl((ui_Configuration | 0x00080000),
-               devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 8);
-       return 0;
-}
+                       /* i_Count=-1; */
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function   Name   :  int i_APCI3200_Reset(struct comedi_device *dev)                            |
-  |                                                                                             |
-  +----------------------------------------------------------------------------+
-  | Task              :Resets the registers of the card                        |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  :                                                        |
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  +----------------------------------------------------------------------------+
-  | Return Value      :                                                        |
-  |                                                                                     |
-  +----------------------------------------------------------------------------+
-*/
+                       s_BoardInfos[dev->minor].i_Count = -1;
 
-int i_APCI3200_Reset(struct comedi_device *dev)
-{
-       struct addi_private *devpriv = dev->private;
-       int i_Temp;
-       unsigned int dw_Dummy;
+                       /* async->buf_int_count+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */
+                       /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+                       /* async->buf_int_count+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */
+                       /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+                       /* async->buf_int_ptr+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */
+                       /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+                       /* async->buf_int_ptr+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */
+                       /* comedi_eos(dev,s); */
 
-       /* i_InterruptFlag=0; */
-       /* i_Initialised==0; */
-       /* i_Count=0; */
-       /* i_Sum=0; */
+                       /*  Set the event type (Comedi Buffer End Of Scan) */
+                       s->async->events |= COMEDI_CB_EOS;
 
-       s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-       s_BoardInfos[dev->minor].i_Initialised = 0;
-       s_BoardInfos[dev->minor].i_Count = 0;
-       s_BoardInfos[dev->minor].i_Sum = 0;
-       s_BoardInfos[dev->minor].b_StructInitialized = 0;
+                       /*  Test if enougth memory is available and allocate it for 7 values */
+                       /* n = comedi_buf_write_alloc(s->async, 7*sizeof(unsigned int)); */
+                       n = comedi_buf_write_alloc(s->async,
+                               (7 + 12) * sizeof(unsigned int));
 
-       outl(0x83838383, devpriv->i_IobaseAmcc + 0x60);
+                       /*  If not enough memory available, event is set to Comedi Buffer Error */
+                       if (n > ((7 + 12) * sizeof(unsigned int))) {
+                               printk("\ncomedi_buf_write_alloc n = %i", n);
+                               s->async->events |= COMEDI_CB_ERROR;
+                       }
+                       /*  Write all 7 scan values in the comedi buffer */
+                       comedi_buf_memcpy_to(s->async, 0,
+                               (unsigned int *) s_BoardInfos[dev->minor].
+                               ui_ScanValueArray, (7 + 12) * sizeof(unsigned int));
 
-       /*  Enable the interrupt for the controller */
-       dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38);
-       outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38);
-       outl(0, devpriv->i_IobaseAddon);        /* Resets the output */
-  /***************/
-       /*Empty the buffer */
-  /**************/
-       for (i_Temp = 0; i_Temp <= 95; i_Temp++) {
-               /* ui_InterruptChannelValue[i_Temp]=0; */
-               s_BoardInfos[dev->minor].ui_InterruptChannelValue[i_Temp] = 0;
-       }                       /* for(i_Temp=0;i_Temp<=95;i_Temp++) */
-  /*****************************/
-       /*Reset the START and IRQ bit */
-  /*****************************/
-       for (i_Temp = 0; i_Temp <= 192;) {
-               while (((inl(devpriv->iobase + i_Temp + 12) >> 19) & 1) != 1) ;
-               outl(0, devpriv->iobase + i_Temp + 8);
-               i_Temp = i_Temp + 64;
-       }                       /* for(i_Temp=0;i_Temp<=192;i_Temp+64) */
+                       /*  Update comedi buffer pinters indexes */
+                       comedi_buf_write_free(s->async,
+                               (7 + 12) * sizeof(unsigned int));
+
+                       /*  Send events */
+                       comedi_event(dev, s);
+                       /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+
+                       /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+                       /*  */
+                       /* if (s->async->buf_int_ptr>=s->async->data_len) //  for buffer rool over */
+                       /*   { */
+                       /*     /* buffer rollover */ */
+                       /*     s->async->buf_int_ptr=0; */
+                       /*     comedi_eobuf(dev,s); */
+                       /*   } */
+                       /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
+               }
+               /* i_Count++; */
+               s_BoardInfos[dev->minor].i_Count++;
+       }
+       /* i_InterruptFlag=0; */
+       s_BoardInfos[dev->minor].i_InterruptFlag = 0;
        return 0;
 }
 
-/*
-  +----------------------------------------------------------------------------+
-  | Function   Name   : static void v_APCI3200_Interrupt                                            |
-  |                                      (int irq , void *d)                            |
-  +----------------------------------------------------------------------------+
-  | Task              : Interrupt processing Routine                           |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : int irq                 : irq number                   |
-  |                     void *d                 : void pointer                 |
-  +----------------------------------------------------------------------------+
-  | Output Parameters :        --                                                                                                       |
-  +----------------------------------------------------------------------------+
-  | Return Value      : TRUE  : No error occur                                 |
-  |                        : FALSE : Error occur. Return the error                                      |
-  |                                                                                             |
-  +----------------------------------------------------------------------------+
-*/
-void v_APCI3200_Interrupt(int irq, void *d)
+static void v_APCI3200_Interrupt(int irq, void *d)
 {
        struct comedi_device *dev = d;
        struct addi_private *devpriv = dev->private;
@@ -3472,165 +3359,3 @@ void v_APCI3200_Interrupt(int irq, void *d)
        }                       /* switch(i_ScanType) */
        return;
 }
-
-/*
-  +----------------------------------------------------------------------------+
-  | Function name     :int i_APCI3200_InterruptHandleEos(struct comedi_device *dev)   |
-  |                                                                                                             |
-  |                                                                                                     |
-  +----------------------------------------------------------------------------+
-  | Task              : .                   |
-  |                     This function copies the acquired data(from FIFO)      |
-  |                            to Comedi buffer.                                                                        |
-  |                                                                                                                     |
-  +----------------------------------------------------------------------------+
-  | Input Parameters  : struct comedi_device *dev                                                                       |
-  |                                                                                                                                     |
-  |                                                                                             |
-  +----------------------------------------------------------------------------+
-  | Return Value      : 0                                                                       |
-  |                                                                                                                                 |
-  +----------------------------------------------------------------------------+
-*/
-int i_APCI3200_InterruptHandleEos(struct comedi_device *dev)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_StatusRegister = 0;
-       struct comedi_subdevice *s = &dev->subdevices[0];
-
-       /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-       /* comedi_async *async = s->async; */
-       /* UINT *data; */
-       /* data=async->data+async->buf_int_ptr;//new samples added from here onwards */
-       int n = 0, i = 0;
-       /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-
-  /************************************/
-       /*Read the interrupt status register */
-  /************************************/
-       /* ui_StatusRegister = inl(devpriv->iobase+i_Offset + 16); */
-       ui_StatusRegister =
-               inl(devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 16);
-
-  /*************************/
-       /*Test if interrupt occur */
-  /*************************/
-
-       if ((ui_StatusRegister & 0x2) == 0x2) {
-      /*************************/
-               /*Read the channel number */
-      /*************************/
-               /* ui_ChannelNumber = inl(devpriv->iobase+i_Offset + 24); */
-               /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-               /* This value is not used */
-               /* ui_ChannelNumber = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 24); */
-               s->async->events = 0;
-               /* END JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-
-      /*************************************/
-               /*Read the digital Analog Input value */
-      /*************************************/
-
-               /* data[i_Count] = inl(devpriv->iobase+i_Offset + 28); */
-               /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-               /* data[s_BoardInfos [dev->minor].i_Count] = inl(devpriv->iobase+s_BoardInfos [dev->minor].i_Offset + 28); */
-               s_BoardInfos[dev->minor].ui_ScanValueArray[s_BoardInfos[dev->
-                               minor].i_Count] =
-                       inl(devpriv->iobase +
-                       s_BoardInfos[dev->minor].i_Offset + 28);
-               /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-
-               /* if((i_Count == (i_LastChannel-i_FirstChannel+3))) */
-               if ((s_BoardInfos[dev->minor].i_Count ==
-                               (s_BoardInfos[dev->minor].i_LastChannel -
-                                       s_BoardInfos[dev->minor].
-                                       i_FirstChannel + 3))) {
-
-                       /* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-                       s_BoardInfos[dev->minor].i_Count++;
-
-                       for (i = s_BoardInfos[dev->minor].i_FirstChannel;
-                               i <= s_BoardInfos[dev->minor].i_LastChannel;
-                               i++) {
-                               i_APCI3200_GetChannelCalibrationValue(dev, i,
-                                       &s_BoardInfos[dev->minor].
-                                       ui_ScanValueArray[s_BoardInfos[dev->
-                                                       minor].i_Count + ((i -
-                                                               s_BoardInfos
-                                                               [dev->minor].
-                                                               i_FirstChannel)
-                                                       * 3)],
-                                       &s_BoardInfos[dev->minor].
-                                       ui_ScanValueArray[s_BoardInfos[dev->
-                                                       minor].i_Count + ((i -
-                                                               s_BoardInfos
-                                                               [dev->minor].
-                                                               i_FirstChannel)
-                                                       * 3) + 1],
-                                       &s_BoardInfos[dev->minor].
-                                       ui_ScanValueArray[s_BoardInfos[dev->
-                                                       minor].i_Count + ((i -
-                                                               s_BoardInfos
-                                                               [dev->minor].
-                                                               i_FirstChannel)
-                                                       * 3) + 2]);
-                       }
-
-                       /* End JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
-                       /* i_Count=-1; */
-
-                       s_BoardInfos[dev->minor].i_Count = -1;
-
-                       /* async->buf_int_count+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */
-                       /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-                       /* async->buf_int_count+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */
-                       /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-                       /* async->buf_int_ptr+=(i_LastChannel-i_FirstChannel+4)*sizeof(unsigned int); */
-                       /* Begin JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-                       /* async->buf_int_ptr+=(s_BoardInfos [dev->minor].i_LastChannel-s_BoardInfos [dev->minor].i_FirstChannel+4)*sizeof(unsigned int); */
-                       /* comedi_eos(dev,s); */
-
-                       /*  Set the event type (Comedi Buffer End Of Scan) */
-                       s->async->events |= COMEDI_CB_EOS;
-
-                       /*  Test if enougth memory is available and allocate it for 7 values */
-                       /* n = comedi_buf_write_alloc(s->async, 7*sizeof(unsigned int)); */
-                       n = comedi_buf_write_alloc(s->async,
-                               (7 + 12) * sizeof(unsigned int));
-
-                       /*  If not enough memory available, event is set to Comedi Buffer Error */
-                       if (n > ((7 + 12) * sizeof(unsigned int))) {
-                               printk("\ncomedi_buf_write_alloc n = %i", n);
-                               s->async->events |= COMEDI_CB_ERROR;
-                       }
-                       /*  Write all 7 scan values in the comedi buffer */
-                       comedi_buf_memcpy_to(s->async, 0,
-                               (unsigned int *) s_BoardInfos[dev->minor].
-                               ui_ScanValueArray, (7 + 12) * sizeof(unsigned int));
-
-                       /*  Update comedi buffer pinters indexes */
-                       comedi_buf_write_free(s->async,
-                               (7 + 12) * sizeof(unsigned int));
-
-                       /*  Send events */
-                       comedi_event(dev, s);
-                       /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-
-                       /* BEGIN JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-                       /*  */
-                       /* if (s->async->buf_int_ptr>=s->async->data_len) //  for buffer rool over */
-                       /*   { */
-                       /*     /* buffer rollover */ */
-                       /*     s->async->buf_int_ptr=0; */
-                       /*     comedi_eobuf(dev,s); */
-                       /*   } */
-                       /* End JK 18.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-               }
-               /* i_Count++; */
-               s_BoardInfos[dev->minor].i_Count++;
-       }
-       /* i_InterruptFlag=0; */
-       s_BoardInfos[dev->minor].i_InterruptFlag = 0;
-       return 0;
-}
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.h
deleted file mode 100644 (file)
index afa7ba3..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-/* Card Specific information */
-/* #define APCI3200_ADDRESS_RANGE                   264 */
-
-int MODULE_NO;
-struct {
-       int i_Gain;
-       int i_Polarity;
-       int i_OffsetRange;
-       int i_Coupling;
-       int i_SingleDiff;
-       int i_AutoCalibration;
-       unsigned int ui_ReloadValue;
-       unsigned int ui_TimeUnitReloadVal;
-       int i_Interrupt;
-       int i_ModuleSelection;
-} Config_Parameters_Module1, Config_Parameters_Module2,
-    Config_Parameters_Module3, Config_Parameters_Module4;
-
-/* ANALOG INPUT RANGE */
-static const struct comedi_lrange range_apci3200_ai = { 8, {
-                                                    BIP_RANGE(10),
-                                                    BIP_RANGE(5),
-                                                    BIP_RANGE(2),
-                                                    BIP_RANGE(1),
-                                                    UNI_RANGE(10),
-                                                    UNI_RANGE(5),
-                                                    UNI_RANGE(2),
-                                                    UNI_RANGE(1)
-                                                    }
-};
-
-static const struct comedi_lrange range_apci3300_ai = { 4, {
-                                                    UNI_RANGE(10),
-                                                    UNI_RANGE(5),
-                                                    UNI_RANGE(2),
-                                                    UNI_RANGE(1)
-                                                    }
-};
-
-/* Analog Input related Defines */
-#define APCI3200_AI_OFFSET_GAIN                  0
-#define APCI3200_AI_SC_TEST                      4
-#define APCI3200_AI_IRQ                          8
-#define APCI3200_AI_AUTOCAL                      12
-#define APCI3200_RELOAD_CONV_TIME_VAL            32
-#define APCI3200_CONV_TIME_TIME_BASE             36
-#define APCI3200_RELOAD_DELAY_TIME_VAL           40
-#define APCI3200_DELAY_TIME_TIME_BASE            44
-#define APCI3200_AI_MODULE1                      0
-#define APCI3200_AI_MODULE2                      64
-#define APCI3200_AI_MODULE3                      128
-#define APCI3200_AI_MODULE4                      192
-#define TRUE                                     1
-#define FALSE                                    0
-#define APCI3200_AI_EOSIRQ                       16
-#define APCI3200_AI_EOS                          20
-#define APCI3200_AI_CHAN_ID                      24
-#define APCI3200_AI_CHAN_VAL                     28
-#define ANALOG_INPUT                             0
-#define TEMPERATURE                              1
-#define RESISTANCE                               2
-
-#define ENABLE_EXT_TRIG                          1
-#define ENABLE_EXT_GATE                          2
-#define ENABLE_EXT_TRIG_GATE                     3
-
-#define APCI3200_MAXVOLT                         2.5
-#define ADDIDATA_GREATER_THAN_TEST               0
-#define ADDIDATA_LESS_THAN_TEST                  1
-
-#define ADDIDATA_UNIPOLAR                        1
-#define ADDIDATA_BIPOLAR                         2
-
-/* BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-#define MAX_MODULE                             4
-/* END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
-struct str_ADDIDATA_RTDStruct {
-       unsigned int ul_NumberOfValue;
-       unsigned int *pul_ResistanceValue;
-       unsigned int *pul_TemperatureValue;
-};
-
-/* BEGIN JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-struct str_Module {
-
-       /*  Begin JK 05/08/2003 change for Linux */
-       unsigned long ul_CurrentSourceCJC;
-       unsigned long ul_CurrentSource[5];
-       /*  End JK 05/08/2003 change for Linux */
-
-       /*  Begin CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1 */
-       unsigned long ul_GainFactor[8]; /*  Gain Factor */
-       unsigned int w_GainValue[10];
-       /*  End CG 15/02/02 Rev 1.0 -> Rev 1.1 : Add Header Type 1 */
-};
-
-/* END JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
-/* BEGIN JK 06.07.04: Management of sevrals boards */
-struct str_BoardInfos {
-
-       int i_CJCAvailable;
-       int i_CJCPolarity;
-       int i_CJCGain;
-       int i_InterruptFlag;
-       int i_ADDIDATAPolarity;
-       int i_ADDIDATAGain;
-       int i_AutoCalibration;
-       int i_ADDIDATAConversionTime;
-       int i_ADDIDATAConversionTimeUnit;
-       int i_ADDIDATAType;
-       int i_ChannelNo;
-       int i_ChannelCount;
-       int i_ScanType;
-       int i_FirstChannel;
-       int i_LastChannel;
-       int i_Sum;
-       int i_Offset;
-       unsigned int ui_Channel_num;
-       int i_Count;
-       int i_Initialised;
-       /* UINT ui_InterruptChannelValue[96]; //Buffer */
-       unsigned int ui_InterruptChannelValue[144];     /* Buffer */
-       unsigned char b_StructInitialized;
-       /* Begin JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-       unsigned int ui_ScanValueArray[7 + 12]; /*  7 is the maximal number of channels */
-       /* End JK 19.10.2004: APCI-3200 Driver update 0.7.57 -> 0.7.68 */
-
-       /* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-       int i_ConnectionType;
-       int i_NbrOfModule;
-       struct str_Module s_Module[MAX_MODULE];
-       /* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-};
-
-/* END JK 06.07.04: Management of sevrals boards */
-
-/* Hardware Layer  functions for Apci3200 */
-
-/* AI */
-
-int i_APCI3200_ConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-                                struct comedi_insn *insn, unsigned int *data);
-int i_APCI3200_ReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-                              struct comedi_insn *insn, unsigned int *data);
-int i_APCI3200_InsnWriteReleaseAnalogInput(struct comedi_device *dev,
-                                          struct comedi_subdevice *s,
-                                          struct comedi_insn *insn, unsigned int *data);
-int i_APCI3200_InsnBits_AnalogInput_Test(struct comedi_device *dev,
-                                        struct comedi_subdevice *s,
-                                        struct comedi_insn *insn, unsigned int *data);
-int i_APCI3200_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s);
-int i_APCI3200_InterruptHandleEos(struct comedi_device *dev);
-int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
-                                     struct comedi_cmd *cmd);
-int i_APCI3200_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s);
-int i_APCI3200_ReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
-                               struct comedi_insn *insn, unsigned int *data);
-/* Interrupt */
-void v_APCI3200_Interrupt(int irq, void *d);
-int i_APCI3200_InterruptHandleEos(struct comedi_device *dev);
-/* Reset functions */
-int i_APCI3200_Reset(struct comedi_device *dev);
-
-int i_APCI3200_ReadCJCCalOffset(struct comedi_device *dev, unsigned int *data);
-int i_APCI3200_ReadCJCValue(struct comedi_device *dev, unsigned int *data);
-int i_APCI3200_ReadCalibrationGainValue(struct comedi_device *dev, unsigned int *data);
-int i_APCI3200_ReadCalibrationOffsetValue(struct comedi_device *dev, unsigned int *data);
-int i_APCI3200_Read1AnalogInputChannel(struct comedi_device *dev,
-                                      struct comedi_subdevice *s, struct comedi_insn *insn,
-                                      unsigned int *data);
-int i_APCI3200_ReadCJCCalGain(struct comedi_device *dev, unsigned int *data);
index 609edd7ce8d2fde9d3549233da3a1ef172dff5a6..c92ec8fc932f4bf8cedad3d9ece4bb7543c0fd38 100644 (file)
@@ -46,12 +46,43 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +----------+-----------+------------------------------------------------+
 */
 
-/*
-+----------------------------------------------------------------------------+
-|                               Included files                               |
-+----------------------------------------------------------------------------+
-*/
-#include "hwdrv_apci3501.h"
+/* Card Specific information */
+#define APCI3501_ADDRESS_RANGE         255
+
+#define APCI3501_DIGITAL_IP            0x50
+#define APCI3501_DIGITAL_OP            0x40
+#define APCI3501_ANALOG_OUTPUT         0x00
+
+/* Analog Output related Defines */
+#define APCI3501_AO_VOLT_MODE          0
+#define APCI3501_AO_PROG               4
+#define APCI3501_AO_TRIG_SCS           8
+#define UNIPOLAR                       0
+#define BIPOLAR                                1
+#define MODE0                          0
+#define MODE1                          1
+
+/* Watchdog Related Defines */
+
+#define APCI3501_WATCHDOG              0x20
+#define APCI3501_TCW_SYNC_ENABLEDISABLE        0
+#define APCI3501_TCW_RELOAD_VALUE      4
+#define APCI3501_TCW_TIMEBASE          8
+#define APCI3501_TCW_PROG              12
+#define APCI3501_TCW_TRIG_STATUS       16
+#define APCI3501_TCW_IRQ               20
+#define APCI3501_TCW_WARN_TIMEVAL      24
+#define APCI3501_TCW_WARN_TIMEBASE     28
+#define ADDIDATA_TIMER                 0
+#define ADDIDATA_WATCHDOG              2
+
+/* ANALOG OUTPUT RANGE */
+static struct comedi_lrange range_apci3501_ao = {
+       2, {
+               BIP_RANGE(10),
+               UNI_RANGE(10)
+       }
+};
 
 /*
 +----------------------------------------------------------------------------+
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.h
deleted file mode 100644 (file)
index 201fc7b..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-/* Card Specific information */
-#define APCI3501_ADDRESS_RANGE                   255
-
-#define APCI3501_DIGITAL_IP                       0x50
-#define APCI3501_DIGITAL_OP                       0x40
-#define APCI3501_ANALOG_OUTPUT                    0x00
-
-/* Analog Output related Defines */
-#define APCI3501_AO_VOLT_MODE                     0
-#define APCI3501_AO_PROG                          4
-#define APCI3501_AO_TRIG_SCS                      8
-#define UNIPOLAR                                  0
-#define BIPOLAR                                   1
-#define MODE0                                     0
-#define MODE1                                     1
-/* ANALOG OUTPUT RANGE */
-static struct comedi_lrange range_apci3501_ao = { 2, {
-                                       BIP_RANGE(10),
-                                       UNI_RANGE(10)
-                                       }
-};
-
-/* Watchdog Related Defines */
-
-#define APCI3501_WATCHDOG                         0x20
-#define APCI3501_TCW_SYNC_ENABLEDISABLE           0
-#define APCI3501_TCW_RELOAD_VALUE                 4
-#define APCI3501_TCW_TIMEBASE                     8
-#define APCI3501_TCW_PROG                         12
-#define APCI3501_TCW_TRIG_STATUS                  16
-#define APCI3501_TCW_IRQ                          20
-#define APCI3501_TCW_WARN_TIMEVAL                 24
-#define APCI3501_TCW_WARN_TIMEBASE                28
-#define ADDIDATA_TIMER                            0
-#define ADDIDATA_WATCHDOG                         2
index 80974f27ff3006e7d8630c1d95873f21f4a2e110..d1b0ee6b628f4b9c365162f33feae55569fd61ed 100644 (file)
@@ -44,7 +44,35 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   +----------+-----------+------------------------------------------------+
 */
 
-#include "hwdrv_apci3xxx.h"
+#ifndef COMEDI_SUBD_TTLIO
+#define COMEDI_SUBD_TTLIO      11      /* Digital Input Output But TTL */
+#endif
+
+#define APCI3XXX_SINGLE                                0
+#define APCI3XXX_DIFF                          1
+#define APCI3XXX_CONFIGURATION                 0
+
+#define APCI3XXX_TTL_INIT_DIRECTION_PORT2      0
+
+static const struct comedi_lrange range_apci3XXX_ai = {
+       8, {
+               BIP_RANGE(10),
+               BIP_RANGE(5),
+               BIP_RANGE(2),
+               BIP_RANGE(1),
+               UNI_RANGE(10),
+               UNI_RANGE(5),
+               UNI_RANGE(2),
+               UNI_RANGE(1)
+       }
+};
+
+static const struct comedi_lrange range_apci3XXX_ao = {
+       2, {
+               BIP_RANGE(10),
+               UNI_RANGE(10)
+       }
+};
 
 /*
 +----------------------------------------------------------------------------+
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.h
deleted file mode 100644 (file)
index e10b7e5..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
- *
- *     ADDI-DATA GmbH
- *     Dieselstrasse 3
- *     D-77833 Ottersweier
- *     Tel: +19(0)7223/9493-0
- *     Fax: +49(0)7223/9493-92
- *     http://www.addi-data.com
- *     info@addi-data.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#ifndef COMEDI_SUBD_TTLIO
-#define COMEDI_SUBD_TTLIO   11 /* Digital Input Output But TTL */
-#endif
-
-#ifndef ADDIDATA_ENABLE
-#define ADDIDATA_ENABLE  1
-#define ADDIDATA_DISABLE 0
-#endif
-
-#define APCI3XXX_SINGLE                              0
-#define APCI3XXX_DIFF                                1
-#define APCI3XXX_CONFIGURATION                       0
-
-#define APCI3XXX_TTL_INIT_DIRECTION_PORT2   0
-
-#ifdef __KERNEL__
-
-static const struct comedi_lrange range_apci3XXX_ai = { 8, {BIP_RANGE(10),
-                                                    BIP_RANGE(5),
-                                                    BIP_RANGE(2),
-                                                    BIP_RANGE(1),
-                                                    UNI_RANGE(10),
-                                                    UNI_RANGE(5),
-                                                    UNI_RANGE(2),
-                                                    UNI_RANGE(1)}
-};
-
-static const struct comedi_lrange range_apci3XXX_ao = { 2, {BIP_RANGE(10),
-                                                    UNI_RANGE(10)}
-};
-#endif
index 2e3f685fbc5b859be42137a3a13f8b71a1cb1759..43b83cf48107116690f7e99bc5d19fb72da7db46 100644 (file)
@@ -1,19 +1,16 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_035 1
 
 #define ADDIDATA_WATCHDOG 2    /*  Or shold it be something else */
 
-#define ADDIDATA_DRIVER_NAME   "addi_apci_035"
-
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci035.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci035_boardtypes[] = {
        {
                .pc_DriverName          = "apci035",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -40,13 +37,40 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci035_driver = {
+       .driver_name    = "addi_apci_035",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci035_boardtypes),
+       .board_name     = &apci035_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci035_pci_probe(struct pci_dev *dev,
+                                      const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci035_driver);
+}
+
+static void __devexit apci035_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci035_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA,  0x0300) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci035_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci035_pci_driver = {
+       .name           = "addi_apci_035",
+       .id_table       = apci035_pci_table,
+       .probe          = apci035_pci_probe,
+       .remove         = __devexit_p(apci035_pci_remove),
+};
+module_comedi_pci_driver(apci035_driver, apci035_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index cfcba6a268ba062b0b207f66da402ae5e71c0c45..1db3e15ed4babbe418843b40e98278ea3616ccb8 100644 (file)
@@ -1,17 +1,14 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_1032 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_1032"
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci1032.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci1032_boardtypes[] = {
        {
                .pc_DriverName          = "apci1032",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -29,13 +26,40 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci1032_driver = {
+       .driver_name    = "addi_apci_1032",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci1032_boardtypes),
+       .board_name     = &apci1032_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci1032_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci1032_driver);
+}
+
+static void __devexit apci1032_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci1032_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1003) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci1032_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci1032_pci_driver = {
+       .name           = "addi_apci_1032",
+       .id_table       = apci1032_pci_table,
+       .probe          = apci1032_pci_probe,
+       .remove         = __devexit_p(apci1032_pci_remove),
+};
+module_comedi_pci_driver(apci1032_driver, apci1032_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index 59d762fbcb91d6ffff2eb8c829260de1d6e48d94..4fe98e5ce75f0096a57d9c55a2de148d1097ba23 100644 (file)
@@ -1,17 +1,14 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_1500 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_1500"
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci1500.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci1500_boardtypes[] = {
        {
                .pc_DriverName          = "apci1500",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA_OLD,
@@ -40,13 +37,40 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci1500_driver = {
+       .driver_name    = "addi_apci_1500",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci1500_boardtypes),
+       .board_name     = &apci1500_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci1500_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci1500_driver);
+}
+
+static void __devexit apci1500_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci1500_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, 0x80fc) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci1500_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci1500_pci_driver = {
+       .name           = "addi_apci_1500",
+       .id_table       = apci1500_pci_table,
+       .probe          = apci1500_pci_probe,
+       .remove         = __devexit_p(apci1500_pci_remove),
+};
+module_comedi_pci_driver(apci1500_driver, apci1500_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index fdc4b6617b2cda827ddcce0b7727c8e91d094d42..59c0c65ac1898a987d6baf921764f53e771d1ce3 100644 (file)
@@ -1,17 +1,14 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_1516 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_1516"
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci1516.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci1516_boardtypes[] = {
        {
                .pc_DriverName          = "apci1516",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -36,13 +33,40 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci1516_driver = {
+       .driver_name    = "addi_apci_1516",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci1516_boardtypes),
+       .board_name     = &apci1516_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci1516_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci1516_driver);
+}
+
+static void __devexit apci1516_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci1516_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1001) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci1516_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci1516_pci_driver = {
+       .name           = "addi_apci_1516",
+       .id_table       = apci1516_pci_table,
+       .probe          = apci1516_pci_probe,
+       .remove         = __devexit_p(apci1516_pci_remove),
+};
+module_comedi_pci_driver(apci1516_driver, apci1516_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index 6bdbf205847d94ace50e8a4f332a222fa772c576..1dcaadade21c8e46a9b66a73c9082cd20966352e 100644 (file)
@@ -1,17 +1,14 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_1564 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_1564"
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci1564.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci1564_boardtypes[] = {
        {
                .pc_DriverName          = "apci1564",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -39,13 +36,40 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci1564_driver = {
+       .driver_name    = "addi_apci_1564",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci1564_boardtypes),
+       .board_name     = &apci1564_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci1564_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci1564_driver);
+}
+
+static void __devexit apci1564_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci1564_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1006) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci1564_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci1564_pci_driver = {
+       .name           = "addi_apci_1564",
+       .id_table       = apci1564_pci_table,
+       .probe          = apci1564_pci_probe,
+       .remove         = __devexit_p(apci1564_pci_remove),
+};
+module_comedi_pci_driver(apci1564_driver, apci1564_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index 87009c832d2166b6081e6b4f9cb7f5d9e703dd17..14283aad0e420bfef405b94e5dd2dbc4e82fc3e4 100644 (file)
@@ -1,17 +1,14 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_16XX 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_16xx"
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci16xx.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci16xx_boardtypes[] = {
        {
                .pc_DriverName          = "apci1648",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -39,14 +36,41 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci16xx_driver = {
+       .driver_name    = "addi_apci_16xx",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci16xx_boardtypes),
+       .board_name     = &apci16xx_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci16xx_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci16xx_driver);
+}
+
+static void __devexit apci16xx_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci16xx_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1009) },
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x100a) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci16xx_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci16xx_pci_driver = {
+       .name           = "addi_apci_16xx",
+       .id_table       = apci16xx_pci_table,
+       .probe          = apci16xx_pci_probe,
+       .remove         = __devexit_p(apci16xx_pci_remove),
+};
+module_comedi_pci_driver(apci16xx_driver, apci16xx_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index 58c5121e82792e503cb53e8efbeb2d3c32c7470a..66dd94c26900518dc8993f6e359688b2976d8d6b 100644 (file)
@@ -2,9 +2,9 @@
 
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
 
 static void fpu_begin(void)
 {
@@ -16,31 +16,136 @@ static void fpu_end(void)
        kernel_fpu_end();
 }
 
-#define CONFIG_APCI_1710 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_1710"
-
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_APCI1710.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci1710_boardtypes[] = {
        {
                .pc_DriverName          = "apci1710",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA_OLD,
                .i_DeviceId             = APCI1710_BOARD_DEVICE_ID,
-               .i_IorangeBase0         = 128,
-               .i_IorangeBase1         = 8,
-               .i_IorangeBase2         = 256,
-               .i_PCIEeprom            = ADDIDATA_NO_EEPROM,
                .interrupt              = v_APCI1710_Interrupt,
-               .reset                  = i_APCI1710_Reset,
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static irqreturn_t v_ADDI_Interrupt(int irq, void *d)
+{
+       struct comedi_device *dev = d;
+       const struct addi_board *this_board = comedi_board(dev);
+
+       this_board->interrupt(irq, d);
+       return IRQ_RETVAL(1);
+}
+
+static const void *apci1710_find_boardinfo(struct comedi_device *dev,
+                                          struct pci_dev *pcidev)
+{
+       const struct addi_board *this_board;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(apci1710_boardtypes); i++) {
+               this_board = &apci1710_boardtypes[i];
+               if (this_board->i_VendorId == pcidev->vendor &&
+                   this_board->i_DeviceId == pcidev->device)
+                       return this_board;
+       }
+       return NULL;
+}
+
+static int apci1710_attach_pci(struct comedi_device *dev,
+                              struct pci_dev *pcidev)
+{
+       const struct addi_board *this_board;
+       struct addi_private *devpriv;
+       struct comedi_subdevice *s;
+       int ret;
+
+       this_board = apci1710_find_boardinfo(dev, pcidev);
+       if (!this_board)
+               return -ENODEV;
+       dev->board_ptr = this_board;
+       dev->board_name = this_board->pc_DriverName;
+
+       devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
+       if (!devpriv)
+               return -ENOMEM;
+       dev->private = devpriv;
+
+       ret = comedi_pci_enable(pcidev, dev->board_name);
+       if (ret)
+               return ret;
+
+       if (this_board->i_IorangeBase1)
+               dev->iobase = pci_resource_start(pcidev, 1);
+       else
+               dev->iobase = pci_resource_start(pcidev, 0);
+
+       devpriv->iobase = dev->iobase;
+       devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0);
+       devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2);
+       devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3);
+
+       if (pcidev->irq > 0) {
+               ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED,
+                                 dev->board_name, dev);
+               if (ret == 0)
+                       dev->irq = pcidev->irq;
+       }
+
+       i_ADDI_AttachPCI1710(dev);
+
+       devpriv->s_BoardInfos.ui_Address = pci_resource_start(pcidev, 2);
+
+       i_APCI1710_Reset(dev);
+       return 0;
+}
+
+static void apci1710_detach(struct comedi_device *dev)
+{
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+       if (dev->iobase)
+               i_APCI1710_Reset(dev);
+       if (dev->irq)
+               free_irq(dev->irq, dev);
+       if (pcidev) {
+               if (dev->iobase)
+                       comedi_pci_disable(pcidev);
+       }
+}
+
+static struct comedi_driver apci1710_driver = {
+       .driver_name    = "addi_apci_1710",
+       .module         = THIS_MODULE,
+       .attach_pci     = apci1710_attach_pci,
+       .detach         = apci1710_detach,
+};
+
+static int __devinit apci1710_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci1710_driver);
+}
+
+static void __devexit apci1710_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci1710_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, APCI1710_BOARD_DEVICE_ID) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci1710_pci_table);
+
+static struct pci_driver apci1710_pci_driver = {
+       .name           = "addi_apci_1710",
+       .id_table       = apci1710_pci_table,
+       .probe          = apci1710_pci_probe,
+       .remove         = __devexit_p(apci1710_pci_remove),
+};
+module_comedi_pci_driver(apci1710_driver, apci1710_pci_driver);
 
-#include "addi-data/addi_common.c"
+MODULE_AUTHOR("Comedi http://www.comedi.org");
+MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_LICENSE("GPL");
index ece4b9db58ca100814b9f1354f9ea7628bec3fd2..7c71981de7df460e6b04dee72ea244432b7b9912 100644 (file)
@@ -1,17 +1,14 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_2016 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_2016"
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci2016.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci2016_boardtypes[] = {
        {
                .pc_DriverName          = "apci2016",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -33,13 +30,40 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci2016_driver = {
+       .driver_name    = "addi_apci_2016",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci2016_boardtypes),
+       .board_name     = &apci2016_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci2016_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci2016_driver);
+}
+
+static void __devexit apci2016_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci2016_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1002) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci2016_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci2016_pci_driver = {
+       .name           = "addi_apci_2016",
+       .id_table       = apci2016_pci_table,
+       .probe          = apci2016_pci_probe,
+       .remove         = __devexit_p(apci2016_pci_remove),
+};
+module_comedi_pci_driver(apci2016_driver, apci2016_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index 8dddb65f13bdf690a63730513855d43b6930b14f..92650480cd3a1a4f20dd9bb411ce29c43dfe1bf1 100644 (file)
@@ -1,17 +1,14 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_2032 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_2032"
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci2032.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci2032_boardtypes[] = {
        {
                .pc_DriverName          = "apci2032",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -35,13 +32,40 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci2032_driver = {
+       .driver_name    = "addi_apci_2032",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci2032_boardtypes),
+       .board_name     = &apci2032_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci2032_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci2032_driver);
+}
+
+static void __devexit apci2032_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci2032_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1004) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci2032_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci2032_pci_driver = {
+       .name           = "addi_apci_2032",
+       .id_table       = apci2032_pci_table,
+       .probe          = apci2032_pci_probe,
+       .remove         = __devexit_p(apci2032_pci_remove),
+};
+module_comedi_pci_driver(apci2032_driver, apci2032_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index 2c6464825b77573d923b43bc69f4da1693328d94..becb2b4d11cd2da08c2430c9c617b01be8a65509 100644 (file)
@@ -1,17 +1,14 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_2200 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_2200"
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci2200.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci2200_boardtypes[] = {
        {
                .pc_DriverName          = "apci2200",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -35,13 +32,40 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci2200_driver = {
+       .driver_name    = "addi_apci_2200",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci2200_boardtypes),
+       .board_name     = &apci2200_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci2200_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci2200_driver);
+}
+
+static void __devexit apci2200_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci2200_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1005) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci2200_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci2200_pci_driver = {
+       .name           = "addi_apci_2200",
+       .id_table       = apci2200_pci_table,
+       .probe          = apci2200_pci_probe,
+       .remove         = __devexit_p(apci2200_pci_remove),
+};
+module_comedi_pci_driver(apci2200_driver, apci2200_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index d5bc24660d838a4356a4e9219786551a4cf92a89..90506a3d1dc42659a7a37d5a3f7e18fffa00b20e 100644 (file)
@@ -1,17 +1,14 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_3001 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_3001"
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci3120.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci3001_boardtypes[] = {
        {
                .pc_DriverName          = "apci3001",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA_OLD,
@@ -51,13 +48,40 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci3001_driver = {
+       .driver_name    = "addi_apci_3001",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci3001_boardtypes),
+       .board_name     = &apci3001_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci3001_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci3001_driver);
+}
+
+static void __devexit apci3001_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci3001_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, 0x828d) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci3001_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci3001_pci_driver = {
+       .name           = "addi_apci_3001",
+       .id_table       = apci3001_pci_table,
+       .probe          = apci3001_pci_probe,
+       .remove         = __devexit_p(apci3001_pci_remove),
+};
+module_comedi_pci_driver(apci3001_driver, apci3001_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index bd2a654eeba9b1164f3b21c939eef99fecb953d2..5db6bfc0e22562bb4fce7ea8ba61bae5023c8109 100644 (file)
@@ -1,17 +1,16 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
 
 #define CONFIG_APCI_3120 1
 
-#define ADDIDATA_DRIVER_NAME   "addi_apci_3120"
-
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci3120.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci3120_boardtypes[] = {
        {
                .pc_DriverName          = "apci3120",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA_OLD,
@@ -55,13 +54,40 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci3120_driver = {
+       .driver_name    = "addi_apci_3120",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci3120_boardtypes),
+       .board_name     = &apci3120_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci3120_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci3120_driver);
+}
+
+static void __devexit apci3120_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci3120_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, 0x818d) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci3120_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci3120_pci_driver = {
+       .name           = "addi_apci_3120",
+       .id_table       = apci3120_pci_table,
+       .probe          = apci3120_pci_probe,
+       .remove         = __devexit_p(apci3120_pci_remove),
+};
+module_comedi_pci_driver(apci3120_driver, apci3120_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index e3db75cc2937b8db154c4fbed9ec81e6556d3a16..926fd79c11b090f9ff4c48887fa6e11c5212bc02 100644 (file)
@@ -2,9 +2,9 @@
 
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
 
 static void fpu_begin(void)
 {
@@ -16,14 +16,11 @@ static void fpu_end(void)
        kernel_fpu_end();
 }
 
-#define CONFIG_APCI_3200 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_3200"
-
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci3200.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci3200_boardtypes[] = {
        {
                .pc_DriverName          = "apci3200",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -59,10 +56,37 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static DEFINE_PCI_DEVICE_TABLE(apci3200_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3000) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci3200_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct comedi_driver apci3200_driver = {
+       .driver_name    = "addi_apci_3200",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci3200_boardtypes),
+       .board_name     = &apci3200_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci3200_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci3200_driver);
+}
+
+static void __devexit apci3200_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static struct pci_driver apci3200_pci_driver = {
+       .name           = "addi_apci_3200",
+       .id_table       = apci3200_pci_table,
+       .probe          = apci3200_pci_probe,
+       .remove         = __devexit_p(apci3200_pci_remove),
+};
+module_comedi_pci_driver(apci3200_driver, apci3200_pci_driver);
index 81f0549aab40db7a5b0be0833b99b06e4a1a2bf3..e57ef667c8b94be6ce6f4b489e38206cb444ba1f 100644 (file)
@@ -2,9 +2,9 @@
 
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
 
 static void fpu_begin(void)
 {
@@ -16,14 +16,11 @@ static void fpu_end(void)
        kernel_fpu_end();
 }
 
-#define CONFIG_APCI_3300 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_3300"
-
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci3200.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci3300_boardtypes[] = {
        {
                .pc_DriverName          = "apci3300",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -58,10 +55,37 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci3300_driver = {
+       .driver_name    = "addi_apci_3300",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci3300_boardtypes),
+       .board_name     = &apci3300_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci3300_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci3300_driver);
+}
+
+static void __devexit apci3300_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci3300_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3007) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci3300_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci3300_pci_driver = {
+       .name           = "addi_apci_3300",
+       .id_table       = apci3300_pci_table,
+       .probe          = apci3300_pci_probe,
+       .remove         = __devexit_p(apci3300_pci_remove),
+};
+module_comedi_pci_driver(apci3300_driver, apci3300_pci_driver);
index 5c95c7d1d214a48e91b803363ca1959730e7b841..14ee4e0c5a98c13b04d981233fc86bcf05cb85a2 100644 (file)
@@ -1,17 +1,14 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_3501 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_3501"
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci3501.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci3501_boardtypes[] = {
        {
                .pc_DriverName          = "apci3501",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -40,13 +37,40 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static DEFINE_PCI_DEVICE_TABLE(apci3501_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3001) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci3501_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct comedi_driver apci3501_driver = {
+       .driver_name    = "addi_apci_3501",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci3501_boardtypes),
+       .board_name     = &apci3501_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci3501_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci3501_driver);
+}
+
+static void __devexit apci3501_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static struct pci_driver apci3501_pci_driver = {
+       .name           = "addi_apci_3501",
+       .id_table       = apci3501_pci_table,
+       .probe          = apci3501_pci_probe,
+       .remove         = __devexit_p(apci3501_pci_remove),
+};
+module_comedi_pci_driver(apci3501_driver, apci3501_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index d26982386765a15900f434f9797e15e18f4ff595..00c972e140f7d6094a304f8257d079cddd8ab92f 100644 (file)
@@ -1,17 +1,14 @@
 #include "../comedidev.h"
 #include "comedi_fc.h"
+#include "amcc_s5933.h"
 
 #include "addi-data/addi_common.h"
-#include "addi-data/addi_amcc_s5933.h"
-
-#define CONFIG_APCI_3XXX 1
-
-#define ADDIDATA_DRIVER_NAME   "addi_apci_3xxx"
 
 #include "addi-data/addi_eeprom.c"
 #include "addi-data/hwdrv_apci3xxx.c"
+#include "addi-data/addi_common.c"
 
-static const struct addi_board boardtypes[] = {
+static const struct addi_board apci3xxx_boardtypes[] = {
        {
                .pc_DriverName          = "apci3000-16",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
@@ -780,7 +777,28 @@ static const struct addi_board boardtypes[] = {
        },
 };
 
-static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
+static struct comedi_driver apci3xxx_driver = {
+       .driver_name    = "addi_apci_3xxx",
+       .module         = THIS_MODULE,
+       .attach_pci     = addi_attach_pci,
+       .detach         = i_ADDI_Detach,
+       .num_names      = ARRAY_SIZE(apci3xxx_boardtypes),
+       .board_name     = &apci3xxx_boardtypes[0].pc_DriverName,
+       .offset         = sizeof(struct addi_board),
+};
+
+static int __devinit apci3xxx_pci_probe(struct pci_dev *dev,
+                                       const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &apci3xxx_driver);
+}
+
+static void __devexit apci3xxx_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(apci3xxx_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3010) },
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x300f) },
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x300e) },
@@ -808,9 +826,15 @@ static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3024) },
        { 0 }
 };
-MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
+MODULE_DEVICE_TABLE(pci, apci3xxx_pci_table);
 
-#include "addi-data/addi_common.c"
+static struct pci_driver apci3xxx_pci_driver = {
+       .name           = "addi_apci_3xxx",
+       .id_table       = apci3xxx_pci_table,
+       .probe          = apci3xxx_pci_probe,
+       .remove         = __devexit_p(apci3xxx_pci_remove),
+};
+module_comedi_pci_driver(apci3xxx_driver, apci3xxx_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
index 48092958d73bccc71850c72f8995668821933e37..77b86820d7bda73bca9a7e15c484bc97a13e7d2c 100644 (file)
 ************************************************************************/
 
 /*
+ * Driver: gsc_hpdi
+ * Description: General Standards Corporation High
+ *    Speed Parallel Digital Interface rs485 boards
+ * Author: Frank Mori Hess <fmhess@users.sourceforge.net>
+ * Status: only receive mode works, transmit not supported
+ * Updated: Thu, 01 Nov 2012 16:17:38 +0000
+ * Devices: [General Standards Corporation] PCI-HPDI32 (gsc_hpdi),
+ *   PMC-HPDI32
+ *
+ * Configuration options:
+ *    None.
+ *
+ * Manual configuration of supported devices is not supported; they are
+ * configured automatically.
+ *
+ * There are some additional hpdi models available from GSC for which
+ * support could be added to this driver.
+ */
 
-Driver: gsc_hpdi
-Description: General Standards Corporation High
-    Speed Parallel Digital Interface rs485 boards
-Author: Frank Mori Hess <fmhess@users.sourceforge.net>
-Status: only receive mode works, transmit not supported
-Updated: 2003-02-20
-Devices: [General Standards Corporation] PCI-HPDI32 (gsc_hpdi),
-  PMC-HPDI32
-
-Configuration options:
-   [0] - PCI bus of device (optional)
-   [1] - PCI slot of device (optional)
-
-There are some additional hpdi models available from GSC for which
-support could be added to this driver.
-
-*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/interrupt.h>
 #include "../comedidev.h"
@@ -64,9 +66,9 @@ static int dio_config_block_size(struct comedi_device *dev, unsigned int *data);
 /* #define HPDI_DEBUG      enable debugging code */
 
 #ifdef HPDI_DEBUG
-#define DEBUG_PRINT(format, args...)  printk(format , ## args)
+#define DEBUG_PRINT(format, args...)  pr_debug(format , ## args)
 #else
-#define DEBUG_PRINT(format, args...)
+#define DEBUG_PRINT(format, args...)  no_printk(pr_fmt(format), ## args)
 #endif
 
 #define TIMER_BASE 50          /*  20MHz master clock */
@@ -186,8 +188,7 @@ static unsigned int fifo_size(uint32_t fifo_size_bits)
 }
 
 struct hpdi_board {
-
-       char *name;
+       const char *name;       /*  board name */
        int device_id;          /*  pci device id */
        int subdevice_id;       /*  pci subdevice id */
 };
@@ -207,17 +208,7 @@ static const struct hpdi_board hpdi_boards[] = {
 #endif
 };
 
-static inline struct hpdi_board *board(const struct comedi_device *dev)
-{
-       return (struct hpdi_board *)dev->board_ptr;
-}
-
 struct hpdi_private {
-
-       struct pci_dev *hw_dev; /*  pointer to board's pci_dev struct */
-       /*  base addresses (physical) */
-       resource_size_t plx9080_phys_iobase;
-       resource_size_t hpdi_phys_iobase;
        /*  base addresses (ioremapped) */
        void __iomem *plx9080_iobase;
        void __iomem *hpdi_iobase;
@@ -472,74 +463,54 @@ static int setup_dma_descriptors(struct comedi_device *dev,
        return transfer_size;
 }
 
-static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static const struct hpdi_board *hpdi_find_board(struct pci_dev *pcidev)
 {
+       unsigned int i;
+
+       for (i = 0; i < ARRAY_SIZE(hpdi_boards); i++)
+               if (pcidev->device == hpdi_boards[i].device_id &&
+                   pcidev->subsystem_device == hpdi_boards[i].subdevice_id)
+                       return &hpdi_boards[i];
+       return NULL;
+}
+
+static int __devinit hpdi_auto_attach(struct comedi_device *dev,
+                                     unsigned long context_unused)
+{
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       const struct hpdi_board *thisboard;
        struct hpdi_private *devpriv;
-       struct pci_dev *pcidev;
        int i;
        int retval;
 
-       dev_dbg(dev->class_dev, "gsc_hpdi\n");
+       thisboard = hpdi_find_board(pcidev);
+       if (!thisboard) {
+               dev_err(dev->class_dev, "gsc_hpdi: pci %s not supported\n",
+                       pci_name(pcidev));
+               return -EINVAL;
+       }
+       dev->board_ptr = thisboard;
+       dev->board_name = thisboard->name;
 
        devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
        if (!devpriv)
                return -ENOMEM;
        dev->private = devpriv;
 
-       pcidev = NULL;
-       for (i = 0; i < ARRAY_SIZE(hpdi_boards) &&
-                   dev->board_ptr == NULL; i++) {
-               do {
-                       pcidev = pci_get_subsys(PCI_VENDOR_ID_PLX,
-                                               hpdi_boards[i].device_id,
-                                               PCI_VENDOR_ID_PLX,
-                                               hpdi_boards[i].subdevice_id,
-                                               pcidev);
-                       /*  was a particular bus/slot requested? */
-                       if (it->options[0] || it->options[1]) {
-                               /*  are we on the wrong bus/slot? */
-                               if (pcidev->bus->number != it->options[0] ||
-                                   PCI_SLOT(pcidev->devfn) != it->options[1])
-                                       continue;
-                       }
-                       if (pcidev) {
-                               devpriv->hw_dev = pcidev;
-                               dev->board_ptr = hpdi_boards + i;
-                               break;
-                       }
-               } while (pcidev != NULL);
-       }
-       if (dev->board_ptr == NULL) {
-               dev_warn(dev->class_dev, "no hpdi card found\n");
-               return -EIO;
-       }
-
-       dev_warn(dev->class_dev,
-                "found %s on bus %i, slot %i\n", board(dev)->name,
-                pcidev->bus->number, PCI_SLOT(pcidev->devfn));
-
-       if (comedi_pci_enable(pcidev, dev->driver->driver_name)) {
+       if (comedi_pci_enable(pcidev, dev->board_name)) {
                dev_warn(dev->class_dev,
                         "failed enable PCI device and request regions\n");
                return -EIO;
        }
+       dev->iobase = 1;        /* the "detach" needs this */
        pci_set_master(pcidev);
 
-       /* Initialize dev->board_name */
-       dev->board_name = board(dev)->name;
-
-       devpriv->plx9080_phys_iobase =
-           pci_resource_start(pcidev, PLX9080_BADDRINDEX);
-       devpriv->hpdi_phys_iobase =
-           pci_resource_start(pcidev, HPDI_BADDRINDEX);
-
-       /*  remap, won't work with 2.0 kernels but who cares */
-       devpriv->plx9080_iobase = ioremap(devpriv->plx9080_phys_iobase,
-                                           pci_resource_len(pcidev,
-                                           PLX9080_BADDRINDEX));
+       devpriv->plx9080_iobase =
+               ioremap(pci_resource_start(pcidev, PLX9080_BADDRINDEX),
+                       pci_resource_len(pcidev, PLX9080_BADDRINDEX));
        devpriv->hpdi_iobase =
-           ioremap(devpriv->hpdi_phys_iobase,
-                   pci_resource_len(pcidev, HPDI_BADDRINDEX));
+               ioremap(pci_resource_start(pcidev, HPDI_BADDRINDEX),
+                       pci_resource_len(pcidev, HPDI_BADDRINDEX));
        if (!devpriv->plx9080_iobase || !devpriv->hpdi_iobase) {
                dev_warn(dev->class_dev, "failed to remap io memory\n");
                return -ENOMEM;
@@ -552,7 +523,7 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
        /*  get irq */
        if (request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED,
-                       dev->driver->driver_name, dev)) {
+                       dev->board_name, dev)) {
                dev_warn(dev->class_dev,
                         "unable to allocate irq %u\n", pcidev->irq);
                return -EINVAL;
@@ -564,18 +535,17 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        /*  allocate pci dma buffers */
        for (i = 0; i < NUM_DMA_BUFFERS; i++) {
                devpriv->dio_buffer[i] =
-                   pci_alloc_consistent(devpriv->hw_dev, DMA_BUFFER_SIZE,
+                   pci_alloc_consistent(pcidev, DMA_BUFFER_SIZE,
                                         &devpriv->dio_buffer_phys_addr[i]);
                DEBUG_PRINT("dio_buffer at virt 0x%p, phys 0x%lx\n",
                            devpriv->dio_buffer[i],
                            (unsigned long)devpriv->dio_buffer_phys_addr[i]);
        }
        /*  allocate dma descriptors */
-       devpriv->dma_desc = pci_alloc_consistent(devpriv->hw_dev,
-                                                  sizeof(struct plx_dma_desc) *
-                                                  NUM_DMA_DESCRIPTORS,
-                                                  &devpriv->
-                                                  dma_desc_phys_addr);
+       devpriv->dma_desc = pci_alloc_consistent(pcidev,
+                                                sizeof(struct plx_dma_desc) *
+                                                NUM_DMA_DESCRIPTORS,
+                                                &devpriv->dma_desc_phys_addr);
        if (devpriv->dma_desc_phys_addr & 0xf) {
                dev_warn(dev->class_dev,
                         " dma descriptors not quad-word aligned (bug)\n");
@@ -595,12 +565,13 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 static void hpdi_detach(struct comedi_device *dev)
 {
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct hpdi_private *devpriv = dev->private;
        unsigned int i;
 
        if (dev->irq)
                free_irq(dev->irq, dev);
-       if (devpriv && devpriv->hw_dev) {
+       if (devpriv) {
                if (devpriv->plx9080_iobase) {
                        disable_plx_interrupts(dev);
                        iounmap(devpriv->plx9080_iobase);
@@ -610,21 +581,21 @@ static void hpdi_detach(struct comedi_device *dev)
                /*  free pci dma buffers */
                for (i = 0; i < NUM_DMA_BUFFERS; i++) {
                        if (devpriv->dio_buffer[i])
-                               pci_free_consistent(devpriv->hw_dev,
-                                       DMA_BUFFER_SIZE,
-                                       devpriv->dio_buffer[i],
-                                       devpriv->dio_buffer_phys_addr[i]);
+                               pci_free_consistent(pcidev,
+                                                   DMA_BUFFER_SIZE,
+                                                   devpriv->dio_buffer[i],
+                                                   devpriv->
+                                                   dio_buffer_phys_addr[i]);
                }
                /*  free dma descriptors */
                if (devpriv->dma_desc)
-                       pci_free_consistent(devpriv->hw_dev,
-                               sizeof(struct plx_dma_desc) *
-                               NUM_DMA_DESCRIPTORS,
-                               devpriv->dma_desc,
-                               devpriv-> dma_desc_phys_addr);
-               if (devpriv->hpdi_phys_iobase)
-                       comedi_pci_disable(devpriv->hw_dev);
-               pci_dev_put(devpriv->hw_dev);
+                       pci_free_consistent(pcidev,
+                                           sizeof(struct plx_dma_desc) *
+                                           NUM_DMA_DESCRIPTORS,
+                                           devpriv->dma_desc,
+                                           devpriv->dma_desc_phys_addr);
+               if (dev->iobase)
+                       comedi_pci_disable(pcidev);
        }
 }
 
@@ -974,7 +945,7 @@ static int hpdi_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 static struct comedi_driver gsc_hpdi_driver = {
        .driver_name    = "gsc_hpdi",
        .module         = THIS_MODULE,
-       .attach         = hpdi_attach,
+       .auto_attach    = hpdi_auto_attach,
        .detach         = hpdi_detach,
 };
 
index 68400f13af0e08ae8fa35fc0fc078ec06f6705d5..364541d0f472f5ae45f4061c5bd3144ed19eff6b 100644 (file)
 
 */
 /*
-Driver: jr3_pci
-Description: JR3/PCI force sensor board
-Author: Anders Blomdell <anders.blomdell@control.lth.se>
-Status: works
-Devices: [JR3] PCI force sensor board (jr3_pci)
-
-  The DSP on the board requires initialization code, which can
-  be loaded by placing it in /lib/firmware/comedi.
-  The initialization code should be somewhere on the media you got
-  with your card. One version is available from http://www.comedi.org
-  in the comedi_nonfree_firmware tarball.
-
-  Configuration options:
-  [0] - PCI bus number - if bus number and slot number are 0,
-                         then driver search for first unused card
-  [1] - PCI slot number
-
-*/
+ * Driver: jr3_pci
+ * Description: JR3/PCI force sensor board
+ * Author: Anders Blomdell <anders.blomdell@control.lth.se>
+ * Updated: Thu, 01 Nov 2012 17:34:55 +0000
+ * Status: works
+ * Devices: [JR3] PCI force sensor board (jr3_pci)
+ *
+ * Configuration options:
+ *   None
+ *
+ * Manual configuration of comedi devices is not supported by this
+ * driver; supported PCI devices are configured as comedi devices
+ * automatically.
+ *
+ * The DSP on the board requires initialization code, which can be
+ * loaded by placing it in /lib/firmware/comedi.  The initialization
+ * code should be somewhere on the media you got with your card.  One
+ * version is available from http://www.comedi.org in the
+ * comedi_nonfree_firmware tarball.  The file is called "jr3pci.idm".
+ */
 
 #include "../comedidev.h"
 
@@ -59,16 +61,12 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
 #define PCI_DEVICE_ID_JR3_4_CHANNEL 0x3114
 
 struct jr3_pci_dev_private {
-
-       struct pci_dev *pci_dev;
-       int pci_enabled;
        struct jr3_t __iomem *iobase;
        int n_channels;
        struct timer_list timer;
 };
 
 struct poll_delay_t {
-
        int min;
        int max;
 };
@@ -98,15 +96,15 @@ struct jr3_pci_subdev_private {
 };
 
 /* Hotplug firmware loading stuff */
-static int comedi_load_firmware(struct comedi_device *dev, char *name,
+static int comedi_load_firmware(struct comedi_device *dev, const char *name,
                                int (*cb)(struct comedi_device *dev,
                                        const u8 *data, size_t size))
 {
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        int result = 0;
        const struct firmware *fw;
        char *firmware_path;
        static const char *prefix = "comedi/";
-       struct jr3_pci_dev_private *devpriv = dev->private;
 
        firmware_path = kmalloc(strlen(prefix) + strlen(name) + 1, GFP_KERNEL);
        if (!firmware_path) {
@@ -115,8 +113,7 @@ static int comedi_load_firmware(struct comedi_device *dev, char *name,
                firmware_path[0] = '\0';
                strcat(firmware_path, prefix);
                strcat(firmware_path, name);
-               result = request_firmware(&fw, firmware_path,
-                                         &devpriv->pci_dev->dev);
+               result = request_firmware(&fw, firmware_path, &pcidev->dev);
                if (result == 0) {
                        if (!cb)
                                result = -EINVAL;
@@ -157,7 +154,6 @@ static void set_transforms(struct jr3_channel __iomem *channel,
 
        num &= 0x000f;          /*  Make sure that 0 <= num <= 15 */
        for (i = 0; i < 8; i++) {
-
                set_u16(&channel->transforms[num].link[i].link_type,
                        transf.link[i].link_type);
                udelay(1);
@@ -197,10 +193,6 @@ struct six_axis_t {
 static void set_full_scales(struct jr3_channel __iomem *channel,
                            struct six_axis_t full_scale)
 {
-       printk("%d %d %d %d %d %d\n",
-              full_scale.fx,
-              full_scale.fy,
-              full_scale.fz, full_scale.mx, full_scale.my, full_scale.mz);
        set_s16(&channel->full_scale.fx, full_scale.fx);
        set_s16(&channel->full_scale.fy, full_scale.fy);
        set_s16(&channel->full_scale.fz, full_scale.fz);
@@ -273,71 +265,53 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev,
                                } else {
                                        int F = 0;
                                        switch (axis) {
-                                       case 0:{
-                                                       F = get_s16
-                                                           (&p->channel->filter
-                                                            [filter].fx);
-                                               }
+                                       case 0:
+                                               F = get_s16(&p->channel->
+                                                           filter[filter].fx);
                                                break;
-                                       case 1:{
-                                                       F = get_s16
-                                                           (&p->channel->filter
-                                                            [filter].fy);
-                                               }
+                                       case 1:
+                                               F = get_s16(&p->channel->
+                                                           filter[filter].fy);
                                                break;
-                                       case 2:{
-                                                       F = get_s16
-                                                           (&p->channel->filter
-                                                            [filter].fz);
-                                               }
+                                       case 2:
+                                               F = get_s16(&p->channel->
+                                                           filter[filter].fz);
                                                break;
-                                       case 3:{
-                                                       F = get_s16
-                                                           (&p->channel->filter
-                                                            [filter].mx);
-                                               }
+                                       case 3:
+                                               F = get_s16(&p->channel->
+                                                           filter[filter].mx);
                                                break;
-                                       case 4:{
-                                                       F = get_s16
-                                                           (&p->channel->filter
-                                                            [filter].my);
-                                               }
+                                       case 4:
+                                               F = get_s16(&p->channel->
+                                                           filter[filter].my);
                                                break;
-                                       case 5:{
-                                                       F = get_s16
-                                                           (&p->channel->filter
-                                                            [filter].mz);
-                                               }
+                                       case 5:
+                                               F = get_s16(&p->channel->
+                                                           filter[filter].mz);
                                                break;
-                                       case 6:{
-                                                       F = get_s16
-                                                           (&p->channel->filter
-                                                            [filter].v1);
-                                               }
+                                       case 6:
+                                               F = get_s16(&p->channel->
+                                                           filter[filter].v1);
                                                break;
-                                       case 7:{
-                                                       F = get_s16
-                                                           (&p->channel->filter
-                                                            [filter].v2);
-                                               }
+                                       case 7:
+                                               F = get_s16(&p->channel->
+                                                           filter[filter].v2);
                                                break;
                                        }
                                        data[i] = F + 0x4000;
                                }
                        } else if (channel == 56) {
-                               if (p->state != state_jr3_done) {
+                               if (p->state != state_jr3_done)
                                        data[i] = 0;
-                               } else {
+                               else
                                        data[i] =
-                                           get_u16(&p->channel->model_no);
-                               }
+                                       get_u16(&p->channel->model_no);
                        } else if (channel == 57) {
-                               if (p->state != state_jr3_done) {
+                               if (p->state != state_jr3_done)
                                        data[i] = 0;
-                               } else {
+                               else
                                        data[i] =
-                                           get_u16(&p->channel->serial_no);
-                               }
+                                       get_u16(&p->channel->serial_no);
                        }
                }
        }
@@ -368,8 +342,8 @@ static int read_idm_word(const u8 *data, size_t size, int *pos,
        int result = 0;
        if (pos && val) {
                /*  Skip over non hex */
-               for (; *pos < size && !isxdigit(data[*pos]); (*pos)++) {
-               }
+               for (; *pos < size && !isxdigit(data[*pos]); (*pos)++)
+                       ;
                /*  Collect value */
                *val = 0;
                for (; *pos < size; (*pos)++) {
@@ -378,8 +352,9 @@ static int read_idm_word(const u8 *data, size_t size, int *pos,
                        if (value >= 0) {
                                result = 1;
                                *val = (*val << 4) + value;
-                       } else
+                       } else {
                                break;
+                       }
                }
        }
        return result;
@@ -429,37 +404,38 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 * data,
                        pos = 0;
                        while (more) {
                                unsigned int count, addr;
-                               more = more
-                                   && read_idm_word(data, size, &pos, &count);
+                               more = more &&
+                                      read_idm_word(data, size, &pos, &count);
                                if (more && count == 0xffff)
                                        break;
-                               more = more
-                                   && read_idm_word(data, size, &pos, &addr);
+                               more = more &&
+                                      read_idm_word(data, size, &pos, &addr);
                                dev_dbg(dev->class_dev,
                                        "Loading#%d %4.4x bytes at %4.4x\n",
                                        i, count, addr);
                                while (more && count > 0) {
                                        if (addr & 0x4000) {
-                                               /*  16 bit data, never seen in real life!! */
+                                               /*  16 bit data, never seen
+                                                *  in real life!! */
                                                unsigned int data1;
 
-                                               more = more
-                                                   && read_idm_word(data,
+                                               more = more &&
+                                                      read_idm_word(data,
                                                                     size, &pos,
                                                                     &data1);
                                                count--;
-                                               /* printk("jr3_data, not tested\n"); */
-                                               /* jr3[addr + 0x20000 * pnum] = data1; */
+                                               /* jr3[addr + 0x20000 * pnum] =
+                                                  data1; */
                                        } else {
                                                /*   Download 24 bit program */
                                                unsigned int data1, data2;
 
-                                               more = more
-                                                   && read_idm_word(data,
+                                               more = more &&
+                                                      read_idm_word(data,
                                                                     size, &pos,
                                                                     &data1);
-                                               more = more
-                                                   && read_idm_word(data, size,
+                                               more = more &&
+                                                      read_idm_word(data, size,
                                                                     &pos,
                                                                     &data2);
                                                count -= 2;
@@ -474,7 +450,6 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 * data,
                                                                [i].program_high
                                                                [addr], data2);
                                                        udelay(1);
-
                                                }
                                        }
                                        addr++;
@@ -496,7 +471,6 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
                int errors = get_u16(&channel->errors);
 
                if (errors != p->errors) {
-                       printk("Errors: %x -> %x\n", p->errors, errors);
                        p->errors = errors;
                }
                if (errors & (watch_dog | watch_dog2 | sensor_change)) {
@@ -505,200 +479,141 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 
                }
                switch (p->state) {
-               case state_jr3_poll:{
+               case state_jr3_poll: {
                                u16 model_no = get_u16(&channel->model_no);
                                u16 serial_no = get_u16(&channel->serial_no);
                                if ((errors & (watch_dog | watch_dog2)) ||
                                    model_no == 0 || serial_no == 0) {
-/*
- * Still no sensor, keep on polling. Since it takes up to 10 seconds
- * for offsets to stabilize, polling each second should suffice.
- */
+                                       /*
+                                        * Still no sensor, keep on polling.
+                                        * Since it takes up to 10 seconds
+                                        * for offsets to stabilize, polling
+                                        * each second should suffice.
+                                        */
                                        result = poll_delay_min_max(1000, 2000);
                                } else {
                                        p->retries = 0;
                                        p->state =
-                                           state_jr3_init_wait_for_offset;
+                                               state_jr3_init_wait_for_offset;
                                        result = poll_delay_min_max(1000, 2000);
                                }
                        }
                        break;
-               case state_jr3_init_wait_for_offset:{
-                               p->retries++;
-                               if (p->retries < 10) {
-                                       /*  Wait for offeset to stabilize (< 10 s according to manual) */
-                                       result = poll_delay_min_max(1000, 2000);
-                               } else {
-                                       struct transform_t transf;
-
-                                       p->model_no =
-                                           get_u16(&channel->model_no);
-                                       p->serial_no =
-                                           get_u16(&channel->serial_no);
-
-                                       printk
-                                           ("Setting transform for channel %d\n",
-                                            p->channel_no);
-                                       printk("Sensor Model     = %i\n",
-                                              p->model_no);
-                                       printk("Sensor Serial    = %i\n",
-                                              p->serial_no);
-
-                                       /*  Transformation all zeros */
-                                       for (i = 0; i < ARRAY_SIZE(transf.link); i++) {
-                                               transf.link[i].link_type =
-                                                       (enum link_types)0;
-                                               transf.link[i].link_amount = 0;
-                                       }
-
-                                       set_transforms(channel, transf, 0);
-                                       use_transform(channel, 0);
-                                       p->state =
-                                           state_jr3_init_transform_complete;
-                                       result = poll_delay_min_max(20, 100);   /*  Allow 20 ms for completion */
+               case state_jr3_init_wait_for_offset:
+                       p->retries++;
+                       if (p->retries < 10) {
+                               /*  Wait for offeset to stabilize
+                                *  (< 10 s according to manual) */
+                               result = poll_delay_min_max(1000, 2000);
+                       } else {
+                               struct transform_t transf;
+
+                               p->model_no = get_u16(&channel->model_no);
+                               p->serial_no = get_u16(&channel->serial_no);
+
+                               /*  Transformation all zeros */
+                               for (i = 0; i < ARRAY_SIZE(transf.link); i++) {
+                                       transf.link[i].link_type =
+                                               (enum link_types)0;
+                                       transf.link[i].link_amount = 0;
                                }
-                       } break;
-               case state_jr3_init_transform_complete:{
-                               if (!is_complete(channel)) {
-                                       printk
-                                           ("state_jr3_init_transform_complete complete = %d\n",
-                                            is_complete(channel));
-                                       result = poll_delay_min_max(20, 100);
-                               } else {
-                                       /*  Set full scale */
-                                       struct six_axis_t min_full_scale;
-                                       struct six_axis_t max_full_scale;
-
-                                       min_full_scale =
-                                           get_min_full_scales(channel);
-                                       printk("Obtained Min. Full Scales:\n");
-                                       printk(KERN_DEBUG "%i ", (min_full_scale).fx);
-                                       printk(KERN_CONT "%i ", (min_full_scale).fy);
-                                       printk(KERN_CONT "%i ", (min_full_scale).fz);
-                                       printk(KERN_CONT "%i ", (min_full_scale).mx);
-                                       printk(KERN_CONT "%i ", (min_full_scale).my);
-                                       printk(KERN_CONT "%i ", (min_full_scale).mz);
-                                       printk(KERN_CONT "\n");
-
-                                       max_full_scale =
-                                           get_max_full_scales(channel);
-                                       printk("Obtained Max. Full Scales:\n");
-                                       printk(KERN_DEBUG "%i ", (max_full_scale).fx);
-                                       printk(KERN_CONT "%i ", (max_full_scale).fy);
-                                       printk(KERN_CONT "%i ", (max_full_scale).fz);
-                                       printk(KERN_CONT "%i ", (max_full_scale).mx);
-                                       printk(KERN_CONT "%i ", (max_full_scale).my);
-                                       printk(KERN_CONT "%i ", (max_full_scale).mz);
-                                       printk(KERN_CONT "\n");
-
-                                       set_full_scales(channel,
-                                                       max_full_scale);
 
-                                       p->state =
-                                           state_jr3_init_set_full_scale_complete;
-                                       result = poll_delay_min_max(20, 100);   /*  Allow 20 ms for completion */
-                               }
+                               set_transforms(channel, transf, 0);
+                               use_transform(channel, 0);
+                               p->state = state_jr3_init_transform_complete;
+                               /*  Allow 20 ms for completion */
+                               result = poll_delay_min_max(20, 100);
                        }
                        break;
-               case state_jr3_init_set_full_scale_complete:{
-                               if (!is_complete(channel)) {
-                                       printk
-                                           ("state_jr3_init_set_full_scale_complete complete = %d\n",
-                                            is_complete(channel));
-                                       result = poll_delay_min_max(20, 100);
-                               } else {
-                                       struct force_array __iomem *full_scale;
-
-                                       /*  Use ranges in kN or we will overflow arount 2000N! */
-                                       full_scale = &channel->full_scale;
-                                       p->range[0].range.min =
-                                           -get_s16(&full_scale->fx) * 1000;
-                                       p->range[0].range.max =
-                                           get_s16(&full_scale->fx) * 1000;
-                                       p->range[1].range.min =
-                                           -get_s16(&full_scale->fy) * 1000;
-                                       p->range[1].range.max =
-                                           get_s16(&full_scale->fy) * 1000;
-                                       p->range[2].range.min =
-                                           -get_s16(&full_scale->fz) * 1000;
-                                       p->range[2].range.max =
-                                           get_s16(&full_scale->fz) * 1000;
-                                       p->range[3].range.min =
-                                           -get_s16(&full_scale->mx) * 100;
-                                       p->range[3].range.max =
-                                           get_s16(&full_scale->mx) * 100;
-                                       p->range[4].range.min =
-                                           -get_s16(&full_scale->my) * 100;
-                                       p->range[4].range.max =
-                                           get_s16(&full_scale->my) * 100;
-                                       p->range[5].range.min =
-                                           -get_s16(&full_scale->mz) * 100;
-                                       p->range[5].range.max =
-                                           get_s16(&full_scale->mz) * 100;
-                                       p->range[6].range.min = -get_s16(&full_scale->v1) * 100;        /*  ?? */
-                                       p->range[6].range.max = get_s16(&full_scale->v1) * 100; /*  ?? */
-                                       p->range[7].range.min = -get_s16(&full_scale->v2) * 100;        /*  ?? */
-                                       p->range[7].range.max = get_s16(&full_scale->v2) * 100; /*  ?? */
-                                       p->range[8].range.min = 0;
-                                       p->range[8].range.max = 65535;
-
-                                       {
-                                               int i;
-                                               for (i = 0; i < 9; i++) {
-                                                       printk("%d %d - %d\n",
-                                                              i,
-                                                              p->
-                                                              range[i].range.
-                                                              min,
-                                                              p->
-                                                              range[i].range.
-                                                              max);
-                                               }
-                                       }
-
-                                       use_offset(channel, 0);
-                                       p->state =
-                                           state_jr3_init_use_offset_complete;
-                                       result = poll_delay_min_max(40, 100);   /*  Allow 40 ms for completion */
-                               }
+               case state_jr3_init_transform_complete:
+                       if (!is_complete(channel)) {
+                               result = poll_delay_min_max(20, 100);
+                       } else {
+                               /*  Set full scale */
+                               struct six_axis_t min_full_scale;
+                               struct six_axis_t max_full_scale;
+
+                               min_full_scale = get_min_full_scales(channel);
+                               max_full_scale = get_max_full_scales(channel);
+                               set_full_scales(channel, max_full_scale);
+
+                               p->state =
+                                       state_jr3_init_set_full_scale_complete;
+                               /*  Allow 20 ms for completion */
+                               result = poll_delay_min_max(20, 100);
                        }
                        break;
-               case state_jr3_init_use_offset_complete:{
-                               if (!is_complete(channel)) {
-                                       printk
-                                           ("state_jr3_init_use_offset_complete complete = %d\n",
-                                            is_complete(channel));
-                                       result = poll_delay_min_max(20, 100);
-                               } else {
-                                       printk
-                                           ("Default offsets %d %d %d %d %d %d\n",
-                                            get_s16(&channel->offsets.fx),
-                                            get_s16(&channel->offsets.fy),
-                                            get_s16(&channel->offsets.fz),
-                                            get_s16(&channel->offsets.mx),
-                                            get_s16(&channel->offsets.my),
-                                            get_s16(&channel->offsets.mz));
-
-                                       set_s16(&channel->offsets.fx, 0);
-                                       set_s16(&channel->offsets.fy, 0);
-                                       set_s16(&channel->offsets.fz, 0);
-                                       set_s16(&channel->offsets.mx, 0);
-                                       set_s16(&channel->offsets.my, 0);
-                                       set_s16(&channel->offsets.mz, 0);
-
-                                       set_offset(channel);
-
-                                       p->state = state_jr3_done;
-                               }
+               case state_jr3_init_set_full_scale_complete:
+                       if (!is_complete(channel)) {
+                               result = poll_delay_min_max(20, 100);
+                       } else {
+                               struct force_array __iomem *full_scale;
+
+                               /*  Use ranges in kN or we will
+                                *  overflow around 2000N! */
+                               full_scale = &channel->full_scale;
+                               p->range[0].range.min =
+                                       -get_s16(&full_scale->fx) * 1000;
+                               p->range[0].range.max =
+                                       get_s16(&full_scale->fx) * 1000;
+                               p->range[1].range.min =
+                                       -get_s16(&full_scale->fy) * 1000;
+                               p->range[1].range.max =
+                                       get_s16(&full_scale->fy) * 1000;
+                               p->range[2].range.min =
+                                       -get_s16(&full_scale->fz) * 1000;
+                               p->range[2].range.max =
+                                       get_s16(&full_scale->fz) * 1000;
+                               p->range[3].range.min =
+                                       -get_s16(&full_scale->mx) * 100;
+                               p->range[3].range.max =
+                                       get_s16(&full_scale->mx) * 100;
+                               p->range[4].range.min =
+                                       -get_s16(&full_scale->my) * 100;
+                               p->range[4].range.max =
+                                       get_s16(&full_scale->my) * 100;
+                               p->range[5].range.min =
+                                       -get_s16(&full_scale->mz) * 100;
+                               p->range[5].range.max =
+                                       get_s16(&full_scale->mz) * 100; /* ?? */
+                               p->range[6].range.min =
+                                       -get_s16(&full_scale->v1) * 100;/* ?? */
+                               p->range[6].range.max =
+                                       get_s16(&full_scale->v1) * 100; /* ?? */
+                               p->range[7].range.min =
+                                       -get_s16(&full_scale->v2) * 100;/* ?? */
+                               p->range[7].range.max =
+                                       get_s16(&full_scale->v2) * 100; /* ?? */
+                               p->range[8].range.min = 0;
+                               p->range[8].range.max = 65535;
+
+                               use_offset(channel, 0);
+                               p->state = state_jr3_init_use_offset_complete;
+                               /*  Allow 40 ms for completion */
+                               result = poll_delay_min_max(40, 100);
                        }
                        break;
-               case state_jr3_done:{
-                               poll_delay_min_max(10000, 20000);
+               case state_jr3_init_use_offset_complete:
+                       if (!is_complete(channel)) {
+                               result = poll_delay_min_max(20, 100);
+                       } else {
+                               set_s16(&channel->offsets.fx, 0);
+                               set_s16(&channel->offsets.fy, 0);
+                               set_s16(&channel->offsets.fz, 0);
+                               set_s16(&channel->offsets.mx, 0);
+                               set_s16(&channel->offsets.my, 0);
+                               set_s16(&channel->offsets.mz, 0);
+
+                               set_offset(channel);
+
+                               p->state = state_jr3_done;
                        }
                        break;
-               default:{
-                               poll_delay_min_max(1000, 2000);
-                       }
+               case state_jr3_done:
+                       poll_delay_min_max(10000, 20000);
+                       break;
+               default:
+                       poll_delay_min_max(1000, 2000);
                        break;
                }
        }
@@ -720,22 +635,21 @@ static void jr3_pci_poll_dev(unsigned long data)
        /*  Poll all channels that are ready to be polled */
        for (i = 0; i < devpriv->n_channels; i++) {
                struct jr3_pci_subdev_private *subdevpriv =
-                   dev->subdevices[i].private;
+                       dev->subdevices[i].private;
                if (now > subdevpriv->next_time_min) {
                        struct poll_delay_t sub_delay;
 
                        sub_delay = jr3_pci_poll_subdevice(&dev->subdevices[i]);
                        subdevpriv->next_time_min =
-                           jiffies + msecs_to_jiffies(sub_delay.min);
+                               jiffies + msecs_to_jiffies(sub_delay.min);
                        subdevpriv->next_time_max =
-                           jiffies + msecs_to_jiffies(sub_delay.max);
-                       if (sub_delay.max && sub_delay.max < delay) {
-/*
-* Wake up as late as possible -> poll as many channels as possible
-* at once
-*/
+                               jiffies + msecs_to_jiffies(sub_delay.max);
+                       if (sub_delay.max && sub_delay.max < delay)
+                               /*
+                                * Wake up as late as possible ->
+                                * poll as many channels as possible at once.
+                                */
                                delay = sub_delay.max;
-                       }
                }
        }
        spin_unlock_irqrestore(&dev->spinlock, flags);
@@ -744,17 +658,14 @@ static void jr3_pci_poll_dev(unsigned long data)
        add_timer(&devpriv->timer);
 }
 
-static int jr3_pci_attach(struct comedi_device *dev,
-                         struct comedi_devconfig *it)
+static int __devinit jr3_pci_auto_attach(struct comedi_device *dev,
+                                        unsigned long context_unused)
 {
-       int result = 0;
-       struct pci_dev *card = NULL;
-       int opt_bus, opt_slot, i;
+       int result;
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       int i;
        struct jr3_pci_dev_private *devpriv;
 
-       opt_bus = it->options[0];
-       opt_slot = it->options[1];
-
        if (sizeof(struct jr3_channel) != 0xc00) {
                dev_err(dev->class_dev,
                        "sizeof(struct jr3_channel) = %x [expected %x]\n",
@@ -767,66 +678,37 @@ static int jr3_pci_attach(struct comedi_device *dev,
                return -ENOMEM;
        dev->private = devpriv;
 
-       card = NULL;
        init_timer(&devpriv->timer);
-       while (1) {
-               card = pci_get_device(PCI_VENDOR_ID_JR3, PCI_ANY_ID, card);
-               if (card == NULL) {
-                       /* No card found */
-                       break;
-               } else {
-                       switch (card->device) {
-                       case PCI_DEVICE_ID_JR3_1_CHANNEL:{
-                                       devpriv->n_channels = 1;
-                               }
-                               break;
-                       case PCI_DEVICE_ID_JR3_1_CHANNEL_NEW:{
-                                       devpriv->n_channels = 1;
-                               }
-                               break;
-                       case PCI_DEVICE_ID_JR3_2_CHANNEL:{
-                                       devpriv->n_channels = 2;
-                               }
-                               break;
-                       case PCI_DEVICE_ID_JR3_3_CHANNEL:{
-                                       devpriv->n_channels = 3;
-                               }
-                               break;
-                       case PCI_DEVICE_ID_JR3_4_CHANNEL:{
-                                       devpriv->n_channels = 4;
-                               }
-                               break;
-                       default:{
-                                       devpriv->n_channels = 0;
-                               }
-                       }
-                       if (devpriv->n_channels >= 1) {
-                               if (opt_bus == 0 && opt_slot == 0) {
-                                       /* Take first available card */
-                                       break;
-                               } else if (opt_bus == card->bus->number &&
-                                          opt_slot == PCI_SLOT(card->devfn)) {
-                                       /* Take requested card */
-                                       break;
-                               }
-                       }
-               }
-       }
-       if (!card) {
-               dev_err(dev->class_dev, "no jr3_pci found\n");
-               return -EIO;
-       } else {
-               devpriv->pci_dev = card;
-               dev->board_name = "jr3_pci";
+       switch (pcidev->device) {
+       case PCI_DEVICE_ID_JR3_1_CHANNEL:
+       case PCI_DEVICE_ID_JR3_1_CHANNEL_NEW:
+               devpriv->n_channels = 1;
+               break;
+       case PCI_DEVICE_ID_JR3_2_CHANNEL:
+               devpriv->n_channels = 2;
+               break;
+       case PCI_DEVICE_ID_JR3_3_CHANNEL:
+               devpriv->n_channels = 3;
+               break;
+       case PCI_DEVICE_ID_JR3_4_CHANNEL:
+               devpriv->n_channels = 4;
+               break;
+       default:
+               dev_err(dev->class_dev, "jr3_pci: pci %s not supported\n",
+                       pci_name(pcidev));
+               return -EINVAL;
+               break;
        }
+       dev->board_name = "jr3_pci";
 
-       result = comedi_pci_enable(card, "jr3_pci");
+       result = comedi_pci_enable(pcidev, "jr3_pci");
        if (result < 0)
                return -EIO;
 
-       devpriv->pci_enabled = 1;
-       devpriv->iobase = ioremap(pci_resource_start(card, 0),
-                       offsetof(struct jr3_t, channel[devpriv->n_channels]));
+       dev->iobase = 1;        /* the "detach" needs this */
+       devpriv->iobase = ioremap(pci_resource_start(pcidev, 0),
+                                 offsetof(struct jr3_t,
+                                          channel[devpriv->n_channels]));
        if (!devpriv->iobase)
                return -ENOMEM;
 
@@ -841,7 +723,8 @@ static int jr3_pci_attach(struct comedi_device *dev,
                dev->subdevices[i].n_chan = 8 * 7 + 2;
                dev->subdevices[i].insn_read = jr3_pci_ai_insn_read;
                dev->subdevices[i].private =
-                   kzalloc(sizeof(struct jr3_pci_subdev_private), GFP_KERNEL);
+                       kzalloc(sizeof(struct jr3_pci_subdev_private),
+                               GFP_KERNEL);
                if (dev->subdevices[i].private) {
                        struct jr3_pci_subdev_private *p;
                        int j;
@@ -871,15 +754,15 @@ static int jr3_pci_attach(struct comedi_device *dev,
                        p->range[8].range.max = 65536;
 
                        p->range_table_list[56] =
-                           (struct comedi_lrange *)&p->range[8];
+                               (struct comedi_lrange *)&p->range[8];
                        p->range_table_list[57] =
-                           (struct comedi_lrange *)&p->range[8];
+                               (struct comedi_lrange *)&p->range[8];
                        p->maxdata_list[56] = 0xffff;
                        p->maxdata_list[57] = 0xffff;
                        /*  Channel specific range and maxdata */
                        dev->subdevices[i].range_table = NULL;
                        dev->subdevices[i].range_table_list =
-                           p->range_table_list;
+                               p->range_table_list;
                        dev->subdevices[i].maxdata = 0;
                        dev->subdevices[i].maxdata_list = p->maxdata_list;
                }
@@ -892,19 +775,20 @@ static int jr3_pci_attach(struct comedi_device *dev,
        dev_dbg(dev->class_dev, "Firmare load %d\n", result);
 
        if (result < 0)
-               goto out;
-/*
- * TODO: use firmware to load preferred offset tables. Suggested
- * format:
- *     model serial Fx Fy Fz Mx My Mz\n
- *
- *     comedi_load_firmware(dev, "jr3_offsets_table", jr3_download_firmware);
- */
+               return result;
+       /*
+        * TODO: use firmware to load preferred offset tables. Suggested
+        * format:
+        *     model serial Fx Fy Fz Mx My Mz\n
+        *
+        *     comedi_load_firmware(dev, "jr3_offsets_table",
+        *                          jr3_download_firmware);
+        */
 
-/*
- * It takes a few milliseconds for software to settle as much as we
- * can read firmware version
- */
+       /*
       * It takes a few milliseconds for software to settle as much as we
       * can read firmware version
       */
        msleep_interruptible(25);
        for (i = 0; i < 0x18; i++) {
                dev_dbg(dev->class_dev, "%c\n",
@@ -925,13 +809,13 @@ static int jr3_pci_attach(struct comedi_device *dev,
        devpriv->timer.expires = jiffies + msecs_to_jiffies(1000);
        add_timer(&devpriv->timer);
 
-out:
        return result;
 }
 
 static void jr3_pci_detach(struct comedi_device *dev)
 {
        int i;
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct jr3_pci_dev_private *devpriv = dev->private;
 
        if (devpriv) {
@@ -943,17 +827,15 @@ static void jr3_pci_detach(struct comedi_device *dev)
                }
                if (devpriv->iobase)
                        iounmap(devpriv->iobase);
-               if (devpriv->pci_enabled)
-                       comedi_pci_disable(devpriv->pci_dev);
-               if (devpriv->pci_dev)
-                       pci_dev_put(devpriv->pci_dev);
+               if (dev->iobase)
+                       comedi_pci_disable(pcidev);
        }
 }
 
 static struct comedi_driver jr3_pci_driver = {
        .driver_name    = "jr3_pci",
        .module         = THIS_MODULE,
-       .attach         = jr3_pci_attach,
+       .auto_attach    = jr3_pci_auto_attach,
        .detach         = jr3_pci_detach,
 };
 
index b5b43e41f3f4c474bf31ba0ce4b5451822688032..76c6a13ea9d627ad0e8fbcc5b3f5c576dda5c1d5 100644 (file)
@@ -175,7 +175,7 @@ struct ni_private {
 
        struct pcmcia_device *link;
 
- NI_PRIVATE_COMMON};
+NI_PRIVATE_COMMON};
 
 /* How we access registers */
 
@@ -251,7 +251,7 @@ static void mio_cs_config(struct pcmcia_device *link);
 static void cs_release(struct pcmcia_device *link);
 static void cs_detach(struct pcmcia_device *);
 
-static struct pcmcia_device *cur_dev = NULL;
+static struct pcmcia_device *cur_dev;
 
 static int cs_attach(struct pcmcia_device *link)
 {
@@ -340,13 +340,15 @@ static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
        irq = link->irq;
 
-       printk("comedi%d: %s: DAQCard: io 0x%04lx, irq %u, ",
-              dev->minor, dev->driver->driver_name, dev->iobase, irq);
+       dev->board_ptr = ni_boards + ni_getboardtype(dev, link);
 
 #if 0
        {
                int i;
 
+               printk("comedi%d: %s: DAQCard: io 0x%04lx, irq %u, ",
+                      dev->minor, dev->driver->driver_name, dev->iobase, irq);
+
                printk(" board fingerprint:");
                for (i = 0; i < 32; i += 2) {
                        printk(" %04x %02x", inw(dev->iobase + i),
@@ -357,18 +359,17 @@ static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                for (i = 0; i < 10; i++)
                        printk(" 0x%04x", win_in(i));
                printk("\n");
+
+               printk("boardtype.name: %s\n", boardtype.name);
        }
 #endif
 
-       dev->board_ptr = ni_boards + ni_getboardtype(dev, link);
-
-       printk(" %s", boardtype.name);
        dev->board_name = boardtype.name;
 
        ret = request_irq(irq, ni_E_interrupt, NI_E_IRQ_FLAGS,
                          "ni_mio_cs", dev);
        if (ret < 0) {
-               printk(" irq not available\n");
+               dev_err(dev->class_dev, "irq not available\n");
                return -EINVAL;
        }
        dev->irq = irq;
@@ -401,7 +402,8 @@ static int ni_getboardtype(struct comedi_device *dev,
                        return i;
        }
 
-       printk("unknown board 0x%04x -- pretend it is a ", link->card_id);
+       dev_err(dev->class_dev,
+               "unknown board 0x%04x -- pretend it is a ", link->card_id);
 
        return 0;
 }
index e42bd6b1153c029fc4ac899532b508956d5d4cea..23b76d0b1a56e3eaf9989b0c471d9aaf842dbf6e 100644 (file)
@@ -1284,8 +1284,10 @@ static const void *rtd_find_boardinfo(struct comedi_device *dev,
        return NULL;
 }
 
-static int rtd_attach_pci(struct comedi_device *dev, struct pci_dev *pcidev)
+static int __devinit rtd_auto_attach(struct comedi_device *dev,
+                                    unsigned long context_unused)
 {
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        const struct rtdBoard *thisboard;
        struct rtdPrivate *devpriv;
        struct comedi_subdevice *s;
@@ -1420,7 +1422,7 @@ static void rtd_detach(struct comedi_device *dev)
 static struct comedi_driver rtd520_driver = {
        .driver_name    = "rtd520",
        .module         = THIS_MODULE,
-       .attach_pci     = rtd_attach_pci,
+       .auto_attach    = rtd_auto_attach,
        .detach         = rtd_detach,
 };
 
index e1b78a11196055baa98744fc0fa6109c6d6e04c2..162bf266f769b5498794c83791a77a91bc5c9598 100644 (file)
@@ -92,6 +92,7 @@ Configuration Options:
  */
 struct skel_board {
        const char *name;
+       unsigned int devid;
        int ai_chans;
        int ai_bits;
        int have_dio;
@@ -100,36 +101,20 @@ struct skel_board {
 static const struct skel_board skel_boards[] = {
        {
         .name = "skel-100",
+        .devid = 0x100,
         .ai_chans = 16,
         .ai_bits = 12,
         .have_dio = 1,
         },
        {
         .name = "skel-200",
+        .devid = 0x200,
         .ai_chans = 8,
         .ai_bits = 16,
         .have_dio = 0,
         },
 };
 
-/* This is used by modprobe to translate PCI IDs to drivers.  Should
- * only be used for PCI and ISA-PnP devices */
-/* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
- * upstream. */
-#define PCI_VENDOR_ID_SKEL 0xdafe
-static DEFINE_PCI_DEVICE_TABLE(skel_pci_table) = {
-       { PCI_DEVICE(PCI_VENDOR_ID_SKEL, 0x0100) },
-       { PCI_DEVICE(PCI_VENDOR_ID_SKEL, 0x0200) },
-       { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, skel_pci_table);
-
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct skel_board *)dev->board_ptr)
-
 /* this structure is for data unique to this hardware driver.  If
    several hardware drivers keep similar information in this structure,
    feel free to suggest moving the variable to the struct comedi_device struct.
@@ -138,159 +123,25 @@ struct skel_private {
 
        int data;
 
-       /* would be useful for a PCI device */
-       struct pci_dev *pci_dev;
-
        /* Used for AO readback */
        unsigned int ao_readback[2];
 };
 
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static void skel_detach(struct comedi_device *dev);
-static struct comedi_driver driver_skel = {
-       .driver_name = "dummy",
-       .module = THIS_MODULE,
-       .attach = skel_attach,
-       .detach = skel_detach,
-/* It is not necessary to implement the following members if you are
- * writing a driver for a ISA PnP or PCI card */
-       /* Most drivers will support multiple types of boards by
-        * having an array of board structures.  These were defined
-        * in skel_boards[] above.  Note that the element 'name'
-        * was first in the structure -- Comedi uses this fact to
-        * extract the name of the board without knowing any details
-        * about the structure except for its length.
-        * When a device is attached (by comedi_config), the name
-        * of the device is given to Comedi, and Comedi tries to
-        * match it by going through the list of board names.  If
-        * there is a match, the address of the pointer is put
-        * into dev->board_ptr and driver->attach() is called.
-        *
-        * Note that these are not necessary if you can determine
-        * the type of board in software.  ISA PnP, PCI, and PCMCIA
-        * devices are such boards.
-        */
-       .board_name = &skel_boards[0].name,
-       .offset = sizeof(struct skel_board),
-       .num_names = ARRAY_SIZE(skel_boards),
-};
-
-static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-                        struct comedi_insn *insn, unsigned int *data);
-static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-                        struct comedi_insn *insn, unsigned int *data);
-static int skel_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-                        struct comedi_insn *insn, unsigned int *data);
-static int skel_dio_insn_bits(struct comedi_device *dev,
-                             struct comedi_subdevice *s,
-                             struct comedi_insn *insn, unsigned int *data);
-static int skel_dio_insn_config(struct comedi_device *dev,
-                               struct comedi_subdevice *s,
-                               struct comedi_insn *insn, unsigned int *data);
-static int skel_ai_cmdtest(struct comedi_device *dev,
-                          struct comedi_subdevice *s, struct comedi_cmd *cmd);
-static int skel_ns_to_timer(unsigned int *ns, int round);
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board.  If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+/* This function doesn't require a particular form, this is just
+ * what happens to be used in some of the drivers.  It should
+ * convert ns nanoseconds to a counter value suitable for programming
+ * the device.  Also, it should adjust ns so that it cooresponds to
+ * the actual time that the device will use. */
+static int skel_ns_to_timer(unsigned int *ns, int round)
 {
-       struct skel_private *devpriv;
-       struct comedi_subdevice *s;
-       int ret;
-
-       pr_info("comedi%d: skel: ", dev->minor);
-
-/*
- * If you can probe the device to determine what device in a series
- * it is, this is the place to do it.  Otherwise, dev->board_ptr
- * should already be initialized.
- */
-       /* dev->board_ptr = skel_probe(dev, it); */
-
-/*
- * 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;
-
-       /* Allocate the private data */
-       devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
-       if (!devpriv)
-               return -ENOMEM;
-       dev->private = devpriv;
-
-       ret = comedi_alloc_subdevices(dev, 3);
-       if (ret)
-               return ret;
-
-       s = &dev->subdevices[0];
-       /* dev->read_subdev=s; */
-       /* analog input subdevice */
-       s->type = COMEDI_SUBD_AI;
-       /* we support single-ended (ground) and differential */
-       s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
-       s->n_chan = thisboard->ai_chans;
-       s->maxdata = (1 << thisboard->ai_bits) - 1;
-       s->range_table = &range_bipolar10;
-       s->len_chanlist = 16;   /* This is the maximum chanlist length that
-                                  the board can handle */
-       s->insn_read = skel_ai_rinsn;
-/*
-*       s->subdev_flags |= SDF_CMD_READ;
-*       s->do_cmd = skel_ai_cmd;
-*/
-       s->do_cmdtest = skel_ai_cmdtest;
-
-       s = &dev->subdevices[1];
-       /* analog output subdevice */
-       s->type = COMEDI_SUBD_AO;
-       s->subdev_flags = SDF_WRITABLE;
-       s->n_chan = 1;
-       s->maxdata = 0xffff;
-       s->range_table = &range_bipolar5;
-       s->insn_write = skel_ao_winsn;
-       s->insn_read = skel_ao_rinsn;
-
-       s = &dev->subdevices[2];
-       /* digital i/o subdevice */
-       if (thisboard->have_dio) {
-               s->type = COMEDI_SUBD_DIO;
-               s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
-               s->n_chan = 16;
-               s->maxdata = 1;
-               s->range_table = &range_digital;
-               s->insn_bits = skel_dio_insn_bits;
-               s->insn_config = skel_dio_insn_config;
-       } else {
-               s->type = COMEDI_SUBD_UNUSED;
-       }
-
-       pr_info("attached\n");
-
-       return 0;
-}
+       /* trivial timer */
+       /* if your timing is done through two cascaded timers, the
+        * i8253_cascade_ns_to_timer() function in 8253.h can be
+        * very helpful.  There are also i8254_load() and i8254_mm_load()
+        * which can be used to load values into the ubiquitous 8254 counters
+        */
 
-/*
- * _detach is called to deconfigure a device.  It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach().  dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static void skel_detach(struct comedi_device *dev)
-{
+       return *ns;
 }
 
 /*
@@ -300,6 +151,7 @@ static void skel_detach(struct comedi_device *dev)
 static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
                         struct comedi_insn *insn, unsigned int *data)
 {
+       const struct skel_board *thisboard = comedi_board(dev);
        int n, i;
        unsigned int d;
        unsigned int status;
@@ -325,9 +177,7 @@ static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
                                break;
                }
                if (i == TIMEOUT) {
-                       /* printk() should be used instead of printk()
-                        * whenever the code can be called from real-time. */
-                       pr_info("timeout\n");
+                       dev_warn(dev->class_dev, "ai timeout\n");
                        return -ETIMEDOUT;
                }
 
@@ -478,23 +328,6 @@ static int skel_ai_cmdtest(struct comedi_device *dev,
        return 0;
 }
 
-/* This function doesn't require a particular form, this is just
- * what happens to be used in some of the drivers.  It should
- * convert ns nanoseconds to a counter value suitable for programming
- * the device.  Also, it should adjust ns so that it cooresponds to
- * the actual time that the device will use. */
-static int skel_ns_to_timer(unsigned int *ns, int round)
-{
-       /* trivial timer */
-       /* if your timing is done through two cascaded timers, the
-        * i8253_cascade_ns_to_timer() function in 8253.h can be
-        * very helpful.  There are also i8254_load() and i8254_mm_load()
-        * which can be used to load values into the ubiquitous 8254 counters
-        */
-
-       return *ns;
-}
-
 static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
                         struct comedi_insn *insn, unsigned int *data)
 {
@@ -502,7 +335,6 @@ static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
        int i;
        int chan = CR_CHAN(insn->chanspec);
 
-       pr_info("skel_ao_winsn\n");
        /* Writing a list of values to an AO channel is probably not
         * very useful, but that's how the interface is defined. */
        for (i = 0; i < insn->n; i++) {
@@ -589,46 +421,336 @@ static int skel_dio_insn_config(struct comedi_device *dev,
        return insn->n;
 }
 
-#ifdef CONFIG_COMEDI_PCI_DRIVERS
-static int __devinit driver_skel_pci_probe(struct pci_dev *dev,
-                                          const struct pci_device_id *ent)
+static const struct skel_board *skel_find_pci_board(struct pci_dev *pcidev)
 {
-       return comedi_pci_auto_config(dev, &driver_skel);
+       unsigned int i;
+
+/*
+ * This example code assumes all the entries in skel_boards[] are PCI boards
+ * and all use the same PCI vendor ID.  If skel_boards[] contains a mixture
+ * of PCI and non-PCI boards, this loop should skip over the non-PCI boards.
+ */
+       for (i = 0; i < ARRAY_SIZE(skel_boards); i++)
+               if (/* skel_boards[i].bustype == pci_bustype && */
+                   pcidev->device == skel_boards[i].devid)
+                       return &skel_boards[i];
+       return NULL;
 }
 
-static void __devexit driver_skel_pci_remove(struct pci_dev *dev)
+/*
+ * Handle common part of skel_attach() and skel_auto_attach().
+ */
+static int skel_common_attach(struct comedi_device *dev)
 {
-       comedi_pci_auto_unconfig(dev);
+       const struct skel_board *thisboard = comedi_board(dev);
+       struct comedi_subdevice *s;
+       int ret;
+
+       ret = comedi_alloc_subdevices(dev, 3);
+       if (ret)
+               return ret;
+
+       s = &dev->subdevices[0];
+       /* dev->read_subdev=s; */
+       /* analog input subdevice */
+       s->type = COMEDI_SUBD_AI;
+       /* we support single-ended (ground) and differential */
+       s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
+       s->n_chan = thisboard->ai_chans;
+       s->maxdata = (1 << thisboard->ai_bits) - 1;
+       s->range_table = &range_bipolar10;
+       s->len_chanlist = 16;   /* This is the maximum chanlist length that
+                                  the board can handle */
+       s->insn_read = skel_ai_rinsn;
+/*
+*       s->subdev_flags |= SDF_CMD_READ;
+*       s->do_cmd = skel_ai_cmd;
+*/
+       s->do_cmdtest = skel_ai_cmdtest;
+
+       s = &dev->subdevices[1];
+       /* analog output subdevice */
+       s->type = COMEDI_SUBD_AO;
+       s->subdev_flags = SDF_WRITABLE;
+       s->n_chan = 1;
+       s->maxdata = 0xffff;
+       s->range_table = &range_bipolar5;
+       s->insn_write = skel_ao_winsn;
+       s->insn_read = skel_ao_rinsn;
+
+       s = &dev->subdevices[2];
+       /* digital i/o subdevice */
+       if (thisboard->have_dio) {
+               s->type = COMEDI_SUBD_DIO;
+               s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+               s->n_chan = 16;
+               s->maxdata = 1;
+               s->range_table = &range_digital;
+               s->insn_bits = skel_dio_insn_bits;
+               s->insn_config = skel_dio_insn_config;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
+       dev_info(dev->class_dev, "skel: attached\n");
+
+       return 0;
 }
 
-static struct pci_driver driver_skel_pci_driver = {
-       .id_table = skel_pci_table,
-       .probe = &driver_skel_pci_probe,
-       .remove = __devexit_p(&driver_skel_pci_remove)
-};
+/*
+ * _attach is called by the Comedi core to configure the driver
+ * for a particular board in response to the COMEDI_DEVCONFIG ioctl for
+ * a matching board or driver name.  If you specified a board_name array
+ * in the driver structure, dev->board_ptr contains that address.
+ *
+ * Drivers that handle only PCI or USB devices do not usually support
+ * manual attachment of those devices via the COMEDI_DEVCONFIG ioctl, so
+ * those drivers do not have an _attach function; they just have an
+ * _auto_attach function instead.  (See skel_auto_attach() for an example
+ * of such a function.)
+ */
+static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+       const struct skel_board *thisboard;
+       struct skel_private *devpriv;
+
+/*
+ * If you can probe the device to determine what device in a series
+ * it is, this is the place to do it.  Otherwise, dev->board_ptr
+ * should already be initialized.
+ */
+       /* dev->board_ptr = skel_probe(dev, it); */
+
+       thisboard = comedi_board(dev);
+
+/*
+ * Initialize dev->board_name.
+ */
+       dev->board_name = thisboard->name;
+
+       /* Allocate the private data */
+       devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
+       if (!devpriv)
+               return -ENOMEM;
+       dev->private = devpriv;
+
+/*
+ * Supported boards are usually either auto-attached via the
+ * Comedi driver's _auto_attach routine, or manually attached via the
+ * Comedi driver's _attach routine.  In most cases, attempts to
+ * manual attach boards that are usually auto-attached should be
+ * rejected by this function.
+ */
+/*
+ *     if (thisboard->bustype == pci_bustype) {
+ *             dev_err(dev->class_dev,
+ *                     "Manual attachment of PCI board '%s' not supported\n",
+ *                     thisboard->name);
+ *     }
+ */
+
+/*
+ * For ISA boards, get the i/o base address from it->options[],
+ * request the i/o region and set dev->iobase * from it->options[].
+ * If using interrupts, get the IRQ number from it->options[].
+ */
 
-static int __init driver_skel_init_module(void)
+       /*
+        * Call a common function to handle the remaining things to do for
+        * attaching ISA or PCI boards.  (Extra parameters could be added
+        * to pass additional information such as IRQ number.)
+        */
+       return skel_common_attach(dev);
+}
+
+/*
+ * _auto_attach is called via comedi_pci_auto_config() (or
+ * comedi_usb_auto_config(), etc.) to handle devices that can be attached
+ * to the Comedi core automatically without the COMEDI_DEVCONFIG ioctl.
+ *
+ * For PCI devices, comedi_pci_auto_config() is usually called directly from
+ * the struct pci_driver probe() function, so this _auto_attach() function
+ * can be tagged __devinit.
+ *
+ * The context parameter is usually unused, but if the driver called
+ * comedi_auto_config() directly instead of the comedi_pci_auto_config()
+ * wrapper function, this will be a copy of the context passed to
+ * comedi_auto_config().
+ */
+static int __devinit skel_auto_attach(struct comedi_device *dev,
+                                     unsigned long context)
 {
-       int retval;
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       const struct skel_board *thisboard;
+       struct skel_private *devpriv;
+       int ret;
 
-       retval = comedi_driver_register(&driver_skel);
-       if (retval < 0)
-               return retval;
+       /* Hack to allow unused code to be optimized out. */
+       if (!IS_ENABLED(CONFIG_COMEDI_PCI_DRIVERS))
+               return -EINVAL;
 
-       driver_skel_pci_driver.name = (char *)driver_skel.driver_name;
-       return pci_register_driver(&driver_skel_pci_driver);
+       /* Find a matching board in skel_boards[]. */
+       thisboard = skel_find_pci_board(pcidev);
+       if (!thisboard) {
+               dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
+               return -EINVAL;
+       }
+
+       /*
+        * Point the struct comedi_device to the matching board info
+        * and set the board name.
+        */
+       dev->board_ptr = thisboard;
+       dev->board_name = thisboard->name;
+
+       /* Allocate the private data */
+       devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
+       if (!devpriv)
+               return -ENOMEM;
+       dev->private = devpriv;
+
+       /* Enable the PCI device. */
+       ret = comedi_pci_enable(pcidev, dev->board_name);
+       if (ret)
+               return ret;
+
+       /*
+        * Record the fact that the PCI device is enabled so that it can
+        * be disabled during _detach().
+        *
+        * For this example driver, we assume PCI BAR 0 is the main I/O
+        * region for the board registers and use dev->iobase to hold the
+        * I/O base address and to indicate that the PCI device has been
+        * enabled.
+        *
+        * (For boards with memory-mapped registers, dev->iobase is not
+        * usually needed for register access, so can just be set to 1
+        * to indicate that the PCI device has been enabled.)
+        */
+       dev->iobase = pci_resource_start(pcidev, 0);
+
+       /*
+        * Call a common function to handle the remaining things to do for
+        * attaching ISA or PCI boards.  (Extra parameters could be added
+        * to pass additional information such as IRQ number.)
+        */
+       return skel_common_attach(dev);
+}
+
+/*
+ * _detach is called to deconfigure a device.  It should deallocate
+ * resources.
+ * This function is also called when _attach() fails, so it should be
+ * careful not to release resources that were not necessarily
+ * allocated by _attach().  dev->private and dev->subdevices are
+ * deallocated automatically by the core.
+ */
+static void skel_detach(struct comedi_device *dev)
+{
+       const struct skel_board *thisboard = comedi_board(dev);
+       struct skel_private *devpriv = dev->private;
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+       if (!thisboard || !devpriv)
+               return;
+
+/*
+ * Do common stuff such as freeing IRQ, unmapping remapped memory
+ * regions, etc., being careful to check that the stuff is valid given
+ * that _detach() is called even when _attach() or _auto_attach() return
+ * an error.
+ */
+
+       if (IS_ENABLED(CONFIG_COMEDI_PCI_DRIVERS) /* &&
+           thisboard->bustype == pci_bustype */) {
+               /*
+                * PCI board
+                *
+                * If PCI device enabled by _auto_attach() (or _attach()),
+                * disable it here.
+                */
+               if (pcidev && dev->iobase)
+                       comedi_pci_disable(pcidev);
+       } else {
+               /*
+                * ISA board
+                *
+                * If I/O regions successfully requested by _attach(),
+                * release them here.
+                */
+               if (dev->iobase)
+                       release_region(dev->iobase, SKEL_SIZE);
+       }
+}
+
+/*
+ * The struct comedi_driver structure tells the Comedi core module
+ * which functions to call to configure/deconfigure (attach/detach)
+ * the board, and also about the kernel module that contains
+ * the device code.
+ */
+static struct comedi_driver skel_driver = {
+       .driver_name = "dummy",
+       .module = THIS_MODULE,
+       .attach = skel_attach,
+       .auto_attach = skel_auto_attach,
+       .detach = skel_detach,
+/* It is not necessary to implement the following members if you are
+ * writing a driver for a ISA PnP or PCI card */
+       /* Most drivers will support multiple types of boards by
+        * having an array of board structures.  These were defined
+        * in skel_boards[] above.  Note that the element 'name'
+        * was first in the structure -- Comedi uses this fact to
+        * extract the name of the board without knowing any details
+        * about the structure except for its length.
+        * When a device is attached (by comedi_config), the name
+        * of the device is given to Comedi, and Comedi tries to
+        * match it by going through the list of board names.  If
+        * there is a match, the address of the pointer is put
+        * into dev->board_ptr and driver->attach() is called.
+        *
+        * Note that these are not necessary if you can determine
+        * the type of board in software.  ISA PnP, PCI, and PCMCIA
+        * devices are such boards.
+        */
+       .board_name = &skel_boards[0].name,
+       .offset = sizeof(struct skel_board),
+       .num_names = ARRAY_SIZE(skel_boards),
+};
+
+#ifdef CONFIG_COMEDI_PCI_DRIVERS
+
+/* This is used by modprobe to translate PCI IDs to drivers.  Should
+ * only be used for PCI and ISA-PnP devices */
+/* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
+ * upstream. */
+#define PCI_VENDOR_ID_SKEL 0xdafe
+static DEFINE_PCI_DEVICE_TABLE(skel_pci_table) = {
+       { PCI_DEVICE(PCI_VENDOR_ID_SKEL, 0x0100) },
+       { PCI_DEVICE(PCI_VENDOR_ID_SKEL, 0x0200) },
+       { 0 }
+};
+MODULE_DEVICE_TABLE(pci, skel_pci_table);
+
+static int __devinit skel_pci_probe(struct pci_dev *dev,
+                                          const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, &skel_driver);
 }
 
-static void __exit driver_skel_cleanup_module(void)
+static void __devexit skel_pci_remove(struct pci_dev *dev)
 {
-       pci_unregister_driver(&driver_skel_pci_driver);
-       comedi_driver_unregister(&driver_skel);
+       comedi_pci_auto_unconfig(dev);
 }
 
-module_init(driver_skel_init_module);
-module_exit(driver_skel_cleanup_module);
+static struct pci_driver skel_pci_driver = {
+       .id_table = skel_pci_table,
+       .probe = &skel_pci_probe,
+       .remove = __devexit_p(&skel_pci_remove)
+};
+module_comedi_pci_driver(skel_driver, skel_pci_driver);
 #else
-module_comedi_driver(driver_skel);
+module_comedi_driver(skel_driver);
 #endif
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
index 7d2fccde9fb73404ff91127be104e0dd4908c150..6d8df836681723289ae948130faa593bdf3b2131 100644 (file)
@@ -53,24 +53,6 @@ void CsrWifiNmeApFreeUpstreamMessageContents(u16 eventClass, void *message);
  *----------------------------------------------------------------------------*/
 void CsrWifiNmeApFreeDownstreamMessageContents(u16 eventClass, void *message);
 
-/*----------------------------------------------------------------------------*
- * Enum to string functions
- *----------------------------------------------------------------------------*/
-const char* CsrWifiNmeApPersCredentialTypeToString(CsrWifiNmeApPersCredentialType value);
-
-
-/*----------------------------------------------------------------------------*
- * CsrPrim Type toString function.
- * Converts a message type to the String name of the Message
- *----------------------------------------------------------------------------*/
-const char* CsrWifiNmeApPrimTypeToString(CsrPrim msgType);
-
-/*----------------------------------------------------------------------------*
- * Lookup arrays for PrimType name Strings
- *----------------------------------------------------------------------------*/
-extern const char *CsrWifiNmeApUpstreamPrimNames[CSR_WIFI_NME_AP_PRIM_UPSTREAM_COUNT];
-extern const char *CsrWifiNmeApDownstreamPrimNames[CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT];
-
 /*******************************************************************************
 
   NAME
index 1b1e0376a86ed71fd89422665aeba274228c153b..5a1f132009bf982f24c9af069e5300402e69e8ca 100644 (file)
 #error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_lib.h
 #endif
 
-/*----------------------------------------------------------------------------*
- *  CsrWifiNmeFreeUpstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_NME upstream message. Does not
- *      free the message itself, and can only be used for upstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_NME upstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiNmeFreeUpstreamMessageContents(u16 eventClass, void *message);
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiNmeFreeDownstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_NME downstream message. Does not
- *      free the message itself, and can only be used for downstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_NME downstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiNmeFreeDownstreamMessageContents(u16 eventClass, void *message);
-
-/*----------------------------------------------------------------------------*
- * Enum to string functions
- *----------------------------------------------------------------------------*/
-const char* CsrWifiNmeAuthModeToString(CsrWifiNmeAuthMode value);
-const char* CsrWifiNmeBssTypeToString(CsrWifiNmeBssType value);
-const char* CsrWifiNmeCcxOptionsMaskToString(CsrWifiNmeCcxOptionsMask value);
-const char* CsrWifiNmeConfigActionToString(CsrWifiNmeConfigAction value);
-const char* CsrWifiNmeConnectionStatusToString(CsrWifiNmeConnectionStatus value);
-const char* CsrWifiNmeCredentialTypeToString(CsrWifiNmeCredentialType value);
-const char* CsrWifiNmeEapMethodToString(CsrWifiNmeEapMethod value);
-const char* CsrWifiNmeEncryptionToString(CsrWifiNmeEncryption value);
-const char* CsrWifiNmeIndicationsToString(CsrWifiNmeIndications value);
-const char* CsrWifiNmeSecErrorToString(CsrWifiNmeSecError value);
-const char* CsrWifiNmeSimCardTypeToString(CsrWifiNmeSimCardType value);
-const char* CsrWifiNmeUmtsAuthResultToString(CsrWifiNmeUmtsAuthResult value);
-const char* CsrWifiNmeWmmQosInfoToString(CsrWifiNmeWmmQosInfo value);
-
-
-/*----------------------------------------------------------------------------*
- * CsrPrim Type toString function.
- * Converts a message type to the String name of the Message
- *----------------------------------------------------------------------------*/
-const char* CsrWifiNmePrimTypeToString(CsrPrim msgType);
-
-/*----------------------------------------------------------------------------*
- * Lookup arrays for PrimType name Strings
- *----------------------------------------------------------------------------*/
-extern const char *CsrWifiNmeUpstreamPrimNames[CSR_WIFI_NME_PRIM_UPSTREAM_COUNT];
-extern const char *CsrWifiNmeDownstreamPrimNames[CSR_WIFI_NME_PRIM_DOWNSTREAM_COUNT];
-
 /*******************************************************************************
 
   NAME
index 8a1aae66140b15c5cd5a1e4f95414d96f4c92efd..84e973a59bb25811eeaa25c188fba9ededc0d846 100644 (file)
@@ -22,9 +22,6 @@
 
 #define CSR_WIFI_NME_LOG_ID 0x1203FFFF
 extern CsrSchedQid CSR_WIFI_NME_IFACEQUEUE;
-void CsrWifiNmeInit(void **gash);
-void CsrWifiNmeDeinit(void **gash);
-void CsrWifiNmeHandler(void **gash);
 
 #endif /* CSR_WIFI_NME_TASK_H__ */
 
index b4acb54ecc621a9a8af1fc886422375bf9732930..b3ef818fef35d8d8be37bf626f7b4174b9454824 100644 (file)
@@ -93,14 +93,12 @@ static struct notifier_block uf_inetaddr_notifier = {
 
 void uf_register_inet_notifier(void)
 {
-    if (atomic_inc_return(&inet_notif_refs) == 1) {
-        register_inetaddr_notifier(&uf_inetaddr_notifier);
-    }
+       if (atomic_inc_return(&inet_notif_refs) == 1)
+               register_inetaddr_notifier(&uf_inetaddr_notifier);
 }
 
 void uf_unregister_inet_notifier(void)
 {
-    if (atomic_dec_return(&inet_notif_refs) == 0) {
-        unregister_inetaddr_notifier(&uf_inetaddr_notifier);
-    }
+       if (atomic_dec_return(&inet_notif_refs) == 0)
+               unregister_inetaddr_notifier(&uf_inetaddr_notifier);
 }
index 543e8f2c407a048ece010a23fbb920f34d42a947..d88ccd5bd42861405844e350069ed56cdecf16a6 100644 (file)
@@ -270,17 +270,15 @@ int sme_mgt_wifi_off(unifi_priv_t *priv)
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     /* Stop the SME */
     CsrWifiSmeWifiOffReqSend(0);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_wifi_off: unifi_mgt_wifi_off_req <-- (r=%d, status=%d)\n",
@@ -300,16 +298,14 @@ int sme_mgt_key(unifi_priv_t *priv, CsrWifiSmeKey *sme_key,
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeKeyReqSend(0, CSR_WIFI_INTERFACE_IN_USE, action, *sme_key);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     return convert_sme_error(priv->sme_reply.reply_status);
 }
@@ -332,9 +328,8 @@ int sme_mgt_scan_full(unifi_priv_t *priv,
     unifi_trace(priv, UDBG4, "sme_mgt_scan_full: -->\n");
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     /* If a channel list is provided, do an active scan */
     if (is_active) {
@@ -354,16 +349,14 @@ int sme_mgt_scan_full(unifi_priv_t *priv,
                               0, NULL);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4, "sme_mgt_scan_full: <-- (status=%d)\n", priv->sme_reply.reply_status);
-    if (priv->sme_reply.reply_status == CSR_WIFI_RESULT_UNAVAILABLE) {
+    if (priv->sme_reply.reply_status == CSR_WIFI_RESULT_UNAVAILABLE)
         return 0; /* initial scan already underway */
-    } else {
+    else
         return convert_sme_error(priv->sme_reply.reply_status);
-    }
 }
 
 
@@ -385,15 +378,13 @@ int sme_mgt_scan_results_get_async(unifi_priv_t *priv,
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeScanResultsGetReqSend(0);
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     scan_result_list_count = priv->sme_reply.reply_scan_results_count;
     scan_result_list = priv->sme_reply.reply_scan_results;
@@ -454,20 +445,17 @@ int sme_mgt_connect(unifi_priv_t *priv)
                 priv->connection_config.ssid.ssid);
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeConnectReqSend(0, CSR_WIFI_INTERFACE_IN_USE, priv->connection_config);
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
-    if (priv->sme_reply.reply_status) {
+    if (priv->sme_reply.reply_status)
         unifi_trace(priv, UDBG1, "sme_mgt_connect: failed with SME status %d\n",
                     priv->sme_reply.reply_status);
-    }
 
     return convert_sme_error(priv->sme_reply.reply_status);
 }
@@ -483,15 +471,13 @@ int sme_mgt_disconnect(unifi_priv_t *priv)
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeDisconnectReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4, "sme_mgt_disconnect: <-- (status=%d)\n", priv->sme_reply.reply_status);
     return convert_sme_error(priv->sme_reply.reply_status);
@@ -510,16 +496,14 @@ int sme_mgt_pmkid(unifi_priv_t *priv,
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmePmkidReqSend(0, CSR_WIFI_INTERFACE_IN_USE, action,
                         pmkid_list->pmkidsCount, pmkid_list->pmkids);
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4, "sme_mgt_pmkid: <-- (status=%d)\n", priv->sme_reply.reply_status);
     return convert_sme_error(priv->sme_reply.reply_status);
@@ -537,9 +521,8 @@ int sme_mgt_mib_get(unifi_priv_t *priv,
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     priv->mib_cfm_buffer = varbind;
     priv->mib_cfm_buffer_length = MAX_VARBIND_LENGTH;
@@ -571,15 +554,13 @@ int sme_mgt_mib_set(unifi_priv_t *priv,
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeMibSetReqSend(0, length, varbind);
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4, "sme_mgt_mib_set: <-- (status=%d)\n", priv->sme_reply.reply_status);
     return convert_sme_error(priv->sme_reply.reply_status);
@@ -598,16 +579,14 @@ int sme_mgt_power_config_set(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerCon
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmePowerConfigSetReqSend(0, *powerConfig);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_set_value_async: unifi_mgt_set_value_req <-- (r=%d status=%d)\n",
@@ -637,29 +616,26 @@ int sme_mgt_sme_config_set(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, C
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeSmeStaConfigSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE, *staConfig);
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
+
     unifi_trace(priv, UDBG4,
                 "sme_mgt_sme_config_set: CsrWifiSmeSmeStaConfigSetReq <-- (r=%d status=%d)\n",
                 r, priv->sme_reply.reply_status);
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeSmeCommonConfigSetReqSend(0, *deviceConfig);
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_sme_config_set: CsrWifiSmeSmeCommonConfigSetReq <-- (r=%d status=%d)\n",
@@ -693,16 +669,14 @@ int sme_mgt_mib_config_set(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig)
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeMibConfigSetReqSend(0, *mibConfig);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_mib_config_set: unifi_mgt_set_mib_config_req <-- (r=%d status=%d)\n",
@@ -732,16 +706,14 @@ int sme_mgt_coex_config_set(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeCoexConfigSetReqSend(0, *coexConfig);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_coex_config_set: unifi_mgt_set_mib_config_req <-- (r=%d status=%d)\n",
@@ -773,16 +745,14 @@ int sme_mgt_host_config_set(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeHostConfigSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE, *hostConfig);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_host_config_set: unifi_mgt_set_host_config_req <-- (r=%d status=%d)\n",
@@ -815,16 +785,14 @@ int sme_mgt_versions_get(unifi_priv_t *priv, CsrWifiSmeVersions *versions)
 
     unifi_trace(priv, UDBG4, "sme_mgt_versions_get: unifi_mgt_versions_get_req -->\n");
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeVersionsGetReqSend(0);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     /* store the reply */
     if (versions != NULL) {
@@ -861,16 +829,14 @@ int sme_mgt_power_config_get(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerCon
 
     unifi_trace(priv, UDBG4, "sme_mgt_power_config_get: unifi_mgt_power_config_req -->\n");
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmePowerConfigGetReqSend(0);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     /* store the reply */
     if (powerConfig != NULL) {
@@ -905,23 +871,20 @@ int sme_mgt_host_config_get(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig
 
     unifi_trace(priv, UDBG4, "sme_mgt_host_config_get: unifi_mgt_host_config_get_req -->\n");
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeHostConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     /* store the reply */
-    if (hostConfig != NULL) {
+    if (hostConfig != NULL)
         memcpy((unsigned char*)hostConfig,
                (unsigned char*)&priv->sme_reply.hostConfig,
                sizeof(CsrWifiSmeHostConfig));
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_host_config_get: unifi_mgt_host_config_get_req <-- (r=%d status=%d)\n",
@@ -951,41 +914,35 @@ int sme_mgt_sme_config_get(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, C
 
     /* Common device config */
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeSmeCommonConfigGetReqSend(0);
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     /* store the reply */
-    if (deviceConfig != NULL) {
+    if (deviceConfig != NULL)
         memcpy((unsigned char*)deviceConfig,
                (unsigned char*)&priv->sme_reply.deviceConfig,
                sizeof(CsrWifiSmeDeviceConfig));
-    }
 
     /* STA config */
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeSmeStaConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     /* store the reply */
-    if (staConfig != NULL) {
+    if (staConfig != NULL)
         memcpy((unsigned char*)staConfig,
                (unsigned char*)&priv->sme_reply.staConfig,
                sizeof(CsrWifiSmeStaConfig));
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_sme_config_get: unifi_mgt_sme_config_get_req <-- (r=%d status=%d)\n",
@@ -1014,23 +971,20 @@ int sme_mgt_coex_info_get(unifi_priv_t *priv, CsrWifiSmeCoexInfo *coexInfo)
 
     unifi_trace(priv, UDBG4, "sme_mgt_coex_info_get: unifi_mgt_coex_info_get_req -->\n");
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeCoexInfoGetReqSend(0);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     /* store the reply */
-    if (coexInfo != NULL) {
+    if (coexInfo != NULL)
         memcpy((unsigned char*)coexInfo,
                (unsigned char*)&priv->sme_reply.coexInfo,
                sizeof(CsrWifiSmeCoexInfo));
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_coex_info_get: unifi_mgt_coex_info_get_req <-- (r=%d status=%d)\n",
@@ -1060,23 +1014,20 @@ int sme_mgt_coex_config_get(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig
 
     unifi_trace(priv, UDBG4, "sme_mgt_coex_config_get: unifi_mgt_coex_config_get_req -->\n");
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeCoexConfigGetReqSend(0);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     /* store the reply */
-    if (coexConfig != NULL) {
+    if (coexConfig != NULL)
         memcpy((unsigned char*)coexConfig,
                (unsigned char*)&priv->sme_reply.coexConfig,
                sizeof(CsrWifiSmeCoexConfig));
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_coex_config_get: unifi_mgt_coex_config_get_req <-- (r=%d status=%d)\n",
@@ -1104,23 +1055,20 @@ int sme_mgt_mib_config_get(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig)
 
     unifi_trace(priv, UDBG4, "sme_mgt_mib_config_get: unifi_mgt_mib_config_get_req -->\n");
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeMibConfigGetReqSend(0);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     /* store the reply */
-    if (mibConfig != NULL) {
+    if (mibConfig != NULL)
         memcpy((unsigned char*)mibConfig,
                (unsigned char*)&priv->sme_reply.mibConfig,
                sizeof(CsrWifiSmeMibConfig));
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_mib_config_get: unifi_mgt_mib_config_get_req <-- (r=%d status=%d)\n",
@@ -1148,23 +1096,20 @@ int sme_mgt_connection_info_get(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *co
 
     unifi_trace(priv, UDBG4, "sme_mgt_connection_info_get: unifi_mgt_connection_info_get_req -->\n");
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeConnectionInfoGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     /* store the reply */
-    if (connectionInfo != NULL) {
+    if (connectionInfo != NULL)
         memcpy((unsigned char*)connectionInfo,
                (unsigned char*)&priv->sme_reply.connectionInfo,
                sizeof(CsrWifiSmeConnectionInfo));
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_connection_info_get: unifi_mgt_connection_info_get_req <-- (r=%d status=%d)\n",
@@ -1192,23 +1137,20 @@ int sme_mgt_connection_config_get(unifi_priv_t *priv, CsrWifiSmeConnectionConfig
 
     unifi_trace(priv, UDBG4, "sme_mgt_connection_config_get: unifi_mgt_connection_config_get_req -->\n");
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeConnectionConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     /* store the reply */
-    if (connectionConfig != NULL) {
+    if (connectionConfig != NULL)
         memcpy((unsigned char*)connectionConfig,
                (unsigned char*)&priv->sme_reply.connectionConfig,
                sizeof(CsrWifiSmeConnectionConfig));
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_connection_config_get: unifi_mgt_connection_config_get_req <-- (r=%d status=%d)\n",
@@ -1236,23 +1178,20 @@ int sme_mgt_connection_stats_get(unifi_priv_t *priv, CsrWifiSmeConnectionStats *
 
     unifi_trace(priv, UDBG4, "sme_mgt_connection_stats_get: unifi_mgt_connection_stats_get_req -->\n");
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiSmeConnectionStatsGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     /* store the reply */
-    if (connectionStats != NULL) {
+    if (connectionStats != NULL)
         memcpy((unsigned char*)connectionStats,
                (unsigned char*)&priv->sme_reply.connectionStats,
                sizeof(CsrWifiSmeConnectionStats));
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_mgt_connection_stats_get: unifi_mgt_connection_stats_get_req <-- (r=%d status=%d)\n",
@@ -1272,58 +1211,56 @@ int sme_mgt_connection_stats_get(unifi_priv_t *priv, CsrWifiSmeConnectionStats *
 
 int sme_mgt_packet_filter_set(unifi_priv_t *priv)
 {
-    CsrWifiIp4Address ipAddress = {{0xFF, 0xFF, 0xFF, 0xFF }};
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_packet_filter_set: invalid smepriv\n");
-        return -EIO;
-    }
-    if (priv->packet_filters.arp_filter) {
-        ipAddress.a[0] = (priv->sta_ip_address      ) & 0xFF;
-        ipAddress.a[1] = (priv->sta_ip_address >>  8) & 0xFF;
-        ipAddress.a[2] = (priv->sta_ip_address >> 16) & 0xFF;
-        ipAddress.a[3] = (priv->sta_ip_address >> 24) & 0xFF;
-    }
-
-    unifi_trace(priv, UDBG5,
-                "sme_mgt_packet_filter_set: IP address %d.%d.%d.%d\n",
-                ipAddress.a[0], ipAddress.a[1],
-                ipAddress.a[2], ipAddress.a[3]);
-
-    /* Doesn't block for a confirm */
-    CsrWifiSmePacketFilterSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE,
-                                     priv->packet_filters.tclas_ies_length,
-                                     priv->filter_tclas_ies,
-                                     priv->packet_filters.filter_mode,
-                                     ipAddress);
-    return 0;
+       CsrWifiIp4Address ipAddress = {{0xFF, 0xFF, 0xFF, 0xFF }};
+       if (priv->smepriv == NULL) {
+               unifi_error(priv, "sme_mgt_packet_filter_set: invalid smepriv\n");
+               return -EIO;
+       }
+       if (priv->packet_filters.arp_filter) {
+               ipAddress.a[0] = (priv->sta_ip_address      ) & 0xFF;
+               ipAddress.a[1] = (priv->sta_ip_address >>  8) & 0xFF;
+               ipAddress.a[2] = (priv->sta_ip_address >> 16) & 0xFF;
+               ipAddress.a[3] = (priv->sta_ip_address >> 24) & 0xFF;
+       }
+
+       unifi_trace(priv, UDBG5,
+               "sme_mgt_packet_filter_set: IP address %d.%d.%d.%d\n",
+               ipAddress.a[0], ipAddress.a[1],
+               ipAddress.a[2], ipAddress.a[3]);
+
+       /* Doesn't block for a confirm */
+       CsrWifiSmePacketFilterSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE,
+                                    priv->packet_filters.tclas_ies_length,
+                                    priv->filter_tclas_ies,
+                                    priv->packet_filters.filter_mode,
+                                    ipAddress);
+       return 0;
 }
 
 int sme_mgt_tspec(unifi_priv_t *priv, CsrWifiSmeListAction action,
         u32 tid, CsrWifiSmeDataBlock *tspec, CsrWifiSmeDataBlock *tclas)
 {
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_tspec: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r) {
-        return -EIO;
-    }
-
-    CsrWifiSmeTspecReqSend(0, CSR_WIFI_INTERFACE_IN_USE,
-                           action, tid, TRUE, 0,
-                           tspec->length, tspec->data,
-                           tclas->length, tclas->data);
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
-        return r;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_tspec: <-- (status=%d)\n", priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
+       int r;
+
+       if (priv->smepriv == NULL) {
+               unifi_error(priv, "sme_mgt_tspec: invalid smepriv\n");
+               return -EIO;
+       }
+
+       r = sme_init_request(priv);
+       if (r)
+               return -EIO;
+
+       CsrWifiSmeTspecReqSend(0, CSR_WIFI_INTERFACE_IN_USE,
+                             action, tid, TRUE, 0,
+                             tspec->length, tspec->data,
+                             tclas->length, tclas->data);
+       r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+       if (r)
+               return r;
+
+       unifi_trace(priv, UDBG4, "sme_mgt_tspec: <-- (status=%d)\n", priv->sme_reply.reply_status);
+       return convert_sme_error(priv->sme_reply.reply_status);
 }
 
 
@@ -1339,9 +1276,8 @@ int sme_sys_suspend(unifi_priv_t *priv)
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     /* Suspend the SME, which MAY cause it to power down UniFi */
     CsrWifiRouterCtrlSuspendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0, 0, priv->wol_suspend);
@@ -1427,17 +1363,15 @@ int sme_sys_resume(unifi_priv_t *priv)
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiRouterCtrlResumeIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0, priv->wol_suspend);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_SYS_LONG_TIMEOUT);
-    if (r) {
+    if (r)
         unifi_notice(priv,
                 "resume: SME did not reply, return success anyway\n");
-    }
 
     return 0;
 }
@@ -1453,16 +1387,14 @@ int sme_ap_stop(unifi_priv_t *priv,u16 interface_tag)
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiNmeApStopReqSend(0,interface_tag);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_ap_stop <-- (r=%d status=%d)\n",
@@ -1484,9 +1416,8 @@ int sme_ap_start(unifi_priv_t *priv,u16 interface_tag,
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiNmeApStartReqSend(0,interface_tag,CSR_WIFI_AP_TYPE_LEGACY,FALSE,
                              ap_config->ssid,1,ap_config->channel,
@@ -1494,9 +1425,8 @@ int sme_ap_start(unifi_priv_t *priv,u16 interface_tag,
                              p2p_go_param,FALSE);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
+    if (r)
         return r;
-    }
 
     unifi_trace(priv, UDBG4,
                 "sme_ap_start <-- (r=%d status=%d)\n",
@@ -1518,14 +1448,15 @@ int sme_ap_config(unifi_priv_t *priv,
     }
 
     r = sme_init_request(priv);
-    if (r) {
+    if (r)
         return -EIO;
-    }
 
     CsrWifiNmeApConfigSetReqSend(0,*group_security_config,
                                  *ap_mac_config);
 
     r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+       if (r)
+               return r;
 
     unifi_trace(priv, UDBG4,
                 "sme_ap_config <-- (r=%d status=%d)\n",
index daa5247bd011d9d572a951146cdbf28e56273c14..1534582eedc4d7ed6cb24af9496e1e56daadb869 100644 (file)
@@ -3587,7 +3587,12 @@ static void et131x_get_regs(struct net_device *netdev,
        et131x_mii_read(adapter, 0x08, (u16 *)&regs_buff[num++]);
        et131x_mii_read(adapter, MII_CTRL1000, (u16 *)&regs_buff[num++]);
        et131x_mii_read(adapter, MII_STAT1000, (u16 *)&regs_buff[num++]);
+       et131x_mii_read(adapter, 0x0b, (u16 *)&regs_buff[num++]);
+       et131x_mii_read(adapter, 0x0c, (u16 *)&regs_buff[num++]);
+       et131x_mii_read(adapter, MII_MMD_CTRL, (u16 *)&regs_buff[num++]);
+       et131x_mii_read(adapter, MII_MMD_DATA, (u16 *)&regs_buff[num++]);
        et131x_mii_read(adapter, MII_ESTATUS, (u16 *)&regs_buff[num++]);
+
        et131x_mii_read(adapter, PHY_INDEX_REG, (u16 *)&regs_buff[num++]);
        et131x_mii_read(adapter, PHY_DATA_REG, (u16 *)&regs_buff[num++]);
        et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
@@ -3596,6 +3601,7 @@ static void et131x_get_regs(struct net_device *netdev,
                        (u16 *)&regs_buff[num++]);
        et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL+1,
                        (u16 *)&regs_buff[num++]);
+
        et131x_mii_read(adapter, PHY_REGISTER_MGMT_CONTROL,
                        (u16 *)&regs_buff[num++]);
        et131x_mii_read(adapter, PHY_CONFIG, (u16 *)&regs_buff[num++]);
index 2e087acf1578998c292362093e68449d11766560..33c0009b30826f88a7774fdf972c2d68836735ec 100644 (file)
@@ -2304,8 +2304,8 @@ error:
  */
 void oz_hcd_term(void)
 {
-       tasklet_disable(&g_urb_process_tasklet);
-       tasklet_disable(&g_urb_cancel_tasklet);
+       tasklet_kill(&g_urb_process_tasklet);
+       tasklet_kill(&g_urb_cancel_tasklet);
        platform_device_unregister(g_plat_dev);
        platform_driver_unregister(&g_oz_plat_drv);
        oz_trace("Pending urbs:%d\n", atomic_read(&g_pending_urbs));
index 42900ee4825b67c0e37aae090deccc082602a568..759d7c7d78e5d582111a1dba6592d9dbc0c2c69e 100644 (file)
@@ -287,7 +287,7 @@ static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee,
 {
        struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
        struct tx_ts_record *pTxTs = NULL;
-       struct rtllib_hdr_1addrhdr = (struct rtllib_hdr_1addr *)skb->data;
+       struct rtllib_hdr_1addr *hdr = (struct rtllib_hdr_1addr *)skb->data;
 
        if (rtllib_act_scanning(ieee, false))
                return;
index 018b4ff3c3aea9f3f0679f85d7b85cb23c0d765b..58c5f5cf4cec00ccdaa74c32aef388e8a5250ec7 100644 (file)
@@ -9,7 +9,6 @@
 /*                                                                            */
 /*                                                                            */
 /******************************************************************************/
-#include <linux/version.h>
 
 #include <linux/kernel.h>      /* We're doing kernel work */
 #include <linux/module.h>      /* Specifically, a module */
index a726d90853e626d93009329f53255d80b7a2dfa4..d8c1d27650b4d437db779f1edbbe8ef7af03d31b 100644 (file)
@@ -15,7 +15,6 @@
 
 #include "bp_ioctl.h"
 #include "libbp_sd.h"
-#include <linux/version.h>
 
 #define IF_NAME            "eth"
 #define SILICOM_VID        0x1374
index 6edefde23722b436641166f5b678291d6648c6b2..fb4a7c94aed36f087cb41cc771f947b1d6776678 100644 (file)
@@ -183,62 +183,25 @@ static inline int is_partial_io(struct bio_vec *bvec)
        return bvec->bv_len != PAGE_SIZE;
 }
 
-static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
-                         u32 index, int offset, struct bio *bio)
+static int zram_decompress_page(struct zram *zram, char *mem, u32 index)
 {
-       int ret;
-       size_t clen;
-       struct page *page;
-       unsigned char *user_mem, *cmem, *uncmem = NULL;
-
-       page = bvec->bv_page;
-
-       if (zram_test_flag(zram, index, ZRAM_ZERO)) {
-               handle_zero_page(bvec);
-               return 0;
-       }
+       int ret = LZO_E_OK;
+       size_t clen = PAGE_SIZE;
+       unsigned char *cmem;
+       unsigned long handle = zram->table[index].handle;
 
-       /* Requested page is not present in compressed area */
-       if (unlikely(!zram->table[index].handle)) {
-               pr_debug("Read before write: sector=%lu, size=%u",
-                        (ulong)(bio->bi_sector), bio->bi_size);
-               handle_zero_page(bvec);
+       if (!handle || zram_test_flag(zram, index, ZRAM_ZERO)) {
+               memset(mem, 0, PAGE_SIZE);
                return 0;
        }
 
-       if (is_partial_io(bvec)) {
-               /* Use  a temporary buffer to decompress the page */
-               uncmem = kmalloc(PAGE_SIZE, GFP_KERNEL);
-               if (!uncmem) {
-                       pr_info("Error allocating temp memory!\n");
-                       return -ENOMEM;
-               }
-       }
-
-       user_mem = kmap_atomic(page);
-       if (!is_partial_io(bvec))
-               uncmem = user_mem;
-       clen = PAGE_SIZE;
-
-       cmem = zs_map_object(zram->mem_pool, zram->table[index].handle,
-                               ZS_MM_RO);
-
-       if (zram->table[index].size == PAGE_SIZE) {
-               memcpy(uncmem, cmem, PAGE_SIZE);
-               ret = LZO_E_OK;
-       } else {
+       cmem = zs_map_object(zram->mem_pool, handle, ZS_MM_RO);
+       if (zram->table[index].size == PAGE_SIZE)
+               memcpy(mem, cmem, PAGE_SIZE);
+       else
                ret = lzo1x_decompress_safe(cmem, zram->table[index].size,
-                                   uncmem, &clen);
-       }
-
-       if (is_partial_io(bvec)) {
-               memcpy(user_mem + bvec->bv_offset, uncmem + offset,
-                      bvec->bv_len);
-               kfree(uncmem);
-       }
-
-       zs_unmap_object(zram->mem_pool, zram->table[index].handle);
-       kunmap_atomic(user_mem);
+                                               mem, &clen);
+       zs_unmap_object(zram->mem_pool, handle);
 
        /* Should NEVER happen. Return bio error if it does. */
        if (unlikely(ret != LZO_E_OK)) {
@@ -247,36 +210,56 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
                return ret;
        }
 
-       flush_dcache_page(page);
-
        return 0;
 }
 
-static int zram_read_before_write(struct zram *zram, char *mem, u32 index)
+static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
+                         u32 index, int offset, struct bio *bio)
 {
        int ret;
-       size_t clen = PAGE_SIZE;
-       unsigned char *cmem;
-       unsigned long handle = zram->table[index].handle;
+       struct page *page;
+       unsigned char *user_mem, *uncmem = NULL;
 
-       if (zram_test_flag(zram, index, ZRAM_ZERO) || !handle) {
-               memset(mem, 0, PAGE_SIZE);
+       page = bvec->bv_page;
+
+       if (unlikely(!zram->table[index].handle) ||
+                       zram_test_flag(zram, index, ZRAM_ZERO)) {
+               handle_zero_page(bvec);
                return 0;
        }
 
-       cmem = zs_map_object(zram->mem_pool, handle, ZS_MM_RO);
-       ret = lzo1x_decompress_safe(cmem, zram->table[index].size,
-                                   mem, &clen);
-       zs_unmap_object(zram->mem_pool, handle);
+       user_mem = kmap_atomic(page);
+       if (is_partial_io(bvec))
+               /* Use  a temporary buffer to decompress the page */
+               uncmem = kmalloc(PAGE_SIZE, GFP_KERNEL);
+       else
+               uncmem = user_mem;
 
+       if (!uncmem) {
+               pr_info("Unable to allocate temp memory\n");
+               ret = -ENOMEM;
+               goto out_cleanup;
+       }
+
+       ret = zram_decompress_page(zram, uncmem, index);
        /* Should NEVER happen. Return bio error if it does. */
        if (unlikely(ret != LZO_E_OK)) {
                pr_err("Decompression failed! err=%d, page=%u\n", ret, index);
                zram_stat64_inc(zram, &zram->stats.failed_reads);
-               return ret;
+               goto out_cleanup;
        }
 
-       return 0;
+       if (is_partial_io(bvec))
+               memcpy(user_mem + bvec->bv_offset, uncmem + offset,
+                               bvec->bv_len);
+
+       flush_dcache_page(page);
+       ret = 0;
+out_cleanup:
+       kunmap_atomic(user_mem);
+       if (is_partial_io(bvec))
+               kfree(uncmem);
+       return ret;
 }
 
 static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
@@ -302,7 +285,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
                        ret = -ENOMEM;
                        goto out;
                }
-               ret = zram_read_before_write(zram, uncmem, index);
+               ret = zram_decompress_page(zram, uncmem, index);
                if (ret) {
                        kfree(uncmem);
                        goto out;
index edb0ed4125d5b2c9a08058d2d01f5db507a4d1ee..de1eacf65dbdc167bf4707cdcf6a9eb7bfa0fbf7 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/genhd.h>
 #include <linux/mm.h>
+#include <linux/kernel.h>
 
 #include "zram_drv.h"
 
@@ -54,13 +55,12 @@ static ssize_t disksize_show(struct device *dev,
 static ssize_t disksize_store(struct device *dev,
                struct device_attribute *attr, const char *buf, size_t len)
 {
-       int ret;
        u64 disksize;
        struct zram *zram = dev_to_zram(dev);
 
-       ret = kstrtoull(buf, 10, &disksize);
-       if (ret)
-               return ret;
+       disksize = memparse(buf, NULL);
+       if (!disksize)
+               return -EINVAL;
 
        down_write(&zram->init_lock);
        if (zram->init_done) {