Ensure, that chip wakeup_tx function is not called for not fully setup CAN channel.
authorppisa <ppisa>
Wed, 8 Oct 2008 23:43:53 +0000 (23:43 +0000)
committerppisa <ppisa>
Wed, 8 Oct 2008 23:43:53 +0000 (23:43 +0000)
Problem found by Jan Kriz during USB<->CAN converter support development.

lincan/src/Makefile.omk
lincan/src/devcommon.c
lincan/src/finish.c

index b424979..38a2ba2 100644 (file)
@@ -39,7 +39,7 @@ endif
 
 ifneq ($(filter hms30c7202_can ns_dev_can,$(lincan_cards_SELECTED)),)
 $(warning Not finished C_CAN support requested)
-lincan_cards_SOURCES += c_can.c c_can_irq.c 
+lincan_cards_SOURCES += c_can.c c_can_irq.c
 endif
 
 ifneq ($(CONFIG_OC_LINCANRTL),y)
@@ -61,5 +61,5 @@ lincan_SOURCES = can_queue.c can_quekern.c main.c modparms.c \
                open.c close.c read.c write.c ioctl.c select.c fasync.c \
                proc.c ioctl_query.c ioctl_remote.c \
                $(lincan_cards_SOURCES) $(lincan_rtl_SOURCES)
-               
+
 endif #CONFIG_OC_LINCAN
index 8341254..bc4157d 100644 (file)
@@ -59,7 +59,10 @@ void canqueue_notify_chip(struct canque_ends_t *qends, struct canque_edge_t *qed
                case CANQUEUE_NOTIFY_PROC:
                    #ifndef CAN_WITH_RTL
                        /*wake_up(&qends->endinfo.chipinfo.daemonq);*/
-                       chip->chipspecops->wakeup_tx(chip, obj);
+                       if(canque_fifo_test_fl(&qedge->fifo, READY)){
+                               if ((chip) && (chip->flags & CHIP_ATTACHED))
+                                       chip->chipspecops->wakeup_tx(chip, obj);
+                       }
                    #else /*CAN_WITH_RTL*/
                        can_msgobj_set_fl(obj,TX_REQUEST);
                        canqueue_wake_chip_worker(qends, chip, obj);
index 532d868..d25e936 100644 (file)
@@ -66,8 +66,10 @@ void canchip_done(struct canchip_t *chip)
        int i;
        struct msgobj_t *obj;
 
-       if(chip->flags & CHIP_ATTACHED)
+       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)