Skip to content

Commit 7b8bce8

Browse files
pabigotnashif
authored andcommitted
net: openthread: radio: switch to new API for k_work_pending
Uses of k_work_pending are to be replaced by k_work_is_pending which conforms to current proposed naming guidelines. Switch to the new function. Also initialize the private work structure at build time, rather than on each iteration (it is not permitted to invoke work API on an uninitialized work item). The implementation here is racy: that a work item is pending does not mean changes since it was first submitted are guaranteed to be seen when the work item begins (began) executing. A better solution would be to have transmit_message be able to determine whether there is unprocessed work. Then the work item can be submitted unconditionally. Signed-off-by: Peter Bigot <[email protected]>
1 parent e373004 commit 7b8bce8

File tree

1 file changed

+2
-3
lines changed
  • subsys/net/lib/openthread/platform

1 file changed

+2
-3
lines changed

subsys/net/lib/openthread/platform/radio.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,13 @@ int notify_new_tx_frame(struct net_pkt *pkt)
379379

380380
static int run_tx_task(otInstance *aInstance)
381381
{
382-
static struct k_work tx_job;
382+
static K_WORK_DEFINE(tx_job, transmit_message);
383383

384384
ARG_UNUSED(aInstance);
385385

386-
if (k_work_pending(&tx_job) == 0) {
386+
if (!k_work_is_pending(&tx_job)) {
387387
sState = OT_RADIO_STATE_TRANSMIT;
388388

389-
k_work_init(&tx_job, transmit_message);
390389
k_work_submit_to_queue(&ot_work_q, &tx_job);
391390
return 0;
392391
} else {

0 commit comments

Comments
 (0)