Skip to content

Commit 1685011

Browse files
committed
samples: bluetooth: Fix usage of nrfx error codes
Since nrfx 4, driver APIs return errno values. Comparing against NRFX_SUCCESS is therefore wrong. Unfortunately such cases cannot be found by enabling compiler warnings. Signed-off-by: Rubin Gerritsen <[email protected]>
1 parent 7e270a4 commit 1685011

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

samples/bluetooth/conn_time_sync/src/controller_time_nrf52.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ static int timer_config(void)
121121
uint32_t tep;
122122

123123
ret = nrfx_timer_init(&app_timer_instance, &timer_cfg, unused_timer_isr_handler);
124-
if (ret != NRFX_SUCCESS) {
125-
printk("Failed initializing timer (ret: %d)\n", ret - NRFX_ERROR_BASE_NUM);
124+
if (ret != 0) {
125+
printk("Failed initializing timer (ret: %d)\n", ret);
126126
return -ENODEV;
127127
}
128128

samples/bluetooth/conn_time_sync/src/controller_time_nrf53_app.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ static int timer_config(void)
9595
uint32_t tep = nrfx_timer_task_address_get(&app_timer_instance, NRF_TIMER_TASK_CLEAR);
9696

9797
ret = nrfx_timer_init(&app_timer_instance, &timer_cfg, unused_timer_isr_handler);
98-
if (ret != NRFX_SUCCESS) {
99-
printk("Failed initializing timer (ret: %d)\n", ret - NRFX_ERROR_BASE_NUM);
98+
if (ret != 0) {
99+
printk("Failed initializing timer (ret: %d)\n", ret);
100100
return -ENODEV;
101101
}
102102

samples/bluetooth/conn_time_sync/src/controller_time_nrf54.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ void controller_time_trigger_set(uint64_t timestamp_us)
4242
};
4343

4444
ret = nrfx_grtc_syscounter_cc_absolute_set(&chan_data, timestamp_us, false);
45-
if (ret != NRFX_SUCCESS) {
46-
printk("Failed setting CC (ret: %d)\n", ret - NRFX_ERROR_BASE_NUM);
45+
if (ret != 0) {
46+
printk("Failed setting CC (ret: %d)\n", ret);
4747
}
4848
}
4949

samples/bluetooth/direct_test_mode/src/dtm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,15 +795,15 @@ BUILD_ASSERT(false, "No Clock Control driver");
795795

796796
static int timer_init(void)
797797
{
798-
nrfx_err_t err;
798+
int err;
799799
nrfx_timer_config_t timer_cfg = {
800800
.frequency = NRFX_MHZ_TO_HZ(1),
801801
.mode = NRF_TIMER_MODE_TIMER,
802802
.bit_width = NRF_TIMER_BIT_WIDTH_16,
803803
};
804804

805805
err = nrfx_timer_init(&dtm_inst.timer, &timer_cfg, dtm_timer_handler);
806-
if (err != NRFX_SUCCESS) {
806+
if (err != 0) {
807807
printk("nrfx_timer_init failed with: %d\n", err);
808808
return -EAGAIN;
809809
}
@@ -817,7 +817,7 @@ static int timer_init(void)
817817
#if NRF52_ERRATA_172_PRESENT
818818
static int anomaly_timer_init(void)
819819
{
820-
nrfx_err_t err;
820+
int err;
821821
nrfx_timer_config_t timer_cfg = {
822822
.frequency = NRFX_KHZ_TO_HZ(125),
823823
.mode = NRF_TIMER_MODE_TIMER,
@@ -826,7 +826,7 @@ static int anomaly_timer_init(void)
826826

827827
err = nrfx_timer_init(&dtm_inst.anomaly_timer, &timer_cfg,
828828
anomaly_timer_handler);
829-
if (err != NRFX_SUCCESS) {
829+
if (err != 0) {
830830
printk("nrfx_timer_init failed with: %d\n", err);
831831
return -EAGAIN;
832832
}

samples/bluetooth/iso_time_sync/src/controller_time_nrf52.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ static int timer_config(void)
121121
uint32_t tep = nrfx_timer_task_address_get(&app_timer_instance, NRF_TIMER_TASK_CLEAR);
122122

123123
ret = nrfx_timer_init(&app_timer_instance, &timer_cfg, unused_timer_isr_handler);
124-
if (ret != NRFX_SUCCESS) {
125-
printk("Failed initializing timer (ret: %d)\n", ret - NRFX_ERROR_BASE_NUM);
124+
if (ret != 0) {
125+
printk("Failed initializing timer (ret: %d)\n", ret);
126126
return -ENODEV;
127127
}
128128

samples/bluetooth/iso_time_sync/src/controller_time_nrf53_app.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ static int timer_config(void)
9595
uint32_t tep = nrfx_timer_task_address_get(&app_timer_instance, NRF_TIMER_TASK_CLEAR);
9696

9797
ret = nrfx_timer_init(&app_timer_instance, &timer_cfg, unused_timer_isr_handler);
98-
if (ret != NRFX_SUCCESS) {
99-
printk("Failed initializing timer (ret: %d)\n", ret - NRFX_ERROR_BASE_NUM);
98+
if (ret != 0) {
99+
printk("Failed initializing timer (ret: %d)\n", ret);
100100
return -ENODEV;
101101
}
102102

samples/bluetooth/iso_time_sync/src/controller_time_nrf54.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ void controller_time_trigger_set(uint64_t timestamp_us)
4242
};
4343

4444
ret = nrfx_grtc_syscounter_cc_absolute_set(&chan_data, timestamp_us, false);
45-
if (ret != NRFX_SUCCESS) {
46-
printk("Failed setting CC (ret: %d)\n", ret - NRFX_ERROR_BASE_NUM);
45+
if (ret != 0) {
46+
printk("Failed setting CC (ret: %d)\n", ret);
4747
}
4848
}
4949

0 commit comments

Comments
 (0)