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


Change subject: Use uint8_t instead of int8_t for Timing Advance
......................................................................

Use uint8_t instead of int8_t for Timing Advance

According to the GSM specifications, Timing Advance value shall
be in range [0..63]. For some reason, a signed int8_t type was
used to store this value. Let's use an unsigned uint8_t in order
to avoid possible confusion and to prevent possible mistakes
of passing a negative value.

Change-Id: Ib2ffd24bfb5abb7cc03b20a99628ef18dd365c15
---
M include/l1ctl_proto.h
M src/host/trxcon/l1ctl.c
M src/host/trxcon/trx_if.c
M src/host/trxcon/trx_if.h
M src/host/virt_phy/src/l1ctl_sap.c
M src/target/firmware/include/layer1/sync.h
M src/target/firmware/layer1/l23_api.c
7 files changed, 11 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/80/10780/1

diff --git a/include/l1ctl_proto.h b/include/l1ctl_proto.h
index 9d548bc..9992eae 100644
--- a/include/l1ctl_proto.h
+++ b/include/l1ctl_proto.h
@@ -241,7 +241,7 @@

 /* the l1_info_ul header is in front */
 struct l1ctl_par_req {
-       int8_t ta;
+       uint8_t ta;
        uint8_t tx_power;
        uint8_t padding[2];
 } __attribute__((packed));
diff --git a/src/host/trxcon/l1ctl.c b/src/host/trxcon/l1ctl.c
index 49d6a12..0efd0be 100644
--- a/src/host/trxcon/l1ctl.c
+++ b/src/host/trxcon/l1ctl.c
@@ -659,7 +659,7 @@
        par_req = (struct l1ctl_par_req *) ul->payload;

        LOGP(DL1C, LOGL_NOTICE, "Received L1CTL_PARAM_REQ "
-               "(ta=%d, tx_power=%u)\n", par_req->ta, par_req->tx_power);
+               "(ta=%u, tx_power=%u)\n", par_req->ta, par_req->tx_power);

        rc |= trx_if_cmd_setta(l1l->trx, par_req->ta);

diff --git a/src/host/trxcon/trx_if.c b/src/host/trxcon/trx_if.c
index 89331f3..6fa4996 100644
--- a/src/host/trxcon/trx_if.c
+++ b/src/host/trxcon/trx_if.c
@@ -409,19 +409,19 @@
  * RSP SETTA <status> <TA>
  */

-int trx_if_cmd_setta(struct trx_instance *trx, int8_t ta)
+int trx_if_cmd_setta(struct trx_instance *trx, uint8_t ta)
 {
        /* Do nothing, if requested TA value matches the current */
        if (trx->ta == ta)
                return 0;

        /* Make sure that TA value is in valid range */
-       if (ta < 0 || ta > 63) {
-               LOGP(DTRX, LOGL_ERROR, "TA value %d is out of allowed range\n", 
ta);
+       if (ta > 63) {
+               LOGP(DTRX, LOGL_ERROR, "TA value %u is out of allowed range\n", 
ta);
                return -ENOTSUP;
        }

-       return trx_ctrl_cmd(trx, 0, "SETTA", "%d", ta);
+       return trx_ctrl_cmd(trx, 0, "SETTA", "%u", ta);
 }

 /* Get response from CTRL socket */
diff --git a/src/host/trxcon/trx_if.h b/src/host/trxcon/trx_if.h
index ed6bd3f..9e2615f 100644
--- a/src/host/trxcon/trx_if.h
+++ b/src/host/trxcon/trx_if.h
@@ -34,7 +34,7 @@
        uint8_t tx_power;
        uint8_t bsic;
        uint8_t tsc;
-       int8_t ta;
+       uint8_t ta;

        /* Scheduler stuff */
        struct trx_sched sched;
@@ -64,7 +64,7 @@
 int trx_if_cmd_setpower(struct trx_instance *trx, int db);
 int trx_if_cmd_adjpower(struct trx_instance *trx, int db);

-int trx_if_cmd_setta(struct trx_instance *trx, int8_t ta);
+int trx_if_cmd_setta(struct trx_instance *trx, uint8_t ta);

 int trx_if_cmd_rxtune(struct trx_instance *trx, uint16_t band_arfcn);
 int trx_if_cmd_txtune(struct trx_instance *trx, uint16_t band_arfcn);
diff --git a/src/host/virt_phy/src/l1ctl_sap.c 
b/src/host/virt_phy/src/l1ctl_sap.c
index aac49bf..df4ad64 100644
--- a/src/host/virt_phy/src/l1ctl_sap.c
+++ b/src/host/virt_phy/src/l1ctl_sap.c
@@ -399,7 +399,7 @@
        struct l1ctl_info_ul *ul = (struct l1ctl_info_ul *)l1h->data;
        struct l1ctl_par_req *par_req = (struct l1ctl_par_req *)ul->payload;

-       LOGPMS(DL1C, LOGL_INFO, ms, "Rx L1CTL_PARAM_REQ (ta=%d, tx_power=%d)\n",
+       LOGPMS(DL1C, LOGL_INFO, ms, "Rx L1CTL_PARAM_REQ (ta=%u, tx_power=%d)\n",
                par_req->ta, par_req->tx_power);
 }

diff --git a/src/target/firmware/include/layer1/sync.h 
b/src/target/firmware/include/layer1/sync.h
index dae85a1..ed305e9 100644
--- a/src/target/firmware/include/layer1/sync.h
+++ b/src/target/firmware/include/layer1/sync.h
@@ -75,7 +75,7 @@
        int32_t         tpu_offset_correction;

        /* TX parameters */
-       int8_t          ta;
+       uint8_t         ta;
        uint8_t         tx_power;

        /* TCH */
diff --git a/src/target/firmware/layer1/l23_api.c 
b/src/target/firmware/layer1/l23_api.c
index e53b0c8..5bfece7 100644
--- a/src/target/firmware/layer1/l23_api.c
+++ b/src/target/firmware/layer1/l23_api.c
@@ -337,7 +337,7 @@
        struct l1ctl_info_ul *ul = (struct l1ctl_info_ul *) l1h->data;
        struct l1ctl_par_req *par_req = (struct l1ctl_par_req *) ul->payload;

-       printd("L1CTL_PARAM_REQ (ta=%d, tx_power=%d)\n", par_req->ta,
+       printd("L1CTL_PARAM_REQ (ta=%u, tx_power=%d)\n", par_req->ta,
                par_req->tx_power);

        l1s.ta = par_req->ta;

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

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib2ffd24bfb5abb7cc03b20a99628ef18dd365c15
Gerrit-Change-Number: 10780
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <[email protected]>

Reply via email to