]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/sysdep_lnx.c
LinCAN sources go through big white-space cleanup.
[lincan.git] / lincan / src / sysdep_lnx.c
index 2220890144618a3383816829feb35a272101af82..03f45509abf7ed423648b4ca33693c82345e1f0b 100644 (file)
  *
  * The function is used in the driver initialization phase to catch possible memory
  * leaks for future driver finalization or case, that driver initialization fail.
- * 
+ *
  * Return Value: pointer to the allocated memory or NULL in the case of fail
  */
 void *can_checked_malloc(size_t size)
 {
        struct mem_addr *mem_new;
        void *address_p;
-       
+
        address_p=kmalloc(size,GFP_KERNEL);
        if(address_p == NULL) {
                CANMSG("can_checked_malloc: out of the memory\n");
@@ -109,9 +109,9 @@ int can_checked_free(void *address_p)
                kfree(address_p);
                return 0;
        }
-       
+
        CANMSG("can_checked_free: address %p not found on the mem list\n", address_p);
-       
+
        kfree(address_p);
        return -1;
 }
@@ -142,7 +142,7 @@ int can_del_mem_list(void)
                kfree(mem->address);
                kfree(mem);
        }
-       
+
        return 0;
 }
 
@@ -214,6 +214,37 @@ void can_release_mem_region(unsigned long start, unsigned long n)
     #endif
 }
 
+#ifdef CAN_ENABLE_PCI_SUPPORT
+
+struct pci_dev *can_pci_get_next_untaken_device(unsigned int vendor, unsigned int device)
+{
+       struct pci_dev *pcidev = NULL;
+
+       do {
+               pcidev = can_pci_get_device(vendor, device, pcidev);
+               if(pcidev == NULL)
+                       return NULL;
+       } while(can_check_dev_taken(pcidev));
+
+       return pcidev;
+}
+
+struct pci_dev *can_pci_get_next_untaken_subsyst(unsigned int vendor, unsigned int device,
+                       unsigned int ss_vendor, unsigned int ss_device)
+{
+       struct pci_dev *pcidev = NULL;
+
+       do {
+               pcidev = can_pci_get_subsys(vendor, device, ss_vendor, ss_device, pcidev);
+               if(pcidev == NULL)
+                       return NULL;
+       } while(can_check_dev_taken(pcidev));
+
+       return pcidev;
+}
+
+#endif /*CAN_ENABLE_PCI_SUPPORT*/
+
 #ifndef CAN_WITH_RTL
 
 /**
@@ -223,7 +254,7 @@ void can_release_mem_region(unsigned long start, unsigned long n)
  *     The CAN driver uses this pointer to store relationship of interrupt
  *     to chip state structure - @struct canchip_t
  * @regs: system dependent value pointing to registers stored in exception frame
- * 
+ *
  * File: src/setup.c
  */
 can_irqreturn_t can_default_irq_dispatch(CAN_IRQ_HANDLER_ARGS(irq_number, dev_id))
@@ -249,7 +280,7 @@ int can_chip_setup_irq(struct canchip_t *chip)
                return 0;
        if(chip->flags & CHIP_IRQ_CUSTOM)
                return 1;
-                       
+
        if ((chip->flags & CHIP_IRQ_VME) == 0) {
                if (request_irq(chip->chip_irq,can_default_irq_dispatch,IRQF_SHARED,DEVICE_NAME,chip))
                        return -1;
@@ -263,7 +294,7 @@ int can_chip_setup_irq(struct canchip_t *chip)
                        CANMSG("Bad irq parameter. (1 <= irq <= 255).\n");
                        return -EINVAL;
                }
-               
+
                request_vmeirq(chip->chip_irq, can_default_irq_dispatch, chip);
                DEBUGMSG("Registered VME interrupt vector %d\n",chip->chip_irq);
                chip->flags |= CHIP_IRQ_SETUP;
@@ -285,7 +316,7 @@ void can_chip_free_irq(struct canchip_t *chip)
 
                if ((chip->flags & CHIP_IRQ_VME) == 0)
                        free_irq(chip->chip_irq, chip);
-               else { 
+               else {
 #ifdef CAN_ENABLE_VME_SUPPORT
                        free_vmeirq(chip->chip_irq);
 #endif