3 * Comedi PCMCIA driver specific functions.
5 * COMEDI - Linux Control and Measurement Device Interface
6 * Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <linux/kernel.h>
25 #include <pcmcia/cistpl.h>
26 #include <pcmcia/ds.h>
28 #include "comedidev.h"
31 * comedi_to_pcmcia_dev() - comedi_device pointer to pcmcia_device pointer.
32 * @dev: comedi_device struct
34 struct pcmcia_device *comedi_to_pcmcia_dev(struct comedi_device *dev)
36 return dev->hw_dev ? to_pcmcia_dev(dev->hw_dev) : NULL;
38 EXPORT_SYMBOL_GPL(comedi_to_pcmcia_dev);
40 static int comedi_pcmcia_conf_check(struct pcmcia_device *link,
43 if (link->config_index == 0)
46 return pcmcia_request_io(link);
50 * comedi_pcmcia_enable() - Request the regions and enable the PCMCIA device.
51 * @dev: comedi_device struct
52 * @conf_check: optional callback to check the pcmcia_device configuration
54 * The comedi PCMCIA driver needs to set the link->config_flags, as
55 * appropriate for that driver, before calling this function in order
56 * to allow pcmcia_loop_config() to do its internal autoconfiguration.
58 int comedi_pcmcia_enable(struct comedi_device *dev,
59 int (*conf_check)(struct pcmcia_device *, void *))
61 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
68 conf_check = comedi_pcmcia_conf_check;
70 ret = pcmcia_loop_config(link, conf_check, NULL);
74 return pcmcia_enable_device(link);
76 EXPORT_SYMBOL_GPL(comedi_pcmcia_enable);
79 * comedi_pcmcia_disable() - Disable the PCMCIA device and release the regions.
80 * @dev: comedi_device struct
82 void comedi_pcmcia_disable(struct comedi_device *dev)
84 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
87 pcmcia_disable_device(link);
89 EXPORT_SYMBOL_GPL(comedi_pcmcia_disable);
92 * comedi_pcmcia_auto_config() - Configure/probe a comedi PCMCIA driver.
93 * @link: pcmcia_device struct
94 * @driver: comedi_driver struct
96 * Typically called from the pcmcia_driver (*probe) function.
98 int comedi_pcmcia_auto_config(struct pcmcia_device *link,
99 struct comedi_driver *driver)
101 return comedi_auto_config(&link->dev, driver, 0);
103 EXPORT_SYMBOL_GPL(comedi_pcmcia_auto_config);
106 * comedi_pcmcia_auto_unconfig() - Unconfigure/remove a comedi PCMCIA driver.
107 * @link: pcmcia_device struct
109 * Typically called from the pcmcia_driver (*remove) function.
111 void comedi_pcmcia_auto_unconfig(struct pcmcia_device *link)
113 comedi_auto_unconfig(&link->dev);
115 EXPORT_SYMBOL_GPL(comedi_pcmcia_auto_unconfig);
118 * comedi_pcmcia_driver_register() - Register a comedi PCMCIA driver.
119 * @comedi_driver: comedi_driver struct
120 * @pcmcia_driver: pcmcia_driver struct
122 * This function is used for the module_init() of comedi USB drivers.
123 * Do not call it directly, use the module_comedi_pcmcia_driver() helper
126 int comedi_pcmcia_driver_register(struct comedi_driver *comedi_driver,
127 struct pcmcia_driver *pcmcia_driver)
131 ret = comedi_driver_register(comedi_driver);
135 ret = pcmcia_register_driver(pcmcia_driver);
137 comedi_driver_unregister(comedi_driver);
143 EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_register);
146 * comedi_pcmcia_driver_unregister() - Unregister a comedi PCMCIA driver.
147 * @comedi_driver: comedi_driver struct
148 * @pcmcia_driver: pcmcia_driver struct
150 * This function is used for the module_exit() of comedi PCMCIA drivers.
151 * Do not call it directly, use the module_comedi_pcmcia_driver() helper
154 void comedi_pcmcia_driver_unregister(struct comedi_driver *comedi_driver,
155 struct pcmcia_driver *pcmcia_driver)
157 pcmcia_unregister_driver(pcmcia_driver);
158 comedi_driver_unregister(comedi_driver);
160 EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_unregister);