Skip to content

Commit 4677e08

Browse files
committed
drivers: nrf: Clean up remnants of nrfx error codes
Starting with nrfx 4.0.0, the nrfx_err_t, NRFX_SUCCESS and NRFX_ERROR_* have been deprecated. Most of them were removed here: #99399 but a few were missed. Signed-off-by: Carles Cufi <[email protected]>
1 parent 1814b90 commit 4677e08

File tree

8 files changed

+34
-44
lines changed

8 files changed

+34
-44
lines changed

drivers/i2c/i2c_nrfx_twi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static int i2c_nrfx_twi_transfer(const struct device *dev,
9090
break;
9191
}
9292

93-
if (data->res != NRFX_SUCCESS) {
93+
if (data->res != 0) {
9494
ret = -EIO;
9595
break;
9696
}

drivers/i2c/i2c_nrfx_twi_common.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ struct i2c_nrfx_twi_config {
3636
const struct pinctrl_dev_config *pcfg;
3737
};
3838

39-
static inline nrfx_err_t i2c_nrfx_twi_get_evt_result(nrfx_twi_evt_t const *p_event)
39+
static inline int i2c_nrfx_twi_get_evt_result(nrfx_twi_evt_t const *p_event)
4040
{
4141
switch (p_event->type) {
4242
case NRFX_TWI_EVT_DONE:
43-
return NRFX_SUCCESS;
43+
return 0;
4444
case NRFX_TWI_EVT_ADDRESS_NACK:
45-
return NRFX_ERROR_DRV_TWI_ERR_ANACK;
45+
__fallthrough;
4646
case NRFX_TWI_EVT_DATA_NACK:
47-
return NRFX_ERROR_DRV_TWI_ERR_DNACK;
47+
return -EIO;
4848
default:
49-
return NRFX_ERROR_INTERNAL;
49+
return -EINVAL;
5050
}
5151
}
5252

drivers/i2c/i2c_nrfx_twi_rtio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static void event_handler(nrfx_twi_evt_t const *p_event, void *p_context)
154154
const struct device *dev = p_context;
155155
int status = 0;
156156

157-
if (i2c_nrfx_twi_get_evt_result(p_event) != NRFX_SUCCESS) {
157+
if (i2c_nrfx_twi_get_evt_result(p_event) != 0) {
158158
status = -EIO;
159159
}
160160

drivers/usb/common/nrf_usbd_common/nrf_usbd_common.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ typedef struct {
248248
size_t transfer_cnt;
249249
/** Configured endpoint size. */
250250
uint16_t max_packet_size;
251-
/** NRFX_SUCCESS or error code, never NRFX_ERROR_BUSY - this one is calculated. */
251+
/** NRF_USBD_COMMON_EP_* - this one is calculated. */
252252
nrf_usbd_common_ep_status_t status;
253253
} usbd_ep_state_t;
254254

@@ -1096,12 +1096,12 @@ void nrf_usbd_common_irq_handler(void)
10961096
/** @} */
10971097
/** @} */
10981098

1099-
nrfx_err_t nrf_usbd_common_init(nrf_usbd_common_event_handler_t event_handler)
1099+
int nrf_usbd_common_init(nrf_usbd_common_event_handler_t event_handler)
11001100
{
11011101
__ASSERT_NO_MSG(event_handler);
11021102

11031103
if (m_drv_state != NRFX_DRV_STATE_UNINITIALIZED) {
1104-
return NRFX_ERROR_INVALID_STATE;
1104+
return -EALREADY;
11051105
}
11061106

11071107
m_event_handler = event_handler;
@@ -1132,7 +1132,7 @@ nrfx_err_t nrf_usbd_common_init(nrf_usbd_common_event_handler_t event_handler)
11321132
p_state->transfer_cnt = 0;
11331133
}
11341134

1135-
return NRFX_SUCCESS;
1135+
return 0;
11361136
}
11371137

11381138
void nrf_usbd_common_uninit(void)
@@ -1458,18 +1458,18 @@ void nrf_usbd_common_ep_disable(nrf_usbd_common_ep_t ep)
14581458
usbd_int_rise();
14591459
}
14601460

