-
Notifications
You must be signed in to change notification settings - Fork 27
subsys: fs: bm_zms: remove global callbacks array #485
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
base: main
Are you sure you want to change the base?
Conversation
a5c5d6f to
95aaac4
Compare
|
You can find the documentation preview for this PR here. |
27aa479 to
564795f
Compare
aa2458f to
67d1e18
Compare
|
@MirkoCovizzi I do not understand this bug. |
|
I suppose that's one way to fix it. It does however add one limitation, which is that only the owner of an instance can receive callbacks from it, thus forcing a single owner for each instance. In practice, it is no longer possible to share a partition, every instance would need its own. But it may be fine, first, because there a no events that are relevant for the whole application (like GC was). And second, because the application could still be designed in a way that allows to share a partition, by wrapping NVM operations. |
It is not a use case. The current implementation makes it possible for a user to call the register function on the same instance multiple times, each time incrementing the |
What are some examples of situations where an application might want to share a single partition between different instances of a file system (or storage)? |
subsys/fs/bm_zms/bm_zms.c
Outdated
| zms_cb_table[i] = cb; | ||
| fs->user_num = i; | ||
| fs->user_cb = cb; | ||
| fs->init_flags.cb_registred = true; |
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.
I don't see the cb_registered flag used for anything. Remove it?
67d1e18 to
00a1b44
Compare
| /** | ||
| * @brief Bare Metal ZMS event handler function prototype. | ||
| * | ||
| * @param p_evt The event. |
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.
| * @param p_evt The event. | |
| * @param evt The event. |
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 will be addressed separately
| * | ||
| * @param p_evt The event. | ||
| */ | ||
| typedef void (*bm_zms_cb_t)(bm_zms_evt_t const *p_evt); |
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.
| typedef void (*bm_zms_cb_t)(bm_zms_evt_t const *p_evt); | |
| typedef void (*bm_zms_cb_t)(bm_zms_evt_t const *evt); |
| * Removed the :kconfig:option:`CONFIG_BM_ZMS_MAX_USERS` Kconfig option. Now the library expects at most one callback for each instance of the struct :c:struct:`bm_zms_fs`. | ||
| * Removed the :c:member:`bm_zms_init_flags.cb_registred` member since it was not used anymore. |
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.
| * Removed the :kconfig:option:`CONFIG_BM_ZMS_MAX_USERS` Kconfig option. Now the library expects at most one callback for each instance of the struct :c:struct:`bm_zms_fs`. | |
| * Removed the :c:member:`bm_zms_init_flags.cb_registred` member since it was not used anymore. | |
| * Removed: | |
| * The :kconfig:option:`CONFIG_BM_ZMS_MAX_USERS` Kconfig option. | |
| Now, the library expects at most one callback for each instance of the :c:struct:`bm_zms_fs` structure. | |
| * The :c:member:`bm_zms_init_flags.cb_registred` member as it was not used anymore. |
31a4e76 to
e4a83c9
Compare
|
|
||
| * Removed: | ||
|
|
||
| * The :kconfig:option:`CONFIG_BM_ZMS_MAX_USERS` Kconfig option. Now the library expects at most one callback for each instance of the struct :c:struct:`bm_zms_fs`. |
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.
| * The :kconfig:option:`CONFIG_BM_ZMS_MAX_USERS` Kconfig option. Now the library expects at most one callback for each instance of the struct :c:struct:`bm_zms_fs`. | |
| * The :kconfig:option:`CONFIG_BM_ZMS_MAX_USERS` Kconfig option. | |
| Now, the library expects at most one callback for each instance of the struct :c:struct:`bm_zms_fs`. |
Remember, every sentence on its own line. Do we need "at most"?
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.
"At most" clarifies that the callback is optional. Without it, it would seem that there has to be one callback. It also clarifies the difference compared to before, where it would seem that a user can set multiple callbacks on an instance.
| * Removed: | ||
|
|
||
| * The :kconfig:option:`CONFIG_BM_ZMS_MAX_USERS` Kconfig option. Now the library expects at most one callback for each instance of the struct :c:struct:`bm_zms_fs`. | ||
| * The :c:member:`bm_zms_init_flags.cb_registred` member since it was not used anymore. |
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.
| * The :c:member:`bm_zms_init_flags.cb_registred` member since it was not used anymore. | |
| * The :c:member:`bm_zms_init_flags.cb_registred` member as it was not used anymore. |
e4a83c9 to
a7ba3e8
Compare
Removes global callbacks array and replaces with callback member inside `struct bm_zms_fs`. This fixes a bug where registering multiple callbacks on the same `struct bm_zms_fs` would update the user reference number incrementally and saturate the global callbacks array. When calling `bm_zms_clear`, this would only reset to NULL the last callback set, leaving the rest still set. This update makes it so that there can only be one callback per each `struct bm_zms_fs` instance, mirroring the behavior of other libraries. Due to this change, also removes the `BM_ZMS_MAX_USERS` Kconfig option. Also removes the member `cb_registred` in the struct `bm_zms_init_flags` since it is not used anymore. Signed-off-by: Mirko Covizzi <mirko.covizzi@nordicsemi.no>
Cleans up Doxygen. Signed-off-by: Mirko Covizzi <mirko.covizzi@nordicsemi.no>
a7ba3e8 to
b7a25cc
Compare
peknis
left a comment
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.
Approved with a couple of further suggestions.
|
|
||
| * Removed: | ||
|
|
||
| * The :kconfig:option:`CONFIG_BM_ZMS_MAX_USERS` Kconfig option. |
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.
| * The :kconfig:option:`CONFIG_BM_ZMS_MAX_USERS` Kconfig option. | |
| * The ``CONFIG_BM_ZMS_MAX_USERS`` Kconfig option. |
Sorry, my bad. The :kconfig:option: would not work anymore as the option is removed, thus double back-ticks.
|
|
||
| * The :kconfig:option:`CONFIG_BM_ZMS_MAX_USERS` Kconfig option. | ||
| Now the library expects at most one callback for each instance of the struct :c:struct:`bm_zms_fs`. | ||
| * The :c:member:`bm_zms_init_flags.cb_registred` member as it was not used anymore. |
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.
| * The :c:member:`bm_zms_init_flags.cb_registred` member as it was not used anymore. | |
| * The ``bm_zms_init_flags.cb_registred`` member as it was not used anymore. |
Same here, the directive :c:member: would not work as it is removed.
Removes global callbacks array and replaces with callback
member inside
struct bm_zms_fs.This fixes a bug where registering multiple callbacks on
the same
struct bm_zms_fswould update the user referencenumber incrementally and saturate the global callbacks array.
When calling
bm_zms_clear, this would only reset to NULLthe last callback set, leaving the rest still set.
This update makes it so that there can only be one callback
per each
struct bm_zms_fsinstance, mirroring the behaviorof other libraries.
Due to this change, also removes the
BM_ZMS_MAX_USERSKconfig option.