From e3a6442ae901ce5f5c25f5ad614a7d2461a4fcf7 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 9 Jan 2013 16:01:12 -0800 Subject: [PATCH] core: Load link keys and long term keys only when controller supports it Check for BR/EDR support before loading link keys and check for LE support before loading long term keys. This has the nice benefit that for BR/EDR only controllers the warning message from the kernel bug for loading long term keys is gone now. And only systems with dual mode controllers will expierence it. Makes it a little bit less confusing. --- src/adapter.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 236fe2d29..7bf5bcae0 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -1961,6 +1961,16 @@ static void load_link_keys(struct btd_adapter *adapter, GSList *keys, unsigned int id; GSList *l; + /* + * If the controller does not support BR/EDR operation, + * there is no point in trying to load the link keys into + * the kernel. + * + * This is an optimization for Low Energy only controllers. + */ + if (!(adapter->supported_settings & MGMT_SETTING_BREDR)) + return; + key_count = g_slist_length(keys); DBG("hci%u keys %zu debug_keys %d", adapter->dev_id, key_count, @@ -2036,6 +2046,19 @@ static void load_ltks(struct btd_adapter *adapter, GSList *keys) size_t key_count, cp_size; GSList *l; + /* + * If the controller does not support Low Energy operation, + * there is no point in trying to load the long term keys + * into the kernel. + * + * While there is no harm in loading keys into the kernel, + * this is an optimization to avoid a confusing warning + * message when the loading of the keys timed out due to + * a kernel bug (see comment below). + */ + if (!(adapter->supported_settings & MGMT_SETTING_LE)) + return; + key_count = g_slist_length(keys); DBG("hci%u keys %zu", adapter->dev_id, key_count); -- 2.11.0