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 "comedi_pcmcia.h"
25 * comedi_to_pcmcia_dev() - comedi_device pointer to pcmcia_device pointer.
26 * @dev: comedi_device struct
28 struct pcmcia_device *comedi_to_pcmcia_dev(struct comedi_device *dev)
30 return dev->hw_dev ? to_pcmcia_dev(dev->hw_dev) : NULL;
32 EXPORT_SYMBOL_GPL(comedi_to_pcmcia_dev);
34 static int comedi_pcmcia_conf_check(struct pcmcia_device *link,
37 if (link->config_index == 0)
40 return pcmcia_request_io(link);
44 * comedi_pcmcia_enable() - Request the regions and enable the PCMCIA device.
45 * @dev: comedi_device struct
46 * @conf_check: optional callback to check the pcmcia_device configuration
48 * The comedi PCMCIA driver needs to set the link->config_flags, as
49 * appropriate for that driver, before calling this function in order
50 * to allow pcmcia_loop_config() to do its internal autoconfiguration.
52 int comedi_pcmcia_enable(struct comedi_device *dev,
53 int (*conf_check)(struct pcmcia_device *, void *))
55 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
62 conf_check = comedi_pcmcia_conf_check;
64 ret = pcmcia_loop_config(link, conf_check, NULL);
68 return pcmcia_enable_device(link);
70 EXPORT_SYMBOL_GPL(comedi_pcmcia_enable);
73 * comedi_pcmcia_disable() - Disable the PCMCIA device and release the regions.
74 * @dev: comedi_device struct
76 void comedi_pcmcia_disable(struct comedi_device *dev)
78 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
81 pcmcia_disable_device(link);
83 EXPORT_SYMBOL_GPL(comedi_pcmcia_disable);
86 * comedi_pcmcia_auto_config() - Configure/probe a comedi PCMCIA driver.
87 * @link: pcmcia_device struct
88 * @driver: comedi_driver struct
90 * Typically called from the pcmcia_driver (*probe) function.
92 int comedi_pcmcia_auto_config(struct pcmcia_device *link,
93 struct comedi_driver *driver)
95 return comedi_auto_config(&link->dev, driver, 0);
97 EXPORT_SYMBOL_GPL(comedi_pcmcia_auto_config);
100 * comedi_pcmcia_auto_unconfig() - Unconfigure/remove a comedi PCMCIA driver.
101 * @link: pcmcia_device struct
103 * Typically called from the pcmcia_driver (*remove) function.
105 void comedi_pcmcia_auto_unconfig(struct pcmcia_device *link)
107 comedi_auto_unconfig(&link->dev);
109 EXPORT_SYMBOL_GPL(comedi_pcmcia_auto_unconfig);
112 * comedi_pcmcia_driver_register() - Register a comedi PCMCIA driver.
113 * @comedi_driver: comedi_driver struct
114 * @pcmcia_driver: pcmcia_driver struct
116 * This function is used for the module_init() of comedi USB drivers.
117 * Do not call it directly, use the module_comedi_pcmcia_driver() helper
120 int comedi_pcmcia_driver_register(struct comedi_driver *comedi_driver,
121 struct pcmcia_driver *pcmcia_driver)
125 ret = comedi_driver_register(comedi_driver);
129 ret = pcmcia_register_driver(pcmcia_driver);
131 comedi_driver_unregister(comedi_driver);
137 EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_register);
140 * comedi_pcmcia_driver_unregister() - Unregister a comedi PCMCIA driver.
141 * @comedi_driver: comedi_driver struct
142 * @pcmcia_driver: pcmcia_driver struct
144 * This function is used for the module_exit() of comedi PCMCIA drivers.
145 * Do not call it directly, use the module_comedi_pcmcia_driver() helper
148 void comedi_pcmcia_driver_unregister(struct comedi_driver *comedi_driver,
149 struct pcmcia_driver *pcmcia_driver)
151 pcmcia_unregister_driver(pcmcia_driver);
152 comedi_driver_unregister(comedi_driver);
154 EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_unregister);
156 static int __init comedi_pcmcia_init(void)
160 module_init(comedi_pcmcia_init);
162 static void __exit comedi_pcmcia_exit(void)
165 module_exit(comedi_pcmcia_exit);
167 MODULE_AUTHOR("http://www.comedi.org");
168 MODULE_DESCRIPTION("Comedi PCMCIA interface module");
169 MODULE_LICENSE("GPL");