From 5ef1c7139a39e79f3b7a4365808312f47abfe0e8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 23 Feb 2015 20:14:39 -0600 Subject: CAN driver: Another Ooops... Cannot save the updated driver open count if the we fail to initialize the CAN driver, causing the open to fail --- nuttx/drivers/can.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/nuttx/drivers/can.c b/nuttx/drivers/can.c index 6eb98cc0a..d36d7e00a 100644 --- a/nuttx/drivers/can.c +++ b/nuttx/drivers/can.c @@ -185,14 +185,20 @@ static int can_open(FAR struct file *filep) /* Finally, Enable the CAN RX interrupt */ dev_rxint(dev, true); + + /* Save the new open count on success */ + + dev->cd_ocount = 1; } irqrestore(flags); } + else + { + /* Save the incremented open count on success */ - /* Save the new open count on success */ - - dev->cd_ocount = tmp; + dev->cd_ocount = tmp; + } } sem_post(&dev->cd_closesem); -- cgit v1.2.3