Re: [PATCH] staging: comedi_pci: make comedi_pci_disable() safe to always call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 13/03/2013 00:41, H Hartley Sweeten wrote:
--- a/drivers/staging/comedi/comedi_pci.c
+++ b/drivers/staging/comedi/comedi_pci.c
@@ -57,14 +57,16 @@ EXPORT_SYMBOL_GPL(comedi_pci_enable);

  /**
   * comedi_pci_disable() - Release the regions and disable the PCI device.
- * @pcidev: pci_dev struct
- *
- * This must be matched with a previous successful call to comedi_pci_enable().
+ * @dev: comedi_device struct
   */
-void comedi_pci_disable(struct pci_dev *pcidev)
+void comedi_pci_disable(struct comedi_device *dev)
  {
-       pci_release_regions(pcidev);
-       pci_disable_device(pcidev);
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+       if (pcidev && dev->iobase) {
+               pci_release_regions(pcidev);
+               pci_disable_device(pcidev);
+       }
  }

Maybe it should set dev->iobase to 0 as well and your reworked comedi_pci_enable() set dev->iobase to a temporary non-zero value. Several drivers only use dev->iobase as a flag anyway. (Maybe we shouldn't be overloading dev->iobase in this way - it seems kind of yucky. Perhaps we should use a new member of struct comedi_device.) This can be done in a follow-up patch.

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux