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/kernel.h>
21 #include <pcmcia/cistpl.h>
22 #include <pcmcia/ds.h>
24 #include "comedidev.h"
27 * comedi_to_pcmcia_dev() - comedi_device pointer to pcmcia_device pointer.
28 * @dev: comedi_device struct
30 struct pcmcia_device
*comedi_to_pcmcia_dev(struct comedi_device
*dev
)
32 return dev
->hw_dev
? to_pcmcia_dev(dev
->hw_dev
) : NULL
;
34 EXPORT_SYMBOL_GPL(comedi_to_pcmcia_dev
);
36 static int comedi_pcmcia_conf_check(struct pcmcia_device
*link
,
39 if (link
->config_index
== 0)
42 return pcmcia_request_io(link
);
46 * comedi_pcmcia_enable() - Request the regions and enable the PCMCIA device.
47 * @dev: comedi_device struct
48 * @conf_check: optional callback to check the pcmcia_device configuration
50 * The comedi PCMCIA driver needs to set the link->config_flags, as
51 * appropriate for that driver, before calling this function in order
52 * to allow pcmcia_loop_config() to do its internal autoconfiguration.
54 int comedi_pcmcia_enable(struct comedi_device
*dev
,
55 int (*conf_check
)(struct pcmcia_device
*, void *))
57 struct pcmcia_device
*link
= comedi_to_pcmcia_dev(dev
);
64 conf_check
= comedi_pcmcia_conf_check
;
66 ret
= pcmcia_loop_config(link
, conf_check
, NULL
);
70 return pcmcia_enable_device(link
);
72 EXPORT_SYMBOL_GPL(comedi_pcmcia_enable
);
75 * comedi_pcmcia_disable() - Disable the PCMCIA device and release the regions.
76 * @dev: comedi_device struct
78 void comedi_pcmcia_disable(struct comedi_device
*dev
)
80 struct pcmcia_device
*link
= comedi_to_pcmcia_dev(dev
);
83 pcmcia_disable_device(link
);
85 EXPORT_SYMBOL_GPL(comedi_pcmcia_disable
);
88 * comedi_pcmcia_auto_config() - Configure/probe a comedi PCMCIA driver.
89 * @link: pcmcia_device struct
90 * @driver: comedi_driver struct
92 * Typically called from the pcmcia_driver (*probe) function.
94 int comedi_pcmcia_auto_config(struct pcmcia_device
*link
,
95 struct comedi_driver
*driver
)
97 return comedi_auto_config(&link
->dev
, driver
, 0);
99 EXPORT_SYMBOL_GPL(comedi_pcmcia_auto_config
);
102 * comedi_pcmcia_auto_unconfig() - Unconfigure/remove a comedi PCMCIA driver.
103 * @link: pcmcia_device struct
105 * Typically called from the pcmcia_driver (*remove) function.
107 void comedi_pcmcia_auto_unconfig(struct pcmcia_device
*link
)
109 comedi_auto_unconfig(&link
->dev
);
111 EXPORT_SYMBOL_GPL(comedi_pcmcia_auto_unconfig
);
114 * comedi_pcmcia_driver_register() - Register a comedi PCMCIA driver.
115 * @comedi_driver: comedi_driver struct
116 * @pcmcia_driver: pcmcia_driver struct
118 * This function is used for the module_init() of comedi USB drivers.
119 * Do not call it directly, use the module_comedi_pcmcia_driver() helper
122 int comedi_pcmcia_driver_register(struct comedi_driver
*comedi_driver
,
123 struct pcmcia_driver
*pcmcia_driver
)
127 ret
= comedi_driver_register(comedi_driver
);
131 ret
= pcmcia_register_driver(pcmcia_driver
);
133 comedi_driver_unregister(comedi_driver
);
139 EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_register
);
142 * comedi_pcmcia_driver_unregister() - Unregister a comedi PCMCIA driver.
143 * @comedi_driver: comedi_driver struct
144 * @pcmcia_driver: pcmcia_driver struct
146 * This function is used for the module_exit() of comedi PCMCIA drivers.
147 * Do not call it directly, use the module_comedi_pcmcia_driver() helper
150 void comedi_pcmcia_driver_unregister(struct comedi_driver
*comedi_driver
,
151 struct pcmcia_driver
*pcmcia_driver
)
153 pcmcia_unregister_driver(pcmcia_driver
);
154 comedi_driver_unregister(comedi_driver
);
156 EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_unregister
);