-
Notifications
You must be signed in to change notification settings - Fork 8.3k
drivers: CAN: Abstract blocking send call #20890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: CAN: Abstract blocking send call #20890
Conversation
This commit moves the semaphore for a blocking call from the driver implementation to the stack of the caller. It reduces the complexity of the drivers and saves some RAM. Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
|
All checks passed. checkpatch (informational only, not a failure)Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
| struct can_send_wait send_wait; | ||
| int ret; | ||
|
|
||
| k_sem_init(&send_wait.sem, 0, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will introduce an overhead of initialising a semaphore on each can_send() call without any callback defined. I am not sure it is worth it.
It also seem very unlike any other API implementation in Zephyr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I am sort of ambivalent about it. Not sure how much of a trade-off the memory saved vs the calling overhead it is.
In terms of driver complexity I think it isn't a big improvement, we all had the same approach and it's not so hard to follow either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will introduce an overhead of initialising a semaphore on each can_send() call without any callback defined. I am not sure it is worth it.
The overhead of initializing is not that much. The blocking send call is used rarely, and in the current implementation, we need to maintain a sem for every mailbox just in case we will need it.
In terms of driver complexity I think it isn't a big improvement, we all had the same approach and it's not so hard to follow either.
The complexity raised with the timeout patch :-)
I really don't like #19707 in its current state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah gotcha. What would be your plan then, use that can_common_isr_callback_handler() for failing sends with timeouts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated #19707 on top of this PR. Looks better now!
This commit moves the semaphore for a blocking call from
the driver implementation to the stack of the caller.
It reduces the complexity of the drivers and saves some RAM.
Fixes #22379