From 5398ae0710e59bf965ccbb4e53a770f350ecaf02 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Wed, 2 Nov 2022 12:49:09 +0530 Subject: [PATCH] Bluetooth: Controller: Add LL_CIS_HANDLE_LAST, IDX_FROM_HANDLE define Rename LAST_VALID_CIS_HANDLE to LL_CIS_HANDLE_LAST, to be consistent naming with LL_CIS_HANDLE_BASE. Add IDX_FROM_HANDLE defines. Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/controller/ll_sw/ull_conn_iso.c | 5 +++-- .../bluetooth/controller/ll_sw/ull_iso_types.h | 16 +++++----------- .../controller/ll_sw/ull_peripheral_iso.c | 3 ++- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c b/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c index c38e1c1fac7..a171d78f076 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn_iso.c @@ -227,7 +227,7 @@ struct ll_conn_iso_stream *ll_conn_iso_stream_get_by_group(struct ll_conn_iso_gr handle_start = (handle_iter == NULL) || ((*handle_iter) == UINT16_MAX) ? LL_CIS_HANDLE_BASE : (*handle_iter) + 1; - for (handle = handle_start; handle <= LAST_VALID_CIS_HANDLE; handle++) { + for (handle = handle_start; handle <= LL_CIS_HANDLE_LAST; handle++) { cis = ll_conn_iso_stream_get(handle); if (cis->group == cig) { if (handle_iter) { @@ -557,7 +557,8 @@ static int init_reset(void) cig->lll.num_cis = 0; } - for (handle = LL_CIS_HANDLE_BASE; handle <= LAST_VALID_CIS_HANDLE; handle++) { + for (handle = LL_CIS_HANDLE_BASE; handle <= LL_CIS_HANDLE_LAST; + handle++) { cis = ll_conn_iso_stream_get(handle); cis->cis_id = 0; cis->group = NULL; diff --git a/subsys/bluetooth/controller/ll_sw/ull_iso_types.h b/subsys/bluetooth/controller/ll_sw/ull_iso_types.h index 614c5e3d702..1e45c2def92 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_iso_types.h +++ b/subsys/bluetooth/controller/ll_sw/ull_iso_types.h @@ -28,26 +28,20 @@ ((conn_handle) <= ((LL_BIS_SYNC_HANDLE_BASE) + \ (BT_CTLR_SYNC_ISO_STREAM_MAX) - 1U))) #else +#define LL_BIS_SYNC_IDX_FROM_HANDLE(conn_handle) 0U #define IS_SYNC_ISO_HANDLE(conn_handle) 0U #endif /* CONFIG_BT_CTLR_SYNC_ISO */ /* CIS */ +#if defined(CONFIG_BT_CTLR_CONN_ISO) #define LL_CIS_HANDLE_BASE (BT_CTLR_CONN_ISO_STREAM_HANDLE_BASE) - -#if defined(CONFIG_BT_CTLR_CONN_ISO_STREAMS) -#define LAST_VALID_CIS_HANDLE \ - (CONFIG_BT_CTLR_CONN_ISO_STREAMS + LL_CIS_HANDLE_BASE - 1) -#else -#define LAST_VALID_CIS_HANDLE (LL_CIS_HANDLE_BASE - 1) -#endif /* CONFIG_BT_CTLR_CONN_ISO_STREAMS */ - #define LL_CIS_IDX_FROM_HANDLE(_handle) \ ((_handle) - LL_CIS_HANDLE_BASE) - -#if defined(CONFIG_BT_CTLR_CONN_ISO) +#define LL_CIS_HANDLE_LAST \ + (CONFIG_BT_CTLR_CONN_ISO_STREAMS + LL_CIS_HANDLE_BASE - 1) #define IS_CIS_HANDLE(_handle) \ (((_handle) >= LL_CIS_HANDLE_BASE) && \ - ((_handle) <= LAST_VALID_CIS_HANDLE)) + ((_handle) <= LL_CIS_HANDLE_LAST)) #else #define IS_CIS_HANDLE(_handle) 0 #endif /* CONFIG_BT_CTLR_CONN_ISO */ diff --git a/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c b/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c index 5c2c6f6add5..55fe1469d0d 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c +++ b/subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c @@ -218,7 +218,8 @@ uint8_t ull_peripheral_iso_acquire(struct ll_conn *acl, return BT_HCI_ERR_INSUFFICIENT_RESOURCES; } - for (handle = LL_CIS_HANDLE_BASE; handle <= LAST_VALID_CIS_HANDLE; handle++) { + for (handle = LL_CIS_HANDLE_BASE; handle <= LL_CIS_HANDLE_LAST; + handle++) { cis = ll_iso_stream_connected_get(handle); if (cis && cis->group && cis->cis_id == req->cis_id) { /* CIS ID already in use */