]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/finish.c
changed usb vendor and product id.
[lincan.git] / lincan / src / finish.c
index 0641048b914b522296d5057ac672cf390b6531b6..5e789ae4e56bb36881f5772727389ae9edd85c25 100644 (file)
@@ -14,7 +14,7 @@
 #include "../include/finish.h"
 #include "../include/setup.h"
 
-
+extern int next_minor;
 /**
  * msgobj_done - destroys one CAN message object
  * @obj: pointer to CAN message object structure
@@ -35,14 +35,17 @@ void msgobj_done(struct msgobj_t *obj)
                        CANMSG("msgobj_done: not registered in the canchip_t\n");
                obj->hostchip=NULL;
        }
-       
+
        if((obj->minor>=0)) {
-               if(objects_p[obj->minor] == obj)
+               if(objects_p[obj->minor] == obj){
                        objects_p[obj->minor] = NULL;
+                       if (--next_minor<0)
+                               next_minor=0;
+               }
                else
                        CANMSG("msgobj_done: not registered as minor\n");
        }
-       
+
        del_timer_sync(&obj->tx_timeout);
 
        if(obj->qends) {
@@ -66,6 +69,11 @@ void canchip_done(struct canchip_t *chip)
        int i;
        struct msgobj_t *obj;
 
+       if(chip->flags & CHIP_ATTACHED){
+               chip->chipspecops->release_chip(chip);
+               chip->flags &= ~CHIP_ATTACHED;
+       }
+
        if((chip->hostdevice) && (chip->chip_idx>=0)) {
                if(chip->hostdevice->chip[chip->chip_idx] == chip)
                        chip->hostdevice->chip[chip->chip_idx] = NULL;
@@ -74,16 +82,16 @@ void canchip_done(struct canchip_t *chip)
        }
 
        can_chip_free_irq(chip);
-               
+
        can_synchronize_irq(chip->chip_irq);
-       
+
        for(i=0; i<chip->max_objects; i++){
                if((obj=chip->msgobj[i])==NULL)
                        continue;
                msgobj_done(obj);
                can_checked_free(obj);
        }
-       
+
        can_checked_free(chip->chipspecops);
        chip->chipspecops=NULL;
 
@@ -97,13 +105,13 @@ void candevice_done(struct candevice_t *candev)
 {
        int i;
        struct canchip_t *chip;
-       
+
        for(i=0; i<candev->nr_all_chips; i++){
                if((chip=candev->chip[i])==NULL)
                        continue;
                canchip_done(chip);
                can_checked_free(chip);
-       
+
        }
        if(candev->flags & CANDEV_IO_RESERVED) {
                candev->hwspecops->release_io(candev);
@@ -121,8 +129,8 @@ void canhardware_done(struct canhardware_t *canhw)
 {
        int i;
        struct candevice_t *candev;
-       
-       for(i=0; i<canhw->nr_boards; i++){
+
+       for(i=0; i<MAX_HW_CARDS; i++){
                if((candev=canhw->candevice[i])==NULL)
                        continue;
                candevice_done(candev);