Skip to content

Commit beed762

Browse files
edmontcarlescufi
authored andcommitted
net: openthread: style adjustments in radio.c
Avoid splitting lines when possible while keeping length below 100 chars. Some other minor style corrections. Signed-off-by: Eduardo Montoya <[email protected]>
1 parent 2e8836f commit beed762

File tree

1 file changed

+23
-43
lines changed
  • subsys/net/lib/openthread/platform

1 file changed

+23
-43
lines changed

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

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_OPENTHREAD_L2_LOG_LEVEL);
4545
#define FRAME_TYPE_ACK 0x02
4646

4747
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
48-
#define OT_WORKER_PRIORITY K_PRIO_COOP(CONFIG_OPENTHREAD_THREAD_PRIORITY)
48+
#define OT_WORKER_PRIORITY K_PRIO_COOP(CONFIG_OPENTHREAD_THREAD_PRIORITY)
4949
#else
50-
#define OT_WORKER_PRIORITY K_PRIO_PREEMPT(CONFIG_OPENTHREAD_THREAD_PRIORITY)
50+
#define OT_WORKER_PRIORITY K_PRIO_PREEMPT(CONFIG_OPENTHREAD_THREAD_PRIORITY)
5151
#endif
5252

5353
enum pending_events {
@@ -82,7 +82,7 @@ static uint16_t channel;
8282
static bool promiscuous;
8383

8484
static uint16_t energy_detection_time;
85-
static uint8_t energy_detection_channel;
85+
static uint8_t energy_detection_channel;
8686
static int16_t energy_detected_value;
8787

8888
ATOMIC_DEFINE(pending_events, PENDING_EVENT_COUNT);
@@ -169,8 +169,7 @@ void handle_radio_event(const struct device *dev, enum ieee802154_event evt,
169169
break;
170170
case IEEE802154_EVENT_RX_FAILED:
171171
if (sState == OT_RADIO_STATE_RECEIVE) {
172-
switch (*(enum ieee802154_rx_fail_reason *)
173-
event_params) {
172+
switch (*(enum ieee802154_rx_fail_reason *) event_params) {
174173
case IEEE802154_RX_FAIL_NOT_RECEIVED:
175174
rx_result = OT_ERROR_NO_FRAME_RECEIVED;
176175
break;
@@ -180,8 +179,7 @@ void handle_radio_event(const struct device *dev, enum ieee802154_event evt,
180179
break;
181180

182181
case IEEE802154_RX_FAIL_ADDR_FILTERED:
183-
rx_result
184-
= OT_ERROR_DESTINATION_ADDRESS_FILTERED;
182+
rx_result = OT_ERROR_DESTINATION_ADDRESS_FILTERED;
185183
break;
186184

187185
case IEEE802154_RX_FAIL_OTHER:
@@ -262,8 +260,7 @@ void transmit_message(struct k_work *tx_job)
262260
if (sTransmitFrame.mInfo.mTxInfo.mCsmaCaEnabled) {
263261
if (radio_api->get_capabilities(radio_dev) &
264262
IEEE802154_HW_CSMA) {
265-
if (radio_api->tx(radio_dev,
266-
IEEE802154_TX_MODE_CSMA_CA,
263+
if (radio_api->tx(radio_dev, IEEE802154_TX_MODE_CSMA_CA,
267264
tx_pkt, tx_payload) != 0) {
268265
tx_result = OT_ERROR_CHANNEL_ACCESS_FAILURE;
269266
}
@@ -273,8 +270,7 @@ void transmit_message(struct k_work *tx_job)
273270
tx_result = OT_ERROR_CHANNEL_ACCESS_FAILURE;
274271
}
275272
} else {
276-
if (radio_api->tx(radio_dev, IEEE802154_TX_MODE_DIRECT,
277-
tx_pkt, tx_payload)) {
273+
if (radio_api->tx(radio_dev, IEEE802154_TX_MODE_DIRECT, tx_pkt, tx_payload)) {
278274
tx_result = OT_ERROR_CHANNEL_ACCESS_FAILURE;
279275
}
280276
}
@@ -285,8 +281,7 @@ void transmit_message(struct k_work *tx_job)
285281
static inline void handle_tx_done(otInstance *aInstance)
286282
{
287283
if (IS_ENABLED(CONFIG_OPENTHREAD_DIAG) && otPlatDiagModeGet()) {
288-
otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame,
289-
tx_result);
284+
otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, tx_result);
290285
} else {
291286
if (sTransmitFrame.mPsdu[0] & IEEE802154_AR_FLAG_SET) {
292287
if (ack_frame.mLength == 0) {
@@ -298,8 +293,7 @@ static inline void handle_tx_done(otInstance *aInstance)
298293
&ack_frame, tx_result);
299294
}
300295
} else {
301-
otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL,
302-
tx_result);
296+
otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, tx_result);
303297
}
304298
ack_frame.mLength = 0;
305299
}
@@ -316,22 +310,19 @@ static void openthread_handle_received_frame(otInstance *instance,
316310
recv_frame.mChannel = platformRadioChannelGet(instance);
317311
recv_frame.mInfo.mRxInfo.mLqi = net_pkt_ieee802154_lqi(pkt);
318312
recv_frame.mInfo.mRxInfo.mRssi = net_pkt_ieee802154_rssi(pkt);
319-
recv_frame.mInfo.mRxInfo.mAckedWithFramePending =
320-
net_pkt_ieee802154_ack_fpb(pkt);
313+
recv_frame.mInfo.mRxInfo.mAckedWithFramePending = net_pkt_ieee802154_ack_fpb(pkt);
321314

322315
#if defined(CONFIG_NET_PKT_TIMESTAMP)
323316
struct net_ptp_time *time = net_pkt_timestamp(pkt);
324317

325-
recv_frame.mInfo.mRxInfo.mTimestamp = time->second * USEC_PER_SEC +
326-
time->nanosecond / NSEC_PER_USEC;
318+
recv_frame.mInfo.mRxInfo.mTimestamp =
319+
time->second * USEC_PER_SEC + time->nanosecond / NSEC_PER_USEC;
327320
#endif
328321

329322
if (IS_ENABLED(CONFIG_OPENTHREAD_DIAG) && otPlatDiagModeGet()) {
330-
otPlatDiagRadioReceiveDone(instance,
331-
&recv_frame, OT_ERROR_NONE);
323+
otPlatDiagRadioReceiveDone(instance, &recv_frame, OT_ERROR_NONE);
332324
} else {
333-
otPlatRadioReceiveDone(instance,
334-
&recv_frame, OT_ERROR_NONE);
325+
otPlatRadioReceiveDone(instance, &recv_frame, OT_ERROR_NONE);
335326
}
336327

337328
net_pkt_unref(pkt);
@@ -354,8 +345,7 @@ static void openthread_handle_frame_to_send(otInstance *instance,
354345
}
355346

356347
for (buf = pkt->buffer; buf; buf = buf->frags) {
357-
if (otMessageAppend(message, buf->data,
358-
buf->len) != OT_ERROR_NONE) {
348+
if (otMessageAppend(message, buf->data, buf->len) != OT_ERROR_NONE) {
359349
NET_ERR("Error while appending to otMessage");
360350
otMessageFree(message);
361351
goto exit;
@@ -412,14 +402,11 @@ void platformRadioProcess(otInstance *aInstance)
412402
struct net_pkt *tx_pkt;
413403

414404
reset_pending_event(PENDING_EVENT_FRAME_TO_SEND);
415-
while ((tx_pkt = (struct net_pkt *)k_fifo_get(&tx_pkt_fifo,
416-
K_NO_WAIT))
417-
!= NULL) {
405+
while ((tx_pkt = (struct net_pkt *) k_fifo_get(&tx_pkt_fifo, K_NO_WAIT)) != NULL) {
418406
if (IS_ENABLED(CONFIG_OPENTHREAD_COPROCESSOR_RCP)) {
419407
net_pkt_unref(tx_pkt);
420408
} else {
421-
openthread_handle_frame_to_send(aInstance,
422-
tx_pkt);
409+
openthread_handle_frame_to_send(aInstance, tx_pkt);
423410
}
424411
}
425412
}
@@ -428,21 +415,17 @@ void platformRadioProcess(otInstance *aInstance)
428415
struct net_pkt *rx_pkt;
429416

430417
reset_pending_event(PENDING_EVENT_FRAME_RECEIVED);
431-
while ((rx_pkt = (struct net_pkt *)k_fifo_get(&rx_pkt_fifo,
432-
K_NO_WAIT))
433-
!= NULL) {
418+
while ((rx_pkt = (struct net_pkt *) k_fifo_get(&rx_pkt_fifo, K_NO_WAIT)) != NULL) {
434419
openthread_handle_received_frame(aInstance, rx_pkt);
435420
}
436421
}
437422

438423
if (is_pending_event_set(PENDING_EVENT_RX_FAILED)) {
439424
reset_pending_event(PENDING_EVENT_RX_FAILED);
440425
if (IS_ENABLED(CONFIG_OPENTHREAD_DIAG) && otPlatDiagModeGet()) {
441-
otPlatDiagRadioReceiveDone(aInstance,
442-
NULL, rx_result);
426+
otPlatDiagRadioReceiveDone(aInstance, NULL, rx_result);
443427
} else {
444-
otPlatRadioReceiveDone(aInstance,
445-
NULL, rx_result);
428+
otPlatRadioReceiveDone(aInstance, NULL, rx_result);
446429
}
447430
}
448431

@@ -477,8 +460,7 @@ void platformRadioProcess(otInstance *aInstance)
477460
}
478461

479462
if (is_pending_event_set(PENDING_EVENT_DETECT_ENERGY_DONE)) {
480-
otPlatRadioEnergyScanDone(aInstance,
481-
(int8_t)energy_detected_value);
463+
otPlatRadioEnergyScanDone(aInstance, (int8_t) energy_detected_value);
482464
reset_pending_event(PENDING_EVENT_DETECT_ENERGY_DONE);
483465
}
484466
}
@@ -589,8 +571,7 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aPacket)
589571

590572
radio_caps = radio_api->get_capabilities(radio_dev);
591573

592-
if ((sState == OT_RADIO_STATE_RECEIVE) ||
593-
(radio_caps & IEEE802154_HW_SLEEP_TO_TX)) {
574+
if ((sState == OT_RADIO_STATE_RECEIVE) || (radio_caps & IEEE802154_HW_SLEEP_TO_TX)) {
594575
if (run_tx_task(aInstance) == 0) {
595576
error = OT_ERROR_NONE;
596577
}
@@ -715,8 +696,7 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel,
715696

716697
radio_api->set_channel(radio_dev, aScanChannel);
717698

718-
if (radio_api->ed_scan(radio_dev, energy_detection_time,
719-
energy_detected) != 0) {
699+
if (radio_api->ed_scan(radio_dev, energy_detection_time, energy_detected) != 0) {
720700
/*
721701
* OpenThread API does not accept failure of this function,
722702
* it can return 'No Error' or 'Not Implemented' error only.

0 commit comments

Comments
 (0)