diff options
author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-05-12 12:09:13 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-05-12 12:09:13 +1000 |
commit | 0c185983848ccbc1c3793d6d8333014625639d4e (patch) | |
tree | ddb0bdcbb669743f6241c8a1f76586630254fa4f | |
parent | f7c8f35ce7328f1b7e0181abf5c6233747570694 (diff) | |
download | skiboot-0c185983848ccbc1c3793d6d8333014625639d4e.zip skiboot-0c185983848ccbc1c3793d6d8333014625639d4e.tar.gz skiboot-0c185983848ccbc1c3793d6d8333014625639d4e.tar.bz2 |
Add pr_fmt to do printf/prlog prefixing automagically
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r-- | core/console-log.c | 10 | ||||
-rw-r--r-- | core/opal-msg.c | 10 | ||||
-rw-r--r-- | core/test/Makefile.check | 1 | ||||
-rw-r--r-- | core/test/run-console-log-buf-overrun.c | 1 | ||||
-rw-r--r-- | core/test/run-console-log.c | 4 | ||||
-rw-r--r-- | core/test/run-msg.c | 6 | ||||
-rw-r--r-- | core/test/stubs.c | 9 | ||||
-rw-r--r-- | hdata/test/stubs.c | 9 | ||||
-rw-r--r-- | hw/fsp/fsp-dpo.c | 30 | ||||
-rw-r--r-- | hw/fsp/fsp-epow.c | 35 | ||||
-rw-r--r-- | hw/fsp/fsp-leds.c | 211 | ||||
-rw-r--r-- | hw/fsp/fsp-mem-err.c | 21 | ||||
-rw-r--r-- | hw/ipmi/test/run-fru.c | 2 | ||||
-rw-r--r-- | include/skiboot.h | 8 | ||||
-rw-r--r-- | libc/include/stdio.h | 10 |
15 files changed, 177 insertions, 190 deletions
diff --git a/core/console-log.c b/core/console-log.c index a9556ea..3b9475e 100644 --- a/core/console-log.c +++ b/core/console-log.c @@ -60,23 +60,23 @@ static int vprlog(int log_level, const char *fmt, va_list ap) * Callers shouldn't care, prlog and friends should do something generically * sane in such crazy situations. */ -void prlog(int log_level, const char* fmt, ...) +void _prlog(int log_level, const char* fmt, ...) { va_list ap; - + va_start(ap, fmt); vprlog(log_level, fmt, ap); va_end(ap); } -int printf(const char* fmt, ...) +int _printf(const char* fmt, ...) { int count; va_list ap; - + va_start(ap, fmt); count = vprlog(PR_PRINTF, fmt, ap); va_end(ap); - + return count; } diff --git a/core/opal-msg.c b/core/opal-msg.c index cd35162..b0d8aaf 100644 --- a/core/opal-msg.c +++ b/core/opal-msg.c @@ -14,15 +14,13 @@ * limitations under the License. */ - +#define pr_fmt(fmt) "opalmsg: " fmt #include <skiboot.h> #include <opal-msg.h> #include <opal-api.h> #include <lock.h> #define OPAL_MAX_MSGS (OPAL_MSG_TYPE_MAX + OPAL_MAX_ASYNC_COMP - 1) -#define OPAL_MSG_PREFIX "opalmsg: " - struct opal_msg_entry { struct list_node link; @@ -46,10 +44,10 @@ int _opal_queue_msg(enum opal_msg_type msg_type, void *data, entry = list_pop(&msg_free_list, struct opal_msg_entry, link); if (!entry) { - prerror(OPAL_MSG_PREFIX "No available node in the free list, allocating\n"); + prerror("No available node in the free list, allocating\n"); entry = zalloc(sizeof(struct opal_msg_entry)); if (!entry) { - prerror(OPAL_MSG_PREFIX "Allocation failed\n"); + prerror("Allocation failed\n"); unlock(&opal_msg_lock); return OPAL_RESOURCE; } @@ -60,7 +58,7 @@ int _opal_queue_msg(enum opal_msg_type msg_type, void *data, entry->msg.msg_type = msg_type; if (num_params > ARRAY_SIZE(entry->msg.params)) { - prerror(OPAL_MSG_PREFIX "Discarding extra parameters\n"); + prerror("Discarding extra parameters\n"); num_params = ARRAY_SIZE(entry->msg.params); } memcpy(entry->msg.params, params, num_params*sizeof(u64)); diff --git a/core/test/Makefile.check b/core/test/Makefile.check index 457b61c..f28ce3e 100644 --- a/core/test/Makefile.check +++ b/core/test/Makefile.check @@ -3,6 +3,7 @@ CORE_TEST := core/test/run-device core/test/run-mem_region core/test/run-malloc CORE_TEST_NOSTUB := core/test/run-console-log CORE_TEST_NOSTUB += core/test/run-console-log-buf-overrun +CORE_TEST_NOSTUB += core/test/run-console-log-pr_fmt LCOV_EXCLUDE += $(CORE_TEST:%=%.c) core/test/stubs.c LCOV_EXCLUDE += $(CORE_TEST_NOSTUB:%=%.c) /usr/include/* diff --git a/core/test/run-console-log-buf-overrun.c b/core/test/run-console-log-buf-overrun.c index eda99e2..a09742e 100644 --- a/core/test/run-console-log-buf-overrun.c +++ b/core/test/run-console-log-buf-overrun.c @@ -43,6 +43,7 @@ static inline unsigned long mftb(void) return 42; } +#include "../../libc/include/stdio.h" #include "../console-log.c" #include "../../libc/stdio/snprintf.c" #include "../../libc/stdio/vsnprintf.c" diff --git a/core/test/run-console-log.c b/core/test/run-console-log.c index 2603247..5c9b73a 100644 --- a/core/test/run-console-log.c +++ b/core/test/run-console-log.c @@ -22,11 +22,15 @@ #define __TEST__ +#define _printf printf + static inline unsigned long mftb(void) { return 42; } +int _printf(const char* fmt, ...); + #include "../console-log.c" struct debug_descriptor debug_descriptor; diff --git a/core/test/run-msg.c b/core/test/run-msg.c index 197d92e..66b8429 100644 --- a/core/test/run-msg.c +++ b/core/test/run-msg.c @@ -13,9 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include <skiboot.h> #include <inttypes.h> +#include <stdbool.h> +#include <stddef.h> #include <assert.h> +#include <errno.h> +#include <stdlib.h> static bool zalloc_should_fail = false; static int zalloc_should_fail_after = 0; @@ -33,6 +36,7 @@ static void *zalloc(size_t size) } #include "../opal-msg.c" +#include <skiboot.h> void lock(struct lock *l) { diff --git a/core/test/stubs.c b/core/test/stubs.c index 2ab04f6..33a3385 100644 --- a/core/test/stubs.c +++ b/core/test/stubs.c @@ -17,9 +17,14 @@ #include <stdio.h> #include <stdarg.h> -void prlog(int log_level __attribute__((unused)), const char* fmt, ...) __attribute__((format (printf, 2, 3))); +void _prlog(int log_level __attribute__((unused)), const char* fmt, ...) __attribute__((format (printf, 2, 3))); -void prlog(int log_level __attribute__((unused)), const char* fmt, ...) +#ifndef pr_fmt +#define pr_fmt(fmt) fmt +#endif +#define prlog(l, f, ...) do { _prlog(l, pr_fmt(f), ##__VA_ARGS__); } while(0) + +void _prlog(int log_level __attribute__((unused)), const char* fmt, ...) { va_list ap; diff --git a/hdata/test/stubs.c b/hdata/test/stubs.c index b4bfa03..16f75ba 100644 --- a/hdata/test/stubs.c +++ b/hdata/test/stubs.c @@ -17,9 +17,14 @@ #include <stdio.h> #include <stdarg.h> -void prlog(int log_level __attribute__((unused)), const char* fmt, ...) __attribute__((format (printf, 2, 3))); +void _prlog(int log_level __attribute__((unused)), const char* fmt, ...) __attribute__((format (printf, 2, 3))); -void prlog(int log_level __attribute__((unused)), const char* fmt, ...) +#ifndef pr_fmt +#define pr_fmt(fmt) fmt +#endif +#define prlog(l, f, ...) do { _prlog(l, pr_fmt(f), ##__VA_ARGS__); } while(0) + +void _prlog(int log_level __attribute__((unused)), const char* fmt, ...) { va_list ap; diff --git a/hw/fsp/fsp-dpo.c b/hw/fsp/fsp-dpo.c index d818120..51c4824 100644 --- a/hw/fsp/fsp-dpo.c +++ b/hw/fsp/fsp-dpo.c @@ -16,6 +16,7 @@ /* * Handle FSP DPO (Delayed Power Off) event notification */ +#define pr_fmt(fmt) "FSPDPO: " fmt #include <skiboot.h> #include <console.h> #include <fsp.h> @@ -25,8 +26,6 @@ #include <opal.h> #include <opal-msg.h> -#define PREFIX "FSPDPO: " - #define DPO_CMD_SGN_BYTE0 0xf4 /* Byte[0] signature */ #define DPO_CMD_SGN_BYTE1 0x20 /* Byte[1] signature */ #define DPO_TIMEOUT 2700 /* 45 minutes in seconds */ @@ -62,17 +61,16 @@ static void fsp_process_dpo(struct fsp_msg *msg) /* DPO message does not have the correct signatures */ if ((msg->data.bytes[0] != DPO_CMD_SGN_BYTE0) || (msg->data.bytes[1] != DPO_CMD_SGN_BYTE1)) { - prlog(PR_ERR, PREFIX "Message signatures did not match\n"); + prlog(PR_ERR, "Message signatures did not match\n"); cmd |= FSP_STATUS_INVALID_CMD; resp = fsp_mkmsg(cmd, 0); if (resp == NULL) { - prerror(PREFIX "%s : Message allocation failed\n", - __func__); + prerror("%s : Message allocation failed\n", __func__); return; } if (fsp_queue_msg(resp, fsp_freemsg)) { fsp_freemsg(resp); - prerror(PREFIX "%s : Failed to queue response " + prerror("%s : Failed to queue response " "message\n", __func__); } return; @@ -80,17 +78,17 @@ static void fsp_process_dpo(struct fsp_msg *msg) /* Sapphire is already in "DPO pending" state */ if (fsp_dpo_pending) { - prlog(PR_ERR, PREFIX "OPAL is already in DPO pending state\n"); + prlog(PR_ERR, "OPAL is already in DPO pending state\n"); cmd |= FSP_STATUS_INVALID_DPOSTATE; resp = fsp_mkmsg(cmd, 0); if (resp == NULL) { - prerror(PREFIX "%s : Message allocation failed\n", + prerror("%s : Message allocation failed\n", __func__); return; } if (fsp_queue_msg(resp, fsp_freemsg)) { fsp_freemsg(resp); - prerror(PREFIX "%s : Failed to queue response " + prerror("%s : Failed to queue response " "message\n", __func__); } return; @@ -102,17 +100,17 @@ static void fsp_process_dpo(struct fsp_msg *msg) /* Inform the host about DPO */ rc = opal_queue_msg(OPAL_MSG_DPO, NULL, NULL); if (rc) { - prlog(PR_ERR, PREFIX "OPAL message queuing failed\n"); + prlog(PR_ERR, "OPAL message queuing failed\n"); cmd |= FSP_STATUS_GENERIC_ERROR; resp = fsp_mkmsg(cmd, 0); if (resp == NULL) { - prerror(PREFIX "%s : Message allocation failed\n", + prerror("%s : Message allocation failed\n", __func__); return; } if (fsp_queue_msg(resp, fsp_freemsg)) { fsp_freemsg(resp); - prerror(PREFIX "%s : Failed to queue response " + prerror("%s : Failed to queue response " "message\n", __func__); } return; @@ -121,12 +119,12 @@ static void fsp_process_dpo(struct fsp_msg *msg) /* Acknowledge the FSP on DPO */ resp = fsp_mkmsg(cmd, 0); if (resp == NULL) { - prerror(PREFIX "%s : Message allocation failed\n", __func__); + prerror("%s : Message allocation failed\n", __func__); return; } if (fsp_queue_msg(resp, fsp_freemsg)) { fsp_freemsg(resp); - prerror(PREFIX "%s : Failed to queue response message\n", + prerror("%s : Failed to queue response message\n", __func__); } @@ -149,7 +147,7 @@ static void fsp_process_dpo(struct fsp_msg *msg) static bool fsp_dpo_message(u32 cmd_sub_mod, struct fsp_msg *msg) { if (cmd_sub_mod == FSP_CMD_INIT_DPO) { - prlog(PR_TRACE, PREFIX "SP initiated Delayed Power Off (DPO)\n"); + prlog(PR_TRACE, "SP initiated Delayed Power Off (DPO)\n"); fsp_process_dpo(msg); return true; } @@ -164,5 +162,5 @@ void fsp_dpo_init(void) { fsp_register_client(&fsp_dpo_client, FSP_MCLASS_SERVICE); opal_register(OPAL_GET_DPO_STATUS, fsp_opal_get_dpo_status, 1); - prlog(PR_TRACE, PREFIX "FSP DPO support initialized\n"); + prlog(PR_TRACE, "FSP DPO support initialized\n"); } diff --git a/hw/fsp/fsp-epow.c b/hw/fsp/fsp-epow.c index eaba8bb..cac1dc7 100644 --- a/hw/fsp/fsp-epow.c +++ b/hw/fsp/fsp-epow.c @@ -16,6 +16,7 @@ /* * Handle FSP Environmental and Power Warning (EPOW) events notification */ +#define pr_fmt(fmt) "FSPEPOW: " fmt #include <skiboot.h> #include <console.h> #include <fsp.h> @@ -27,8 +28,6 @@ #include "fsp-epow.h" -#define PREFIX "FSPEPOW: " - /* * System EPOW status * @@ -68,12 +67,12 @@ static void epow_process_base_event(u8 *epow) } if (epow[3] & SPCN_POWR_FAIL) { - prlog(PR_TRACE, PREFIX "FSP message with SPCN_POWR_FAIL\n"); + prlog(PR_TRACE, "FSP message with SPCN_POWR_FAIL\n"); epow_status[OPAL_SYSEPOW_POWER] |= OPAL_SYSPOWER_FAIL; } if (epow[3] & SPCN_INCL_POWR) { - prlog(PR_TRACE, PREFIX "FSP message with SPCN_INCL_POWR\n"); + prlog(PR_TRACE, "FSP message with SPCN_INCL_POWR\n"); epow_status[OPAL_SYSEPOW_POWER] |= OPAL_SYSPOWER_INCL; } } @@ -85,17 +84,17 @@ static void epow_process_ex1_event(u8 *epow) epow_status[OPAL_SYSEPOW_TEMP] &= ~(OPAL_SYSTEMP_AMB | OPAL_SYSTEMP_INT); if (epow[4] == EPOW_ON_UPS) { - prlog(PR_TRACE, PREFIX "FSP message with EPOW_ON_UPS\n"); + prlog(PR_TRACE, "FSP message with EPOW_ON_UPS\n"); epow_status[OPAL_SYSEPOW_POWER] |= OPAL_SYSPOWER_UPS; } if (epow[4] == EPOW_TMP_AMB) { - prlog(PR_TRACE, PREFIX "FSP message with EPOW_TMP_AMB\n"); + prlog(PR_TRACE, "FSP message with EPOW_TMP_AMB\n"); epow_status[OPAL_SYSEPOW_TEMP] |= OPAL_SYSTEMP_AMB; } if (epow[4] == EPOW_TMP_INT) { - prlog(PR_TRACE, PREFIX "FSP message with EPOW_TMP_INT\n"); + prlog(PR_TRACE, "FSP message with EPOW_TMP_INT\n"); epow_status[OPAL_SYSEPOW_TEMP] |= OPAL_SYSTEMP_INT; } } @@ -127,7 +126,7 @@ static void fsp_epow_update(u8 *epow, int epow_type) /*FIXME: Key position information present but not used */ break; default: - prlog(PR_WARNING, PREFIX "Unknown EPOW event notification\n"); + prlog(PR_WARNING, "Unknown EPOW event notification\n"); break; } unlock(&epow_lock); @@ -139,7 +138,7 @@ static void fsp_epow_update(u8 *epow, int epow_type) if (epow_changed) { rc = opal_queue_msg(OPAL_MSG_EPOW, NULL, NULL); if (rc) { - prlog(PR_ERR, PREFIX "OPAL EPOW message queuing failed\n"); + prlog(PR_ERR, "OPAL EPOW message queuing failed\n"); return; } } @@ -153,7 +152,7 @@ static void fsp_process_epow(struct fsp_msg *msg, int epow_type) /* Basic EPOW signature */ if (msg->data.bytes[0] != 0xF2) { - prlog(PR_ERR, PREFIX "Signature mismatch\n"); + prlog(PR_ERR, "Signature mismatch\n"); return; } @@ -177,13 +176,13 @@ static void fsp_process_epow(struct fsp_msg *msg, int epow_type) case EPOW_NORMAL: resp = fsp_mkmsg(FSP_CMD_STATUS_REQ, 0); if (resp == NULL) { - prerror(PREFIX "%s : Message allocation failed\n", + prerror("%s : Message allocation failed\n", __func__); break; } if (fsp_queue_msg(resp, fsp_freemsg)) { fsp_freemsg(resp); - prerror(PREFIX "%s : Failed to queue response " + prerror("%s : Failed to queue response " "message\n", __func__); } break; @@ -192,31 +191,31 @@ static void fsp_process_epow(struct fsp_msg *msg, int epow_type) epow[4] = msg->data.bytes[4]; resp = fsp_mkmsg(FSP_CMD_STATUS_EX1_REQ, 0); if (resp == NULL) { - prerror(PREFIX "%s : Message allocation failed\n", + prerror("%s : Message allocation failed\n", __func__); break; } if (fsp_queue_msg(resp, fsp_freemsg)) { fsp_freemsg(resp); - prerror(PREFIX "%s : Failed to queue response " + prerror("%s : Failed to queue response " "message\n", __func__); } break; case EPOW_EX2: resp = fsp_mkmsg(FSP_CMD_STATUS_EX2_REQ, 0); if (resp == NULL) { - prerror(PREFIX "%s : Message allocation failed\n", + prerror("%s : Message allocation failed\n", __func__); break; } if (fsp_queue_msg(resp, fsp_freemsg)) { fsp_freemsg(resp); - prerror(PREFIX "%s : Failed to queue response " + prerror("%s : Failed to queue response " "message\n", __func__); } break; default: - prlog(PR_WARNING, PREFIX "Unknown EPOW event notification\n"); + prlog(PR_WARNING, "Unknown EPOW event notification\n"); return; } fsp_epow_update(epow, epow_type); @@ -299,5 +298,5 @@ void fsp_epow_init(void) np = dt_new(opal_node, "epow"); dt_add_property_strings(np, "compatible", "ibm,opal-v3-epow"); dt_add_property_strings(np, "epow-classes", "power", "temperature", "cooling"); - prlog(PR_TRACE, PREFIX "FSP EPOW support initialized\n"); + prlog(PR_TRACE, "FSP EPOW support initialized\n"); } diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c index d1381db..eef932c 100644 --- a/hw/fsp/fsp-leds.c +++ b/hw/fsp/fsp-leds.c @@ -18,6 +18,8 @@ /* * LED location code and indicator handling */ + +#define pr_fmt(fmt) "FSPLED: " fmt #include <skiboot.h> #include <fsp.h> #include <device.h> @@ -29,10 +31,6 @@ #include <fsp-leds.h> #include <fsp-sysparam.h> - -/* LED prefix */ -#define PREFIX "FSPLED: " - #define buf_write(p, type, val) do { *(type *)(p) = val;\ p += sizeof(type); } while(0) #define buf_read(p, type, addr) do { *addr = *(type *)(p);\ @@ -220,7 +218,7 @@ static void fsp_set_sai_complete(struct fsp_msg *msg) struct led_set_cmd *spcn_cmd = (struct led_set_cmd *)msg->user_data; if (rc) { - prlog(PR_ERR, PREFIX "Update SAI cmd failed [rc=%d].\n", rc); + prlog(PR_ERR, "Update SAI cmd failed [rc=%d].\n", rc); ret = OPAL_INTERNAL_ERROR; /* Roll back */ @@ -257,14 +255,12 @@ static int fsp_set_sai(struct led_set_cmd *spcn_cmd) else cmd |= FSP_LED_RESET_REAL_SAI; - prlog(PR_TRACE, PREFIX - "Update SAI Indicator [cur : 0x%x, new : 0x%x].\n", + prlog(PR_TRACE, "Update SAI Indicator [cur : 0x%x, new : 0x%x].\n", sai_data.state, spcn_cmd->state); msg = fsp_mkmsg(cmd, 0); if (!msg) { - prlog(PR_ERR, PREFIX - "%s: Memory allocation failed.\n", __func__); + prlog(PR_ERR, "%s: Memory allocation failed.\n", __func__); goto sai_fail; } @@ -273,8 +269,7 @@ static int fsp_set_sai(struct led_set_cmd *spcn_cmd) rc = fsp_queue_msg(msg, fsp_set_sai_complete); if (rc) { fsp_freemsg(msg); - prlog(PR_ERR, PREFIX - "%s: Failed to queue the message\n", __func__); + prlog(PR_ERR, "%s: Failed to queue the message\n", __func__); goto sai_fail; } @@ -297,15 +292,13 @@ static void fsp_get_sai_complete(struct fsp_msg *msg) int rc = msg->resp->word1 & 0xff00; if (rc) { - prlog(PR_ERR, PREFIX - "Read real SAI cmd failed [rc = 0x%x].\n", rc); + prlog(PR_ERR, "Read real SAI cmd failed [rc = 0x%x].\n", rc); } else { /* Update SAI state */ lock(&sai_lock); sai_data.state = msg->resp->data.words[0] & 0xff; unlock(&sai_lock); - prlog(PR_TRACE, PREFIX - "SAI initial state = 0x%x\n", sai_data.state); + prlog(PR_TRACE, "SAI initial state = 0x%x\n", sai_data.state); } fsp_freemsg(msg); @@ -320,15 +313,13 @@ static void fsp_get_sai(void) msg = fsp_mkmsg(cmd, 0); if (!msg) { - prlog(PR_ERR, PREFIX - "%s: Memory allocation failed.\n", __func__); + prlog(PR_ERR, "%s: Memory allocation failed.\n", __func__); return; } rc = fsp_queue_msg(msg, fsp_get_sai_complete); if (rc) { fsp_freemsg(msg); - prlog(PR_ERR, PREFIX - "%s: Failed to queue the message\n", __func__); + prlog(PR_ERR, "%s: Failed to queue the message\n", __func__); } } @@ -352,8 +343,7 @@ static bool sai_update_notification(struct fsp_msg *msg) sai_data.state = *state; unlock(&sai_lock); - prlog(PR_TRACE, PREFIX - "SAI updated. New SAI state = 0x%x\n", *state); + prlog(PR_TRACE, "SAI updated. New SAI state = 0x%x\n", *state); return true; } @@ -372,7 +362,7 @@ static void update_led_list(char *loc_code, u32 led_state, u32 excl_bit) encl_cec_led = fsp_find_encl_cec_led(loc_code); if (!encl_cec_led) { log_simple_error(&e_info(OPAL_RC_LED_LC), - PREFIX "Could not find enclosure LED in CEC LC=%s\n", + "Could not find enclosure LED in CEC LC=%s\n", loc_code); return; } @@ -384,7 +374,7 @@ static void update_led_list(char *loc_code, u32 led_state, u32 excl_bit) } else { /* Descendant LED in CEC list */ led = fsp_find_cec_led(loc_code); if (!led) { - log_simple_error(&e_info(OPAL_RC_LED_LC), PREFIX + log_simple_error(&e_info(OPAL_RC_LED_LC), "Could not find descendent LED in \ CEC LC=%s\n", loc_code); return; @@ -396,7 +386,7 @@ static void update_led_list(char *loc_code, u32 led_state, u32 excl_bit) encl_led = fsp_find_encl_encl_led(loc_code); if (!encl_led) { log_simple_error(&e_info(OPAL_RC_LED_LC), - PREFIX "Could not find enclosure LED in ENCL LC=%s\n", + "Could not find enclosure LED in ENCL LC=%s\n", loc_code); return; } @@ -423,15 +413,14 @@ static int fsp_set_led_response(uint32_t cmd) msg = fsp_mkmsg(cmd, 0); if (!msg) { - prerror(PREFIX - "Failed to allocate FSP_RSP_SET_LED_STATE [cmd=%x])\n", + prerror("Failed to allocate FSP_RSP_SET_LED_STATE [cmd=%x])\n", cmd); } else { rc = fsp_queue_msg(msg, fsp_freemsg); if (rc != OPAL_SUCCESS) { fsp_freemsg(msg); - prerror(PREFIX "Failed to queue " - "FSP_RSP_SET_LED_STATE [cmd=%x]\n", cmd); + prerror("Failed to queue FSP_RSP_SET_LED_STATE" + " [cmd=%x]\n", cmd); } } return rc; @@ -454,7 +443,7 @@ static void fsp_spcn_set_led_completion(struct fsp_msg *msg) */ if (status != FSP_STATUS_SUCCESS) { log_simple_error(&e_info(OPAL_RC_LED_SPCN), - PREFIX "Last SPCN command failed, status=%02x\n", + "Last SPCN command failed, status=%02x\n", status); cmd |= FSP_STATUS_GENERIC_ERROR; @@ -614,7 +603,7 @@ static int fsp_msg_set_led_state(struct led_set_cmd *spcn_cmd) update_fail: if (rc) { log_simple_error(&e_info(OPAL_RC_LED_STATE), - PREFIX "Set led state failed at LC=%s\n", + "Set led state failed at LC=%s\n", spcn_cmd->loc_code); if (spcn_cmd->cmd_src == SPCN_SRC_FSP) @@ -689,8 +678,7 @@ static int queue_led_state_change(char *loc_code, u8 command, /* New request node */ cmd = zalloc(sizeof(struct led_set_cmd)); if (!cmd) { - prlog(PR_ERR, PREFIX - "SPCN set command node allocation failed\n"); + prlog(PR_ERR, "SPCN set command node allocation failed\n"); return -1; } @@ -858,12 +846,11 @@ static void fsp_ret_loc_code_list(u16 req_type, char *loc_code) msg = fsp_mkmsg(FSP_RSP_GET_LED_LIST, 3, 0, PSI_DMA_LOC_COD_BUF, total_size); if (!msg) { - prerror(PREFIX "Failed to allocate FSP_RSP_GET_LED_LIST.\n"); + prerror("Failed to allocate FSP_RSP_GET_LED_LIST.\n"); } else { if (fsp_queue_msg(msg, fsp_freemsg)) { fsp_freemsg(msg); - prerror(PREFIX - "Failed to queue FSP_RSP_GET_LED_LIST\n"); + prerror("Failed to queue FSP_RSP_GET_LED_LIST\n"); } } } @@ -895,12 +882,12 @@ static void fsp_get_led_list(struct fsp_msg *msg) msg = fsp_mkmsg(FSP_RSP_GET_LED_LIST | FSP_STATUS_INVALID_DATA, 0); if (!msg) { - prerror(PREFIX "Failed to allocate FSP_RSP_GET_LED_LIST" + prerror("Failed to allocate FSP_RSP_GET_LED_LIST" " | FSP_STATUS_INVALID_DATA\n"); } else { if (fsp_queue_msg(msg, fsp_freemsg)) { fsp_freemsg(msg); - prerror(PREFIX "Failed to queue " + prerror("Failed to queue " "FSP_RSP_GET_LED_LIST |" " FSP_STATUS_INVALID_DATA\n"); } @@ -909,7 +896,7 @@ static void fsp_get_led_list(struct fsp_msg *msg) } memcpy(&req, buf, sizeof(req)); - prlog(PR_TRACE, PREFIX "Request for loc code list type 0x%04x LC=%s\n", + prlog(PR_TRACE, "Request for loc code list type 0x%04x LC=%s\n", req.req_type, req.loc_code); fsp_ret_loc_code_list(req.req_type, req.loc_code); @@ -932,18 +919,18 @@ static void fsp_free_led_list_buf(struct fsp_msg *msg) /* Token does not point to outbound buffer */ if (tce_token != PSI_DMA_LOC_COD_BUF) { log_simple_error(&e_info(OPAL_RC_LED_BUFF), - PREFIX "Invalid tce token from FSP\n"); + "Invalid tce token from FSP\n"); cmd |= FSP_STATUS_GENERIC_ERROR; resp = fsp_mkmsg(cmd, 0); if (!resp) { - prerror(PREFIX "Failed to allocate FSP_RSP_RET_LED_BUFFER" + prerror("Failed to allocate FSP_RSP_RET_LED_BUFFER" "| FSP_STATUS_GENERIC_ERROR\n"); return; } if (fsp_queue_msg(resp, fsp_freemsg)) { fsp_freemsg(resp); - prerror(PREFIX "Failed to queue " + prerror("Failed to queue " "RET_LED_BUFFER|ERROR\n"); } return; @@ -954,12 +941,12 @@ static void fsp_free_led_list_buf(struct fsp_msg *msg) resp = fsp_mkmsg(cmd, 0); if (!resp) { - prerror(PREFIX "Failed to allocate FSP_RSP_RET_LED_BUFFER\n"); + prerror("Failed to allocate FSP_RSP_RET_LED_BUFFER\n"); return; } if (fsp_queue_msg(resp, fsp_freemsg)) { fsp_freemsg(resp); - prerror(PREFIX "Failed to queue FSP_RSP_RET_LED_BUFFER\n"); + prerror("Failed to queue FSP_RSP_RET_LED_BUFFER\n"); } } @@ -980,31 +967,29 @@ static void fsp_ret_led_state(char *loc_code) ind_state |= FSP_IND_FAULT_ACTV; msg = fsp_mkmsg(FSP_RSP_GET_LED_STATE, 1, ind_state); if (!msg) { - prerror(PREFIX - "Couldn't alloc FSP_RSP_GET_LED_STATE\n"); + prerror("Couldn't alloc FSP_RSP_GET_LED_STATE\n"); return; } if (fsp_queue_msg(msg, fsp_freemsg)) { fsp_freemsg(msg); - prerror(PREFIX - "Couldn't queue FSP_RSP_GET_LED_STATE\n"); + prerror("Couldn't queue FSP_RSP_GET_LED_STATE\n"); } return; } /* Location code not found */ log_simple_error(&e_info(OPAL_RC_LED_LC), - PREFIX "Could not find the location code LC=%s\n", loc_code); + "Could not find the location code LC=%s\n", loc_code); msg = fsp_mkmsg(FSP_RSP_GET_LED_STATE | FSP_STATUS_INVALID_LC, 1, 0xff); if (!msg) { - prerror(PREFIX "Failed to alloc FSP_RSP_GET_LED_STATE " + prerror("Failed to alloc FSP_RSP_GET_LED_STATE " "| FSP_STATUS_INVALID_LC\n"); return; } if (fsp_queue_msg(msg, fsp_freemsg)) { fsp_freemsg(msg); - prerror(PREFIX "Failed to queue FSP_RSP_GET_LED_STATE " + prerror("Failed to queue FSP_RSP_GET_LED_STATE " "| FSP_STATUS_INVALID_LC\n"); } } @@ -1027,13 +1012,13 @@ static void fsp_get_led_state(struct fsp_msg *msg) msg = fsp_mkmsg(FSP_RSP_GET_LED_STATE | FSP_STATUS_INVALID_DATA, 0); if (!msg) { - prerror(PREFIX "Failed to allocate FSP_RSP_GET_LED_STATE" + prerror("Failed to allocate FSP_RSP_GET_LED_STATE" " | FSP_STATUS_INVALID_DATA\n"); return; } if (fsp_queue_msg(msg, fsp_freemsg)) { fsp_freemsg(msg); - prerror(PREFIX "Failed to queue FSP_RSP_GET_LED_STATE" + prerror("Failed to queue FSP_RSP_GET_LED_STATE" " | FSP_STATUS_INVALID_DATA\n"); } return; @@ -1049,8 +1034,8 @@ static void fsp_get_led_state(struct fsp_msg *msg) /* Bound check */ if (req.lc_len >= LOC_CODE_SIZE) { log_simple_error(&e_info(OPAL_RC_LED_LC), - PREFIX "Loc code too large in %s: %d bytes\n", - __func__, req.lc_len); + "Loc code too large in %s: %d bytes\n", + __func__, req.lc_len); req.lc_len = LOC_CODE_SIZE - 1; } /* Ensure NULL termination */ @@ -1093,8 +1078,8 @@ static void fsp_set_led_state(struct fsp_msg *msg) /* Bound check */ if (req.lc_len >= LOC_CODE_SIZE) { log_simple_error(&e_info(OPAL_RC_LED_LC), - PREFIX "Loc code too large in %s: %d bytes\n", - __func__, req.lc_len); + "Loc code too large in %s: %d bytes\n", + __func__, req.lc_len); req.lc_len = LOC_CODE_SIZE - 1; } /* Ensure NULL termination */ @@ -1149,30 +1134,26 @@ static bool fsp_indicator_message(u32 cmd_sub_mod, struct fsp_msg *msg) /* LED support not available yet */ if (led_support != LED_STATE_PRESENT) { log_simple_error(&e_info(OPAL_RC_LED_SUPPORT), - PREFIX "Indicator message while LED support not" + "Indicator message while LED support not" " available yet\n"); return false; } switch (cmd_sub_mod) { case FSP_CMD_GET_LED_LIST: - prlog(PR_TRACE, PREFIX - "FSP_CMD_GET_LED_LIST command received\n"); + prlog(PR_TRACE, "FSP_CMD_GET_LED_LIST command received\n"); fsp_get_led_list(msg); return true; case FSP_CMD_RET_LED_BUFFER: - prlog(PR_TRACE, PREFIX - "FSP_CMD_RET_LED_BUFFER command received\n"); + prlog(PR_TRACE, "FSP_CMD_RET_LED_BUFFER command received\n"); fsp_free_led_list_buf(msg); return true; case FSP_CMD_GET_LED_STATE: - prlog(PR_TRACE, PREFIX - "FSP_CMD_GET_LED_STATE command received\n"); + prlog(PR_TRACE, "FSP_CMD_GET_LED_STATE command received\n"); fsp_get_led_state(msg); return true; case FSP_CMD_SET_LED_STATE: - prlog(PR_TRACE, PREFIX - "FSP_CMD_SET_LED_STATE command received\n"); + prlog(PR_TRACE, "FSP_CMD_SET_LED_STATE command received\n"); fsp_set_led_state(msg); return true; /* @@ -1181,54 +1162,44 @@ static bool fsp_indicator_message(u32 cmd_sub_mod, struct fsp_msg *msg) * the field service processor with a generic error. */ case FSP_CMD_GET_MTMS_LIST: - prlog(PR_TRACE, PREFIX - "FSP_CMD_GET_MTMS_LIST command received\n"); + prlog(PR_TRACE, "FSP_CMD_GET_MTMS_LIST command received\n"); cmd = FSP_RSP_GET_MTMS_LIST; break; case FSP_CMD_RET_MTMS_BUFFER: - prlog(PR_TRACE, PREFIX - "FSP_CMD_RET_MTMS_BUFFER command received\n"); + prlog(PR_TRACE, "FSP_CMD_RET_MTMS_BUFFER command received\n"); cmd = FSP_RSP_RET_MTMS_BUFFER; break; case FSP_CMD_SET_ENCL_MTMS: - prlog(PR_TRACE, PREFIX - "FSP_CMD_SET_MTMS command received\n"); + prlog(PR_TRACE, "FSP_CMD_SET_MTMS command received\n"); cmd = FSP_RSP_SET_ENCL_MTMS; break; case FSP_CMD_CLR_INCT_ENCL: - prlog(PR_TRACE, PREFIX - "FSP_CMD_CLR_INCT_ENCL command received\n"); + prlog(PR_TRACE, "FSP_CMD_CLR_INCT_ENCL command received\n"); cmd = FSP_RSP_CLR_INCT_ENCL; break; case FSP_CMD_ENCL_MCODE_INIT: - prlog(PR_TRACE, PREFIX - "FSP_CMD_ENCL_MCODE_INIT command received\n"); + prlog(PR_TRACE, "FSP_CMD_ENCL_MCODE_INIT command received\n"); cmd = FSP_RSP_ENCL_MCODE_INIT; break; case FSP_CMD_ENCL_MCODE_INTR: - prlog(PR_TRACE, PREFIX - "FSP_CMD_ENCL_MCODE_INTR command received\n"); + prlog(PR_TRACE, "FSP_CMD_ENCL_MCODE_INTR command received\n"); cmd = FSP_RSP_ENCL_MCODE_INTR; break; case FSP_CMD_ENCL_POWR_TRACE: - prlog(PR_TRACE, PREFIX - "FSP_CMD_ENCL_POWR_TRACE command received\n"); + prlog(PR_TRACE, "FSP_CMD_ENCL_POWR_TRACE command received\n"); cmd = FSP_RSP_ENCL_POWR_TRACE; break; case FSP_CMD_RET_ENCL_TRACE_BUFFER: - prlog(PR_TRACE, PREFIX "FSP_CMD_RET_ENCL_TRACE_BUFFER \ - command received\n"); + prlog(PR_TRACE, "FSP_CMD_RET_ENCL_TRACE_BUFFER command received\n"); cmd = FSP_RSP_RET_ENCL_TRACE_BUFFER; break; case FSP_CMD_GET_SPCN_LOOP_STATUS: - prlog(PR_TRACE, PREFIX "FSP_CMD_GET_SPCN_LOOP_STATUS \ - command received\n"); + prlog(PR_TRACE, "FSP_CMD_GET_SPCN_LOOP_STATUS command received\n"); cmd = FSP_RSP_GET_SPCN_LOOP_STATUS; break; case FSP_CMD_INITIATE_LAMP_TEST: /* XXX: FSP ACK not required for this sub command */ - prlog(PR_TRACE, PREFIX "FSP_CMD_INITIATE_LAMP_TEST \ - command received\n"); + prlog(PR_TRACE, "FSP_CMD_INITIATE_LAMP_TEST command received\n"); return true; default: return false; @@ -1236,14 +1207,12 @@ static bool fsp_indicator_message(u32 cmd_sub_mod, struct fsp_msg *msg) cmd |= FSP_STATUS_GENERIC_ERROR; resp = fsp_mkmsg(cmd, 0); if (!resp) { - prerror(PREFIX - "Failed to allocate FSP_STATUS_GENERIC_ERROR\n"); + prerror("Failed to allocate FSP_STATUS_GENERIC_ERROR\n"); return false; } if (fsp_queue_msg(resp, fsp_freemsg)) { fsp_freemsg(resp); - prerror(PREFIX - "Failed to queue FSP_STATUS_GENERIC_ERROR\n"); + prerror("Failed to queue FSP_STATUS_GENERIC_ERROR\n"); return false; } return true; @@ -1487,15 +1456,13 @@ static struct dt_node *dt_get_led_node(void) struct dt_node *pled; if (!opal_node) { - prlog(PR_WARNING, PREFIX - "OPAL parent device node not available\n"); + prlog(PR_WARNING, "OPAL parent device node not available\n"); return NULL; } pled = dt_find_by_path(opal_node, DT_PROPERTY_LED_NODE); if (!pled) - prlog(PR_WARNING, PREFIX - "Parent device node not available\n"); + prlog(PR_WARNING, "Parent device node not available\n"); return pled; } @@ -1522,8 +1489,7 @@ static void dt_get_sai_loc_code(void) memcpy(sai_data.loc_code, child->name, LOC_CODE_SIZE - 1); - prlog(PR_TRACE, PREFIX "SAI Location code = %s\n", - sai_data.loc_code); + prlog(PR_TRACE, "SAI Location code = %s\n", sai_data.loc_code); return; } } @@ -1551,7 +1517,7 @@ void create_led_device_nodes(void) opal_run_pollers(); if (led_support == LED_STATE_ABSENT) { - prlog(PR_WARNING, PREFIX "LED support not available, \ + prlog(PR_WARNING, "LED support not available, \ hence device tree nodes will not be created\n"); return; } @@ -1565,7 +1531,7 @@ void create_led_device_nodes(void) led_mode = dt_prop_get(pled, DT_PROPERTY_LED_MODE); if (!led_mode) { - prlog(PR_WARNING, PREFIX "Unknown LED operating mode\n"); + prlog(PR_WARNING, "Unknown LED operating mode\n"); return; } @@ -1573,15 +1539,15 @@ void create_led_device_nodes(void) list_for_each_safe(&cec_ledq, led, next, link) { /* Duplicate LED location code */ if (dt_find_by_path(pled, led->loc_code)) { - prlog(PR_WARNING, PREFIX "duplicate location code %s", + prlog(PR_WARNING, "duplicate location code %s", led->loc_code); continue; } cled = dt_new(pled, led->loc_code); if (!cled) { - prlog(PR_WARNING, PREFIX - "Child device node creation failed\n"); + prlog(PR_WARNING, "Child device node creation " + "failed\n"); continue; } @@ -1705,9 +1671,8 @@ static void replay_spcn_cmd(u32 last_spcn_cmd) PSI_DMA_LED_BUF), fsp_read_leds_data_complete); if (rc) - prlog(PR_ERR, PREFIX - "Replay SPCN_MOD_PRS_LED_DATA_FIRST" - " command could not be queued\n"); + prlog(PR_ERR, "Replay SPCN_MOD_PRS_LED_DATA_FIRST" + " command could not be queued\n"); } if (last_spcn_cmd == SPCN_MOD_PRS_LED_DATA_SUB) { @@ -1717,9 +1682,8 @@ static void replay_spcn_cmd(u32 last_spcn_cmd) 0, PSI_DMA_LED_BUF), fsp_read_leds_data_complete); if (rc) - prlog(PR_ERR, PREFIX - "Replay SPCN_MOD_PRS_LED_DATA_SUB" - " command could not be queued\n"); + prlog(PR_ERR, "Replay SPCN_MOD_PRS_LED_DATA_SUB" + " command could not be queued\n"); } /* Failed to queue MBOX message */ @@ -1752,8 +1716,8 @@ static void fsp_read_leds_data_complete(struct fsp_msg *msg) if (msg_status != FSP_STATUS_SUCCESS) { log_simple_error(&e_info(OPAL_RC_LED_SUPPORT), - PREFIX "FSP returned error %x LED not supported\n", - msg_status); + "FSP returned error %x LED not supported\n", + msg_status); /* LED support not available */ led_support = LED_STATE_ABSENT; @@ -1765,8 +1729,7 @@ static void fsp_read_leds_data_complete(struct fsp_msg *msg) switch (led_status) { /* Last 1KB of LED data */ case SPCN_RSP_STATUS_SUCCESS: - prlog(PR_DEBUG, PREFIX - "SPCN_RSP_STATUS_SUCCESS: %d bytes received\n", + prlog(PR_DEBUG, "SPCN_RSP_STATUS_SUCCESS: %d bytes received\n", data_len); led_support = LED_STATE_PRESENT; @@ -1775,10 +1738,9 @@ static void fsp_read_leds_data_complete(struct fsp_msg *msg) fsp_process_leds_data(data_len); /* LEDs captured on the system */ - prlog(PR_DEBUG, PREFIX - "CEC LEDs captured on the system:\n"); + prlog(PR_DEBUG, "CEC LEDs captured on the system:\n"); list_for_each_safe(&cec_ledq, led, next, link) { - prlog(PR_DEBUG, PREFIX + prlog(PR_DEBUG, "rid: %x\t" "len: %x " "lcode: %-30s\t" @@ -1791,9 +1753,9 @@ static void fsp_read_leds_data_complete(struct fsp_msg *msg) led->status); } - prlog(PR_DEBUG, PREFIX "ENCL LEDs captured on the system:\n"); + prlog(PR_DEBUG, "ENCL LEDs captured on the system:\n"); list_for_each_safe(&encl_ledq, led, next, link) { - prlog(PR_DEBUG, PREFIX + prlog(PR_DEBUG, "rid: %x\t" "len: %x " "lcode: %-30s\t" @@ -1810,8 +1772,7 @@ static void fsp_read_leds_data_complete(struct fsp_msg *msg) /* If more 1KB of LED data present */ case SPCN_RSP_STATUS_COND_SUCCESS: - prlog(PR_DEBUG, PREFIX - "SPCN_RSP_STATUS_COND_SUCCESS: %d bytes " + prlog(PR_DEBUG, "SPCN_RSP_STATUS_COND_SUCCESS: %d bytes " " received\n", data_len); /* Copy data to the local list */ @@ -1825,8 +1786,8 @@ static void fsp_read_leds_data_complete(struct fsp_msg *msg) cmd_hdr, 0, PSI_DMA_LED_BUF), fsp_read_leds_data_complete); if (rc) { - prlog(PR_ERR, PREFIX "SPCN_MOD_PRS_LED_DATA_SUB command" - " could not be queued\n"); + prlog(PR_ERR, "SPCN_MOD_PRS_LED_DATA_SUB command" + " could not be queued\n"); led_support = LED_STATE_ABSENT; } @@ -1895,9 +1856,9 @@ static void fsp_leds_query_spcn(void) SPCN_ADDR_MODE_CEC_NODE, cmd_hdr, 0, PSI_DMA_LED_BUF), fsp_read_leds_data_complete); if (rc) - prlog(PR_ERR, PREFIX - "SPCN_MOD_PRS_LED_DATA_FIRST command could" - " not be queued\n"); + prlog(PR_ERR, + "SPCN_MOD_PRS_LED_DATA_FIRST command could" + " not be queued\n"); else /* Initiated LED list fetch MBOX command */ led_support = LED_STATE_READING; } @@ -1916,7 +1877,7 @@ void fsp_led_init(void) list_head_init(&spcn_cmdq); fsp_leds_query_spcn(); - prlog(PR_TRACE, PREFIX "Init completed\n"); + prlog(PR_TRACE, "Init completed\n"); /* Get System attention indicator state */ dt_get_sai_loc_code(); @@ -1924,12 +1885,12 @@ void fsp_led_init(void) /* Handle FSP initiated async LED commands */ fsp_register_client(&fsp_indicator_client, FSP_MCLASS_INDICATOR); - prlog(PR_TRACE, PREFIX "FSP async command client registered\n"); + prlog(PR_TRACE, "FSP async command client registered\n"); /* Register for SAI update notification */ sysparam_add_update_notifier(sai_update_notification); opal_register(OPAL_LEDS_GET_INDICATOR, fsp_opal_leds_get_ind, 4); opal_register(OPAL_LEDS_SET_INDICATOR, fsp_opal_leds_set_ind, 5); - prlog(PR_TRACE, PREFIX "LED OPAL interface registered\n"); + prlog(PR_TRACE, "LED OPAL interface registered\n"); } diff --git a/hw/fsp/fsp-mem-err.c b/hw/fsp/fsp-mem-err.c index d73736b..9c42aee 100644 --- a/hw/fsp/fsp-mem-err.c +++ b/hw/fsp/fsp-mem-err.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#define pr_fmt(fmt) "FSPMEMERR: " fmt #include <skiboot.h> #include <opal.h> #include <opal-msg.h> @@ -21,9 +22,6 @@ #include <fsp.h> #include <errorlog.h> -/* debug message prefix */ -#define PREFIX "FSPMEMERR: " - /* FSP sends real address of 4K memory page. */ #define MEM_ERR_PAGE_SIZE_4K (1UL << 12) @@ -71,8 +69,7 @@ static bool send_response_to_fsp(u32 cmd_sub_mod) rc = fsp_queue_msg(rsp, fsp_freemsg); if (rc) { /* XXX Generate error logs */ - prerror(PREFIX "Error %d queueing FSP memory error" - " reply\n", rc); + prerror("Error %d queueing FSP memory error reply\n", rc); return false; } return true; @@ -146,7 +143,7 @@ static int queue_mem_err_node(struct OpalMemoryErrorData *merr_evt) lock(&mem_err_lock); entry = list_pop(&merr_free_list, struct fsp_mem_err_node, list); if (!entry) { - printf(PREFIX "Failed to queue up memory error event.\n"); + printf("Failed to queue up memory error event.\n"); unlock(&mem_err_lock); return -ENOMEM; } @@ -202,7 +199,7 @@ static bool handle_memory_resilience(u32 cmd_sub_mod, u64 paddr) memset(&mem_err_evt, 0, sizeof(struct OpalMemoryErrorData)); /* Check arguments */ if (paddr == 0) { - prerror(PREFIX "memory resilience: Invalid real address.\n"); + prerror("memory resilience: Invalid real address.\n"); err = FSP_RESP_STATUS_GENERIC_FAILURE; } @@ -303,7 +300,7 @@ static bool handle_memory_deallocation(u64 paddr_start, u64 paddr_end) memset(&mem_err_evt, 0, sizeof(struct OpalMemoryErrorData)); /* Check arguments */ if ((paddr_start == 0) || (paddr_end == 0)) { - prerror(PREFIX "memory deallocation: Invalid " + prerror("memory deallocation: Invalid " "starting/ending real address.\n"); err = FSP_RESP_STATUS_GENERIC_FAILURE; } @@ -349,7 +346,7 @@ static bool fsp_mem_err_msg(u32 cmd_sub_mod, struct fsp_msg *msg) { u64 paddr_start, paddr_end; - printf(PREFIX "Received 0x%08ux command\n", cmd_sub_mod); + printf("Received 0x%08ux command\n", cmd_sub_mod); switch (cmd_sub_mod) { case FSP_CMD_MEM_RES_CE: case FSP_CMD_MEM_RES_UE: @@ -360,13 +357,13 @@ static bool fsp_mem_err_msg(u32 cmd_sub_mod, struct fsp_msg *msg) * address of 4K memory page in which the error occured. */ paddr_start = *((u64 *)&msg->data.words[0]); - printf(PREFIX "Got memory resilience error message for " + printf("Got memory resilience error message for " "paddr=0x%016llux\n", paddr_start); return handle_memory_resilience(cmd_sub_mod, paddr_start); case FSP_CMD_MEM_DYN_DEALLOC: paddr_start = *((u64 *)&msg->data.words[0]); paddr_end = *((u64 *)&msg->data.words[2]); - printf(PREFIX "Got dynamic memory deallocation message: " + printf("Got dynamic memory deallocation message: " "paddr_start=0x%016llux, paddr_end=0x%016llux\n", paddr_start, paddr_end); return handle_memory_deallocation(paddr_start, paddr_end); @@ -401,7 +398,7 @@ void fsp_memory_err_init(void) { int rc; - printf(PREFIX "Intializing fsp memory handling.\n"); + printf("Intializing fsp memory handling.\n"); /* If we have an FSP, register for notifications */ if (!fsp_present()) return; diff --git a/hw/ipmi/test/run-fru.c b/hw/ipmi/test/run-fru.c index 0c70e2d..423b3c7 100644 --- a/hw/ipmi/test/run-fru.c +++ b/hw/ipmi/test/run-fru.c @@ -48,7 +48,7 @@ int ipmi_queue_msg(struct ipmi_msg __unused *msg) return 0; } -void prlog(int __unused log_level, const __unused char* fmt, ...) +void _prlog(int __unused log_level, const __unused char* fmt, ...) { return; } diff --git a/include/skiboot.h b/include/skiboot.h index fd4d842..9751a31 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -92,7 +92,13 @@ extern struct debug_descriptor debug_descriptor; #define PR_DEBUG 7 #define PR_TRACE 8 #define PR_INSANE 9 -void prlog(int log_level, const char* fmt, ...) __attribute__((format (printf, 2, 3))); + +#ifndef pr_fmt +#define pr_fmt(fmt) fmt +#endif + +void _prlog(int log_level, const char* fmt, ...) __attribute__((format (printf, 2, 3))); +#define prlog(l, f, ...) do { _prlog(l, pr_fmt(f), ##__VA_ARGS__); } while(0) #define prerror(fmt...) do { prlog(PR_ERR, fmt); } while(0) #define prlog_once(arg, ...) \ ({ \ diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 787c06b..db5f1b0 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -40,7 +40,15 @@ extern FILE stderr_data; #define stderr (&stderr_data) int fileno(FILE *stream); -int printf(const char *format, ...) __attribute__((format (printf, 1, 2))); + +int _printf(const char *format, ...) __attribute__((format (printf, 1, 2))); + +#ifndef pr_fmt +#define prfmt(fmt) fmt +#endif + +#define printf(f, ...) do { _printf(pr_fmt(f), ##__VA_ARGS__); } while(0) + int fprintf(FILE *stream, const char *format, ...) __attribute__((format (printf, 2, 3))); int snprintf(char *str, size_t size, const char *format, ...) __attribute__((format (printf, 3, 4))); int vfprintf(FILE *stream, const char *format, va_list); |