X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/422c9bdbad34a21948dd32297d306fe5872c09fd..3367930de7bb1e08bed6463ff3ed66f242bf8fc0:/lincan/src/esdpci200.c diff --git a/lincan/src/esdpci200.c b/lincan/src/esdpci200.c index 718db1e..292ae90 100644 --- a/lincan/src/esdpci200.c +++ b/lincan/src/esdpci200.c @@ -290,15 +290,15 @@ int esdpci200_reset(struct candevice_t *candev) int esdpci200_init_hw_data(struct candevice_t *candev) { - struct pci_dev *pcidev = NULL; + struct pci_dev *pcidev; + + pcidev = can_pci_get_next_untaken_device(ESDPCI200_PCI_VENDOR_ID, ESDPCI200_PCI_PRODUCT_ID); + if(pcidev == NULL) + return -ENODEV; - do { - pcidev = pci_find_device(ESDPCI200_PCI_VENDOR_ID, ESDPCI200_PCI_PRODUCT_ID, pcidev); - if(pcidev == NULL) return -ENODEV; - } while(can_check_dev_taken(pcidev)); - if (pci_enable_device (pcidev)){ printk(KERN_CRIT "Setup of ESDPCI200 failed\n"); + can_pci_dev_put(pcidev); return -EIO; } candev->sysdevptr.pcidev=pcidev; @@ -308,17 +308,20 @@ int esdpci200_init_hw_data(struct candevice_t *candev) if(!(pci_resource_flags(pcidev, 0)&IORESOURCE_MEM)) { printk(KERN_CRIT "PCI200 region %d is not MEM\n",0); + can_pci_dev_put(pcidev); return -EIO; } if(!(pci_resource_flags(pcidev, 1)&IORESOURCE_IO)) { printk(KERN_CRIT "PCI200 region %d is not IO\n",1); + can_pci_dev_put(pcidev); return -EIO; } if(!(pci_resource_flags(pcidev,2)&IORESOURCE_MEM)) { printk(KERN_CRIT "PCI200 region %d is not MEM\n",2); + can_pci_dev_put(pcidev); return -EIO; } @@ -339,6 +342,12 @@ int esdpci200_init_hw_data(struct candevice_t *candev) return 0; } +void esdpci200_done_hw_data(struct candevice_t *candev) +{ + struct pci_dev *pcidev = candev->sysdevptr.pcidev; + can_pci_dev_put(pcidev); +} + int esdpci200_init_chip_data(struct candevice_t *candev, int chipnr) { @@ -389,6 +398,7 @@ int esdpci200_register(struct hwspecops_t *hwspecops) hwspecops->release_io = esdpci200_release_io; hwspecops->reset = esdpci200_reset; hwspecops->init_hw_data = esdpci200_init_hw_data; + hwspecops->done_hw_data = esdpci200_done_hw_data; hwspecops->init_chip_data = esdpci200_init_chip_data; hwspecops->init_obj_data = esdpci200_init_obj_data; hwspecops->write_register = esdpci200_write_register;