drivers: regulator: avoid improper access to internal structures

Nothing in the API description the delayed work structure sanctions
direct reference to internal fields.  Do not assume that a delayed
work item can be submitted without delay by invoking k_work_submit()
with a reference to the contained work item.  Instead submit with the
delayed API and no wait.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-11-22 06:31:34 -06:00 committed by Jukka Rissanen
commit 5263289631

View file

@ -190,7 +190,7 @@ static void start(struct onoff_manager *mgr,
__ASSERT_NO_MSG(data->task == WORK_TASK_UNDEFINED);
data->task = WORK_TASK_ENABLE;
data->notify = notify;
k_work_submit(&data->delayed_work.work);
k_delayed_work_submit(&data->delayed_work, K_NO_WAIT);
return;
}
#endif /* CONFIG_MULTITHREADING */
@ -228,7 +228,7 @@ static void stop(struct onoff_manager *mgr,
__ASSERT_NO_MSG(data->task == WORK_TASK_UNDEFINED);
data->task = WORK_TASK_DISABLE;
data->notify = notify;
k_work_submit(&data->delayed_work.work);
k_delayed_work_submit(&data->delayed_work, K_NO_WAIT);
return;
}
#endif /* CONFIG_MULTITHREADING */