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.
19 #include <linux/module.h>
20 #include <linux/kernel.h>
22 #include <pcmcia/cistpl.h>
23 #include <pcmcia/ds.h>
25 #include "comedidev.h"
28 * comedi_to_pcmcia_dev() - comedi_device pointer to pcmcia_device pointer.
29 * @dev: comedi_device struct
31 struct pcmcia_device *comedi_to_pcmcia_dev(struct comedi_device *dev)
33 return dev->hw_dev ? to_pcmcia_dev(dev->hw_dev) : NULL;
35 EXPORT_SYMBOL_GPL(comedi_to_pcmcia_dev);
37 static int comedi_pcmcia_conf_check(struct pcmcia_device *link,
40 if (link->config_index == 0)
43 return pcmcia_request_io(link);
47 * comedi_pcmcia_enable() - Request the regions and enable the PCMCIA device.
48 * @dev: comedi_device struct
49 * @conf_check: optional callback to check the pcmcia_device configuration
51 * The comedi PCMCIA driver needs to set the link->config_flags, as
52 * appropriate for that driver, before calling this function in order
53 * to allow pcmcia_loop_config() to do its internal autoconfiguration.
55 int comedi_pcmcia_enable(struct comedi_device *dev,
56 int (*conf_check)(struct pcmcia_device *, void *))
58 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
65 conf_check = comedi_pcmcia_conf_check;
67 ret = pcmcia_loop_config(link, conf_check, NULL);
71 return pcmcia_enable_device(link);
73 EXPORT_SYMBOL_GPL(comedi_pcmcia_enable);
76 * comedi_pcmcia_disable() - Disable the PCMCIA device and release the regions.
77 * @dev: comedi_device struct
79 void comedi_pcmcia_disable(struct comedi_device *dev)
81 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
84 pcmcia_disable_device(link);
86 EXPORT_SYMBOL_GPL(comedi_pcmcia_disable);
89 * comedi_pcmcia_auto_config() - Configure/probe a comedi PCMCIA driver.
90 * @link: pcmcia_device struct
91 * @driver: comedi_driver struct
93 * Typically called from the pcmcia_driver (*probe) function.
95 int comedi_pcmcia_auto_config(struct pcmcia_device *link,
96 struct comedi_driver *driver)
98 return comedi_auto_config(&link->dev, driver, 0);
100 EXPORT_SYMBOL_GPL(comedi_pcmcia_auto_config);
103 * comedi_pcmcia_auto_unconfig() - Unconfigure/remove a comedi PCMCIA driver.
104 * @link: pcmcia_device struct
106 * Typically called from the pcmcia_driver (*remove) function.
108 void comedi_pcmcia_auto_unconfig(struct pcmcia_device *link)
110 comedi_auto_unconfig(&link->dev);
112 EXPORT_SYMBOL_GPL(comedi_pcmcia_auto_unconfig);
115 * comedi_pcmcia_driver_register() - Register a comedi PCMCIA driver.
116 * @comedi_driver: comedi_driver struct
117 * @pcmcia_driver: pcmcia_driver struct
119 * This function is used for the module_init() of comedi USB drivers.
120 * Do not call it directly, use the module_comedi_pcmcia_driver() helper
123 int comedi_pcmcia_driver_register(struct comedi_driver *comedi_driver,
124 struct pcmcia_driver *pcmcia_driver)
128 ret = comedi_driver_register(comedi_driver);
132 ret = pcmcia_register_driver(pcmcia_driver);
134 comedi_driver_unregister(comedi_driver);
140 EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_register);
143 * comedi_pcmcia_driver_unregister() - Unregister a comedi PCMCIA driver.
144 * @comedi_driver: comedi_driver struct
145 * @pcmcia_driver: pcmcia_driver struct
147 * This function is used for the module_exit() of comedi PCMCIA drivers.
148 * Do not call it directly, use the module_comedi_pcmcia_driver() helper
151 void comedi_pcmcia_driver_unregister(struct comedi_driver *comedi_driver,
152 struct pcmcia_driver *pcmcia_driver)
154 pcmcia_unregister_driver(pcmcia_driver);
155 comedi_driver_unregister(comedi_driver);
157 EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_unregister);
159 static int __init comedi_pcmcia_init(void)
163 module_init(comedi_pcmcia_init);
165 static void __exit comedi_pcmcia_exit(void)
168 module_exit(comedi_pcmcia_exit);
170 MODULE_AUTHOR("http://www.comedi.org");
171 MODULE_DESCRIPTION("Comedi PCMCIA interface module");
172 MODULE_LICENSE("GPL");