aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-06-03 16:10:51 +0200
committerlaforge <laforge@osmocom.org>2020-06-05 20:57:08 +0000
commit897aa786c20b1fcb91aebb4f579554902f151c48 (patch)
treec77475c16871413b899c58c9346b14bc80deb3f5
parentaa5e46dc9aa92c3086fb66acbbf1966df692edba (diff)
bts-trx: phy_link: Improve logging fmt in phy_link_state_set()
-rw-r--r--include/osmo-bts/phy_link.h2
-rw-r--r--src/common/phy_link.c23
2 files changed, 16 insertions, 9 deletions
diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h
index cf877bde..2bed8ea3 100644
--- a/include/osmo-bts/phy_link.h
+++ b/include/osmo-bts/phy_link.h
@@ -157,6 +157,7 @@ struct phy_instance {
struct phy_link *phy_link_by_num(int num);
struct phy_link *phy_link_create(void *ctx, int num);
void phy_link_destroy(struct phy_link *plink);
+const char *phy_link_name(struct phy_link *plink);
void phy_link_state_set(struct phy_link *plink, enum phy_link_state state);
enum phy_link_state phy_link_state_get(struct phy_link *plink);
const char *phy_link_state_name(enum phy_link_state state);
@@ -178,4 +179,5 @@ static inline struct phy_instance *trx_phy_instance(const struct gsm_bts_trx *tr
int bts_model_phy_link_open(struct phy_link *plink);
+#define LOGPPHL(plink, section, lvl, fmt, args...) LOGP(section, lvl, "%s: " fmt, phy_link_name(plink), ##args)
#define LOGPPHI(pinst, section, lvl, fmt, args...) LOGP(section, lvl, "%s: " fmt, phy_instance_name(pinst), ##args)
diff --git a/src/common/phy_link.c b/src/common/phy_link.c
index 85f9e143..38819ebf 100644
--- a/src/common/phy_link.c
+++ b/src/common/phy_link.c
@@ -53,9 +53,9 @@ void phy_link_state_set(struct phy_link *plink, enum phy_link_state state)
{
struct phy_instance *pinst;
- LOGP(DL1C, LOGL_INFO, "PHY link state change %s -> %s\n",
- get_value_string(phy_link_state_vals, plink->state),
- get_value_string(phy_link_state_vals, state));
+ LOGPPHL(plink, DL1C, LOGL_INFO, "PHY link state change %s -> %s\n",
+ get_value_string(phy_link_state_vals, plink->state),
+ get_value_string(phy_link_state_vals, state));
/* notify all TRX associated with this phy */
llist_for_each_entry(pinst, &plink->instances, list) {
@@ -65,11 +65,11 @@ void phy_link_state_set(struct phy_link *plink, enum phy_link_state state)
switch (state) {
case PHY_LINK_CONNECTED:
- LOGP(DL1C, LOGL_INFO, "trx_set_avail(1)\n");
+ LOGPPHI(pinst, DL1C, LOGL_INFO, "trx_set_avail(1)\n");
trx_set_available(trx, 1);
break;
case PHY_LINK_SHUTDOWN:
- LOGP(DL1C, LOGL_INFO, "trx_set_avail(0)\n");
+ LOGPPHI(pinst, DL1C, LOGL_INFO, "trx_set_avail(0)\n");
trx_set_available(trx, 0);
break;
case PHY_LINK_CONNECTING:
@@ -148,6 +148,13 @@ void phy_link_destroy(struct phy_link *plink)
talloc_free(plink);
}
+static char name_buf[32];
+const char *phy_link_name(struct phy_link *plink)
+{
+ snprintf(name_buf, sizeof(name_buf), "phy%u", plink->num);
+ return name_buf;
+}
+
int phy_links_open(void)
{
struct phy_link *plink;
@@ -165,9 +172,7 @@ int phy_links_open(void)
const char *phy_instance_name(struct phy_instance *pinst)
{
- static char buf[32];
-
- snprintf(buf, sizeof(buf), "phy%u.%u", pinst->phy_link->num,
+ snprintf(name_buf, sizeof(name_buf), "phy%u.%u", pinst->phy_link->num,
pinst->num);
- return buf;
+ return name_buf;
}