From 8a2422db1fcf5992146ca570ea69484226a141ff Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Fri, 13 Oct 2023 20:57:49 +0700 Subject: [PATCH] firmware/layer1: clean up l1s_tch_cmd(): reduce nesting Change-Id: If4f0bb37cb3e12e09078027461cd5040524e43b2 Related: OS#4396 --- src/target/firmware/layer1/prim_tch.c | 28 +++++++++++---------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/target/firmware/layer1/prim_tch.c b/src/target/firmware/layer1/prim_tch.c index 1e3ca7521..7d5c1f466 100644 --- a/src/target/firmware/layer1/prim_tch.c +++ b/src/target/firmware/layer1/prim_tch.c @@ -434,7 +434,6 @@ static int l1s_tch_cmd(__unused uint8_t p1, __unused uint8_t p2, uint16_t p3) if (traffic_tx_now) { volatile uint16_t *traffic_buf; struct msgb *msg; - const uint8_t *data; /* Reset play mode */ dsp_api.ndb->d_tch_mode &= ~B_PLAY_UL; @@ -448,30 +447,25 @@ static int l1s_tch_cmd(__unused uint8_t p1, __unused uint8_t p2, uint16_t p3) /* Pull Traffic data (if any) */ msg = msgb_dequeue(&l1s.tx_queue[L1S_CHAN_TRAFFIC]); + if (msg == NULL) + goto skip_tx_traffic; /* Copy actual data, skipping the information block [0,1,2] */ - if (msg) { - data = msg->l2h; - dsp_memcpy_to_api(&traffic_buf[3], data, 33, 1); + dsp_memcpy_to_api(&traffic_buf[3], msgb_l2(msg), 33, 1); - traffic_buf[0] = (1 << B_BLUD); /* 1st word: Set B_BLU bit. */ - traffic_buf[1] = 0; /* 2nd word: cleared. */ - traffic_buf[2] = 0; /* 3nd word: cleared. */ - } + traffic_buf[0] = (1 << B_BLUD); /* 1st word: Set B_BLU bit. */ + traffic_buf[1] = 0; /* 2nd word: cleared. */ + traffic_buf[2] = 0; /* 3nd word: cleared. */ - if (msg) - dsp_api.ndb->d_tch_mode |= B_PLAY_UL; + dsp_api.ndb->d_tch_mode |= B_PLAY_UL; /* Indicate completion (FIXME: early but easier this way for now) */ - if (msg) { - last_tx_tch_fn = l1s.next_time.fn; - last_tx_tch_type |= TX_TYPE_TRAFFIC; - l1s_compl_sched(L1_COMPL_TX_TCH); - } + last_tx_tch_fn = l1s.next_time.fn; + last_tx_tch_type |= TX_TYPE_TRAFFIC; + l1s_compl_sched(L1_COMPL_TX_TCH); /* Free msg now that we're done with it */ - if (msg) - msgb_free(msg); + msgb_free(msg); } skip_tx_traffic: