3 * Comedi PCI 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/pci.h>
25 #include "comedidev.h"
28 * comedi_to_pci_dev() - comedi_device pointer to pci_dev pointer.
29 * @dev: comedi_device struct
31 struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev)
33 return dev->hw_dev ? to_pci_dev(dev->hw_dev) : NULL;
35 EXPORT_SYMBOL_GPL(comedi_to_pci_dev);
38 * comedi_pci_enable() - Enable the PCI device and request the regions.
39 * @pcidev: pci_dev struct
40 * @res_name: name for the requested reqource
42 int comedi_pci_enable(struct pci_dev *pcidev, const char *res_name)
46 rc = pci_enable_device(pcidev);
50 rc = pci_request_regions(pcidev, res_name);
52 pci_disable_device(pcidev);
56 EXPORT_SYMBOL_GPL(comedi_pci_enable);
59 * comedi_pci_disable() - Release the regions and disable the PCI device.
60 * @pcidev: pci_dev struct
62 * This must be matched with a previous successful call to comedi_pci_enable().
64 void comedi_pci_disable(struct pci_dev *pcidev)
66 pci_release_regions(pcidev);
67 pci_disable_device(pcidev);
69 EXPORT_SYMBOL_GPL(comedi_pci_disable);
72 * comedi_pci_auto_config() - Configure/probe a comedi PCI driver.
73 * @pcidev: pci_dev struct
74 * @driver: comedi_driver struct
76 * Typically called from the pci_driver (*probe) function.
78 int comedi_pci_auto_config(struct pci_dev *pcidev,
79 struct comedi_driver *driver)
81 return comedi_auto_config(&pcidev->dev, driver, 0);
83 EXPORT_SYMBOL_GPL(comedi_pci_auto_config);
86 * comedi_pci_auto_unconfig() - Unconfigure/remove a comedi PCI driver.
87 * @pcidev: pci_dev struct
89 * Typically called from the pci_driver (*remove) function.
91 void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
93 comedi_auto_unconfig(&pcidev->dev);
95 EXPORT_SYMBOL_GPL(comedi_pci_auto_unconfig);
98 * comedi_pci_driver_register() - Register a comedi PCI driver.
99 * @comedi_driver: comedi_driver struct
100 * @pci_driver: pci_driver struct
102 * This function is used for the module_init() of comedi PCI drivers.
103 * Do not call it directly, use the module_comedi_pci_driver() helper
106 int comedi_pci_driver_register(struct comedi_driver *comedi_driver,
107 struct pci_driver *pci_driver)
111 ret = comedi_driver_register(comedi_driver);
115 ret = pci_register_driver(pci_driver);
117 comedi_driver_unregister(comedi_driver);
123 EXPORT_SYMBOL_GPL(comedi_pci_driver_register);
126 * comedi_pci_driver_unregister() - Unregister a comedi PCI driver.
127 * @comedi_driver: comedi_driver struct
128 * @pci_driver: pci_driver struct
130 * This function is used for the module_exit() of comedi PCI drivers.
131 * Do not call it directly, use the module_comedi_pci_driver() helper
134 void comedi_pci_driver_unregister(struct comedi_driver *comedi_driver,
135 struct pci_driver *pci_driver)
137 pci_unregister_driver(pci_driver);
138 comedi_driver_unregister(comedi_driver);
140 EXPORT_SYMBOL_GPL(comedi_pci_driver_unregister);