Lines Matching +full:pci +full:- +full:dev

1 // SPDX-License-Identifier: GPL-2.0+
4 * Comedi PCI driver specific functions.
6 * COMEDI - Linux Control and Measurement Device Interface
7 * Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org>
15 * comedi_to_pci_dev() - Return PCI device attached to COMEDI device
16 * @dev: COMEDI device.
18 * Assuming @dev->hw_dev is non-%NULL, it is assumed to be pointing to a
21 * Return: Attached PCI device if @dev->hw_dev is non-%NULL.
22 * Return %NULL if @dev->hw_dev is %NULL.
24 struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev) in comedi_to_pci_dev() argument
26 return dev->hw_dev ? to_pci_dev(dev->hw_dev) : NULL; in comedi_to_pci_dev()
31 * comedi_pci_enable() - Enable the PCI device and request the regions
32 * @dev: COMEDI device.
34 * Assuming @dev->hw_dev is non-%NULL, it is assumed to be pointing to a
35 * a &struct device embedded in a &struct pci_dev. Enable the PCI device
36 * and request its regions. Set @dev->ioenabled to %true if successful,
43 * -%ENODEV if @dev->hw_dev is %NULL,
44 * -%EBUSY if regions busy,
45 * or some negative error number if failed to enable PCI device.
48 int comedi_pci_enable(struct comedi_device *dev) in comedi_pci_enable() argument
50 struct pci_dev *pcidev = comedi_to_pci_dev(dev); in comedi_pci_enable()
54 return -ENODEV; in comedi_pci_enable()
60 rc = pci_request_regions(pcidev, dev->board_name); in comedi_pci_enable()
64 dev->ioenabled = true; in comedi_pci_enable()
71 * comedi_pci_disable() - Release the regions and disable the PCI device
72 * @dev: COMEDI device.
74 * Assuming @dev->hw_dev is non-%NULL, it is assumed to be pointing to a
76 * to comedi_pci_enable() was successful, release the PCI device's regions
77 * and disable it. Reset @dev->ioenabled back to %false.
79 void comedi_pci_disable(struct comedi_device *dev) in comedi_pci_disable() argument
81 struct pci_dev *pcidev = comedi_to_pci_dev(dev); in comedi_pci_disable()
83 if (pcidev && dev->ioenabled) { in comedi_pci_disable()
87 dev->ioenabled = false; in comedi_pci_disable()
92 * comedi_pci_detach() - A generic "detach" handler for PCI COMEDI drivers
93 * @dev: COMEDI device.
95 * COMEDI drivers for PCI devices that need no special clean-up of private data
96 * and have no ioremapped regions other than that pointed to by @dev->mmio may
98 * COMEDI device is being detached from the low-level driver. It may be also
99 * called from a more specific "detach" handler that does additional clean-up.
101 * Free the IRQ if @dev->irq is non-zero, iounmap @dev->mmio if it is
102 * non-%NULL, and call comedi_pci_disable() to release the PCI device's regions
105 void comedi_pci_detach(struct comedi_device *dev) in comedi_pci_detach() argument
107 struct pci_dev *pcidev = comedi_to_pci_dev(dev); in comedi_pci_detach()
109 if (!pcidev || !dev->ioenabled) in comedi_pci_detach()
112 if (dev->irq) { in comedi_pci_detach()
113 free_irq(dev->irq, dev); in comedi_pci_detach()
114 dev->irq = 0; in comedi_pci_detach()
116 if (dev->mmio) { in comedi_pci_detach()
117 iounmap(dev->mmio); in comedi_pci_detach()
118 dev->mmio = NULL; in comedi_pci_detach()
120 comedi_pci_disable(dev); in comedi_pci_detach()
125 * comedi_pci_auto_config() - Configure/probe a PCI COMEDI device
126 * @pcidev: PCI device.
130 * Typically called from the pci_driver (*probe) function. Auto-configure
143 return comedi_auto_config(&pcidev->dev, driver, context); in comedi_pci_auto_config()
148 * comedi_pci_auto_unconfig() - Unconfigure/remove a PCI COMEDI device
149 * @pcidev: PCI device.
151 * Typically called from the pci_driver (*remove) function. Auto-unconfigure
152 * a COMEDI device attached to this PCI device, using a pointer to the
163 comedi_auto_unconfig(&pcidev->dev); in comedi_pci_auto_unconfig()
168 * comedi_pci_driver_register() - Register a PCI COMEDI driver
170 * @pci_driver: PCI driver to be registered.
172 * This function is called from the module_init() of PCI COMEDI driver modules
173 * to register the COMEDI driver and the PCI driver. Do not call it directly,
198 * comedi_pci_driver_unregister() - Unregister a PCI COMEDI driver
200 * @pci_driver: PCI driver to be unregistered.
202 * This function is called from the module_exit() of PCI COMEDI driver modules
203 * to unregister the PCI driver and the COMEDI driver. Do not call it
226 MODULE_DESCRIPTION("Comedi PCI interface module");