Skip to content

Commit

Permalink
bluetooth: fast_pair: fmdn: callbacks: migrate to slist find API
Browse files Browse the repository at this point in the history
Updated the FMDN callbacks module that is part of the Google Fast Pair
library to use the new slist API for checking if the potential slist
node is already included in the target slist instance.

Ref: NCSDK-30487

Signed-off-by: Kamil Piszczek <[email protected]>
  • Loading branch information
kapi-no authored and carlescufi committed Dec 9, 2024
1 parent f7d4af3 commit 2c47cf7
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions subsys/bluetooth/services/fast_pair/fmdn/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include <zephyr/kernel.h>
#include <zephyr/sys/slist.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(fp_fmdn_callbacks, CONFIG_BT_FAST_PAIR_LOG_LEVEL);
Expand Down Expand Up @@ -56,19 +57,6 @@ void fp_fmdn_callbacks_provisioning_state_changed_notify(bool provisioned)
}
}

static bool node_uniqueness_validate(sys_slist_t *slist, sys_snode_t *new_node)
{
sys_snode_t *current_node;

SYS_SLIST_FOR_EACH_NODE(slist, current_node) {
if (current_node == new_node) {
return false;
}
}

return true;
}

static int cb_register(sys_slist_t *slist, struct bt_fast_pair_fmdn_info_cb *cb)
{
if (bt_fast_pair_is_ready()) {
Expand All @@ -83,7 +71,7 @@ static int cb_register(sys_slist_t *slist, struct bt_fast_pair_fmdn_info_cb *cb)
return -EINVAL;
}

if (!node_uniqueness_validate(slist, &cb->node)) {
if (sys_slist_find(slist, &cb->node, NULL)) {
return 0;
}

Expand Down

0 comments on commit 2c47cf7

Please sign in to comment.