-
Notifications
You must be signed in to change notification settings - Fork 3k
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
_acquire() function added & removed duplication in format/freq calls #4635
Conversation
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.
Seems fine to me
1. Private _acquire() function is added to avoid multiple locking/unlocking 2. format and frequency functions updated to use appropriate function calls instead of a aquire()
b2e1202
to
de89be3
Compare
drivers/SPI.cpp
Outdated
SPI::_owner = NULL; // Not that elegant, but works. rmeyer | ||
aquire(); | ||
spi_frequency(&_spi, _hz); | ||
_owner = this; |
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.
The owner can be changed here without ensuring that both frequency and format are set. The format setting maybe be incorrect on the next write since it was not updated.
A sequence similar to this would cause that:
spi_a.write(value_a) <-Internal call to _acquire will change owner and set frequency and format for SPI A
spi_b.frequency(freq_b) <- Owner changed to B and frequency set
spi_b.write(value_b) <- Interal call to _acquire won't change setting. Frequency will be set correctly for B and format will be set for A
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.
Thanks for updating this
drivers/SPI.h
Outdated
@@ -270,6 +270,12 @@ class SPI { | |||
int _bits; | |||
int _mode; | |||
int _hz; | |||
|
|||
private: | |||
/* Private acquire fucntion without locking/unlocking |
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.
typo fucntion
A question, now we use |
Private _acquire has no locking, but since we lock before using this function behavior will be same. We do not have virtual function for aquire in code base, but some user might be having it, hence old aquire API is kept unchanged. |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
Description
instead of a aquire()
Issue
#4626
Status
READY