You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/06/22 13:18:25 UTC

[mynewt-nimble] 05/12: nimble/ll/css: Simplify slot move

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 586be82f68610aa51113cdc333f243d54e83ede7
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Jun 9 17:43:05 2022 +0200

    nimble/ll/css: Simplify slot move
---
 nimble/controller/src/ble_ll_conn.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c
index 9199c867..94f0930e 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -463,15 +463,12 @@ ble_ll_conn_css_move(struct ble_ll_conn_sm *connsm, uint16_t slot_idx)
                   (slot_idx != BLE_LL_CONN_CSS_NO_SLOT));
 
     slot_diff = slot_idx - connsm->css_slot_idx;
-
-    if (slot_diff > 0) {
-        offset = slot_diff * ble_ll_sched_css_get_slot_us() /
-                  BLE_LL_CONN_ITVL_USECS;
-    } else {
-        offset = (ble_ll_sched_css_get_period_slots() + slot_diff) *
-                 ble_ll_sched_css_get_slot_us() / BLE_LL_CONN_ITVL_USECS;
+    if (slot_diff < 0) {
+        slot_diff += ble_ll_sched_css_get_period_slots();
     }
 
+    offset = slot_diff * ble_ll_sched_css_get_slot_us() / BLE_LL_CONN_ITVL_USECS;
+
     if (offset >= 0xffff) {
         return -1;
     }