The current watchdog support in hwdrv_apci2200.c does not conform
to the comedi API.

Use the addi_watchdog module to provide support for the watchdog
subdevice and remove the now unneeded hwdrv_apci2200.c file.

Signed-off-by: H Hartley Sweeten <[email protected]>
Cc: Ian Abbott <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
---
 drivers/staging/comedi/Kconfig                     |   1 +
 .../comedi/drivers/addi-data/hwdrv_apci2200.c      | 176 ---------------------
 drivers/staging/comedi/drivers/addi_apci_2200.c    |  36 ++---
 3 files changed, 10 insertions(+), 203 deletions(-)
 delete mode 100644 drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 39cf735..6fcd1fd 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -635,6 +635,7 @@ config COMEDI_ADDI_APCI_2032
 
 config COMEDI_ADDI_APCI_2200
        tristate "ADDI-DATA APCI_2200 support"
+       select COMEDI_ADDI_WATCHDOG
        ---help---
          Enable support for ADDI-DATA APCI_2200 cards
 
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c
deleted file mode 100644
index 4d32509..0000000
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
-@verbatim
-
-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
-       [email protected]
-
-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.
-
-This program is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple 
Place, Suite 330, Boston, MA 02111-1307 USA
-
-You should also find the complete GPL in the COPYING file accompanying this 
source code.
-
-@endverbatim
-*/
-/*
-
-  +-----------------------------------------------------------------------+
-  | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |
-  +-----------------------------------------------------------------------+
-  | Tel : +49 (0) 7223/9493-0     | email    : [email protected]         |
-  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |
-  +-------------------------------+---------------------------------------+
-  | Project     : APCI-2200       | Compiler   : GCC                      |
-  | Module name : hwdrv_apci2200.c| Version    : 2.96                     |
-  +-------------------------------+---------------------------------------+
-  | Project manager: Eric Stolz   | Date       :  02/12/2002              |
-  +-------------------------------+---------------------------------------+
-  | Description :   Hardware Layer Access For APCI-2200                   |
-  +-----------------------------------------------------------------------+
-  |                             UPDATES                                   |
-  +----------+-----------+------------------------------------------------+
-  |   Date   |   Author  |          Description of updates                |
-  +----------+-----------+------------------------------------------------+
-  |          |           |                                                |
-  |          |           |                                                |
-  |          |           |                                                |
-  +----------+-----------+------------------------------------------------+
-*/
-
-/* TIMER COUNTER WATCHDOG DEFINES */
-
-#define APCI2200_WATCHDOG              0x08
-#define APCI2200_WATCHDOG_ENABLEDISABLE        12
-#define APCI2200_WATCHDOG_RELOAD_VALUE 4
-#define APCI2200_WATCHDOG_STATUS       16
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI2200_ConfigWatchdog(struct comedi_device *dev,
-|                      struct comedi_subdevice *s,struct comedi_insn 
*insn,unsigned int *data)  |
-|                                                                              
     |
-+----------------------------------------------------------------------------+
-| Task              : Configures The Watchdog                                |
-+----------------------------------------------------------------------------+
-| Input Parameters  :   struct comedi_device *dev      : Driver handle         
     |
