From f63c32274036546a4c94c0382c86c4c2efe6ba55 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Fri, 20 Jul 2018 14:45:19 -0700 Subject: [PATCH] smbus: Replace debug printf statements with macro --- hw/xbox/smbus_cx25871.c | 38 +++++++++++++++----------------------- hw/xbox/smbus_xbox_smc.c | 33 +++++++++++++-------------------- 2 files changed, 28 insertions(+), 43 deletions(-) diff --git a/hw/xbox/smbus_cx25871.c b/hw/xbox/smbus_cx25871.c index b0c4a224d9..f743e6d8b6 100644 --- a/hw/xbox/smbus_cx25871.c +++ b/hw/xbox/smbus_cx25871.c @@ -23,56 +23,48 @@ #include "hw/i2c/smbus.h" #include "smbus.h" -//#define DEBUG +// #define DEBUG +#ifdef DEBUG +# define DPRINTF(format, ...) printf(format, ## __VA_ARGS__) +#else +# define DPRINTF(format, ...) do { } while (0) +#endif typedef struct SMBusCX25871Device { SMBusDevice smbusdev; - uint8_t registers[256]; } SMBusCX25871Device; static void cx_quick_cmd(SMBusDevice *dev, uint8_t read) { -#ifdef DEBUG - printf("cx_quick_cmd: addr=0x%02x read=%d\n", dev->i2c.address, read); -#endif + DPRINTF("cx_quick_cmd: addr=0x%02x read=%d\n", dev->i2c.address, read); } static void cx_send_byte(SMBusDevice *dev, uint8_t val) { -#ifdef DEBUG - printf("cx_send_byte: addr=0x%02x val=0x%02x\n", - dev->i2c.address, val); -#endif + DPRINTF("cx_send_byte: addr=0x%02x val=0x%02x\n", dev->i2c.address, val); } static uint8_t cx_receive_byte(SMBusDevice *dev) { -#ifdef DEBUG - printf("cx_receive_byte: addr=0x%02x\n", - dev->i2c.address); -#endif + DPRINTF("cx_receive_byte: addr=0x%02x\n", dev->i2c.address); return 0; } static void cx_write_data(SMBusDevice *dev, uint8_t cmd, uint8_t *buf, int len) { - SMBusCX25871Device *cx = (SMBusCX25871Device *) dev; -#ifdef DEBUG - printf("cx_write_byte: addr=0x%02x cmd=0x%02x val=0x%02x\n", - dev->i2c.address, cmd, buf[0]); -#endif + SMBusCX25871Device *cx = (SMBusCX25871Device *)dev; + DPRINTF("cx_write_byte: addr=0x%02x cmd=0x%02x val=0x%02x\n", + dev->i2c.address, cmd, buf[0]); memcpy(cx->registers + cmd, buf, MIN(len, 256 - cmd)); } static uint8_t cx_read_data(SMBusDevice *dev, uint8_t cmd, int n) { - SMBusCX25871Device *cx = (SMBusCX25871Device *) dev; - #ifdef DEBUG - printf("cx_read_data: addr=0x%02x cmd=0x%02x n=%d\n", - dev->i2c.address, cmd, n); - #endif + SMBusCX25871Device *cx = (SMBusCX25871Device *)dev; + DPRINTF("cx_read_data: addr=0x%02x cmd=0x%02x n=%d\n", + dev->i2c.address, cmd, n); return cx->registers[cmd]; } diff --git a/hw/xbox/smbus_xbox_smc.c b/hw/xbox/smbus_xbox_smc.c index 6ae16f4705..525a234427 100644 --- a/hw/xbox/smbus_xbox_smc.c +++ b/hw/xbox/smbus_xbox_smc.c @@ -26,7 +26,12 @@ #include "sysemu/sysemu.h" #include "smbus.h" -//#define DEBUG +// #define DEBUG +#ifdef DEBUG +# define DPRINTF(format, ...) printf(format, ## __VA_ARGS__) +#else +# define DPRINTF(format, ...) do { } while (0) +#endif /* * Hardware is a PIC16LC @@ -77,35 +82,25 @@ typedef struct SMBusSMCDevice { static void smc_quick_cmd(SMBusDevice *dev, uint8_t read) { -#ifdef DEBUG - printf("smc_quick_cmd: addr=0x%02x read=%d\n", dev->i2c.address, read); -#endif + DPRINTF("smc_quick_cmd: addr=0x%02x read=%d\n", dev->i2c.address, read); } static void smc_send_byte(SMBusDevice *dev, uint8_t val) { -#ifdef DEBUG - printf("smc_send_byte: addr=0x%02x val=0x%02x\n", - dev->i2c.address, val); -#endif + DPRINTF("smc_send_byte: addr=0x%02x val=0x%02x\n", dev->i2c.address, val); } static uint8_t smc_receive_byte(SMBusDevice *dev) { -#ifdef DEBUG - printf("smc_receive_byte: addr=0x%02x\n", - dev->i2c.address); -#endif + DPRINTF("smc_receive_byte: addr=0x%02x\n", dev->i2c.address); return 0; } static void smc_write_data(SMBusDevice *dev, uint8_t cmd, uint8_t *buf, int len) { SMBusSMCDevice *smc = (SMBusSMCDevice *) dev; -#ifdef DEBUG - printf("smc_write_byte: addr=0x%02x cmd=0x%02x val=0x%02x\n", + DPRINTF("smc_write_byte: addr=0x%02x cmd=0x%02x val=0x%02x\n", dev->i2c.address, cmd, buf[0]); -#endif switch (cmd) { case SMC_REG_VER: @@ -139,11 +134,9 @@ static void smc_write_data(SMBusDevice *dev, uint8_t cmd, uint8_t *buf, int len) static uint8_t smc_read_data(SMBusDevice *dev, uint8_t cmd, int n) { - SMBusSMCDevice *smc = (SMBusSMCDevice *) dev; - #ifdef DEBUG - printf("smc_read_data: addr=0x%02x cmd=0x%02x n=%d\n", - dev->i2c.address, cmd, n); - #endif + SMBusSMCDevice *smc = (SMBusSMCDevice *)dev; + DPRINTF("smc_read_data: addr=0x%02x cmd=0x%02x n=%d\n", + dev->i2c.address, cmd, n); switch (cmd) { case SMC_REG_VER: