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

samples: mesh_badge: conversion of k_work API #34299

Merged
merged 1 commit into from
Apr 20, 2021

Conversation

jfischer-no
Copy link
Collaborator

Replace all existing deprecated API with the recommended alternative.

Fixes #34097

@galak galak requested a review from pabigot April 19, 2021 13:17
Copy link
Collaborator

@pabigot pabigot left a comment

Choose a reason for hiding this comment

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

Approving based on the expectation this has been tested; AFAICT it's unchanged from the rote conversion patch.

I think several of the calls could use schedule instead of reschedule, which would preserve deadlines better. With reschedule there's theoretically a potential for livelock: the trigger event occurs fast enough that the work is never executed. But that's not new behavior, just not taking advantage of new capabilities.

k_delayed_work_init(&motion_work, motion_timeout);
k_delayed_work_submit(&motion_work, MOTION_TIMEOUT);
k_work_init_delayable(&motion_work, motion_timeout);
k_work_reschedule(&motion_work, MOTION_TIMEOUT);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could be k_work_schedule() since there is no earlier timeout that might need to be overridden.

@@ -93,7 +93,7 @@ static void motion_timeout(struct k_work *work)
printk("power save\n");

if (!mesh_is_initialized()) {
k_delayed_work_submit(&motion_work, MOTION_TIMEOUT);
k_work_reschedule(&motion_work, MOTION_TIMEOUT);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this too could be k_work_schedule(), in case a motion event was detected after the work was queued but before the work thread got to it.

Replace all existing deprecated API with the recommended alternative.

Be aware that this does not address architectural errors in the use
of the work API.

Fixes zephyrproject-rtos#34097

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
@carlescufi carlescufi merged commit 20f5022 into zephyrproject-rtos:master Apr 20, 2021
@jfischer-no jfischer-no deleted the pr-fix-34097 branch April 20, 2021 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert samples/boards/reel_board/mesh_badge to new kwork API
4 participants