Skip to contentSkip to conversation

hw/gpio: Replace printf() calls by qemu_log_mask()

PATCH Applied Philippe Mathieu-Daudé 2 participants 7 messages Sep 1, 2020 – Sep 9, 2020

lore
Share & tools
lore
#0 lore raw

cover hw/gpio: Replace printf() calls by qemu_log_mask()

Trivial patches logging via qemu_log_mask() instead of using stdio directly.

Philippe Mathieu-Daudé (2):
hw/gpio/omap_gpio: Replace fprintf() by qemu_log_mask(GUEST_ERROR) hw/gpio/max7310: Replace disabled printf() by qemu_log_mask(UNIMP)

 hw/gpio/max7310.c   | 11 +++++------
 hw/gpio/omap_gpio.c |  6 ++++--
 2 files changed, 9 insertions(+), 8 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/2 hw/gpio/omap_gpio: Replace fprintf() by qemu_log_mask(GUEST_ERROR)

Replace fprintf() by qemu_log_mask(LOG_GUEST_ERROR).

---
 hw/gpio/omap_gpio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/gpio/omap_gpio.c +4 -2
index f662c4cb958..e25084b40c9 100644
@@ -392,8 +392,10 @@ static void omap2_gpio_module_write(void *opaque, hwaddr addr,
         break;
 
     case 0x10:	/* GPIO_SYSCONFIG */
-        if (((value >> 3) & 3) == 3)
-            fprintf(stderr, "%s: bad IDLEMODE value\n", __func__);
+        if (((value >> 3) & 3) == 3) {
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "%s: Illegal IDLEMODE value: 3\n", __func__);
+        }
         if (value & 2)
             omap2_gpio_module_reset(s);
         s->config[0] = value & 0x1d;
Signature · 1 line
2.26.2
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] hw/gpio/omap_gpio: Replace fprintf() by qemu_log_mask(GUEST_ERROR)

Le 01/09/2020 à 12:42, Philippe Mathieu-Daudé a écrit :

Quoted 15 lines

Replace fprintf() by qemu_log_mask(LOG_GUEST_ERROR).

---
 hw/gpio/omap_gpio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/gpio/omap_gpio.c +0 -0
index f662c4cb958..e25084b40c9 100644
@@ -392,8 +392,10 @@ static void omap2_gpio_module_write(void *opaque, hwaddr addr,
         break;
 

hw/gpio/omap_gpio.c static void omap2_gpio_module_write(void *opaque, hwaddr addr, · line 401

Quoted 10 lines
hw/gpio/omap_gpio.c +4 -2
     case 0x10:	/* GPIO_SYSCONFIG */
-        if (((value >> 3) & 3) == 3)
-            fprintf(stderr, "%s: bad IDLEMODE value\n", __func__);
+        if (((value >> 3) & 3) == 3) {
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "%s: Illegal IDLEMODE value: 3\n", __func__);
+        }
         if (value & 2)
             omap2_gpio_module_reset(s);
         s->config[0] = value & 0x1d;
#3 lore raw

Re: [PATCH 1/2] hw/gpio/omap_gpio: Replace fprintf() by qemu_log_mask(GUEST_ERROR)

In reply to Philippe Mathieu-Daudé

Le 01/09/2020 à 12:42, Philippe Mathieu-Daudé a écrit :

Quoted 15 lines

Replace fprintf() by qemu_log_mask(LOG_GUEST_ERROR).

---
 hw/gpio/omap_gpio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/gpio/omap_gpio.c +0 -0
index f662c4cb958..e25084b40c9 100644
@@ -392,8 +392,10 @@ static void omap2_gpio_module_write(void *opaque, hwaddr addr,
         break;
 

hw/gpio/omap_gpio.c static void omap2_gpio_module_write(void *opaque, hwaddr addr, · line 401

Quoted 10 lines
hw/gpio/omap_gpio.c +4 -2
     case 0x10:	/* GPIO_SYSCONFIG */
-        if (((value >> 3) & 3) == 3)
-            fprintf(stderr, "%s: bad IDLEMODE value\n", __func__);
+        if (((value >> 3) & 3) == 3) {
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "%s: Illegal IDLEMODE value: 3\n", __func__);
+        }
         if (value & 2)
             omap2_gpio_module_reset(s);
         s->config[0] = value & 0x1d;

Applied to my trivial-patches branch.

Thanks,
Laurent

#4 lore raw

PATCH 2/2 hw/gpio/max7310: Replace disabled printf() by qemu_log_mask(UNIMP)

In reply to Philippe Mathieu-Daudé

Replace disabled printf() by qemu_log_mask(UNIMP).

---
 hw/gpio/max7310.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
hw/gpio/max7310.c +5 -6
index 7f5de189acf..c58a1996418 100644
@@ -11,6 +11,7 @@
 #include "hw/i2c/i2c.h"
 #include "hw/irq.h"
 #include "migration/vmstate.h"
+#include "qemu/log.h"
 #include "qemu/module.h"
 
 #define TYPE_MAX7310 "max7310"
@@ -69,9 +70,8 @@ static uint8_t max7310_rx(I2CSlave *i2c)
         return 0xff;
 
     default:
-#ifdef VERBOSE
-        printf("%s: unknown register %02x\n", __func__, s->command);
-#endif
+        qemu_log_mask(LOG_UNIMP, "%s: Unsupported register 0x02%" PRIx8 "\n",
+                      __func__, s->command);
         break;
     }
     return 0xff;
@@ -123,9 +123,8 @@ static int max7310_tx(I2CSlave *i2c, uint8_t data)
     case 0x00:	/* Input port - ignore writes */
         break;
     default:
-#ifdef VERBOSE
-        printf("%s: unknown register %02x\n", __func__, s->command);
-#endif
+        qemu_log_mask(LOG_UNIMP, "%s: Unsupported register 0x02%" PRIx8 "\n",
+                      __func__, s->command);
         return 1;
     }
 
