zephyr/subsys/bluetooth/controller/ll_sw/ll_feat.c
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00

84 lines
1.7 KiB
C

/*
* Copyright (c) 2021 Nordic Semiconductor ASA
* Copyright (c) 2020 Demant
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include "util/util.h"
#include "util/memq.h"
#include "util/dbuf.h"
#include "hal/ccm.h"
#include "pdu.h"
#include "lll.h"
#include "lll/lll_df_types.h"
#include "lll_conn.h"
#include "ull_conn_internal.h"
#include "ll_feat.h"
#include "ll_settings.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER)
#define LOG_MODULE_NAME bt_ctlr_ll_feat
#include "common/log.h"
#include "hal/debug.h"
#if defined(CONFIG_BT_CTLR_SET_HOST_FEATURE)
static uint64_t host_features;
uint8_t ll_set_host_feature(uint8_t bit_number, uint8_t bit_value)
{
uint64_t feature;
/* Check if Bit_Number is not controlled by the Host */
feature = BIT64(bit_number);
if (!(feature & LL_FEAT_HOST_BIT_MASK)) {
return BT_HCI_ERR_UNSUPP_FEATURE_PARAM_VAL;
}
#if defined(CONFIG_BT_CONN)
/* Check if the Controller has an established ACL */
uint16_t conn_free_count = ll_conn_free_count_get();
/* Check if any connection contexts where allocated */
if (conn_free_count != CONFIG_BT_MAX_CONN) {
uint16_t handle;
/* Check if there are established connections */
for (handle = 0U; handle < CONFIG_BT_MAX_CONN; handle++) {
if (ll_connected_get(handle)) {
return BT_HCI_ERR_CMD_DISALLOWED;
}
}
}
#endif /* CONFIG_BT_CONN */
/* Set or Clear the Host feature bit */
if (bit_value) {
host_features |= feature;
} else {
host_features &= ~feature;
}
return BT_HCI_ERR_SUCCESS;
}
uint64_t ll_feat_get(void)
{
return LL_FEAT | (host_features & LL_FEAT_HOST_BIT_MASK);
}
#else /* !CONFIG_BT_CTLR_SET_HOST_FEATURE */
uint64_t ll_feat_get(void)
{
return LL_FEAT;
}
#endif /* !CONFIG_BT_CTLR_SET_HOST_FEATURE */