diff options
Diffstat (limited to 'nuttx/drivers/can.c')
-rw-r--r-- | nuttx/drivers/can.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/nuttx/drivers/can.c b/nuttx/drivers/can.c index 278acbd4f..f1a57925e 100644 --- a/nuttx/drivers/can.c +++ b/nuttx/drivers/can.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/can.c * - * Copyright (C) 2008-2009, 2011-2012, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2012, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -116,6 +116,9 @@ static const struct file_operations g_canops = #ifndef CONFIG_DISABLE_POLL , 0 /* poll */ #endif +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + , 0 /* unlink */ +#endif }; /**************************************************************************** @@ -183,13 +186,21 @@ static int can_open(FAR struct file *filep) dev_rxint(dev, true); - /* Save the new open count on success */ + /* Save the new open count only on success */ - dev->cd_ocount = tmp; + dev->cd_ocount = 1; } + irqrestore(flags); } + else + { + /* Save the incremented open count */ + + dev->cd_ocount = tmp; + } } + sem_post(&dev->cd_closesem); } @@ -336,9 +347,9 @@ static ssize_t can_read(FAR struct file *filep, FAR char *buffer, int msglen = CAN_MSGLEN(msg->cm_hdr.ch_dlc); if (nread + msglen > buflen) - { - break; - } + { + break; + } /* Copy the message to the user buffer */ @@ -409,7 +420,7 @@ static int can_xmit(FAR struct can_dev_s *dev) while (dev->cd_xmit.tx_queue != dev->cd_xmit.tx_tail && dev_txready(dev)) { - /* No.. The fifo should not be empty in this case */ + /* No.. The FIFO should not be empty in this case */ DEBUGASSERT(dev->cd_xmit.tx_head != dev->cd_xmit.tx_tail); @@ -487,7 +498,7 @@ static ssize_t can_write(FAR struct file *filep, FAR const char *buffer, nexttail = 0; } - /* If the XMIT fifo becomes full, then wait for space to become available */ + /* If the XMIT FIFO becomes full, then wait for space to become available */ while (nexttail == fifo->tx_head) { @@ -637,7 +648,7 @@ static int can_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { FAR struct inode *inode = filep->f_inode; FAR struct can_dev_s *dev = inode->i_private; - int ret = OK; + int ret = OK; canvdbg("cmd: %d arg: %ld\n", cmd, arg); |