1461-
nrfx_err_t nrf_usbd_common_ep_transfer(nrf_usbd_common_ep_t ep,
1461+
int nrf_usbd_common_ep_transfer(nrf_usbd_common_ep_t ep,
14621462
nrf_usbd_common_transfer_t const *p_transfer)
14631463
{
1464-
nrfx_err_t ret;
1464+
int ret;
14651465
const uint8_t ep_bitpos = ep2bit(ep);
14661466
unsigned int irq_lock_key = irq_lock();
14671467

14681468
__ASSERT_NO_MSG(p_transfer != NULL);
14691469

14701470
/* Setup data transaction can go only in one direction at a time */
14711471
if ((NRF_USBD_COMMON_EP_NUM(ep) == 0) && (ep != m_last_setup_dir)) {
1472-
ret = NRFX_ERROR_INVALID_ADDR;
1472+
ret = -EFAULT;
14731473
if (NRF_USBD_COMMON_FAILED_TRANSFERS_DEBUG &&
14741474
(NRF_USBD_COMMON_ISO_DEBUG || (!NRF_USBD_COMMON_EP_IS_ISO(ep)))) {
14751475
LOG_DBG("Transfer failed: Invalid EPr\n");
@@ -1478,7 +1478,7 @@ nrfx_err_t nrf_usbd_common_ep_transfer(nrf_usbd_common_ep_t ep,
14781478
(1U << ep_bitpos)) {
14791479
/* IN (Device -> Host) transfer has to be transmitted out to allow new transmission
14801480
*/
1481-
ret = NRFX_ERROR_BUSY;
1481+
ret = -EBUSY;
14821482
if (NRF_USBD_COMMON_FAILED_TRANSFERS_DEBUG) {
14831483
LOG_DBG("Transfer failed: EP is busy");
14841484
}
@@ -1494,7 +1494,7 @@ nrfx_err_t nrf_usbd_common_ep_transfer(nrf_usbd_common_ep_t ep,
14941494
p_state->transfer_cnt = 0;
14951495
p_state->status = NRF_USBD_COMMON_EP_OK;
14961496
m_ep_dma_waiting |= 1U << ep_bitpos;
1497-
ret = NRFX_SUCCESS;
1497+
ret = 0;
14981498
usbd_int_rise();
14991499
}
15001500

drivers/usb/common/nrf_usbd_common/nrf_usbd_common.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ typedef struct {
276276
*
277277
* @param[in] event_handler Event handler provided by the user. Cannot be null.
278278
*
279-
* @retval NRFX_SUCCESS Initialization successful.
280-
* @retval NRFX_ERROR_INVALID_STATE Driver was already initialized.
279+
* @retval 0 Initialization successful.
280+
* @retval -EALREADY Driver was already initialized.
281281
*/
282-
nrfx_err_t nrf_usbd_common_init(nrf_usbd_common_event_handler_t event_handler);
282+
int nrf_usbd_common_init(nrf_usbd_common_event_handler_t event_handler);
283283

284284
/**
285285
* @brief Driver deinitialization.
@@ -503,11 +503,11 @@ void nrf_usbd_common_ep_disable(nrf_usbd_common_ep_t ep);
503503
* For OUT endpoint receiving would be initiated.
504504
* @param[in] p_transfer Transfer parameters.
505505
*
506-
* @retval NRFX_SUCCESS Transfer queued or started.
507-
* @retval NRFX_ERROR_BUSY Selected endpoint is pending.
508-
* @retval NRFX_ERROR_INVALID_ADDR Unexpected transfer on EPIN0 or EPOUT0.
506+
* @retval 0 Transfer queued or started.
507+
* @retval -EBUSY Selected endpoint is pending.
508+
* @retval -EFAULT Unexpected transfer on EPIN0 or EPOUT0.
509509
*/
510-
nrfx_err_t nrf_usbd_common_ep_transfer(nrf_usbd_common_ep_t ep,
510+
int nrf_usbd_common_ep_transfer(nrf_usbd_common_ep_t ep,
511511
nrf_usbd_common_transfer_t const *p_transfer);
512512

513513
/**

drivers/usb/device/usb_dc_nrfx.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,9 @@ static inline void usbd_work_process_recvreq(struct nrf_usbd_ctx *ctx,
795795
k_mutex_lock(&ctx->drv_lock, K_FOREVER);
796796
NRF_USBD_COMMON_TRANSFER_OUT(transfer, ep_ctx->buf.data,
797797
ep_ctx->cfg.max_sz);
798-
nrfx_err_t err = nrf_usbd_common_ep_transfer(
798+
int err = nrf_usbd_common_ep_transfer(
799799
ep_addr_to_nrfx(ep_ctx->cfg.addr), &transfer);
800-
if (err != NRFX_SUCCESS) {
800+
if (err != 0) {
801801
LOG_ERR("nRF USBD transfer error (OUT): 0x%02x", err);
802802
}
803803
k_mutex_unlock(&ctx->drv_lock);
@@ -1146,7 +1146,7 @@ static void usbd_event_handler(nrf_usbd_common_evt_t const *const p_event)
11461146
static inline void usbd_reinit(void)
11471147
{
11481148
int ret;
1149-
nrfx_err_t err;
1149+
int err;
11501150

11511151
nrfx_power_usbevt_disable();
11521152
nrf_usbd_common_disable();
@@ -1160,7 +1160,7 @@ static inline void usbd_reinit(void)
11601160
nrfx_power_usbevt_enable();
11611161
err = nrf_usbd_common_init(usbd_event_handler);
11621162

1163-
if (err != NRFX_SUCCESS) {
1163+
if (err != 0) {
11641164
LOG_DBG("nRF USBD driver reinit failed. Code: %d", err);
11651165
__ASSERT_NO_MSG(0);
11661166
}
@@ -1692,9 +1692,9 @@ int usb_dc_ep_write(const uint8_t ep, const uint8_t *const data,
16921692

16931693
ep_ctx->write_in_progress = true;
16941694
NRF_USBD_COMMON_TRANSFER_IN(transfer, data, data_len, 0);
1695-
nrfx_err_t err = nrf_usbd_common_ep_transfer(ep_addr_to_nrfx(ep), &transfer);
1695+
int err = nrf_usbd_common_ep_transfer(ep_addr_to_nrfx(ep), &transfer);
16961696

1697-
if (err != NRFX_SUCCESS) {
1697+
if (err != 0) {
16981698
ep_ctx->write_in_progress = false;
16991699
if (ret_bytes) {
17001700
*ret_bytes = 0;
@@ -1883,7 +1883,7 @@ int usb_dc_wakeup_request(void)
18831883
static int usb_init(void)
18841884
{
18851885
struct nrf_usbd_ctx *ctx = get_usbd_ctx();
1886-
nrfx_err_t err;
1886+
int err;
18871887

18881888
#ifdef CONFIG_HAS_HW_NRF_USBREG
18891889
/* Use CLOCK/POWER priority for compatibility with other series where
@@ -1909,12 +1909,12 @@ static int usb_init(void)
19091909
};
19101910

19111911
err = nrf_usbd_common_init(usbd_event_handler);
1912-
if (err != NRFX_SUCCESS) {
1912+
if (err != 0) {
19131913
LOG_DBG("nRF USBD driver init failed. Code: %d", (uint32_t)err);
19141914
return -EIO;
19151915
}
19161916

1917-
/* Ignore the return value, as NRFX_ERROR_ALREADY is not
1917+
/* Ignore the return value, as -EALREADY is not
19181918
* a problem here.
19191919
*/
19201920
(void)nrfx_power_init(&power_config);

modules/hal_nordic/nrfx/nrfx_glue.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,6 @@ void nrfx_busy_wait(uint32_t usec_to_wait);
256256

257257
//------------------------------------------------------------------------------
258258

259-
/**
260-
* @brief When set to a non-zero value, this macro specifies that the
261-
* @ref nrfx_error_codes and the @ref nrfx_err_t type itself are defined
262-
* in a customized way and the default definitions from @c <nrfx_error.h>
263-
* should not be used.
264-
*/
265-
#define NRFX_CUSTOM_ERROR_CODES 0
266-
267-
//------------------------------------------------------------------------------
268-
269259
/**
270260
* @brief When set to a non-zero value, this macro specifies that inside HALs
271261
* the event registers are read back after clearing, on devices that

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,13 +1941,13 @@ uint32_t radio_tmr_sample_get(void)
19411941
int radio_gpio_pa_lna_init(void)
19421942
{
19431943
#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN) || defined(HAL_RADIO_GPIO_HAVE_LNA_PIN)
1944-
if (nrfx_gpiote_channel_alloc(gpiote_palna, &gpiote_ch_palna) != NRFX_SUCCESS) {
1944+
if (nrfx_gpiote_channel_alloc(gpiote_palna, &gpiote_ch_palna) != 0) {
19451945
return -ENOMEM;
19461946
}
19471947
#endif
19481948

19491949
#if defined(NRF_GPIO_PDN_PIN)
1950-
if (nrfx_gpiote_channel_alloc(gpiote_pdn, &gpiote_ch_pdn) != NRFX_SUCCESS) {
1950+
if (nrfx_gpiote_channel_alloc(gpiote_pdn, &gpiote_ch_pdn) != 0) {
19511951
return -ENOMEM;
19521952
}
19531953
#endif

0 commit comments

Comments
 (0)