staging: comedi: comedi_pcmcia: allow drivers to use a custom conf_check()
[pandora-kernel.git] / drivers / staging / comedi / drivers / ni_daq_dio24.c
1 /*
2     comedi/drivers/ni_daq_dio24.c
3     Driver for National Instruments PCMCIA DAQ-Card DIO-24
4     Copyright (C) 2002 Daniel Vecino Castel <dvecino@able.es>
5
6     PCMCIA crap at end of file is adapted from dummy_cs.c 1.31 2001/08/24 12:13:13
7     from the pcmcia package.
8     The initial developer of the pcmcia dummy_cs.c code is David A. Hinds
9     <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
10     are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
11
12     This program is free software; you can redistribute it and/or modify
13     it under the terms of the GNU General Public License as published by
14     the Free Software Foundation; either version 2 of the License, or
15     (at your option) any later version.
16
17     This program is distributed in the hope that it will be useful,
18     but WITHOUT ANY WARRANTY; without even the implied warranty of
19     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20     GNU General Public License for more details.
21
22     You should have received a copy of the GNU General Public License
23     along with this program; if not, write to the Free Software
24     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
26 ************************************************************************
27 */
28 /*
29 Driver: ni_daq_dio24
30 Description: National Instruments PCMCIA DAQ-Card DIO-24
31 Author: Daniel Vecino Castel <dvecino@able.es>
32 Devices: [National Instruments] PCMCIA DAQ-Card DIO-24 (ni_daq_dio24)
33 Status: ?
34 Updated: Thu, 07 Nov 2002 21:53:06 -0800
35
36 This is just a wrapper around the 8255.o driver to properly handle
37 the PCMCIA interface.
38 */
39
40 #include "../comedidev.h"
41
42 #include <pcmcia/cistpl.h>
43 #include <pcmcia/cisreg.h>
44 #include <pcmcia/ds.h>
45
46 #include "8255.h"
47
48 static int dio24_auto_attach(struct comedi_device *dev,
49                              unsigned long context)
50 {
51         struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
52         struct comedi_subdevice *s;
53         int ret;
54
55         dev->board_name = dev->driver->driver_name;
56
57         link->config_flags |= CONF_AUTO_SET_IO;
58         ret = comedi_pcmcia_enable(dev, NULL);
59                 return ret;
60         dev->iobase = link->resource[0]->start;
61
62         ret = comedi_alloc_subdevices(dev, 1);
63         if (ret)
64                 return ret;
65
66         /* 8255 dio */
67         s = &dev->subdevices[0];
68         ret = subdev_8255_init(dev, s, NULL, dev->iobase);
69         if (ret)
70                 return ret;
71
72         return 0;
73 }
74
75 static void dio24_detach(struct comedi_device *dev)
76 {
77         if (dev->subdevices)
78                 subdev_8255_cleanup(dev, &dev->subdevices[0]);
79         comedi_pcmcia_disable(dev);
80 }
81
82 static struct comedi_driver driver_dio24 = {
83         .driver_name    = "ni_daq_dio24",
84         .module         = THIS_MODULE,
85         .auto_attach    = dio24_auto_attach,
86         .detach         = dio24_detach,
87 };
88
89 static int dio24_cs_attach(struct pcmcia_device *link)
90 {
91         return comedi_pcmcia_auto_config(link, &driver_dio24);
92 }
93
94 static const struct pcmcia_device_id dio24_cs_ids[] = {
95         PCMCIA_DEVICE_MANF_CARD(0x010b, 0x475c),        /* daqcard-dio24 */
96         PCMCIA_DEVICE_NULL
97 };
98 MODULE_DEVICE_TABLE(pcmcia, dio24_cs_ids);
99
100 static struct pcmcia_driver dio24_cs_driver = {
101         .name           = "ni_daq_dio24",
102         .owner          = THIS_MODULE,
103         .id_table       = dio24_cs_ids,
104         .probe          = dio24_cs_attach,
105         .remove         = comedi_pcmcia_auto_unconfig,
106 };
107 module_comedi_pcmcia_driver(driver_dio24, dio24_cs_driver);
108
109 MODULE_AUTHOR("Daniel Vecino Castel <dvecino@able.es>");
110 MODULE_DESCRIPTION(
111         "Comedi driver for National Instruments PCMCIA DAQ-Card DIO-24");
112 MODULE_LICENSE("GPL");