staging: comedi: contec_pci_dio: remove the private data
[pandora-kernel.git] / drivers / staging / comedi / drivers / contec_pci_dio.c
index e4d37fc..944cfee 100644 (file)
@@ -57,15 +57,6 @@ static const struct contec_board contec_boards[] = {
 
 #define thisboard ((const struct contec_board *)dev->board_ptr)
 
-struct contec_private {
-       int data;
-
-       struct pci_dev *pci_dev;
-
-};
-
-#define devpriv ((struct contec_private *)dev->private)
-
 static int contec_do_insn_bits(struct comedi_device *dev,
                               struct comedi_subdevice *s,
                               struct comedi_insn *insn, unsigned int *data)
@@ -101,22 +92,25 @@ static struct pci_dev *contec_find_pci_dev(struct comedi_device *dev,
                                           struct comedi_devconfig *it)
 {
        struct pci_dev *pcidev = NULL;
+       int bus = it->options[0];
+       int slot = it->options[1];
 
        for_each_pci_dev(pcidev) {
-               if (pcidev->vendor == PCI_VENDOR_ID_CONTEC &&
-                   pcidev->device == PCI_DEVICE_ID_PIO1616L) {
-                       if (it->options[0] || it->options[1]) {
-                               /* Check bus and slot. */
-                               if (it->options[0] != pcidev->bus->number ||
-                                   it->options[1] != PCI_SLOT(pcidev->devfn)) {
-                                       continue;
-                               }
-                       }
-                       dev->board_ptr = contec_boards + 0;
-                       return pcidev;
+               if (bus || slot) {
+                       if (bus != pcidev->bus->number ||
+                               slot != PCI_SLOT(pcidev->devfn))
+                               continue;
                }
+               if (pcidev->vendor != PCI_VENDOR_ID_CONTEC ||
+                   pcidev->device != PCI_DEVICE_ID_PIO1616L)
+                       continue;
+
+               dev->board_ptr = contec_boards + 0;
+               return pcidev;
        }
-       printk("card not present!\n");
+       dev_err(dev->class_dev,
+               "No supported board found! (req. bus %d, slot %d)\n",
+               bus, slot);
        return NULL;
 }
 
@@ -130,9 +124,6 @@ static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
        dev->board_name = thisboard->name;
 
-       if (alloc_private(dev, sizeof(struct contec_private)) < 0)
-               return -ENOMEM;
-
        ret = comedi_alloc_subdevices(dev, 2);
        if (ret)
                return ret;
@@ -140,7 +131,7 @@ static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        pcidev = contec_find_pci_dev(dev, it);
        if (!pcidev)
                return -EIO;
-       devpriv->pci_dev = pcidev;
+       comedi_set_hw_dev(dev, &pcidev->dev);
 
        if (comedi_pci_enable(pcidev, "contec_pci_dio")) {
                printk("error enabling PCI device and request regions!\n");
@@ -173,10 +164,12 @@ static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 static void contec_detach(struct comedi_device *dev)
 {
-       if (devpriv && devpriv->pci_dev) {
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+       if (pcidev) {
                if (dev->iobase)
-                       comedi_pci_disable(devpriv->pci_dev);
-               pci_dev_put(devpriv->pci_dev);
+                       comedi_pci_disable(pcidev);
+               pci_dev_put(pcidev);
        }
 }