diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2013-03-15 09:15:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-15 12:16:31 -0400 |
commit | 00ca6884186f18a758eae37e94f7c3c0527f8f30 (patch) | |
tree | 69190496dd4ac8e099a2cd0cf0b21d19551cbab9 | |
parent | 13f12b5aea501bce146cdf213d1819083aadc847 (diff) |
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>
-rw-r--r-- | drivers/staging/comedi/comedi_pci.c | 5 | ||||
-rw-r--r-- | drivers/staging/comedi/comedidev.h | 1 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers.c | 1 |
3 files changed, 6 insertions, 1 deletions
diff --git a/drivers/staging/comedi/comedi_pci.c b/drivers/staging/comedi/comedi_pci.c index b164b0353ebe..6f3cdf88f05e 100644 --- a/drivers/staging/comedi/comedi_pci.c +++ b/drivers/staging/comedi/comedi_pci.c | |||
@@ -55,6 +55,8 @@ int comedi_pci_enable(struct comedi_device *dev) | |||
55 | : dev->driver->driver_name); | 55 | : dev->driver->driver_name); |
56 | if (rc < 0) | 56 | if (rc < 0) |
57 | pci_disable_device(pcidev); | 57 | pci_disable_device(pcidev); |
58 | else | ||
59 | dev->ioenabled = true; | ||
58 | 60 | ||
59 | return rc; | 61 | return rc; |
60 | } | 62 | } |
@@ -68,10 +70,11 @@ void comedi_pci_disable(struct comedi_device *dev) | |||
68 | { | 70 | { |
69 | struct pci_dev *pcidev = comedi_to_pci_dev(dev); | 71 | struct pci_dev *pcidev = comedi_to_pci_dev(dev); |
70 | 72 | ||
71 | if (pcidev && dev->iobase) { | 73 | if (pcidev && dev->ioenabled) { |
72 | pci_release_regions(pcidev); | 74 | pci_release_regions(pcidev); |
73 | pci_disable_device(pcidev); | 75 | pci_disable_device(pcidev); |
74 | } | 76 | } |
77 | dev->ioenabled = false; | ||
75 | } | 78 | } |
76 | EXPORT_SYMBOL_GPL(comedi_pci_disable); | 79 | EXPORT_SYMBOL_GPL(comedi_pci_disable); |
77 | 80 | ||
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 86de4ff9501a..9c8662a051dc 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h | |||
@@ -209,6 +209,7 @@ struct comedi_device { | |||
209 | const void *board_ptr; | 209 | const void *board_ptr; |
210 | bool attached:1; | 210 | bool attached:1; |
211 | bool in_request_module:1; | 211 | bool in_request_module:1; |
212 | bool ioenabled:1; | ||
212 | spinlock_t spinlock; | 213 | spinlock_t spinlock; |
213 | struct mutex mutex; | 214 | struct mutex mutex; |
214 | 215 | ||
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 87052735d91c..4724f275830c 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c | |||
@@ -110,6 +110,7 @@ static void cleanup_device(struct comedi_device *dev) | |||
110 | dev->board_name = NULL; | 110 | dev->board_name = NULL; |
111 | dev->board_ptr = NULL; | 111 | dev->board_ptr = NULL; |
112 | dev->iobase = 0; | 112 | dev->iobase = 0; |
113 | dev->ioenabled = false; | ||
113 | dev->irq = 0; | 114 | dev->irq = 0; |
114 | dev->read_subdev = NULL; | 115 | dev->read_subdev = NULL; |
115 | dev->write_subdev = NULL; | 116 | dev->write_subdev = NULL; |