Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/11873


Change subject: Fix deprecated gsm_arfcn2band(), use gsm_arfcn2band_rc()
......................................................................

Fix deprecated gsm_arfcn2band(), use gsm_arfcn2band_rc()

Change-Id: I45aae70f4bc3f4f85d267dafb757debdef1bb7d7
---
M src/osmo-bts-litecell15/utils.c
M src/osmo-bts-oc2g/oml.c
M src/osmo-bts-oc2g/utils.c
M src/osmo-bts-sysmo/utils.c
M src/osmo-bts-trx/loops.c
5 files changed, 27 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/73/11873/1

diff --git a/src/osmo-bts-litecell15/utils.c b/src/osmo-bts-litecell15/utils.c
index 8c3eb5a..8d980ba 100644
--- a/src/osmo-bts-litecell15/utils.c
+++ b/src/osmo-bts-litecell15/utils.c
@@ -82,6 +82,7 @@
 {
        enum gsm_band band;
        struct gsm_bts *bts = trx->bts;
+       int rc;

        if (!bts->auto_band)
                return band_osmo2lc15(trx, bts->band);
@@ -89,7 +90,9 @@
        /*
         * We need to check what will happen now.
         */
-       band = gsm_arfcn2band(arfcn);
+       rc = gsm_arfcn2band_rc(arfcn, &band);
+       if (rc) /* wrong ARFCN, give up */
+               return -1;

        /* if we are already on the right band return */
        if (band == bts->band)
diff --git a/src/osmo-bts-oc2g/oml.c b/src/osmo-bts-oc2g/oml.c
index 65ebc1c..f76de92 100644
--- a/src/osmo-bts-oc2g/oml.c
+++ b/src/osmo-bts-oc2g/oml.c
@@ -398,7 +398,7 @@
        struct msgb *msg;
        GsmL1_MphInitReq_t *mi_req;
        GsmL1_DeviceParam_t *dev_par;
-       int oc2g_band;
+       int rc, oc2g_band;

        if (!gsm_abis_mo_check_attr(&trx->mo, trx_rqd_attr,
                                    ARRAY_SIZE(trx_rqd_attr))) {
@@ -409,7 +409,13 @@
        }

        /* Update TRX band */
-       trx->bts->band = gsm_arfcn2band(trx->arfcn);
+       rc = gsm_arfcn2band_rc(trx->arfcn, &trx->bts->band);
+       if (rc) {
+               /* FIXME: abort initialization? */
+               LOGP(DL1C, LOGL_ERROR, "Could not pick GSM band "
+                       "for ARFCN %u\n", trx->arfcn);
+               trx->bts->band = 0x00;
+       }

        oc2g_band = oc2gbts_select_oc2g_band(trx, trx->arfcn);
        if (oc2g_band < 0) {
diff --git a/src/osmo-bts-oc2g/utils.c b/src/osmo-bts-oc2g/utils.c
index 2894439..cb65f45 100644
--- a/src/osmo-bts-oc2g/utils.c
+++ b/src/osmo-bts-oc2g/utils.c
@@ -82,13 +82,17 @@
 {
        enum gsm_band band;
        struct gsm_bts *bts = trx->bts;
+       int rc;
+
        if (!bts->auto_band)
                return band_osmo2oc2g(trx, bts->band);

        /*
         * We need to check what will happen now.
         */
-       band = gsm_arfcn2band(arfcn);
+       rc = gsm_arfcn2band_rc(arfcn, &band);
+       if (rc) /* wrong ARFCN, give up */
+               return -1;

        /* if we are already on the right band return */
        if (band == bts->band)
diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c
index 7d1aca7..0e3ef27 100644
--- a/src/osmo-bts-sysmo/utils.c
+++ b/src/osmo-bts-sysmo/utils.c
@@ -80,6 +80,7 @@
 {
        enum gsm_band band;
        struct gsm_bts *bts = trx->bts;
+       int rc;

        if (!bts->auto_band)
                return band_osmo2femto(trx, bts->band);
@@ -87,7 +88,9 @@
        /*
         * We need to check what will happen now.
         */
-       band = gsm_arfcn2band(arfcn);
+       rc = gsm_arfcn2band_rc(arfcn, &band);
+       if (rc) /* wrong ARFCN, give up */
+               return -1;

        /* if we are already on the right band return */
        if (band == bts->band)
diff --git a/src/osmo-bts-trx/loops.c b/src/osmo-bts-trx/loops.c
index a959a71..7d131a3 100644
--- a/src/osmo-bts-trx/loops.c
+++ b/src/osmo-bts-trx/loops.c
@@ -33,7 +33,7 @@
 #include "l1_if.h"
 #include "loops.h"

-#define MS_PWR_DBM(arfcn, lvl) ms_pwr_dbm(gsm_arfcn2band(arfcn), lvl)
+#define MS_PWR_DBM(band, lvl) ms_pwr_dbm(band, lvl)

 /*
  * MS Power loop
@@ -42,6 +42,7 @@
 static int ms_power_diff(struct gsm_lchan *lchan, uint8_t chan_nr, int8_t diff)
 {
        struct gsm_bts_trx *trx = lchan->ts->trx;
+       enum gsm_band band = trx->bts->band;
        uint16_t arfcn = trx->arfcn;
        int8_t new_power;

@@ -72,7 +73,7 @@
                LOGP(DLOOP, LOGL_INFO, "Keeping MS new_power of trx=%u "
                        "chan_nr=0x%02x at control level %d (%d dBm)\n",
                        trx->nr, chan_nr, new_power,
-                       MS_PWR_DBM(arfcn, new_power));
+                       MS_PWR_DBM(band, new_power));

                return 0;
        }
@@ -81,8 +82,8 @@
                "control level %d (%d dBm) to %d (%d dBm)\n",
                (diff > 0) ? "Raising" : "Lowering",
                trx->nr, chan_nr, lchan->ms_power_ctrl.current,
-               MS_PWR_DBM(arfcn, lchan->ms_power_ctrl.current), new_power,
-               MS_PWR_DBM(arfcn, new_power));
+               MS_PWR_DBM(band, lchan->ms_power_ctrl.current), new_power,
+               MS_PWR_DBM(band, new_power));

        lchan->ms_power_ctrl.current = new_power;

@@ -158,7 +159,7 @@
        LOGP(DLOOP, LOGL_DEBUG, "Lowest RSSI: %d Target RSSI: %d Current "
                "MS power: %d (%d dBm) of trx=%u chan_nr=0x%02x\n", rssi,
                pinst->phy_link->u.osmotrx.trx_target_rssi, 
lchan->ms_power_ctrl.current,
-               MS_PWR_DBM(trx->arfcn, lchan->ms_power_ctrl.current),
+               MS_PWR_DBM(trx->bts->band, lchan->ms_power_ctrl.current),
                trx->nr, chan_nr);
        ms_power_diff(lchan, chan_nr, 
pinst->phy_link->u.osmotrx.trx_target_rssi - rssi);


--
To view, visit https://gerrit.osmocom.org/11873
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I45aae70f4bc3f4f85d267dafb757debdef1bb7d7
Gerrit-Change-Number: 11873
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <[email protected]>

Reply via email to