Signature · 1 line
2.26.2
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] hw/gpio/max7310: Replace disabled printf() by qemu_log_mask(UNIMP)

Le 01/09/2020 à 12:42, Philippe Mathieu-Daudé a écrit :

Quoted 34 lines

Replace disabled printf() by qemu_log_mask(UNIMP).

---
 hw/gpio/max7310.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
hw/gpio/max7310.c +3 -3
index 7f5de189acf..c58a1996418 100644
@@ -11,6 +11,7 @@
 #include "hw/i2c/i2c.h"
 #include "hw/irq.h"
 #include "migration/vmstate.h"
+#include "qemu/log.h"
 #include "qemu/module.h"
 
 #define TYPE_MAX7310 "max7310"
@@ -69,9 +70,8 @@ static uint8_t max7310_rx(I2CSlave *i2c)
         return 0xff;
 
     default:
-#ifdef VERBOSE
-        printf("%s: unknown register %02x\n", __func__, s->command);
-#endif
+        qemu_log_mask(LOG_UNIMP, "%s: Unsupported register 0x02%" PRIx8 "\n",
+                      __func__, s->command);
         break;
     }
     return 0xff;
@@ -123,9 +123,8 @@ static int max7310_tx(I2CSlave *i2c, uint8_t data)
     case 0x00:	/* Input port - ignore writes */

hw/gpio/max7310.c static int max7310_tx(I2CSlave *i2c, uint8_t data) · line 130

Quoted 10 lines
hw/gpio/max7310.c +2 -3
         break;
     default:
-#ifdef VERBOSE
-        printf("%s: unknown register %02x\n", __func__, s->command);
-#endif
+        qemu_log_mask(LOG_UNIMP, "%s: Unsupported register 0x02%" PRIx8 "\n",
+                      __func__, s->command);
         return 1;
     }
 
#6 lore raw

Re: [PATCH 2/2] hw/gpio/max7310: Replace disabled printf() by qemu_log_mask(UNIMP)

In reply to Philippe Mathieu-Daudé

Le 01/09/2020 à 12:42, Philippe Mathieu-Daudé a écrit :

Quoted 34 lines

Replace disabled printf() by qemu_log_mask(UNIMP).

---
 hw/gpio/max7310.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
hw/gpio/max7310.c +3 -3
index 7f5de189acf..c58a1996418 100644
@@ -11,6 +11,7 @@
 #include "hw/i2c/i2c.h"
 #include "hw/irq.h"
 #include "migration/vmstate.h"
+#include "qemu/log.h"
 #include "qemu/module.h"
 
 #define TYPE_MAX7310 "max7310"
@@ -69,9 +70,8 @@ static uint8_t max7310_rx(I2CSlave *i2c)
         return 0xff;
 
     default:
-#ifdef VERBOSE
-        printf("%s: unknown register %02x\n", __func__, s->command);
-#endif
+        qemu_log_mask(LOG_UNIMP, "%s: Unsupported register 0x02%" PRIx8 "\n",
+                      __func__, s->command);
         break;
     }
     return 0xff;
@@ -123,9 +123,8 @@ static int max7310_tx(I2CSlave *i2c, uint8_t data)
     case 0x00:	/* Input port - ignore writes */

hw/gpio/max7310.c static int max7310_tx(I2CSlave *i2c, uint8_t data) · line 130

Quoted 10 lines
hw/gpio/max7310.c +2 -3
         break;
     default:
-#ifdef VERBOSE
-        printf("%s: unknown register %02x\n", __func__, s->command);
-#endif
+        qemu_log_mask(LOG_UNIMP, "%s: Unsupported register 0x02%" PRIx8 "\n",
+                      __func__, s->command);
         return 1;
     }
 

Applied to my trivial-patches branch.

Thanks,
Laurent