Skip to content

Commit

Permalink
lib: nrf_modem_lib: jump to init callbacks when err
Browse files Browse the repository at this point in the history
`nrf_modem_lib_init` should not initialize traces or log
the firmware version UUID when `nrf_modem_init` fails,
because they require the modem library to be initialized.
However it should iterate through the init callbacks and
report the returned error.

Signed-off-by: Mirko Covizzi <[email protected]>
  • Loading branch information
MirkoCovizzi authored and nordicjm committed Jan 29, 2025
1 parent 8c3501f commit 8e85b62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,10 @@ Modem libraries

* Updated the :ref:`nrf_modem_lib_lte_net_if` to automatically set the actual link :term:`Maximum Transmission Unit (MTU)` on the network interface when PDN connectivity is gained.

* :ref:`nrf_modem_lib_readme`:

* Fixed a bug where various subsystems would be erroneously initialized during a failed initialization of the library.

Multiprotocol Service Layer libraries
-------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions lib/nrf_modem_lib/nrf_modem_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ int nrf_modem_lib_init(void)
err = nrf_modem_init(&init_params);
if (err) {
LOG_ERR("Modem library initialization failed, err %d", err);

/* Jump to the init callbacks and pass them the returned error. */
goto init_callbacks;
}

#if CONFIG_NRF_MODEM_LIB_TRACE
Expand All @@ -182,6 +185,7 @@ int nrf_modem_lib_init(void)
log_fw_version_uuid();
}

init_callbacks:
STRUCT_SECTION_FOREACH(nrf_modem_lib_init_cb, e) {
LOG_DBG("Modem init callback: %p", e->callback);
e->callback(err, e->context);
Expand Down

0 comments on commit 8e85b62

Please sign in to comment.