X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/422c9bdbad34a21948dd32297d306fe5872c09fd..3367930de7bb1e08bed6463ff3ed66f242bf8fc0:/lincan/src/unican.c diff --git a/lincan/src/unican.c b/lincan/src/unican.c index 2ec2aaa..10cc185 100644 --- a/lincan/src/unican.c +++ b/lincan/src/unican.c @@ -970,19 +970,20 @@ int unican_pci_init_hw_data(struct candevice_t *candev) { struct pci_dev *pcidev = NULL; - do { - pcidev = pci_find_device(UNICAN_PCI_VENDOR, UNICAN_PCI_ID, pcidev); - if(pcidev == NULL) return -ENODEV; - } while(can_check_dev_taken(pcidev)); - + pcidev = can_pci_get_next_untaken_device(UNICAN_PCI_VENDOR, UNICAN_PCI_ID); + if(pcidev == NULL) + return -ENODEV; + if (pci_enable_device (pcidev)){ printk(KERN_CRIT "Setup of Unican PCI failed\n"); + can_pci_dev_put(pcidev); return -EIO; } candev->sysdevptr.pcidev=pcidev; if(!(pci_resource_flags(pcidev,0)&IORESOURCE_MEM)){ printk(KERN_CRIT "Unican PCI region 0 is not MEM\n"); + can_pci_dev_put(pcidev); return -EIO; } candev->io_addr=pci_resource_start(pcidev,0); @@ -998,6 +999,11 @@ int unican_pci_init_hw_data(struct candevice_t *candev) return 0; } +void unican_pci_done_hw_data(struct candevice_t *candev) +{ + struct pci_dev *pcidev = candev->sysdevptr.pcidev; + can_pci_dev_put(pcidev); +} int unican_pci_init_chip_data(struct candevice_t *candev, int chipnr) { @@ -1014,6 +1020,7 @@ int unican_pci_register(struct hwspecops_t *hwspecops) hwspecops->release_io = unican_pci_release_io; hwspecops->reset = unican_reset; hwspecops->init_hw_data = unican_pci_init_hw_data; + hwspecops->done_hw_data = unican_pci_done_hw_data; hwspecops->init_chip_data = unican_pci_init_chip_data; hwspecops->init_obj_data = unican_init_obj_data; hwspecops->write_register = NULL;