staging: comedi: add 'ioenabled' flag to device
Add 1-bit bit-field member `ioenabled` of type `bool` to `struct comedi_device`. Use this to keep track of whether a PCI device and its BARs have been successfully enabled by `comedi_pci_enable()`. This avoids overloading the meaning of the `iobase` member which is used by several drivers to hold the base port I/O address of a board's "main" registers. Other drivers using MMIO use `iobase` as a flag to indicate that the preceding call to `comedi_pci_enable()` was successful. They no longer need to do that. The name `ioenabled` is intended to be PCI-agnostic so it can be used for similar purposes by non-PCI drivers. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
13f12b5aea
commit
00ca688418
@ -55,6 +55,8 @@ int comedi_pci_enable(struct comedi_device *dev)
|
|||||||
: dev->driver->driver_name);
|
: dev->driver->driver_name);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
pci_disable_device(pcidev);
|
pci_disable_device(pcidev);
|
||||||
|
else
|
||||||
|
dev->ioenabled = true;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -68,10 +70,11 @@ void comedi_pci_disable(struct comedi_device *dev)
|
|||||||
{
|
{
|
||||||
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
|
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
|
||||||
|
|
||||||
if (pcidev && dev->iobase) {
|
if (pcidev && dev->ioenabled) {
|
||||||
pci_release_regions(pcidev);
|
pci_release_regions(pcidev);
|
||||||
pci_disable_device(pcidev);
|
pci_disable_device(pcidev);
|
||||||
}
|
}
|
||||||
|
dev->ioenabled = false;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(comedi_pci_disable);
|
EXPORT_SYMBOL_GPL(comedi_pci_disable);
|
||||||
|
|
||||||
|
@ -209,6 +209,7 @@ struct comedi_device {
|
|||||||
const void *board_ptr;
|
const void *board_ptr;
|
||||||
bool attached:1;
|
bool attached:1;
|
||||||
bool in_request_module:1;
|
bool in_request_module:1;
|
||||||
|
bool ioenabled:1;
|
||||||
spinlock_t spinlock;
|
spinlock_t spinlock;
|
||||||
struct mutex mutex;
|
struct mutex mutex;
|
||||||
|
|
||||||
|
@ -110,6 +110,7 @@ static void cleanup_device(struct comedi_device *dev)
|
|||||||
dev->board_name = NULL;
|
dev->board_name = NULL;
|
||||||
dev->board_ptr = NULL;
|
dev->board_ptr = NULL;
|
||||||
dev->iobase = 0;
|
dev->iobase = 0;
|
||||||
|
dev->ioenabled = false;
|
||||||
dev->irq = 0;
|
dev->irq = 0;
|
||||||
dev->read_subdev = NULL;
|
dev->read_subdev = NULL;
|
||||||
dev->write_subdev = NULL;
|
dev->write_subdev = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user