From c2a0b0f50bdb3c928e9d329cea93157e7cf0a469 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Wed, 14 Oct 2020 09:53:16 +0200 Subject: [PATCH] Bluetooth: GATT: Fix regression in lazy loading of CCCs Fix regression in lazy loading handling of GATT CCCs. Bug introduced by: 00d370b09aa5dd1dc56986989989df6d4dd53bcf The commit failed to account for ccc_set_direct calling ccc_set. Fixes: #29150 Signed-off-by: Joakim Andersson --- subsys/bluetooth/host/gatt.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c index 76de8cf4de34be..aec724de55f201 100644 --- a/subsys/bluetooth/host/gatt.c +++ b/subsys/bluetooth/host/gatt.c @@ -4339,11 +4339,6 @@ static uint8_t ccc_load(const struct bt_gatt_attr *attr, uint16_t handle, static int ccc_set(const char *name, size_t len_rd, settings_read_cb read_cb, void *cb_arg) { - if (IS_ENABLED(CONFIG_BT_SETTINGS_CCC_LAZY_LOADING)) { - /* Only load CCCs on demand */ - return 0; - } - if (IS_ENABLED(CONFIG_BT_SETTINGS)) { struct ccc_store ccc_store[CCC_STORE_MAX]; struct ccc_load load; @@ -4401,7 +4396,18 @@ static int ccc_set(const char *name, size_t len_rd, settings_read_cb read_cb, return 0; } -SETTINGS_STATIC_HANDLER_DEFINE(bt_ccc, "bt/ccc", NULL, ccc_set, NULL, NULL); +static int ccc_set_cb(const char *name, size_t len_rd, settings_read_cb read_cb, + void *cb_arg) +{ + if (IS_ENABLED(CONFIG_BT_SETTINGS_CCC_LAZY_LOADING)) { + /* Only load CCCs on demand */ + return 0; + } + + return ccc_set(name, len_rd, read_cb, cb_arg); +} + +SETTINGS_STATIC_HANDLER_DEFINE(bt_ccc, "bt/ccc", NULL, ccc_set_cb, NULL, NULL); static int ccc_set_direct(const char *key, size_t len, settings_read_cb read_cb, void *cb_arg, void *param)