]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/main.c
Fully working solution!
[lincan.git] / lincan / src / main.c
index 0e9f2a5cb607e041d8e786b03f961c275c4271e3..b59160be23c40afdc93f97ba6febfe7162c779b0 100644 (file)
@@ -413,7 +413,7 @@ int init_module(void)
 
 
 
-struct candevice_t* register_usbdev(const char *hwname,void *anydev){
+struct candevice_t* register_usbdev(const char *hwname,void *devdata,void (*chipdataregfnc)(struct canchip_t *ch,void *data)){
        int i=0, j, board=0;
        struct candevice_t *candev;
        struct canchip_t *chip;
@@ -446,7 +446,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;
+       candev->sysdevptr.anydev=devdata;
 
        if (candev->hwspecops->request_io(candev))
                goto request_io_error;
@@ -459,6 +459,8 @@ struct candevice_t* register_usbdev(const char *hwname,void *anydev){
                if((chip=candev->chip[j])==NULL)
                        continue;
 
+               chipdataregfnc(chip,devdata);
+
                if(chip->chipspecops->attach_to_chip(chip)<0) {
                        CANMSG("Initial attach to the chip HW failed\n");
                        goto interrupt_error;
@@ -591,29 +593,15 @@ void cleanup_usbdev(struct candevice_t *dev)
        }
 #endif
 
-       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]);
-               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]);
                chips_p[i]=NULL;
        }
 
        hardware_p->candevice[dev->candev_idx]=NULL;
        hardware_p->nr_boards--;
-       //kfree(hw[dev->candev_idx]);
        hw[dev->candev_idx]=NULL;
-       //can_checked_free(dev->hwspecops);
-       //can_checked_free(dev);
 
        candevice_done(dev);
        can_checked_free(dev);