Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
1ed69cd5
Commit
1ed69cd5
authored
9 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
Fix another corner case in the upper half CAN driver
parent
d6cc75dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
drivers/can.c
+26
-17
26 additions, 17 deletions
drivers/can.c
with
26 additions
and
17 deletions
drivers/can.c
+
26
−
17
View file @
1ed69cd5
...
...
@@ -1044,6 +1044,12 @@ int can_receive(FAR struct can_dev_s *dev, FAR struct can_hdr_s *hdr,
* Returned Value:
* OK on success; a negated errno on failure.
*
* Assumptions:
* Interrupts are disabled. This is required by can_xmit() which is called
* by this function. Interrupts are explicitly disabled when called
* through can_write(). Interrupts are expected be disabled when called
* from the CAN interrupt handler.
*
****************************************************************************/
int
can_txdone
(
FAR
struct
can_dev_s
*
dev
)
...
...
@@ -1143,6 +1149,10 @@ int can_txdone(FAR struct can_dev_s *dev)
* Returned Value:
* OK on success; a negated errno on failure.
*
* Assumptions:
* Interrupts are disabled. This is required by can_xmit() which is called
* by this function.
*
****************************************************************************/
#ifdef CONFIG_CAN_TXREADY
...
...
@@ -1154,26 +1164,20 @@ int can_txready(FAR struct can_dev_s *dev)
dev
->
cd_xmit
.
tx_head
,
dev
->
cd_xmit
.
tx_queue
,
dev
->
cd_xmit
.
tx_tail
,
dev
->
cd_ntxwaiters
);
/* Are there any threads waiting for space in the xmit FIFO? */
/* Verify that the xmit FIFO is not empty. This is safe because interrupts
* are always disabled when calling into can_xmit(); this cannot collide
* with ongoing activity from can_write().
*/
if
(
dev
->
cd_
ntxwaiters
>
0
)
if
(
dev
->
cd_
xmit
.
tx_head
!=
dev
->
cd_xmit
.
tx_tail
)
{
/*
Verify that the xmit FIFO is not empty.
*
*
REVISIT: This probably should be an assertion since we should only
*
be waiting for space in the xmit FIFO if the xmit FIFO is full.
/*
Send the next message in the S/W FIFO. In the case where the
*
H/W TX FIFO is not empty, this should add one more CAN message
*
to the H/W TX FIFO and can_txdone() should be called, making
*
space in the S/W FIFO
*/
if
(
dev
->
cd_xmit
.
tx_head
!=
dev
->
cd_xmit
.
tx_tail
)
{
/* Send the next message in the S/W FIFO. In the case where the
* H/W TX FIFO is not empty, this should add one more CAN message
* to the H/W TX FIFO and can_txdone() should be called, making
* space in the S/W FIFO
*/
(
void
)
can_xmit
(
dev
);
}
(
void
)
can_xmit
(
dev
);
/* Inform one waiter that new xmit space is available in the S/W FIFO.
* NOTE that is can_txdone() is, indeed, called twice that the tx_sem
...
...
@@ -1181,7 +1185,12 @@ int can_txready(FAR struct can_dev_s *dev)
* harmful.
*/
ret
=
sem_post
(
&
dev
->
cd_xmit
.
tx_sem
);
/* Are there any threads waiting for space in the xmit FIFO? */
if
(
dev
->
cd_ntxwaiters
>
0
)
{
ret
=
sem_post
(
&
dev
->
cd_xmit
.
tx_sem
);
}
}
return
ret
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment