-
Notifications
You must be signed in to change notification settings - Fork 23
storage: bm_storage: use errno instead of nrf_error #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,10 +52,10 @@ struct bm_storage_evt { | |
| /* Specifies if the operation was performed synchronously or asynchronously. */ | ||
| enum bm_storage_evt_dispatch_type dispatch_type; | ||
| /* Result of the operation. | ||
| * NRF_SUCCESS on success. | ||
| * A positive NRF error otherwise. | ||
| * 0 on success. | ||
| * A negative errno otherwise. | ||
| */ | ||
| uint32_t result; | ||
| int result; | ||
| /* Destination address where the operation was performed. */ | ||
| uint32_t addr; | ||
| /* Pointer to the data that was written to non-volatile memory. | ||
|
|
@@ -143,12 +143,12 @@ struct bm_storage { | |
| * | ||
| * @param[in] storage Storage instance to initialize. | ||
| * | ||
| * @retval NRF_SUCCESS on success. | ||
| * @retval NRF_ERROR_NULL If @p storage is @c NULL. | ||
| * @retval NRF_ERROR_BUSY If the implementation-specific resource is busy. | ||
| * @retval NRF_ERROR_INTERNAL If an implementation-specific internal error occurred. | ||
| * @retval 0 on success. | ||
| * @retval -EFAULT If @p storage is @c NULL. | ||
| * @retval -EBUSY If the implementation-specific resource is busy. | ||
| * @retval -EIO If an implementation-specific internal error occurred. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would use EFAULT for generic failures. IO is more for read/write and such.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use EFAULT for NULL checks.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, not in every library. It is not a standard. For user-space, the standard is |
||
| */ | ||
| uint32_t bm_storage_init(struct bm_storage *storage); | ||
| int bm_storage_init(struct bm_storage *storage); | ||
|
|
||
| /** | ||
| * @brief Uninitialize a storage instance. | ||
|
|
@@ -158,13 +158,13 @@ uint32_t bm_storage_init(struct bm_storage *storage); | |
| * | ||
| * @param[in] storage Storage instance to uninitialize. | ||
| * | ||
| * @retval NRF_SUCCESS on success. | ||
| * @retval NRF_ERROR_NULL If @p storage is @c NULL. | ||
| * @retval NRF_ERROR_INVALID_STATE If @p storage is in an invalid state. | ||
| * @retval NRF_ERROR_BUSY If the implementation-specific backend is busy with an ongoing operation. | ||
| * @retval NRF_ERROR_NOT_SUPPORTED If the backend does not support uninitialization. | ||
| * @retval 0 on success. | ||
| * @retval -EFAULT If @p storage is @c NULL. | ||
| * @retval -EPERM If @p storage is in an invalid state. | ||
| * @retval -EBUSY If the implementation-specific backend is busy with an ongoing operation. | ||
| * @retval -ENOTSUP If the backend does not support uninitialization. | ||
| */ | ||
| uint32_t bm_storage_uninit(struct bm_storage *storage); | ||
| int bm_storage_uninit(struct bm_storage *storage); | ||
|
|
||
| /** | ||
| * @brief Read data from a storage instance. | ||
|
|
@@ -174,16 +174,14 @@ uint32_t bm_storage_uninit(struct bm_storage *storage); | |
| * @param[out] dest Destination where the data will be copied to. | ||
| * @param[in] len Length of the data to copy (in bytes). | ||
| * | ||
| * @retval NRF_SUCCESS on success. | ||
| * @retval NRF_ERROR_NULL If @p storage is @c NULL. | ||
| * @retval NRF_ERROR_INVALID_STATE If @p storage is in an invalid state. | ||
| * @retval NRF_ERROR_INVALID_LENGTH If @p len is zero or not a multiple of | ||
| * @ref bm_storage_info.program_unit. | ||
| * @retval NRF_ERROR_INVALID_ADDR If @p dest or @p src are not 32-bit word aligned, or if they are | ||
| * outside the bounds of the memory region configured in @p storage. | ||
| * @retval NRF_ERROR_FORBIDDEN If the implementation-specific backend has not been initialized. | ||
| * @retval 0 on success. | ||
| * @retval -EFAULT If @p storage is @c NULL or if @p dest or @p src are not 32-bit word aligned, | ||
| * or if they are outside the bounds of the memory region configured in @p storage. | ||
| * @retval -EPERM If @p storage is in an invalid state or if the implementation-specific backend | ||
| * has not been initialized. | ||
| * @retval -EINVAL If @p len is zero or not a multiple of @ref bm_storage_info.program_unit. | ||
| */ | ||
| uint32_t bm_storage_read(const struct bm_storage *storage, uint32_t src, void *dest, uint32_t len); | ||
| int bm_storage_read(const struct bm_storage *storage, uint32_t src, void *dest, uint32_t len); | ||
|
|
||
| /** | ||
| * @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 | |
| * @param[in] ctx Pointer to user data, passed to the implementation-specific API function call. | ||
| * Can be NULL. | ||
| * | ||
| * @retval NRF_SUCCESS on success. | ||
| * @retval NRF_ERROR_NULL If @p storage is @c NULL. | ||
| * @retval NRF_ERROR_INVALID_STATE If @p storage is in an invalid state. | ||
| * @retval NRF_ERROR_INVALID_LENGTH If @p len is zero or not a multiple of | ||
| * @ref bm_storage_info.program_unit. | ||
| * @retval NRF_ERROR_INVALID_ADDR If @p dest or @p src are not 32-bit word aligned, or if they are | ||
| * outside the bounds of the memory region configured in @p storage. | ||
| * @retval NRF_ERROR_FORBIDDEN If the implementation-specific backend has not been initialized. | ||
| * @retval NRF_ERROR_BUSY If the implementation-specific backend is busy with an ongoing operation. | ||
| * @retval NRF_ERROR_INTERNAL If an implementation-specific internal error occurred. | ||
| * @retval 0 on success. | ||
| * @retval -EFAULT If @p storage is @c NULL or if @p dest or @p src are not 32-bit word aligned, | ||
| * or if they are outside the bounds of the memory region configured in @p storage. | ||
| * @retval -EPERM If @p storage is in an invalid state or if the implementation-specific backend | ||
| * has not been initialized. | ||
| * @retval -EINVAL If @p len is zero or not a multiple of @ref bm_storage_info.program_unit. | ||
| * @retval -EBUSY If the implementation-specific backend is busy with an ongoing operation. | ||
| * @retval -EIO If an implementation-specific internal error occurred. | ||
| */ | ||
| uint32_t bm_storage_write(const struct bm_storage *storage, uint32_t dest, const void *src, | ||
| uint32_t len, void *ctx); | ||
| int bm_storage_write(const struct bm_storage *storage, uint32_t dest, const void *src, | ||
| uint32_t len, void *ctx); | ||
|
|
||
| /** | ||
| * @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 | |
| * @param[in] ctx Pointer to user data, passed to the implementation-specific API function call. | ||
| * Can be NULL. | ||
| * | ||
| * @retval NRF_SUCCESS on success. | ||
| * @retval NRF_ERROR_NULL If @p storage is @c NULL. | ||
| * @retval NRF_ERROR_INVALID_STATE If @p storage is in an invalid state. | ||
| * @retval NRF_ERROR_INVALID_LENGTH If @p len is zero or not a multiple of | ||
| * @ref bm_storage_info.erase_unit. | ||
| * @retval NRF_ERROR_INVALID_ADDR If @p addr is outside the bounds of the memory region configured | ||
| * in @p storage. | ||
| * @retval NRF_ERROR_FORBIDDEN If the implementation-specific backend has not been initialized. | ||
| * @retval NRF_ERROR_BUSY If the implementation-specific backend is busy with an ongoing operation. | ||
| * @retval NRF_ERROR_NOT_SUPPORTED If the implementation-specific backend does not implement this | ||
| * function. | ||
| * @retval 0 on success. | ||
| * @retval -EFAULT If @p storage is @c NULL or if @p addr is outside the bounds of the memory region | ||
| * configured in @p storage. | ||
| * @retval -EPERM If @p storage is in an invalid state or if the implementation-specific backend | ||
| * has not been initialized. | ||
| * @retval -EINVAL If @p len is zero or not a multiple of @ref bm_storage_info.erase_unit. | ||
| * @retval -EBUSY If the implementation-specific backend is busy with an ongoing operation. | ||
| * @retval -ENOTSUP If the implementation-specific backend does not implement this function. | ||
| */ | ||
| uint32_t bm_storage_erase(const struct bm_storage *storage, uint32_t addr, uint32_t len, void *ctx); | ||
| int bm_storage_erase(const struct bm_storage *storage, uint32_t addr, uint32_t len, void *ctx); | ||
|
|
||
| /** | ||
| * @brief Query the status of a storage instance. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EINVAL? I prefer to use EINVAL here, but I know that we don't really have a standard for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the standard in the repo.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is not a standard. Some libraries in this repo do it this way. But it's ok, it can stay like this, it's not a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll leave it as is, as it is like this in many other libraries. If we see the need we can align this treewide in a separate PR.