fixeria has uploaded this change for review.
pdch_ul_controller: migrate from fn_cmp() to gsm0502_fn_compare()
This function is also needed in osmocom-bb.git, so it becomes
a library function (part of libosmogsm).
Change-Id: I6a8502c2b2015ca7d0452ab9f5da0484a03ce91e
Depends: libosmocore.git I9590f2e836fc48650decf1564b6ab46306c4fe2d
---
M src/pdch_ul_controller.c
1 file changed, 17 insertions(+), 18 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/21/34521/1
diff --git a/src/pdch_ul_controller.c b/src/pdch_ul_controller.c
index c0e26de..85bfdc9 100644
--- a/src/pdch_ul_controller.c
+++ b/src/pdch_ul_controller.c
@@ -43,20 +43,6 @@
{ 0, NULL }
};
-#define GSM_MAX_FN_THRESH (GSM_MAX_FN >> 1)
-/* 0: equal, -1: fn1 BEFORE fn2, 1: fn1 AFTER fn2 */
-static inline int fn_cmp(uint32_t fn1, uint32_t fn2)
-{
- if (fn1 == fn2)
- return 0;
- /* FN1 goes before FN2: */
- if ((fn1 < fn2 && (fn2 - fn1) < GSM_MAX_FN_THRESH) ||
- (fn1 > fn2 && (fn1 - fn2) > GSM_MAX_FN_THRESH))
- return -1;
- /* FN1 goes after FN2: */
- return 1;
-}
-
struct pdch_ulc *pdch_ulc_alloc(struct gprs_rlcmac_pdch *pdch, void *ctx)
{
struct pdch_ulc* ulc;
@@ -78,7 +64,7 @@
while (node) {
it = rb_entry(node, struct pdch_ulc_node, node);
- res = fn_cmp(it->fn, fn);
+ res = gsm0502_fn_compare(it->fn, fn);
if (res > 0) /* it->fn AFTER fn */
node = node->rb_left;
else if (res < 0) /* it->fn BEFORE fn */
@@ -167,7 +153,7 @@
for (node = rb_first(&ulc->tree_root); node; node = rb_next(node)) {
it = container_of(node, struct pdch_ulc_node, node);
- res = fn_cmp(it->fn, check_fn);
+ res = gsm0502_fn_compare(it->fn, check_fn);
if (res > 0) { /* it->fn AFTER check_fn */
/* Next reserved FN is passed check_fn, hence it means check_fn is free */
return check_fn;
@@ -203,7 +189,7 @@
it = container_of(*n, struct pdch_ulc_node, node);
parent = *n;
- res = fn_cmp(item->fn, it->fn);
+ res = gsm0502_fn_compare(item->fn, it->fn);
if (res < 0) { /* item->fn "BEFORE" it->fn */
n = &((*n)->rb_left);
} else if (res > 0) { /* item->fn "AFTER" it->fn */
@@ -305,7 +291,7 @@
struct rb_node *first;
while ((first = rb_first(&ulc->tree_root))) {
item = container_of(first, struct pdch_ulc_node, node);
- res = fn_cmp(item->fn, fn);
+ res = gsm0502_fn_compare(item->fn, fn);
if (res > 0) /* item->fn AFTER fn */
break;
if (res < 0) { /* item->fn BEFORE fn */
To view, visit change 34521. To unsubscribe, or for help writing mail filters, visit settings.