On Tue, Oct 20, 2015 at 2:19 PM, Jean-Christophe Dubois
<[email protected]> wrote:
> The goal is to have debug code always compiled during build.
>
> Signed-off-by: Jean-Christophe Dubois <[email protected]>
> ---
> hw/i2c/imx_i2c.c | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/hw/i2c/imx_i2c.c b/hw/i2c/imx_i2c.c
> index 8474872..8926f7a 100644
> --- a/hw/i2c/imx_i2c.c
> +++ b/hw/i2c/imx_i2c.c
> @@ -21,13 +21,17 @@
> #include "hw/i2c/imx_i2c.h"
> #include "hw/i2c/i2c.h"
>
> -#ifndef IMX_I2C_DEBUG
> -#define IMX_I2C_DEBUG 0
> +#ifndef DEBUG_IMX_I2C
> +#define DEBUG_IMX_I2C 0
> #endif
>
> -#if IMX_I2C_DEBUG
> -#define DPRINT(fmt, args...) \
> - do { fprintf(stderr, "%s: "fmt, __func__, ## args); } while (0)
> +#define DPRINTF(fmt, args...) \
> + do { \
> + if (DEBUG_IMX_I2C) { \
> + fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX_I2C, \
> + __func__, ##args); \
> + } \
> + } while (0)
>
> static const char *imx_i2c_get_regname(unsigned offset)
> {
> @@ -46,9 +50,6 @@ static const char *imx_i2c_get_regname(unsigned offset)
> return "[?]";
> }
> }
> -#else
> -#define DPRINT(fmt, args...) do { } while (0)
> -#endif
>
> static inline bool imx_i2c_is_enabled(IMXI2CState *s)
> {
> @@ -154,8 +155,8 @@ static uint64_t imx_i2c_read(void *opaque, hwaddr offset,
> break;
> }
>
> - DPRINT("read %s [0x%02x] -> 0x%02x\n", imx_i2c_get_regname(offset),
> - (unsigned int)offset, value);
> + DPRINTF("read %s [0x%02x] -> 0x%02x\n", imx_i2c_get_regname(offset),
> + (unsigned int)offset, value);
Convert args to PRI while fixing. here and below.
Regards,
Peter
>
> return (uint64_t)value;
> }
> @@ -165,8 +166,8 @@ static void imx_i2c_write(void *opaque, hwaddr offset,
> {
> IMXI2CState *s = IMX_I2C(opaque);
>
> - DPRINT("write %s [0x%02x] <- 0x%02x\n", imx_i2c_get_regname(offset),
> - (unsigned int)offset, (int)value);
> + DPRINTF("write %s [0x%02x] <- 0x%02x\n", imx_i2c_get_regname(offset),
> + (unsigned int)offset, (int)value);
>
> value &= 0xff;
>
> --
> 2.1.4
>