From 8d418bf2d286085f0d4d893cdadde34d22458a3d Mon Sep 17 00:00:00 2001 From: ppisa Date: Wed, 8 Oct 2008 23:43:53 +0000 Subject: [PATCH] Ensure, that chip wakeup_tx function is not called for not fully setup CAN channel. Problem found by Jan Kriz during USB<->CAN converter support development. --- lincan/src/Makefile.omk | 4 ++-- lincan/src/devcommon.c | 5 ++++- lincan/src/finish.c | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lincan/src/Makefile.omk b/lincan/src/Makefile.omk index b424979..38a2ba2 100644 --- a/lincan/src/Makefile.omk +++ b/lincan/src/Makefile.omk @@ -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 diff --git a/lincan/src/devcommon.c b/lincan/src/devcommon.c index 8341254..bc4157d 100644 --- a/lincan/src/devcommon.c +++ b/lincan/src/devcommon.c @@ -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); diff --git a/lincan/src/finish.c b/lincan/src/finish.c index 532d868..d25e936 100644 --- a/lincan/src/finish.c +++ b/lincan/src/finish.c @@ -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) -- 2.39.2