Skip to content

Commit 00cfab6

Browse files
nixwardcarlescufi
authored andcommitted
mgmt: mcumgr: use delayed workqueue for reset
Same behaviour, less code, smaller code size. Signed-off-by: Nick Ward <[email protected]>
1 parent 70c7ac7 commit 00cfab6

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ LOG_MODULE_REGISTER(mcumgr_os_grp, CONFIG_MCUMGR_GRP_OS_LOG_LEVEL);
5959

6060
#ifdef CONFIG_REBOOT
6161
static void os_mgmt_reset_work_handler(struct k_work *work);
62-
static void os_mgmt_reset_cb(struct k_timer *timer);
6362

64-
K_WORK_DEFINE(os_mgmt_reset_work, os_mgmt_reset_work_handler);
65-
static K_TIMER_DEFINE(os_mgmt_reset_timer, os_mgmt_reset_cb, NULL);
63+
K_WORK_DELAYABLE_DEFINE(os_mgmt_reset_work, os_mgmt_reset_work_handler);
6664
#endif
6765

6866
/* This is passed to zcbor_map_start/end_endcode as a number of
@@ -358,13 +356,9 @@ static int os_mgmt_taskstat_read(struct smp_streamer *ctxt)
358356
*/
359357
static void os_mgmt_reset_work_handler(struct k_work *work)
360358
{
361-
sys_reboot(SYS_REBOOT_WARM);
362-
}
359+
ARG_UNUSED(work);
363360

364-
static void os_mgmt_reset_cb(struct k_timer *timer)
365-
{
366-
/* Reboot the system from the system workqueue thread. */
367-
k_work_submit(&os_mgmt_reset_work);
361+
sys_reboot(SYS_REBOOT_WARM);
368362
}
369363

370364
static int os_mgmt_reset(struct smp_streamer *ctxt)
@@ -404,8 +398,9 @@ static int os_mgmt_reset(struct smp_streamer *ctxt)
404398
}
405399
#endif
406400

407-
k_timer_start(&os_mgmt_reset_timer, K_MSEC(CONFIG_MCUMGR_GRP_OS_RESET_MS),
408-
K_NO_WAIT);
401+
/* Reboot the system from the system workqueue thread. */
402+
k_work_schedule(&os_mgmt_reset_work, K_MSEC(CONFIG_MCUMGR_GRP_OS_RESET_MS));
403+
409404
return 0;
410405
}
411406
#endif

0 commit comments

Comments
 (0)