-|                     struct comedi_subdevice *s,   :pointer to subdevice 
structure
-|                      struct comedi_insn *insn      :pointer to insn 
structure      |
-|                     unsigned int *data          : Data Pointer to read 
status                                                                          
                                   |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                      
                                                 |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                              
 |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_APCI2200_ConfigWatchdog(struct comedi_device *dev,
-                                    struct comedi_subdevice *s,
-                                    struct comedi_insn *insn,
-                                    unsigned int *data)
-{
-       if (data[0] == 0) {
-               /* Disable the watchdog */
-               outw(0x0, dev->iobase + APCI2200_WATCHDOG +
-                               APCI2200_WATCHDOG_ENABLEDISABLE);
-               /* Loading the Reload value */
-               outw(data[1], dev->iobase + APCI2200_WATCHDOG +
-                               APCI2200_WATCHDOG_RELOAD_VALUE);
-               data[1] = data[1] >> 16;
-               outw(data[1], dev->iobase + APCI2200_WATCHDOG +
-                               APCI2200_WATCHDOG_RELOAD_VALUE + 2);
-       }                       /* if(data[0]==0) */
-       else {
-               printk("\nThe input parameters are wrong\n");
-               return -EINVAL;
-       }                       /* elseif(data[0]==0) */
-
-       return insn->n;
-}
-
- /*
-    
+----------------------------------------------------------------------------+
-    | Function   Name   : int i_APCI2200_StartStopWriteWatchdog                
  |
-    |                           (struct comedi_device *dev,struct 
comedi_subdevice *s,
-    struct comedi_insn *insn,unsigned int *data);                      |
-    
+----------------------------------------------------------------------------+
-    | Task              : Start / Stop The Watchdog                            
  |
-    
+----------------------------------------------------------------------------+
-    | Input Parameters  : struct comedi_device *dev      : Driver handle       
         |
-    |                     struct comedi_subdevice *s,   :pointer to subdevice 
structure
-    struct comedi_insn *insn      :pointer to insn structure      |
-    |                     unsigned int *data          : Data Pointer to read 
status  |
-    
+----------------------------------------------------------------------------+
-    | Output Parameters :       --                                             
                                                          |
-    
+----------------------------------------------------------------------------+
-    | Return Value      : TRUE  : No error occur                               
  |
-    |                       : FALSE : Error occur. Return the error          |
-    |                                                                          
  |
-    
+----------------------------------------------------------------------------+
-  */
-
-static int i_APCI2200_StartStopWriteWatchdog(struct comedi_device *dev,
-                                            struct comedi_subdevice *s,
-                                            struct comedi_insn *insn,
-                                            unsigned int *data)
-{
-       switch (data[0]) {
-       case 0:         /* stop the watchdog */
-               outw(0x0, dev->iobase + APCI2200_WATCHDOG +
-                               APCI2200_WATCHDOG_ENABLEDISABLE);
-               break;
-       case 1:         /* start the watchdog */
-               outw(0x0001, dev->iobase + APCI2200_WATCHDOG +
-                               APCI2200_WATCHDOG_ENABLEDISABLE);
-               break;
-       case 2:         /* Software trigger */
-               outw(0x0201, dev->iobase + APCI2200_WATCHDOG +
-                               APCI2200_WATCHDOG_ENABLEDISABLE);
-               break;
-       default:
-               printk("\nSpecified functionality does not exist\n");
-               return -EINVAL;
-       }                       /*  switch(data[0]) */
-       return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI2200_ReadWatchdog                            |
-|                      (struct comedi_device *dev,struct comedi_subdevice 
*s,struct comedi_insn *insn,
-|                    unsigned int *data);                                      
     |
-+----------------------------------------------------------------------------+
-| Task              : Read The Watchdog                                      |
-+----------------------------------------------------------------------------+
-| Input Parameters  :   struct comedi_device *dev      : Driver handle         
     |
-|                     struct comedi_subdevice *s,   :pointer to subdevice 
structure
-|                      struct comedi_insn *insn      :pointer to insn 
structure      |
-|                     unsigned int *data          : Data Pointer to read 
status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                      
                                                 |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                              
 |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_APCI2200_ReadWatchdog(struct comedi_device *dev,
-                                  struct comedi_subdevice *s,
-                                  struct comedi_insn *insn,
-                                  unsigned int *data)
-{
-       data[0] = inw(dev->iobase + APCI2200_WATCHDOG +
-                       APCI2200_WATCHDOG_STATUS) & 0x1;
-       return insn->n;
-}
diff --git a/drivers/staging/comedi/drivers/addi_apci_2200.c 
b/drivers/staging/comedi/drivers/addi_apci_2200.c
index 15a84e5..99a206a 100644
--- a/drivers/staging/comedi/drivers/addi_apci_2200.c
+++ b/drivers/staging/comedi/drivers/addi_apci_2200.c
@@ -1,25 +1,21 @@
 #include "../comedidev.h"
+#include "addi_watchdog.h"
 #include "comedi_fc.h"
 
 #include "addi-data/addi_common.h"
 
-#include "addi-data/hwdrv_apci2200.c"
-
 /*
  * I/O Register Map
  */
 #define APCI2200_DI_REG                        0x00
 #define APCI2200_DO_REG                        0x04
+#define APCI2200_WDOG_REG              0x08
 
 static const struct addi_board apci2200_boardtypes[] = {
        {
                .pc_DriverName          = "apci2200",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x1005,
-               .i_Timer                = 1,
-               .timer_config           = i_APCI2200_ConfigWatchdog,
-               .timer_write            = i_APCI2200_StartStopWriteWatchdog,
-               .timer_read             = i_APCI2200_ReadWatchdog,
        },
 };
 
@@ -57,12 +53,8 @@ static int apci2200_do_insn_bits(struct comedi_device *dev,
 static int apci2200_reset(struct comedi_device *dev)
 {
        outw(0x0, dev->iobase + APCI2200_DO_REG);
-       outw(0x0, dev->iobase + APCI2200_WATCHDOG +
-                       APCI2200_WATCHDOG_ENABLEDISABLE);
-       outw(0x0, dev->iobase + APCI2200_WATCHDOG +
-                       APCI2200_WATCHDOG_RELOAD_VALUE);
-       outw(0x0, dev->iobase + APCI2200_WATCHDOG +
-                       APCI2200_WATCHDOG_RELOAD_VALUE + 2);
+
+       addi_watchdog_reset(dev->iobase + APCI2200_WDOG_REG);
 
        return 0;
 }
@@ -143,21 +135,9 @@ static int apci2200_auto_attach(struct comedi_device *dev,
 
        /*  Allocate and Initialise Timer Subdevice Structures */
        s = &dev->subdevices[4];
-       if (this_board->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;
-       }
+       ret = addi_watchdog_init(s, dev->iobase + APCI2200_WDOG_REG);
+       if (ret)
+               return ret;
 
        /*  Allocate and Initialise TTL */
        s = &dev->subdevices[5];
@@ -180,6 +160,8 @@ static void apci2200_detach(struct comedi_device *dev)
                if (dev->iobase)
                        apci2200_reset(dev);
        }
+       if (dev->subdevices)
+               addi_watchdog_cleanup(&dev->subdevices[4]);
        if (pcidev) {
                if (dev->iobase)
                        comedi_pci_disable(pcidev);
-- 
1.8.0

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to