From 9d85b55f0aa1b63578aa520e91ebf9ffcf81d83a Mon Sep 17 00:00:00 2001 From: Alessandro Rubini <rubini@gnudd.com> Date: Tue, 27 Oct 2015 09:24:31 +0100 Subject: [PATCH] general: remove mprintf calls, use pp_printf We have not been using mprintf for ages now, and it's better for the code to explicitly call pp_printf, so people is aware of it. We might "#define printf pp_printf", but currently we'd better not. Maybe when we turn this into a real operating system, next millennium... Signed-off-by: Alessandro Rubini <rubini@gnudd.com> --- arch/lm32/ram-wrs.ld | 2 -- arch/lm32/ram.ld.S | 3 --- dev/eeprom.c | 4 ++-- dev/endpoint.c | 2 +- dev/i2c.c | 4 ++-- dev/minic.c | 6 +++--- include/wrc.h | 1 - lib/bootp.c | 6 +++--- lib/net.c | 2 +- lib/util.c | 12 ++++++------ monitor/monitor_ppsi.c | 2 +- shell/cmd_calib.c | 4 ++-- shell/cmd_init.c | 8 ++++---- shell/cmd_ip.c | 4 ++-- shell/cmd_mac.c | 2 +- shell/cmd_mode.c | 2 +- shell/cmd_pll.c | 6 +++--- shell/cmd_ptrack.c | 2 +- shell/cmd_sfp.c | 28 ++++++++++++++-------------- shell/cmd_stat.c | 2 +- shell/cmd_time.c | 4 ++-- shell/shell.c | 16 ++++++++-------- system_checks.c | 2 +- wrc_main.c | 4 ++-- 24 files changed, 61 insertions(+), 67 deletions(-) diff --git a/arch/lm32/ram-wrs.ld b/arch/lm32/ram-wrs.ld index 513d197fb..3b91d373a 100644 --- a/arch/lm32/ram-wrs.ld +++ b/arch/lm32/ram-wrs.ld @@ -86,5 +86,3 @@ SECTIONS PROVIDE(_fstack = ORIGIN(stack) + LENGTH(stack) - 4); } -/* We need to provide mprintf to ptp-noposix object files, if missing */ -PROVIDE(mprintf = pp_printf); diff --git a/arch/lm32/ram.ld.S b/arch/lm32/ram.ld.S index e7c95d99c..69c828db7 100644 --- a/arch/lm32/ram.ld.S +++ b/arch/lm32/ram.ld.S @@ -65,6 +65,3 @@ SECTIONS /* First location in stack is highest address in STACK */ PROVIDE(_fstack = ORIGIN(stack) + LENGTH(stack) - 4); } - -/* We need to provide mprintf to developers with old habits, if missing */ -PROVIDE(mprintf = pp_printf); diff --git a/dev/eeprom.c b/dev/eeprom.c index 4b8a16378..62c87dd87 100644 --- a/dev/eeprom.c +++ b/dev/eeprom.c @@ -323,14 +323,14 @@ int storage_init_show(void) if (used == 0 || used == 0xffff) { used = 0; //this means the memory is blank - mprintf("Empty init script...\n"); + pp_printf("Empty init script...\n"); } //just read and print to the screen char after char for (i = 0; i < used; ++i) { if (eeprom_read(i2cif, i2c_addr, EE_BASE_INIT + sizeof(used) + i, &byte, sizeof(byte)) != sizeof(byte)) return EE_RET_I2CERR; - mprintf("%c", byte); + pp_printf("%c", byte); } return 0; diff --git a/dev/endpoint.c b/dev/endpoint.c index 502a9d3de..143f4b759 100644 --- a/dev/endpoint.c +++ b/dev/endpoint.c @@ -102,7 +102,7 @@ int ep_enable(int enabled, int autoneg) /* Disable the endpoint */ EP->ECR = 0; - mprintf("ID: %x\n", EP->IDCODE); + pp_printf("ID: %x\n", EP->IDCODE); /* Load default packet classifier rules - see ep_pfilter.c for details */ pfilter_init_default(); diff --git a/dev/i2c.c b/dev/i2c.c index 7c01113a0..2ea51a018 100644 --- a/dev/i2c.c +++ b/dev/i2c.c @@ -123,9 +123,9 @@ uint8_t mi2c_devprobe(uint8_t i2cif, uint8_t i2c_addr) // for(i=0x50;i<0x51;i++) // { // mi2c_start(i2cif); -// if(!mi2c_put_byte(i2cif, i<<1)) mprintf("found : %x\n", i); +// if(!mi2c_put_byte(i2cif, i<<1)) pp_printf("found : %x\n", i); // mi2c_stop(i2cif); // // } -// mprintf("Nothing more found...\n"); +// pp_printf("Nothing more found...\n"); //} diff --git a/dev/minic.c b/dev/minic.c index 07d445fab..ece67188d 100644 --- a/dev/minic.c +++ b/dev/minic.c @@ -211,7 +211,7 @@ int minic_rx_frame(uint8_t * hdr, uint8_t * payload, uint32_t buf_size, minic_new_rx_buffer(); } else { //otherwise, weird !! - mprintf("invalid descriptor @%x = %x\n", + pp_printf("invalid descriptor @%x = %x\n", (uint32_t) minic.rx_head, desc_hdr); minic_new_rx_buffer(); } @@ -328,7 +328,7 @@ int minic_tx_frame(uint8_t * hdr, uint8_t * payload, uint32_t size, } if (i == 1000) - mprintf("Warning: tx not terminated infinite mcr=0x%x\n",mcr); + pp_printf("Warning: tx not terminated infinite mcr=0x%x\n",mcr); if (hwts) { uint32_t raw_ts; @@ -348,7 +348,7 @@ int minic_tx_frame(uint8_t * hdr, uint8_t * payload, uint32_t size, if (i == 100) { - mprintf("Warning: tx timestamp never became available\n"); + pp_printf("Warning: tx timestamp never became available\n"); ts_valid = 0; } diff --git a/include/wrc.h b/include/wrc.h index 6f3e86a40..f2df46fd0 100644 --- a/include/wrc.h +++ b/include/wrc.h @@ -10,7 +10,6 @@ #include <inttypes.h> #include <syscon.h> #include <pp-printf.h> -#define mprintf pp_printf #define vprintf pp_vprintf #define sprintf pp_sprintf diff --git a/lib/bootp.c b/lib/bootp.c index 5f609aed8..ad4855b9a 100644 --- a/lib/bootp.c +++ b/lib/bootp.c @@ -134,7 +134,7 @@ int send_bootp(uint8_t * buf, int retry) buf[IP_CHECKSUM + 0] = sum >> 8; buf[IP_CHECKSUM + 1] = sum & 0xff; - // mprintf("Sending BOOTP request...\n"); + // pp_printf("Sending BOOTP request...\n"); return BOOTP_END; } @@ -160,9 +160,9 @@ int process_bootp(uint8_t * buf, int len) return 0; setIP(buf + BOOTP_YIADDR); - + getIP(ip); - mprintf("Discovered IP address (%d.%d.%d.%d)!\n", + pp_printf("Discovered IP address (%d.%d.%d.%d)!\n", ip[0], ip[1], ip[2], ip[3]); return 1; diff --git a/lib/net.c b/lib/net.c index 5bd2edd34..adf5a5967 100644 --- a/lib/net.c +++ b/lib/net.c @@ -50,7 +50,7 @@ int ptpd_netif_init() return PTPD_NETIF_OK; } -//#define TRACE_WRAP mprintf +//#define TRACE_WRAP pp_printf int ptpd_netif_get_hw_addr(wr_socket_t * sock, mac_addr_t * mac) { get_mac_addr((uint8_t *) mac); diff --git a/lib/util.c b/lib/util.c index 8f0e77dda..77f0525ae 100644 --- a/lib/util.c +++ b/lib/util.c @@ -81,25 +81,25 @@ char *format_time(uint64_t sec) void cprintf(int color, const char *fmt, ...) { va_list ap; - mprintf("\e[0%d;3%dm", color & C_DIM ? 2 : 1, color & 0x7f); + pp_printf("\e[0%d;3%dm", color & C_DIM ? 2 : 1, color & 0x7f); va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); - mprintf("\e[m"); + pp_printf("\e[m"); } void pcprintf(int row, int col, int color, const char *fmt, ...) { va_list ap; - mprintf("\e[%d;%df", row, col); - mprintf("\e[0%d;3%dm", color & C_DIM ? 2 : 1, color & 0x7f); + pp_printf("\e[%d;%df", row, col); + pp_printf("\e[0%d;3%dm", color & C_DIM ? 2 : 1, color & 0x7f); va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); - mprintf("\e[m"); + pp_printf("\e[m"); } void term_clear(void) { - mprintf("\e[2J\e[1;1H"); + pp_printf("\e[2J\e[1;1H"); } diff --git a/monitor/monitor_ppsi.c b/monitor/monitor_ppsi.c index 7b667bb36..461dcba2d 100644 --- a/monitor/monitor_ppsi.c +++ b/monitor/monitor_ppsi.c @@ -177,7 +177,7 @@ void wrc_mon_gui(void) if (aux_stat & SPLL_AUX_LOCKED) cprintf(C_GREEN, ", locked"); - mprintf("\n"); + pp_printf("\n"); cprintf(C_BLUE, "\nTiming parameters:\n\n"); diff --git a/shell/cmd_calib.c b/shell/cmd_calib.c index ef19ee78a..7b67774fb 100644 --- a/shell/cmd_calib.c +++ b/shell/cmd_calib.c @@ -30,12 +30,12 @@ static int cmd_calibration(const char *args[]) return storage_phtrans(&trans, 1); } else if (!args[0]) { if (storage_phtrans(&trans, 0) > 0) { - mprintf("Found phase transition in EEPROM: %dps\n", + pp_printf("Found phase transition in EEPROM: %dps\n", trans); cal_phase_transition = trans; return 0; } else { - mprintf("Measuring t2/t4 phase transition...\n"); + pp_printf("Measuring t2/t4 phase transition...\n"); if (measure_t24p(&trans) < 0) return -1; cal_phase_transition = trans; diff --git a/shell/cmd_init.c b/shell/cmd_init.c index 115d840a9..84875b01b 100644 --- a/shell/cmd_init.c +++ b/shell/cmd_init.c @@ -17,18 +17,18 @@ static int cmd_init(const char *args[]) { if (!mi2c_devprobe(WRPC_FMC_I2C, FMC_EEPROM_ADR)) { - mprintf("EEPROM not found..\n"); + pp_printf("EEPROM not found..\n"); return -1; } if (args[0] && !strcasecmp(args[0], "erase")) { if (storage_init_erase() < 0) - mprintf("Could not erase init script\n"); + pp_printf("Could not erase init script\n"); } else if (args[1] && !strcasecmp(args[0], "add")) { if (storage_init_add(args) < 0) - mprintf("Could not add the command\n"); + pp_printf("Could not add the command\n"); else - mprintf("OK.\n"); + pp_printf("OK.\n"); } else if (args[0] && !strcasecmp(args[0], "show")) { storage_init_show(); } else if (args[0] && !strcasecmp(args[0], "boot")) { diff --git a/shell/cmd_ip.c b/shell/cmd_ip.c index cf97aadb9..a7167e2b0 100644 --- a/shell/cmd_ip.c +++ b/shell/cmd_ip.c @@ -42,9 +42,9 @@ static int cmd_ip(const char *args[]) } if (needIP) { - mprintf("IP-address: in training\n"); + pp_printf("IP-address: in training\n"); } else { - mprintf("IP-address: %d.%d.%d.%d\n", + pp_printf("IP-address: %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]); } return 0; diff --git a/shell/cmd_mac.c b/shell/cmd_mac.c index f7dddfd2d..8610b9092 100644 --- a/shell/cmd_mac.c +++ b/shell/cmd_mac.c @@ -52,7 +52,7 @@ static int cmd_mac(const char *args[]) return -EINVAL; } - mprintf("MAC-address: %02x:%02x:%02x:%02x:%02x:%02x\n", + pp_printf("MAC-address: %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); return 0; } diff --git a/shell/cmd_mode.c b/shell/cmd_mode.c index 5e187d86e..3ca95103f 100644 --- a/shell/cmd_mode.c +++ b/shell/cmd_mode.c @@ -31,7 +31,7 @@ static int cmd_mode(const char *args[]) else if (!strcasecmp(args[0], "slave")) mode = WRC_MODE_SLAVE; else { - mprintf("%s\n", modes[wrc_ptp_get_mode()]); + pp_printf("%s\n", modes[wrc_ptp_get_mode()]); return 0; } return wrc_ptp_set_mode(mode); diff --git a/shell/cmd_pll.c b/shell/cmd_pll.c index 3cf235828..d78f94b0e 100644 --- a/shell/cmd_pll.c +++ b/shell/cmd_pll.c @@ -25,7 +25,7 @@ static int cmd_pll(const char *args[]) } else if (!strcasecmp(args[0], "cl")) { if (!args[1]) return -EINVAL; - mprintf("%d\n", spll_check_lock(atoi(args[1]))); + pp_printf("%d\n", spll_check_lock(atoi(args[1]))); } else if (!strcasecmp(args[0], "stat")) { spll_show_stats(); } else if (!strcasecmp(args[0], "sps")) { @@ -36,7 +36,7 @@ static int cmd_pll(const char *args[]) if (!args[1]) return -EINVAL; spll_get_phase_shift(atoi(args[1]), &cur, &tgt); - mprintf("%d %d\n", cur, tgt); + pp_printf("%d %d\n", cur, tgt); } else if (!strcasecmp(args[0], "start")) { if (!args[1]) return -EINVAL; @@ -52,7 +52,7 @@ static int cmd_pll(const char *args[]) } else if (!strcasecmp(args[0], "gdac")) { if (!args[1]) return -EINVAL; - mprintf("%d\n", spll_get_dac(atoi(args[1]))); + pp_printf("%d\n", spll_get_dac(atoi(args[1]))); } else if(!strcasecmp(args[0], "checkvco")) check_vco_frequencies(); else diff --git a/shell/cmd_ptrack.c b/shell/cmd_ptrack.c index 7c48dbcc5..36e317bd8 100644 --- a/shell/cmd_ptrack.c +++ b/shell/cmd_ptrack.c @@ -29,7 +29,7 @@ static int cmd_ptrack(const char *args[]) wr_servo_enable_tracking(0); wrc_phase_tracking = 0; } - mprintf("phase tracking %s\n", wrc_phase_tracking?"ON":"OFF"); + pp_printf("phase tracking %s\n", wrc_phase_tracking?"ON":"OFF"); return 0; } diff --git a/shell/cmd_sfp.c b/shell/cmd_sfp.c index e1240572b..e1b6428be 100644 --- a/shell/cmd_sfp.c +++ b/shell/cmd_sfp.c @@ -40,11 +40,11 @@ static int cmd_sfp(const char *args[]) if (args[0] && !strcasecmp(args[0], "detect")) { if (!sfp_present()) - mprintf("No SFP.\n"); + pp_printf("No SFP.\n"); else sfp_read_part_id(pn); pn[16] = 0; - mprintf("%s\n", pn); + pp_printf("%s\n", pn); return 0; } // else if (!strcasecmp(args[0], "i2cscan")) @@ -55,7 +55,7 @@ static int cmd_sfp(const char *args[]) else if (!strcasecmp(args[0], "erase")) { if (storage_sfpdb_erase() == EE_RET_I2CERR) - mprintf("Could not erase DB\n"); + pp_printf("Could not erase DB\n"); } else if (args[4] && !strcasecmp(args[0], "add")) { if (strlen(args[1]) > 16) temp = 16; @@ -70,44 +70,44 @@ static int cmd_sfp(const char *args[]) sfp.alpha = atoi(args[4]); temp = storage_get_sfp(&sfp, 1, 0); if (temp == EE_RET_DBFULL) - mprintf("SFP DB is full\n"); + pp_printf("SFP DB is full\n"); else if (temp == EE_RET_I2CERR) - mprintf("I2C error\n"); + pp_printf("I2C error\n"); else - mprintf("%d SFPs in DB\n", temp); + pp_printf("%d SFPs in DB\n", temp); } else if (args[0] && !strcasecmp(args[0], "show")) { for (i = 0; i < sfpcount; ++i) { temp = storage_get_sfp(&sfp, 0, i); if (!i) { sfpcount = temp; //only in first round valid sfpcount is returned from storage_get_sfp if (sfpcount == 0 || sfpcount == 0xFF) { - mprintf("SFP database empty...\n"); + pp_printf("SFP database empty...\n"); return 0; } else if (sfpcount == -1) { - mprintf("SFP database corrupted...\n"); + pp_printf("SFP database corrupted...\n"); return 0; } } - mprintf("%d: PN:", i + 1); + pp_printf("%d: PN:", i + 1); for (temp = 0; temp < 16; ++temp) - mprintf("%c", sfp.pn[temp]); - mprintf(" dTx: %d, dRx: %d, alpha: %d\n", sfp.dTx, + pp_printf("%c", sfp.pn[temp]); + pp_printf(" dTx: %d, dRx: %d, alpha: %d\n", sfp.dTx, sfp.dRx, sfp.alpha); } } else if (args[0] && !strcasecmp(args[0], "match")) { if (pn[0] == '\0') { - mprintf("Run sfp detect first\n"); + pp_printf("Run sfp detect first\n"); return 0; } strncpy(sfp.pn, pn, SFP_PN_LEN); if (storage_match_sfp(&sfp) > 0) { - mprintf("SFP matched, dTx=%d, dRx=%d, alpha=%d\n", + pp_printf("SFP matched, dTx=%d, dRx=%d, alpha=%d\n", sfp.dTx, sfp.dRx, sfp.alpha); sfp_deltaTx = sfp.dTx; sfp_deltaRx = sfp.dRx; sfp_alpha = sfp.alpha; } else - mprintf("Could not match to DB\n"); + pp_printf("Could not match to DB\n"); return 0; } else if (args[0] && !strcasecmp(args[0], "ena")) { if(!args[1]) diff --git a/shell/cmd_stat.c b/shell/cmd_stat.c index 7e158e6fd..f151949b3 100644 --- a/shell/cmd_stat.c +++ b/shell/cmd_stat.c @@ -20,7 +20,7 @@ static int cmd_stat(const char *args[]) /* arguments: bts, on, off */ if (!strcasecmp(args[0], "bts")) { - mprintf("%d ps\n", ep_get_bitslide()); + pp_printf("%d ps\n", ep_get_bitslide()); } else if (!strcasecmp(args[0], "on")) { wrc_stat_running = 1; wrc_stats_last--; /* force a line to be printed */ diff --git a/shell/cmd_time.c b/shell/cmd_time.c index 5a083f762..f8546b1d5 100644 --- a/shell/cmd_time.c +++ b/shell/cmd_time.c @@ -49,11 +49,11 @@ static int cmd_time(const char *args[]) return 0; } } else if (args[0] && !strcasecmp(args[0], "raw")) { - mprintf("%d %d\n", (uint32_t) sec, nsec); + pp_printf("%d %d\n", (uint32_t) sec, nsec); return 0; } - mprintf("%s +%d nanoseconds.\n", format_time(sec), nsec); /* fixme: clock freq is not always 125 MHz */ + pp_printf("%s +%d nanoseconds.\n", format_time(sec), nsec); /* fixme: clock freq is not always 125 MHz */ return 0; } diff --git a/shell/shell.c b/shell/shell.c index f81d77cf3..5adeeb524 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -68,7 +68,7 @@ static void delete(int where) static void esc(char code) { - mprintf("\033[1%c", code); + pp_printf("\033[1%c", code); } static int _shell_exec(void) @@ -107,12 +107,12 @@ static int _shell_exec(void) if (!strcasecmp(p->name, tokptr[0])) { rv = p->exec((const char **)(tokptr + 1)); if (rv < 0) - mprintf("Command \"%s\": error %d\n", + pp_printf("Command \"%s\": error %d\n", p->name, rv); return rv; } - mprintf("Unrecognized command \"%s\".\n", tokptr[0]); + pp_printf("Unrecognized command \"%s\".\n", tokptr[0]); return -EINVAL; } @@ -134,7 +134,7 @@ void shell_interactive() int c; switch (state) { case SH_PROMPT: - mprintf("wrc# "); + pp_printf("wrc# "); cmd_pos = 0; cmd_len = 0; state = SH_INPUT; @@ -168,7 +168,7 @@ void shell_interactive() break; case KEY_ENTER: - mprintf("\n"); + pp_printf("\n"); state = SH_EXEC; break; @@ -195,7 +195,7 @@ void shell_interactive() if (!(current_key & ESCAPE_FLAG) && insert(current_key)) { esc('@'); - mprintf("%c", current_key); + pp_printf("%c", current_key); } break; @@ -260,12 +260,12 @@ int shell_boot_script(void) SH_MAX_LINE_LEN, next); if (cmd_len <= 0) { if (next == 0) - mprintf("Empty init script...\n"); + pp_printf("Empty init script...\n"); break; } cmd_buf[cmd_len - 1] = 0; - mprintf("executing: %s\n", cmd_buf); + pp_printf("executing: %s\n", cmd_buf); _shell_exec(); next = 1; } diff --git a/system_checks.c b/system_checks.c index be658db86..5594af04a 100644 --- a/system_checks.c +++ b/system_checks.c @@ -16,7 +16,7 @@ void check_stack(void) { /* print "Stack overflow!" forever if stack corrupted */ while (_endram != ENDRAM_MAGIC) { - mprintf("Stack overflow!\n"); + pp_printf("Stack overflow!\n"); timer_delay_ms(1000); } } diff --git a/wrc_main.c b/wrc_main.c index fd28e3e07..42a141b5d 100644 --- a/wrc_main.c +++ b/wrc_main.c @@ -52,7 +52,7 @@ static void wrc_initialize(void) uart_init_sw(); uart_init_hw(); - mprintf("WR Core: starting up...\n"); + pp_printf("WR Core: starting up...\n"); timer_init(1); wrpc_w1_init(); @@ -67,7 +67,7 @@ static void wrc_initialize(void) storage_init(WRPC_FMC_I2C, FMC_EEPROM_ADR); if (get_persistent_mac(ONEWIRE_PORT, mac_addr) == -1) { - mprintf("Unable to determine MAC address\n"); + pp_printf("Unable to determine MAC address\n"); mac_addr[0] = 0x22; // mac_addr[1] = 0x33; // mac_addr[2] = 0x44; // fallback MAC if get_persistent_mac fails -- GitLab