]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/main.c
Minor repairs in sources
[lincan.git] / lincan / src / main.c
index 115354edfc8a14813f4a48045f4d84191d250223..1574169c3ffd161d9543e1a709d542c42baa32a8 100644 (file)
@@ -74,7 +74,7 @@
 #include "../include/can_iortl.h"
 #endif /*CAN_WITH_RTL*/
 
-#if defined(CONFIG_OC_LINCAN_CARD_ul_usb1)
+#if defined(CONFIG_OC_LINCAN_CARD_usbcan)
        #include "../include/usbcan.h"
 #endif
 
@@ -356,7 +356,7 @@ int init_module(void)
         }
 #endif
 
-#if defined(CONFIG_OC_LINCAN_CARD_ul_usb1)
+#if defined(CONFIG_OC_LINCAN_CARD_usbcan)
        res = usbcan_init();
        if (res){
                CANMSG("usb_register for usbcan failed. Error number %d.\n", res);
@@ -441,6 +441,7 @@ struct candevice_t* register_usbdev(const char *hwname,void *anydev){
 
        candev=hardware_p->candevice[board];
 
+       /* Adding link to usb device structure into can device */
        candev->sysdevptr.anydev=anydev;
 
        if (candev->hwspecops->request_io(candev))
@@ -559,6 +560,9 @@ void cleanup_usbdev(struct candevice_t *dev)
        int i=0;
        int dev_minor;
 
+       if (!dev)
+               return;
+
 #ifdef CONFIG_PROC_FS
        if (can_delete_procentry(dev))
                CANMSG("Error unregistering /proc/can entry.\n");
@@ -586,17 +590,17 @@ void cleanup_usbdev(struct candevice_t *dev)
        for(i=0;i<MAX_TOT_MSGOBJS;i++) {
                if(!objects_p[i]) continue;
                if(objects_p[i]->hostchip->hostdevice != dev) continue;
-               canqueue_ends_done_chip(objects_p[i]->qends);
-               can_checked_free(objects_p[i]->qends);
-               can_checked_free(objects_p[i]);
+               //canqueue_ends_done_chip(objects_p[i]->qends);
+               //can_checked_free(objects_p[i]->qends);
+               //can_checked_free(objects_p[i]);
                objects_p[i]=NULL;
        }
 
        for(i=0;i<MAX_TOT_CHIPS;i++){
                if(!chips_p[i]) continue;
                if(chips_p[i]->hostdevice != dev) continue;
-               can_checked_free(chips_p[i]->chipspecops);
-               can_checked_free(chips_p[i]);
+               //can_checked_free(chips_p[i]->chipspecops);
+               //can_checked_free(chips_p[i]);
                chips_p[i]=NULL;
        }
 
@@ -604,11 +608,11 @@ void cleanup_usbdev(struct candevice_t *dev)
        hardware_p->nr_boards--;
        //kfree(hw[dev->candev_idx]);
        hw[dev->candev_idx]=NULL;
-       can_checked_free(dev->hwspecops);
-       can_checked_free(dev);
-//     if ( can_del_mem_list() )
-//             CANMSG("Error deallocating memory\n");
+       //can_checked_free(dev->hwspecops);
+       //can_checked_free(dev);
 
+       candevice_done(dev);
+       can_checked_free(dev);
 }
 
 
@@ -618,8 +622,8 @@ void cleanup_module(void)
 {
        int res=0,i=0;
 
-#if defined(CONFIG_OC_LINCAN_CARD_ul_usb1)
-       ul_usb1_exit();
+#if defined(CONFIG_OC_LINCAN_CARD_usbcan)
+       usbcan_exit();
 #endif
 
 #ifdef CONFIG_PROC_FS