diff mbox series

[v4,2/3] hw/i2c/smbus_slave: Add object path on error prints

Message ID 20240220211123.2664977-3-komlodi@google.com (mailing list archive)
State New, archived
Headers show
Series hw/i2c: smbus: Reset fixes | expand

Commit Message

Joe Komlodi Feb. 20, 2024, 9:11 p.m. UTC
The current logging doesn't tell us which specific smbus device is an
error state.

Signed-off-by: Joe Komlodi <komlodi@google.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/i2c/smbus_slave.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé Feb. 21, 2024, 6:28 p.m. UTC | #1
On 20/2/24 22:11, Joe Komlodi wrote:
> The current logging doesn't tell us which specific smbus device is an
> error state.
> 
> Signed-off-by: Joe Komlodi <komlodi@google.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/i2c/smbus_slave.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/i2c/smbus_slave.c b/hw/i2c/smbus_slave.c
> index 1300c9ec72..9f9afc25a4 100644
> --- a/hw/i2c/smbus_slave.c
> +++ b/hw/i2c/smbus_slave.c
> @@ -25,11 +25,15 @@
>   #define DPRINTF(fmt, ...) \
>   do { printf("smbus(%02x): " fmt , dev->i2c.address, ## __VA_ARGS__); } while (0)
>   #define BADF(fmt, ...) \
> -do { fprintf(stderr, "smbus: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
> +do { g_autofree char *qom_path = object_get_canonical_path(OBJECT(dev));  \
> +    fprintf(stderr, "%s: smbus: error: " fmt , qom_path, ## __VA_ARGS__); \
> +            exit(1); } while (0)
>   #else
>   #define DPRINTF(fmt, ...) do {} while(0)
>   #define BADF(fmt, ...) \
> -do { fprintf(stderr, "smbus: error: " fmt , ## __VA_ARGS__);} while (0)
> +do { g_autofree char *qom_path = object_get_canonical_path(OBJECT(dev));  \
> +    fprintf(stderr, "%s: smbus: error: " fmt , qom_path, ## __VA_ARGS__); \
> +             } while (0)
>   #endif
>   
>   enum {

Better convert to trace events, so we can enable tracing at runtime.

Anyhow,
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff mbox series

Patch

diff --git a/hw/i2c/smbus_slave.c b/hw/i2c/smbus_slave.c
index 1300c9ec72..9f9afc25a4 100644
--- a/hw/i2c/smbus_slave.c
+++ b/hw/i2c/smbus_slave.c
@@ -25,11 +25,15 @@ 
 #define DPRINTF(fmt, ...) \
 do { printf("smbus(%02x): " fmt , dev->i2c.address, ## __VA_ARGS__); } while (0)
 #define BADF(fmt, ...) \
-do { fprintf(stderr, "smbus: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
+do { g_autofree char *qom_path = object_get_canonical_path(OBJECT(dev));  \
+    fprintf(stderr, "%s: smbus: error: " fmt , qom_path, ## __VA_ARGS__); \
+            exit(1); } while (0)
 #else
 #define DPRINTF(fmt, ...) do {} while(0)
 #define BADF(fmt, ...) \
-do { fprintf(stderr, "smbus: error: " fmt , ## __VA_ARGS__);} while (0)
+do { g_autofree char *qom_path = object_get_canonical_path(OBJECT(dev));  \
+    fprintf(stderr, "%s: smbus: error: " fmt , qom_path, ## __VA_ARGS__); \
+             } while (0)
 #endif
 
 enum {