From patchwork Mon Sep 13 11:18:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Novotny X-Patchwork-Id: 64582 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 814E0B70A3 for ; Mon, 13 Sep 2010 21:18:18 +1000 (EST) Received: from localhost ([127.0.0.1]:54056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ov739-0001u5-Cj for incoming@patchwork.ozlabs.org; Mon, 13 Sep 2010 07:18:15 -0400 Received: from [140.186.70.92] (port=49513 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ov71n-0001Yf-6W for qemu-devel@nongnu.org; Mon, 13 Sep 2010 07:16:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ov71m-0007Yz-6a for qemu-devel@nongnu.org; Mon, 13 Sep 2010 07:16:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49099) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ov71m-0007YP-06 for qemu-devel@nongnu.org; Mon, 13 Sep 2010 07:16:50 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8DBGj8k024097 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Sep 2010 07:16:45 -0400 Received: from mig-laptop.brq.redhat.com (mig-laptop.brq.redhat.com [10.34.26.9]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8DBGgGu014190 for ; Mon, 13 Sep 2010 07:16:45 -0400 Message-ID: <4C8E0883.3060405@redhat.com> Date: Mon, 13 Sep 2010 13:18:27 +0200 From: Michal Novotny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-3.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: "qemu-devel@nongnu.org" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH] Introduce DPRINTF() macro and convert serial printf() calls to DPRINTF()'s X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi, this is the patch to introduce DPRINTF() macro as used in the rest of the qemu source files for printing debug messages when the debugging macro is set (i.e. the debugging is enabled) - e.g. as used in LSI SCSI controller implementation. Signed-off-by: Michal Novotny Reviewed-by: Paolo Bonzini --- case 0: @@ -583,9 +588,7 @@ static uint32_t serial_ioport_read(void *opaque, uint32_t addr) ret = s->scr; break; } -#ifdef DEBUG_SERIAL - printf("serial: read addr=0x%02x val=0x%02x\n", addr, ret); -#endif + DPRINTF("read addr=0x%02x val=0x%02x\n", addr, ret); return ret; } @@ -651,9 +654,7 @@ static void serial_receive1(void *opaque, const uint8_t *buf, int size) static void serial_event(void *opaque, int event) { SerialState *s = opaque; -#ifdef DEBUG_SERIAL - printf("serial: event %x\n", event); -#endif + DPRINTF("event %x\n", event); if (event == CHR_EVENT_BREAK) serial_receive_break(s); } diff --git a/hw/serial.c b/hw/serial.c index b66d13a..49431b2 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -99,6 +99,14 @@ #define RECV_FIFO 1 #define MAX_XMIT_RETRY 4 +#ifdef DEBUG_SERIAL +#define DPRINTF(fmt, ...) \ +do { fprintf(stderr, "serial: " fmt , ## __VA_ARGS__); } while (0); +#else +#define DPRINTF(fmt, ...) \ +do {} while(0); +#endif + typedef struct SerialFIFO { uint8_t data[UART_FIFO_LENGTH]; uint8_t count; @@ -267,10 +275,9 @@ static void serial_update_parameters(SerialState *s) ssp.stop_bits = stop_bits; s->char_transmit_time = (get_ticks_per_sec() / speed) * frame_size; qemu_chr_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp); -#if 0 - printf("speed=%d parity=%c data=%d stop=%d\n", + + DPRINTF("speed=%d parity=%c data=%d stop=%d\n", speed, parity, data_bits, stop_bits); -#endif } static void serial_update_msl(SerialState *s) @@ -360,9 +367,7 @@ static void serial_ioport_write(void *opaque, uint32_t addr, uint32_t val) SerialState *s = opaque; addr &= 7; -#ifdef DEBUG_SERIAL - printf("serial: write addr=0x%02x val=0x%02x\n", addr, val); -#endif + DPRINTF("write addr=0x%02x val=0x%02x\n", addr, val); switch(addr) { default: