Bluetooth: L2CAP: Make use of Z_STRUCT_SECTION_ITERABLE
This makes use of Z_STRUCT_SECTION_ITERABLE to define fixed channel sections. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
8b9920fd77
commit
4e8ddfd640
4 changed files with 20 additions and 24 deletions
|
@ -78,17 +78,17 @@
|
||||||
|
|
||||||
SECTION_DATA_PROLOGUE(_bt_channels_area,,SUBALIGN(4))
|
SECTION_DATA_PROLOGUE(_bt_channels_area,,SUBALIGN(4))
|
||||||
{
|
{
|
||||||
_bt_channels_start = .;
|
_bt_l2cap_fixed_chan_list_start = .;
|
||||||
KEEP(*(SORT_BY_NAME("._bt_channels.static.*")))
|
KEEP(*(SORT_BY_NAME("._bt_l2cap_fixed_chan.static.*")))
|
||||||
_bt_channels_end = .;
|
_bt_l2cap_fixed_chan_list_end = .;
|
||||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||||
|
|
||||||
#if defined(CONFIG_BT_BREDR)
|
#if defined(CONFIG_BT_BREDR)
|
||||||
SECTION_DATA_PROLOGUE(_bt_br_channels_area,,SUBALIGN(4))
|
SECTION_DATA_PROLOGUE(_bt_br_channels_area,,SUBALIGN(4))
|
||||||
{
|
{
|
||||||
_bt_br_channels_start = .;
|
_bt_l2cap_br_fixed_chan_list_start = .;
|
||||||
KEEP(*(SORT_BY_NAME("._bt_br_channels.static.*")))
|
KEEP(*(SORT_BY_NAME("._bt_l2cap_br_fixed_chan.static.*")))
|
||||||
_bt_br_channels_end = .;
|
_bt_l2cap_br_fixed_chan_list_end = .;
|
||||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,6 @@
|
||||||
#define L2CAP_CONN_TIMEOUT K_SECONDS(40)
|
#define L2CAP_CONN_TIMEOUT K_SECONDS(40)
|
||||||
#define L2CAP_DISC_TIMEOUT K_SECONDS(2)
|
#define L2CAP_DISC_TIMEOUT K_SECONDS(2)
|
||||||
|
|
||||||
/* Linker-defined symbols bound to the bt_l2cap_fixed_chan structs */
|
|
||||||
extern const struct bt_l2cap_fixed_chan _bt_channels_start[];
|
|
||||||
extern const struct bt_l2cap_fixed_chan _bt_channels_end[];
|
|
||||||
|
|
||||||
#if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL)
|
#if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL)
|
||||||
/* Size of MTU is based on the maximum amount of data the buffer can hold
|
/* Size of MTU is based on the maximum amount of data the buffer can hold
|
||||||
* excluding ACL and driver headers.
|
* excluding ACL and driver headers.
|
||||||
|
@ -323,7 +319,6 @@ static bool l2cap_chan_add(struct bt_conn *conn, struct bt_l2cap_chan *chan,
|
||||||
|
|
||||||
void bt_l2cap_connected(struct bt_conn *conn)
|
void bt_l2cap_connected(struct bt_conn *conn)
|
||||||
{
|
{
|
||||||
const struct bt_l2cap_fixed_chan *fchan;
|
|
||||||
struct bt_l2cap_chan *chan;
|
struct bt_l2cap_chan *chan;
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BT_BREDR) &&
|
if (IS_ENABLED(CONFIG_BT_BREDR) &&
|
||||||
|
@ -332,7 +327,7 @@ void bt_l2cap_connected(struct bt_conn *conn)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (fchan = _bt_channels_start; fchan < _bt_channels_end; fchan++) {
|
Z_STRUCT_SECTION_FOREACH(bt_l2cap_fixed_chan, fchan) {
|
||||||
struct bt_l2cap_le_chan *ch;
|
struct bt_l2cap_le_chan *ch;
|
||||||
|
|
||||||
if (fchan->accept(conn, &chan) < 0) {
|
if (fchan->accept(conn, &chan) < 0) {
|
||||||
|
|
|
@ -79,9 +79,6 @@ enum {
|
||||||
|
|
||||||
static sys_slist_t br_servers;
|
static sys_slist_t br_servers;
|
||||||
|
|
||||||
/* Linker-defined symbols bound to the bt_l2cap_fixed_chan structs */
|
|
||||||
extern const struct bt_l2cap_fixed_chan _bt_br_channels_start[];
|
|
||||||
extern const struct bt_l2cap_fixed_chan _bt_br_channels_end[];
|
|
||||||
|
|
||||||
/* Pool for outgoing BR/EDR signaling packets, min MTU is 48 */
|
/* Pool for outgoing BR/EDR signaling packets, min MTU is 48 */
|
||||||
NET_BUF_POOL_DEFINE(br_sig_pool, CONFIG_BT_MAX_CONN,
|
NET_BUF_POOL_DEFINE(br_sig_pool, CONFIG_BT_MAX_CONN,
|
||||||
|
@ -386,12 +383,10 @@ done:
|
||||||
|
|
||||||
static u8_t get_fixed_channels_mask(void)
|
static u8_t get_fixed_channels_mask(void)
|
||||||
{
|
{
|
||||||
const struct bt_l2cap_fixed_chan *fchan;
|
|
||||||
u8_t mask = 0U;
|
u8_t mask = 0U;
|
||||||
|
|
||||||
/* this needs to be enhanced if AMP Test Manager support is added */
|
/* this needs to be enhanced if AMP Test Manager support is added */
|
||||||
for (fchan = _bt_br_channels_start; fchan < _bt_br_channels_end;
|
Z_STRUCT_SECTION_FOREACH(bt_l2cap_br_fixed_chan, fchan) {
|
||||||
fchan++) {
|
|
||||||
mask |= BIT(fchan->cid);
|
mask |= BIT(fchan->cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,11 +449,9 @@ static int l2cap_br_info_req(struct bt_l2cap_br *l2cap, u8_t ident,
|
||||||
|
|
||||||
void bt_l2cap_br_connected(struct bt_conn *conn)
|
void bt_l2cap_br_connected(struct bt_conn *conn)
|
||||||
{
|
{
|
||||||
const struct bt_l2cap_fixed_chan *fchan;
|
|
||||||
struct bt_l2cap_chan *chan;
|
struct bt_l2cap_chan *chan;
|
||||||
|
|
||||||
for (fchan = _bt_br_channels_start; fchan < _bt_br_channels_end;
|
Z_STRUCT_SECTION_FOREACH(bt_l2cap_br_fixed_chan, fchan) {
|
||||||
fchan++) {
|
|
||||||
struct bt_l2cap_br_chan *ch;
|
struct bt_l2cap_br_chan *ch;
|
||||||
|
|
||||||
if (!fchan->accept) {
|
if (!fchan->accept) {
|
||||||
|
@ -1550,7 +1543,7 @@ static int l2cap_br_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
BT_L2CAP_CHANNEL_DEFINE(br_fixed_chan, BT_L2CAP_CID_BR_SIG, l2cap_br_accept);
|
BT_L2CAP_BR_CHANNEL_DEFINE(br_fixed_chan, BT_L2CAP_CID_BR_SIG, l2cap_br_accept);
|
||||||
|
|
||||||
void bt_l2cap_br_init(void)
|
void bt_l2cap_br_init(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -205,8 +205,16 @@ struct bt_l2cap_fixed_chan {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BT_L2CAP_CHANNEL_DEFINE(_name, _cid, _accept) \
|
#define BT_L2CAP_CHANNEL_DEFINE(_name, _cid, _accept) \
|
||||||
const struct bt_l2cap_fixed_chan _name __aligned(4) \
|
const Z_STRUCT_SECTION_ITERABLE(bt_l2cap_fixed_chan, _name) = { \
|
||||||
__in_section(_bt_channels, static, _name) = { \
|
.cid = _cid, \
|
||||||
|
.accept = _accept, \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Need a different name for the sections not to conflict */
|
||||||
|
#define bt_l2cap_br_fixed_chan bt_l2cap_fixed_chan
|
||||||
|
|
||||||
|
#define BT_L2CAP_BR_CHANNEL_DEFINE(_name, _cid, _accept) \
|
||||||
|
const Z_STRUCT_SECTION_ITERABLE(bt_l2cap_br_fixed_chan, _name) = { \
|
||||||
.cid = _cid, \
|
.cid = _cid, \
|
||||||
.accept = _accept, \
|
.accept = _accept, \
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue