Skip to content
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

device: Remove z_device_is_ready #72906

Merged
merged 1 commit into from
May 31, 2024

Conversation

ceolin
Copy link
Member

@ceolin ceolin commented May 16, 2024

This duplicates the functionality of device_is_ready.

@@ -40,13 +40,13 @@ const struct device *z_impl_device_get_binding(const char *name)
* performed. Reserve string comparisons for a fallback.
*/
STRUCT_SECTION_FOREACH(device, dev) {
if (z_device_is_ready(dev) && (dev->name == name)) {
if (z_impl_device_is_ready(dev) && (dev->name == name)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you calling the implementation directly here and not using device_is_ready instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we get here, it is already in kernel mode, so there is no need to do the check again whether you are in user mode or kernel mode (as in the syscall wrapper). Note that the wrapper calls the z_impl_* directly if already in kernel mode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we agree that calling implementation (z_impl) in general should not be the norm and that any direct usage of the implementation function need some justification? If yes, this justifcation should be in the commit message, i.e. what @dcpleung wrote above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nashif I have update the commit msg. Please take a look again.

@ceolin ceolin requested a review from nashif May 23, 2024 17:29
This duplicates the functionality of device_is_ready.

Calls for z_device_is_ready are being done in kernel mode, so it is
safe to call its implementation directly.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
@henrikbrixandersen henrikbrixandersen merged commit 65fc5b7 into zephyrproject-rtos:main May 31, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants