From patchwork Tue Oct 27 14:33:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 55609 Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1833852lbq; Tue, 27 Oct 2015 07:36:51 -0700 (PDT) X-Received: by 10.55.43.37 with SMTP id r37mr50497350qkh.57.1445956611545; Tue, 27 Oct 2015 07:36:51 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x18si37372822qkx.53.2015.10.27.07.36.51 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 27 Oct 2015 07:36:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:60048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr5Mp-0006Ve-2H for patch@linaro.org; Tue, 27 Oct 2015 10:36:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr5Jg-0001WA-9k for qemu-devel@nongnu.org; Tue, 27 Oct 2015 10:33:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zr5Jd-0007Vf-HM for qemu-devel@nongnu.org; Tue, 27 Oct 2015 10:33:36 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:35203) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr5Jd-0007SU-8c for qemu-devel@nongnu.org; Tue, 27 Oct 2015 10:33:33 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Zr5JZ-0000Uf-VP for qemu-devel@nongnu.org; Tue, 27 Oct 2015 14:33:29 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 27 Oct 2015 14:33:13 +0000 Message-Id: <1445956409-1818-12-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1445956409-1818-1-git-send-email-peter.maydell@linaro.org> References: <1445956409-1818-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 11/27] i.MX: Standardize i.MX FEC debug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Jean-Christophe Dubois The goal is to have debug code always compiled during build. We standardize all debug output on the following format: [QOM_TYPE_NAME]reporting_function: debug message The qemu_log_mask() output is following the same format as the above debug. Reviewed-by: Peter Crosthwaite Signed-off-by: Jean-Christophe Dubois Message-id: 57e565982db94fb433c32dfa17608888464d21de.1445781957.git.jcd@tribudubois.net Signed-off-by: Peter Maydell --- hw/net/imx_fec.c | 64 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) -- 1.9.1 diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index 725f3fa..c50bf7f 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -27,31 +27,29 @@ /* For crc32 */ #include -#ifndef IMX_FEC_DEBUG -#define IMX_FEC_DEBUG 0 +#ifndef DEBUG_IMX_FEC +#define DEBUG_IMX_FEC 0 #endif -#ifndef IMX_PHY_DEBUG -#define IMX_PHY_DEBUG 0 -#endif - -#if IMX_FEC_DEBUG -#define FEC_PRINTF(fmt, ...) \ - do { fprintf(stderr, "%s[%s]: " fmt , TYPE_IMX_FEC, __func__, \ - ## __VA_ARGS__); \ +#define FEC_PRINTF(fmt, args...) \ + do { \ + if (DEBUG_IMX_FEC) { \ + fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX_FEC, \ + __func__, ##args); \ + } \ } while (0) -#else -#define FEC_PRINTF(fmt, ...) do {} while (0) + +#ifndef DEBUG_IMX_PHY +#define DEBUG_IMX_PHY 0 #endif -#if IMX_PHY_DEBUG -#define PHY_PRINTF(fmt, ...) \ - do { fprintf(stderr, "%s.phy[%s]: " fmt , TYPE_IMX_FEC, __func__, \ - ## __VA_ARGS__); \ +#define PHY_PRINTF(fmt, args...) \ + do { \ + if (DEBUG_IMX_PHY) { \ + fprintf(stderr, "[%s.phy]%s: " fmt , TYPE_IMX_FEC, \ + __func__, ##args); \ + } \ } while (0) -#else -#define PHY_PRINTF(fmt, ...) do {} while (0) -#endif static const VMStateDescription vmstate_imx_fec = { .name = TYPE_IMX_FEC, @@ -182,12 +180,12 @@ static uint32_t do_phy_read(IMXFECState *s, int reg) case 18: case 27: case 31: - qemu_log_mask(LOG_UNIMP, "%s.phy[%s]: reg %d not implemented\n", + qemu_log_mask(LOG_UNIMP, "[%s.phy]%s: reg %d not implemented\n", TYPE_IMX_FEC, __func__, reg); val = 0; break; default: - qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Bad address at offset %d\n", + qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad address at offset %d\n", TYPE_IMX_FEC, __func__, reg); val = 0; break; @@ -230,11 +228,11 @@ static void do_phy_write(IMXFECState *s, int reg, uint32_t val) case 18: case 27: case 31: - qemu_log_mask(LOG_UNIMP, "%s.phy[%s]: reg %d not implemented\n", + qemu_log_mask(LOG_UNIMP, "[%s.phy)%s: reg %d not implemented\n", TYPE_IMX_FEC, __func__, reg); break; default: - qemu_log_mask(LOG_GUEST_ERROR, "%s.phy[%s]: Bad address at offset %d\n", + qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad address at offset %d\n", TYPE_IMX_FEC, __func__, reg); break; } @@ -357,7 +355,7 @@ static uint64_t imx_fec_read(void *opaque, hwaddr addr, unsigned size) { IMXFECState *s = IMX_FEC(opaque); - FEC_PRINTF("reading from @ 0x%03x\n", (int)addr); + FEC_PRINTF("reading from @ 0x%" HWADDR_PRIx "\n", addr); switch (addr & 0x3ff) { case 0x004: @@ -417,8 +415,8 @@ static uint64_t imx_fec_read(void *opaque, hwaddr addr, unsigned size) case 0x308: return s->miigsk_enr; default: - qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Bad address at offset %d\n", - TYPE_IMX_FEC, __func__, (int)addr); + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad address at offset 0x%" + HWADDR_PRIx "\n", TYPE_IMX_FEC, __func__, addr); return 0; } } @@ -428,7 +426,7 @@ static void imx_fec_write(void *opaque, hwaddr addr, { IMXFECState *s = IMX_FEC(opaque); - FEC_PRINTF("writing 0x%08x @ 0x%03x\n", (int)value, (int)addr); + FEC_PRINTF("writing 0x%08x @ 0x%" HWADDR_PRIx "\n", (int)value, addr); switch (addr & 0x3ff) { case 0x004: /* EIR */ @@ -530,8 +528,8 @@ static void imx_fec_write(void *opaque, hwaddr addr, s->miigsk_enr = (value & 0x2) ? 0x6 : 0; break; default: - qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Bad address at offset %d\n", - TYPE_IMX_FEC, __func__, (int)addr); + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad address at offset 0x%" + HWADDR_PRIx "\n", TYPE_IMX_FEC, __func__, addr); break; } @@ -561,7 +559,7 @@ static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf, FEC_PRINTF("len %d\n", (int)size); if (!s->rx_enabled) { - qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Unexpected packet\n", + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Unexpected packet\n", TYPE_IMX_FEC, __func__); return 0; } @@ -592,14 +590,16 @@ static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf, * save the remainder for when more RX buffers are * available, or flag an error. */ - qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Lost end of frame\n", + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Lost end of frame\n", TYPE_IMX_FEC, __func__); break; } buf_len = (size <= s->emrbr) ? size : s->emrbr; bd.length = buf_len; size -= buf_len; - FEC_PRINTF("rx_bd %x length %d\n", addr, bd.length); + + FEC_PRINTF("rx_bd 0x%x length %d\n", addr, bd.length); + /* The last 4 bytes are the CRC. */ if (size < 4) { buf_len += size - 4;