[PATCH] osmo-bts[master]: LC15: fix coding style

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Minh-Quang Nguyen gerrit-no-reply at lists.osmocom.org
Fri Sep 2 18:07:53 UTC 2016


Review at  https://gerrit.osmocom.org/807

LC15: fix coding style

Change-Id: I18d07822df1f36a6855b72f83e2d73d221aa8735
---
M src/osmo-bts-litecell15/calib_file.c
1 file changed, 142 insertions(+), 143 deletions(-)


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

diff --git a/src/osmo-bts-litecell15/calib_file.c b/src/osmo-bts-litecell15/calib_file.c
index ac39e46..0714bc9 100644
--- a/src/osmo-bts-litecell15/calib_file.c
+++ b/src/osmo-bts-litecell15/calib_file.c
@@ -42,10 +42,9 @@
 #include "lc15bts.h"
 #include "utils.h"
 
-/**
- *  * Maximum calibration data chunk size
- *   */
+/* Maximum calibration data chunk size */
 #define MAX_CALIB_TBL_SIZE  65536
+/* Calibration header version */
 #define CALIB_HDR_V1  0x01
 
 struct calib_file_desc {
@@ -93,19 +92,19 @@
     {
         struct
         {
-            uint8_t u8Version;                // Header version (1)
-            uint8_t u8Parity;                 // Parity byte (xor)
-            uint8_t u8Type;                   // Table type (0:TX Downlink, 1:RX-A Uplink, 2:RX-B Uplink)
-            uint8_t u8Band;                   // GSM Band (0:GSM-850, 1:EGSM-900, 2:DCS-1800, 3:PCS-1900)
-            uint32_t u32Len;                  // Table length in bytes including the header
+            uint8_t u8Version;                /* Header version (1) */
+            uint8_t u8Parity;                 /* Parity byte (xor) */
+            uint8_t u8Type;                   /* Table type (0:TX Downlink, 1:RX-A Uplink, 2:RX-B Uplink) */
+            uint8_t u8Band;                   /* GSM Band (0:GSM-850, 1:EGSM-900, 2:DCS-1800, 3:PCS-1900) */
+            uint32_t u32Len;                  /* Table length in bytes including the header */
             struct
             {
-                uint32_t u32DescOfst;         // Description section offset
-                uint32_t u32DateOfst;         // Date section offset
-                uint32_t u32StationOfst;      // Calibration test station section offset
-                uint32_t u32FpgaFwVerOfst;    // Calibration FPGA firmware version section offset
-                uint32_t u32DspFwVerOfst;     // Calibration DSP firmware section offset
-                uint32_t u32DataOfst;         // Calibration data section offset
+                uint32_t u32DescOfst;         /* Description section offset */
+                uint32_t u32DateOfst;         /* Date section offset */
+                uint32_t u32StationOfst;      /* Calibration test station section offset */
+                uint32_t u32FpgaFwVerOfst;    /* Calibration FPGA firmware version section offset */
+                uint32_t u32DspFwVerOfst;     /* Calibration DSP firmware section offset */
+                uint32_t u32DataOfst;         /* Calibration data section offset */
             } toc;
         } v1;
     } hdr;
@@ -137,7 +136,7 @@
 {
 	struct calib_send_state *st = &fl1h->st;
 	char *calib_path = fl1h->phy_inst->u.lc15.calib_path;
-        char fname[PATH_MAX];
+	char fname[PATH_MAX];
 
 	if (st->fp) {
 		LOGP(DL1C, LOGL_NOTICE, "L1 calibration file was left opened !!\n");
@@ -145,9 +144,9 @@
 		st->fp = NULL;
 	}
 
-        fname[0] = '\0';
-        snprintf(fname, sizeof(fname)-1, "%s/%s", calib_path, desc->fname);
-        fname[sizeof(fname)-1] = '\0';
+	fname[0] = '\0';
+	snprintf(fname, sizeof(fname)-1, "%s/%s", calib_path, desc->fname);
+	fname[sizeof(fname)-1] = '\0';
 
         st->fp = fopen(fname, "rb");
         if (!st->fp) {
@@ -225,14 +224,14 @@
 	rc = calib_file_open(fl1h, desc);
 	if (rc < 0) {
 		/* still, we'd like to continue trying to load
-                 * calibration for all other bands */
-                st->last_file_idx = get_next_calib_file_idx(fl1h, st->last_file_idx);
-                if (st->last_file_idx >= 0)
-                        return calib_file_send(fl1h,
-                                               &calib_files[st->last_file_idx]);
+		 * calibration for all other bands */
+		st->last_file_idx = get_next_calib_file_idx(fl1h, st->last_file_idx);
+		if (st->last_file_idx >= 0)
+			return calib_file_send(fl1h,
+					&calib_files[st->last_file_idx]);
 
 		LOGP(DL1C, LOGL_INFO, "L1 calibration table loading complete!\n");
-                return 0;
+		return 0;
 	}
 
 	rc = calib_verify(fl1h, desc);
@@ -269,8 +268,8 @@
 
 		/* Skip this one and try the next one */
 		st->last_file_idx = get_next_calib_file_idx(fl1h, st->last_file_idx);
-	        if (st->last_file_idx >= 0) {
-        	        return calib_file_send(fl1h, 
+		if (st->last_file_idx >= 0) {
+			return calib_file_send(fl1h,
 					&calib_files[st->last_file_idx]);
 		}
 
@@ -307,152 +306,152 @@
 
 static int calib_verify(struct lc15l1_hdl *fl1h, const struct calib_file_desc *desc)
 {
-       int rc, sz;
-       struct calib_send_state *st = &fl1h->st;
-       struct phy_link *plink = fl1h->phy_inst->phy_link;
-       char *rbuf;
-       struct calTbl_t *calTbl;
-       char calChkSum ;
+	int i, rc, sz;
+	struct calib_send_state *st = &fl1h->st;
+	struct phy_link *plink = fl1h->phy_inst->phy_link;
+	char *rbuf;
+	struct calTbl_t *calTbl;
+	char calChkSum ;
 
 
-       //calculate file size in bytes
-       fseek(st->fp, 0L, SEEK_END);
-       sz = ftell(st->fp);
+	/* calculate file size in bytes */
+	fseek(st->fp, 0L, SEEK_END);
+	sz = ftell(st->fp);
 
-       //rewind read poiner
-       fseek(st->fp, 0L, SEEK_SET);
+	/* rewind read poiner */
+	fseek(st->fp, 0L, SEEK_SET);
 
-       //read file
-       rbuf = (char *) malloc( sizeof(char) * sz );
+	/* read file */
+	rbuf = (char *) malloc( sizeof(char) * sz );
 
-       rc = fread(rbuf, 1, sizeof(char) * sz, st->fp);
-       if ( rc != sz) {
+	rc = fread(rbuf, 1, sizeof(char) * sz, st->fp);
+	if (rc != sz) {
+		LOGP(DL1C, LOGL_ERROR, "%s reading error\n", desc->fname);
+		free(rbuf);
 
-               LOGP(DL1C, LOGL_ERROR, "%s reading error\n", desc->fname);
-               free(rbuf);
+		/* close file */
+		rc = calib_file_close(fl1h);
+		if (rc < 0 ) {
+			LOGP(DL1C, LOGL_ERROR, "%s can not close\n", desc->fname);
+			return rc;
+		}
 
-               //close file
-               rc = calib_file_close(fl1h);
-               if (rc < 0 ) {
-                       LOGP(DL1C, LOGL_ERROR, "%s can not close\n", desc->fname);
-                       return rc;
-               }
-
-               return -2;
-       }
+		return -2;
+	}
 
 
-       calTbl = (struct calTbl_t*) rbuf;
-       //calcualte file checksum
-       calChkSum = 0;
-       while ( sz-- ) {
-               calChkSum ^= rbuf[sz];
-       }
+	calTbl = (struct calTbl_t*) rbuf;
+	/* calculate file checksum */
+	calChkSum = 0;
+	while (sz--) {
+		calChkSum ^= rbuf[sz];
+	}
 
-       //validate Tx calibration parity
-       if ( calChkSum ) {
-               LOGP(DL1C, LOGL_ERROR, "%s has invalid checksum %x.\n", desc->fname, calChkSum);
-               return -4;
-       }
+	/* validate Tx calibration parity */
+	if (calChkSum) {
+		LOGP(DL1C, LOGL_ERROR, "%s has invalid checksum %x.\n", desc->fname, calChkSum);
+		return -4;
+	}
 
-       //validate Tx calibration header
-       if ( calTbl->hdr.v1.u8Version != CALIB_HDR_V1 ) {
-               LOGP(DL1C, LOGL_ERROR, "%s has invalid header version %u.\n", desc->fname, calTbl->hdr.v1.u8Version);
-               return -5;
-       }
+	/* validate Tx calibration header */
+	if (calTbl->hdr.v1.u8Version != CALIB_HDR_V1) {
+		LOGP(DL1C, LOGL_ERROR, "%s has invalid header version %u.\n", desc->fname, calTbl->hdr.v1.u8Version);
+		return -5;
+	}
 
-       //validate calibration description
-       if ( calTbl->hdr.v1.toc.u32DescOfst == 0xFFFFFFFF ) {
-               LOGP(DL1C, LOGL_ERROR, "%s has invalid calibration description  offset.\n", desc->fname);
-               return -6;
-       }
+	/* validate calibration description */
+	if (calTbl->hdr.v1.toc.u32DescOfst == 0xFFFFFFFF) {
+		LOGP(DL1C, LOGL_ERROR, "%s has invalid calibration description  offset.\n", desc->fname);
+		return -6;
+	}
 
-       //validate calibration date
-       if ( calTbl->hdr.v1.toc.u32DateOfst == 0xFFFFFFFF ) {
-               LOGP(DL1C, LOGL_ERROR, "%s has invalid calibration date offset.\n", desc->fname);
-               return -7;
-       }
+	/* validate calibration date */
+	if (calTbl->hdr.v1.toc.u32DateOfst == 0xFFFFFFFF) {
+		LOGP(DL1C, LOGL_ERROR, "%s has invalid calibration date offset.\n", desc->fname);
+		return -7;
+	}
 
-       LOGP(DL1C, LOGL_INFO, "L1 calibration table %s created on %s\n",
-               desc->fname,
-               calTbl->u8RawData + calTbl->hdr.v1.toc.u32DateOfst);
+	LOGP(DL1C, LOGL_INFO, "L1 calibration table %s created on %s\n",
+		desc->fname,
+		calTbl->u8RawData + calTbl->hdr.v1.toc.u32DateOfst);
 
-       //validate calibration station
-       if ( calTbl->hdr.v1.toc.u32StationOfst == 0xFFFFFFFF ) {
-               LOGP(DL1C, LOGL_ERROR, "%s has invalid calibration station ID offset.\n", desc->fname);
-               return -8;
-       }
+	/* validate calibration station */
+	if (calTbl->hdr.v1.toc.u32StationOfst == 0xFFFFFFFF) {
+		LOGP(DL1C, LOGL_ERROR, "%s has invalid calibration station ID offset.\n", desc->fname);
+		return -8;
+	}
 
-       //validate FPGA FW version
-       if ( calTbl->hdr.v1.toc.u32FpgaFwVerOfst == 0xFFFFFFFF ) {
-               LOGP(DL1C, LOGL_ERROR, "%s has invalid FPGA FW version offset.\n", desc->fname);
-               return -9;
-       }
-       //validate DSP FW version
-       if ( calTbl->hdr.v1.toc.u32DspFwVerOfst == 0xFFFFFFFF ) {
-               LOGP(DL1C, LOGL_ERROR, "%s has invalid DSP FW version offset.\n", desc->fname);
-               return -10;
-       }
+	/* validate FPGA FW version */
+	if (calTbl->hdr.v1.toc.u32FpgaFwVerOfst == 0xFFF) {
+		LOGP(DL1C, LOGL_ERROR, "%s has invalid FPGA FW version offset.\n", desc->fname);
+		return -9;
+	}
 
-       //validate Tx calibration data offset
-       if ( calTbl->hdr.v1.toc.u32DataOfst == 0xFFFFFFFF ) {
-               LOGP(DL1C, LOGL_ERROR, "%s has invalid calibration data offset.\n", desc->fname);
-               return -11;
-       }
+	/* validate DSP FW version */
+	if (calTbl->hdr.v1.toc.u32DspFwVerOfst == 0xFFFFFFFF) {
+		LOGP(DL1C, LOGL_ERROR, "%s has invalid DSP FW version offset.\n", desc->fname);
+		return -10;
+	}
 
-       if ( !desc->rx ) {
+	/* validate Tx calibration data offset */
+	if (calTbl->hdr.v1.toc.u32DataOfst == 0xFFFFFFFF) {
+		LOGP(DL1C, LOGL_ERROR, "%s has invalid calibration data offset.\n", desc->fname);
+		return -11;
+	}
 
-               //parse min/max Tx power
-               fl1h->phy_inst->u.lc15.minTxPower = calTbl->u8RawData[calTbl->hdr.v1.toc.u32DataOfst + (5 << 2)];
-               fl1h->phy_inst->u.lc15.maxTxPower = calTbl->u8RawData[calTbl->hdr.v1.toc.u32DataOfst + (6 << 2)];
+	if (!desc->rx) {
 
-               //override nominal Tx power of given TRX if needed
-               if ( fl1h->phy_inst->trx->nominal_power > fl1h->phy_inst->u.lc15.maxTxPower) {
-                       LOGP(DL1C, LOGL_INFO, "Set TRX %u nominal Tx power to %d dBm (%d)\n",
-                                       plink->num,
-                                       fl1h->phy_inst->u.lc15.maxTxPower,
-                                       fl1h->phy_inst->trx->nominal_power);
+		/* parse min/max Tx power */
+		fl1h->phy_inst->u.lc15.minTxPower = calTbl->u8RawData[calTbl->hdr.v1.toc.u32DataOfst + (5 << 2)];
+		fl1h->phy_inst->u.lc15.maxTxPower = calTbl->u8RawData[calTbl->hdr.v1.toc.u32DataOfst + (6 << 2)];
 
-                       fl1h->phy_inst->trx->nominal_power = fl1h->phy_inst->u.lc15.maxTxPower;
-               }
+		/* override nominal Tx power of given TRX if needed */
+		if (fl1h->phy_inst->trx->nominal_power > fl1h->phy_inst->u.lc15.maxTxPower) {
+			LOGP(DL1C, LOGL_INFO, "Set TRX %u nominal Tx power to %d dBm (%d)\n",
+				plink->num,
+				fl1h->phy_inst->u.lc15.maxTxPower,
+				fl1h->phy_inst->trx->nominal_power);
 
-               if ( fl1h->phy_inst->trx->nominal_power < fl1h->phy_inst->u.lc15.minTxPower) {
-                       LOGP(DL1C, LOGL_INFO, "Set TRX %u nominal Tx power to %d dBm (%d)\n",
-                                       plink->num,
-                                       fl1h->phy_inst->u.lc15.minTxPower,
-                                       fl1h->phy_inst->trx->nominal_power);
+			fl1h->phy_inst->trx->nominal_power = fl1h->phy_inst->u.lc15.maxTxPower;
+		}
 
-                       fl1h->phy_inst->trx->nominal_power = fl1h->phy_inst->u.lc15.minTxPower;
-               }
+		if (fl1h->phy_inst->trx->nominal_power < fl1h->phy_inst->u.lc15.minTxPower) {
+			LOGP(DL1C, LOGL_INFO, "Set TRX %u nominal Tx power to %d dBm (%d)\n",
+				plink->num,
+				fl1h->phy_inst->u.lc15.minTxPower,
+				fl1h->phy_inst->trx->nominal_power);
 
-               if ( fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm > to_mdB(fl1h->phy_inst->u.lc15.maxTxPower) ) {
-                       LOGP(DL1C, LOGL_INFO, "Set TRX %u Tx power parameter to %d dBm (%d)\n",
-                                       plink->num,
-                                       to_mdB(fl1h->phy_inst->u.lc15.maxTxPower),
-                                       fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm);
+			fl1h->phy_inst->trx->nominal_power = fl1h->phy_inst->u.lc15.minTxPower;
+		}
 
-                       fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm = to_mdB(fl1h->phy_inst->u.lc15.maxTxPower);
-               }
+		if (fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm > to_mdB(fl1h->phy_inst->u.lc15.maxTxPower) ) {
+			LOGP(DL1C, LOGL_INFO, "Set TRX %u Tx power parameter to %d dBm (%d)\n",
+				plink->num,
+				to_mdB(fl1h->phy_inst->u.lc15.maxTxPower),
+				fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm);
 
-               if ( fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm < to_mdB(fl1h->phy_inst->u.lc15.minTxPower) ) {
-                       LOGP(DL1C, LOGL_INFO, "Set TRX %u Tx power parameter to %d dBm (%d)\n",
-                                       plink->num,
-                                       to_mdB(fl1h->phy_inst->u.lc15.minTxPower),
-                                       fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm);
+			fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm = to_mdB(fl1h->phy_inst->u.lc15.maxTxPower);
+		}
 
-                       fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm = to_mdB(fl1h->phy_inst->u.lc15.minTxPower);
-               }
+		if (fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm < to_mdB(fl1h->phy_inst->u.lc15.minTxPower) ) {
+			LOGP(DL1C, LOGL_INFO, "Set TRX %u Tx power parameter to %d dBm (%d)\n",
+				plink->num,
+				to_mdB(fl1h->phy_inst->u.lc15.minTxPower),
+				fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm);
 
-               LOGP(DL1C, LOGL_DEBUG, "%s: minTxPower=%d, maxTxPower=%d\n",
-                               desc->fname,
-                               fl1h->phy_inst->u.lc15.minTxPower,
-                               fl1h->phy_inst->u.lc15.maxTxPower );
-       }
+			fl1h->phy_inst->trx->power_params.trx_p_max_out_mdBm = to_mdB(fl1h->phy_inst->u.lc15.minTxPower);
+		}
 
-       //rewind read poiner for subsequence tasks
-       fseek(st->fp, 0L, SEEK_SET);
-       free(rbuf);
+		LOGP(DL1C, LOGL_DEBUG, "%s: minTxPower=%d, maxTxPower=%d\n",
+			desc->fname,
+			fl1h->phy_inst->u.lc15.minTxPower,
+			fl1h->phy_inst->u.lc15.maxTxPower );
+	}
 
-       return 0;
+	/* rewind read pointer for subsequence tasks */
+	fseek(st->fp, 0L, SEEK_SET);
+	free(rbuf);
+
+	return 0;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/807
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I18d07822df1f36a6855b72f83e2d73d221aa8735
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Minh-Quang Nguyen <minh-quang.nguyen at nutaq.com>



More information about the gerrit-log mailing list