Skip to content

Commit 8b2b9b9

Browse files
storage: bm_storage: use errno instead of nrf_error
Use errnos for BM storage as it is not a BLE library or BLE subsystem. Correct return values for BM ZMS. Signed-off-by: Eivind Jølsgard <[email protected]>
1 parent 33a457e commit 8b2b9b9

File tree

11 files changed

+307
-339
lines changed

11 files changed

+307
-339
lines changed

doc/nrf-bm/release_notes/release_notes_changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ Libraries
116116
* All instances of ``pm_failure_evt_t`` to struct :c:struct:`pm_failure_evt` and removed the ``pm_failure_evt_t`` type.
117117
* All instances of ``pm_evt_t`` to struct :c:struct:`pm_evt` and removed the ``pm_evt_t`` type.
118118

119+
* Storage library:
120+
121+
* Updated to use errno instead of nrf_errors.
122+
123+
119124
Samples
120125
=======
121126

include/bm/storage/bm_storage.h

Lines changed: 39 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ struct bm_storage_evt {
5252
/* Specifies if the operation was performed synchronously or asynchronously. */
5353
enum bm_storage_evt_dispatch_type dispatch_type;
5454
/* Result of the operation.
55-
* NRF_SUCCESS on success.
56-
* A positive NRF error otherwise.
55+
* 0 on success.
56+
* A negative errno otherwise.
5757
*/
5858
uint32_t result;
5959
/* Destination address where the operation was performed. */
@@ -143,12 +143,12 @@ struct bm_storage {
143143
*
144144
* @param[in] storage Storage instance to initialize.
145145
*
146-
* @retval NRF_SUCCESS on success.
147-
* @retval NRF_ERROR_NULL If @p storage is @c NULL.
148-
* @retval NRF_ERROR_BUSY If the implementation-specific resource is busy.
149-
* @retval NRF_ERROR_INTERNAL If an implementation-specific internal error occurred.
146+
* @retval 0 on success.
147+
* @retval -EFAULT If @p storage is @c NULL.
148+
* @retval -EBUSY If the implementation-specific resource is busy.
149+
* @retval -EIO If an implementation-specific internal error occurred.
150150
*/
151-
uint32_t bm_storage_init(struct bm_storage *storage);
151+
int bm_storage_init(struct bm_storage *storage);
152152

153153
/**
154154
* @brief Uninitialize a storage instance.
@@ -158,13 +158,13 @@ uint32_t bm_storage_init(struct bm_storage *storage);
158158
*
159159
* @param[in] storage Storage instance to uninitialize.
160160
*
161-
* @retval NRF_SUCCESS on success.
162-
* @retval NRF_ERROR_NULL If @p storage is @c NULL.
163-
* @retval NRF_ERROR_INVALID_STATE If @p storage is in an invalid state.
164-
* @retval NRF_ERROR_BUSY If the implementation-specific backend is busy with an ongoing operation.
165-
* @retval NRF_ERROR_NOT_SUPPORTED If the backend does not support uninitialization.
161+
* @retval 0 on success.
162+
* @retval -EFAULT If @p storage is @c NULL.
163+
* @retval -EPERM If @p storage is in an invalid state.
164+
* @retval -EBUSY If the implementation-specific backend is busy with an ongoing operation.
165+
* @retval -ENOTSUP If the backend does not support uninitialization.
166166
*/
167-
uint32_t bm_storage_uninit(struct bm_storage *storage);
167+
int bm_storage_uninit(struct bm_storage *storage);
168168

169169
/**
170170
* @brief Read data from a storage instance.
@@ -174,16 +174,14 @@ uint32_t bm_storage_uninit(struct bm_storage *storage);
174174
* @param[out] dest Destination where the data will be copied to.
175175
* @param[in] len Length of the data to copy (in bytes).
176176
*
177-
* @retval NRF_SUCCESS on success.
178-
* @retval NRF_ERROR_NULL If @p storage is @c NULL.
179-
* @retval NRF_ERROR_INVALID_STATE If @p storage is in an invalid state.
180-
* @retval NRF_ERROR_INVALID_LENGTH If @p len is zero or not a multiple of
181-
* @ref bm_storage_info.program_unit.
182-
* @retval NRF_ERROR_INVALID_ADDR If @p dest or @p src are not 32-bit word aligned, or if they are
183-
* outside the bounds of the memory region configured in @p storage.
184-
* @retval NRF_ERROR_FORBIDDEN If the implementation-specific backend has not been initialized.
177+
* @retval 0 on success.
178+
* @retval -EFAULT If @p storage is @c NULL or if @p dest or @p src are not 32-bit word aligned,
179+
* or if they are outside the bounds of the memory region configured in @p storage.
180+
* @retval -EPERM If @p storage is in an invalid state or if the implementation-specific backend
181+
* has not been initialized.
182+
* @retval -EINVAL If @p len is zero or not a multiple of @ref bm_storage_info.program_unit.
185183
*/
186-
uint32_t bm_storage_read(const struct bm_storage *storage, uint32_t src, void *dest, uint32_t len);
184+
int bm_storage_read(const struct bm_storage *storage, uint32_t src, void *dest, uint32_t len);
187185

188186
/**
189187
* @brief Write data to a storage instance.
@@ -195,19 +193,17 @@ uint32_t bm_storage_read(const struct bm_storage *storage, uint32_t src, void *d
195193
* @param[in] ctx Pointer to user data, passed to the implementation-specific API function call.
196194
* Can be NULL.
197195
*
198-
* @retval NRF_SUCCESS on success.
199-
* @retval NRF_ERROR_NULL If @p storage is @c NULL.
200-
* @retval NRF_ERROR_INVALID_STATE If @p storage is in an invalid state.
201-
* @retval NRF_ERROR_INVALID_LENGTH If @p len is zero or not a multiple of
202-
* @ref bm_storage_info.program_unit.
203-
* @retval NRF_ERROR_INVALID_ADDR If @p dest or @p src are not 32-bit word aligned, or if they are
204-
* outside the bounds of the memory region configured in @p storage.
205-
* @retval NRF_ERROR_FORBIDDEN If the implementation-specific backend has not been initialized.
206-
* @retval NRF_ERROR_BUSY If the implementation-specific backend is busy with an ongoing operation.
207-
* @retval NRF_ERROR_INTERNAL If an implementation-specific internal error occurred.
196+
* @retval 0 on success.
197+
* @retval -EFAULT If @p storage is @c NULL or if @p dest or @p src are not 32-bit word aligned,
198+
* or if they are outside the bounds of the memory region configured in @p storage.
199+
* @retval -EPERM If @p storage is in an invalid state or if the implementation-specific backend
200+
* has not been initialized.
201+
* @retval -EINVAL If @p len is zero or not a multiple of @ref bm_storage_info.program_unit.
202+
* @retval -EBUSY If the implementation-specific backend is busy with an ongoing operation.
203+
* @retval -EIO If an implementation-specific internal error occurred.
208204
*/
209-
uint32_t bm_storage_write(const struct bm_storage *storage, uint32_t dest, const void *src,
210-
uint32_t len, void *ctx);
205+
int bm_storage_write(const struct bm_storage *storage, uint32_t dest, const void *src,
206+
uint32_t len, void *ctx);
211207

212208
/**
213209
* @brief Erase data in a storage instance.
@@ -216,19 +212,16 @@ uint32_t bm_storage_write(const struct bm_storage *storage, uint32_t dest, const
216212
* @param[in] ctx Pointer to user data, passed to the implementation-specific API function call.
217213
* Can be NULL.
218214
*
219-
* @retval NRF_SUCCESS on success.
220-
* @retval NRF_ERROR_NULL If @p storage is @c NULL.
221-
* @retval NRF_ERROR_INVALID_STATE If @p storage is in an invalid state.
222-
* @retval NRF_ERROR_INVALID_LENGTH If @p len is zero or not a multiple of
223-
* @ref bm_storage_info.erase_unit.
224-
* @retval NRF_ERROR_INVALID_ADDR If @p addr is outside the bounds of the memory region configured
225-
* in @p storage.
226-
* @retval NRF_ERROR_FORBIDDEN If the implementation-specific backend has not been initialized.
227-
* @retval NRF_ERROR_BUSY If the implementation-specific backend is busy with an ongoing operation.
228-
* @retval NRF_ERROR_NOT_SUPPORTED If the implementation-specific backend does not implement this
229-
* function.
215+
* @retval 0 on success.
216+
* @retval -EFAULT If @p storage is @c NULL or if @p addr is outside the bounds of the memory region
217+
* configured in @p storage.
218+
* @retval -EPERM If @p storage is in an invalid state or if the implementation-specific backend
219+
* has not been initialized.
220+
* @retval -EINVAL If @p len is zero or not a multiple of @ref bm_storage_info.erase_unit.
221+
* @retval -EBUSY If the implementation-specific backend is busy with an ongoing operation.
222+
* @retval -ENOTSUP If the implementation-specific backend does not implement this function.
230223
*/
231-
uint32_t bm_storage_erase(const struct bm_storage *storage, uint32_t addr, uint32_t len, void *ctx);
224+
int bm_storage_erase(const struct bm_storage *storage, uint32_t addr, uint32_t len, void *ctx);
232225

233226
/**
234227
* @brief Query the status of a storage instance.

include/bm/storage/bm_storage_backend.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,57 +24,57 @@ extern "C" {
2424
*
2525
* @note This function must be defined by the backend.
2626
*
27-
* @retval NRF_SUCCESS on success.
28-
* @retval NRF_ERROR_BUSY If the implementation-specific resource is busy.
29-
* @retval NRF_ERROR_INTERNAL If an implementation-specific internal error occurred.
27+
* @retval 0 on success.
28+
* @retval -EBUSY If the implementation-specific resource is busy.
29+
* @retval -EIO If an implementation-specific internal error occurred.
3030
*/
31-
uint32_t bm_storage_backend_init(struct bm_storage *storage);
31+
int bm_storage_backend_init(struct bm_storage *storage);
3232
/**
3333
* @brief Uninitialize the storage peripheral.
3434
*
3535
* @note This function is optional. If not defined in the backend, a weak implementation will return
36-
* NRF_ERROR_NOT_SUPPORTED.
36+
* -ENOTSUP.
3737
*
38-
* @retval NRF_SUCCESS on success.
39-
* @retval NRF_ERROR_BUSY If the implementation-specific backend is busy with an ongoing operation.
40-
* @retval NRF_ERROR_NOT_SUPPORTED If the backend does not support uninitialization.
38+
* @retval 0 on success.
39+
* @retval -EBUSY If the implementation-specific backend is busy with an ongoing operation.
40+
* @retval -ENOTSUP If the backend does not support uninitialization.
4141
*/
42-
uint32_t bm_storage_backend_uninit(struct bm_storage *storage);
42+
int bm_storage_backend_uninit(struct bm_storage *storage);
4343
/**
4444
* @brief Read data from non-volatile memory.
4545
*
4646
* @note This function must be defined by the backend.
4747
*
48-
* @retval NRF_SUCCESS on success.
49-
* @retval NRF_ERROR_FORBIDDEN If the implementation-specific backend has not been initialized.
48+
* @retval 0 on success.
49+
* @retval -EPERM If the implementation-specific backend has not been initialized.
5050
*/
51-
uint32_t bm_storage_backend_read(const struct bm_storage *storage, uint32_t src, void *dest,
52-
uint32_t len);
51+
int bm_storage_backend_read(const struct bm_storage *storage, uint32_t src, void *dest,
52+
uint32_t len);
5353
/**
5454
* @brief Write bytes to non-volatile memory.
5555
*
5656
* @note This function must be defined by the backend.
5757
*
58-
* @retval NRF_SUCCESS on success.
59-
* @retval NRF_ERROR_FORBIDDEN If the implementation-specific backend has not been initialized.
60-
* @retval NRF_ERROR_BUSY If the implementation-specific backend is busy with an ongoing operation.
61-
* @retval NRF_ERROR_INTERNAL If an implementation-specific internal error occurred.
58+
* @retval 0 on success.
59+
* @retval -EPERM If the implementation-specific backend has not been initialized.
60+
* @retval -EBUSY If the implementation-specific backend is busy with an ongoing operation.
61+
* @retval -EIO If an implementation-specific internal error occurred.
6262
*/
63-
uint32_t bm_storage_backend_write(const struct bm_storage *storage, uint32_t dest, const void *src,
64-
uint32_t len, void *ctx);
63+
int bm_storage_backend_write(const struct bm_storage *storage, uint32_t dest, const void *src,
64+
uint32_t len, void *ctx);
6565
/**
6666
* @brief Erase the non-volatile memory.
6767
*
6868
* @note This function is optional. If not defined in the backend, a weak implementation will return
69-
* NRF_ERROR_NOT_SUPPORTED.
69+
* -ENOTSUP.
7070
*
71-
* @retval NRF_SUCCESS on success.
72-
* @retval NRF_ERROR_FORBIDDEN If the implementation-specific backend has not been initialized.
73-
* @retval NRF_ERROR_BUSY If the implementation-specific backend is busy with an ongoing operation.
74-
* @retval NRF_ERROR_NOT_SUPPORTED If the backend does not support erase.
71+
* @retval 0 on success.
72+
* @retval -EPERM If the implementation-specific backend has not been initialized.
73+
* @retval -EBUSY If the implementation-specific backend is busy with an ongoing operation.
74+
* @retval -ENOTSUP If the backend does not support erase.
7575
*/
76-
uint32_t bm_storage_backend_erase(const struct bm_storage *storage, uint32_t addr, uint32_t len,
77-
void *ctx);
76+
int bm_storage_backend_erase(const struct bm_storage *storage, uint32_t addr, uint32_t len,
77+
void *ctx);
7878
/**
7979
* @brief Check if there are any pending operations.
8080
*

lib/bluetooth/ble_adv/ble_adv_data.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,9 @@ static uint32_t manuf_specific_data_encode(const struct ble_adv_data_manufacture
391391
return NRF_ERROR_DATA_SIZE;
392392
}
393393

394-
/* There is only 1 byte intended to encode length which is (data_size + AD_TYPE_FIELD_SIZE) */
394+
/* There is only 1 byte intended to encode length which is
395+
* (data_size + AD_TYPE_FIELD_SIZE)
396+
*/
395397
if (data_size > (0x00FF - AD_TYPE_FIELD_SIZE)) {
396398
return NRF_ERROR_DATA_SIZE;
397399
}

0 commit comments

Comments
 (0)