diff mbox

[2/5] tpm: convert tpm_passthrough.c to use trace-events

Message ID 1520200587-14681-3-git-send-email-stefanb@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Berger March 4, 2018, 9:56 p.m. UTC
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
 hw/tpm/tpm_passthrough.c | 13 +++----------
 hw/tpm/trace-events      |  4 ++++
 2 files changed, 7 insertions(+), 10 deletions(-)

Comments

Philippe Mathieu-Daudé March 5, 2018, 12:08 a.m. UTC | #1
On 03/04/2018 06:56 PM, Stefan Berger wrote:
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  hw/tpm/tpm_passthrough.c | 13 +++----------
>  hw/tpm/trace-events      |  4 ++++
>  2 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
> index a495fe0..2589c4d 100644
> --- a/hw/tpm/tpm_passthrough.c
> +++ b/hw/tpm/tpm_passthrough.c
> @@ -31,14 +31,7 @@
>  #include "hw/hw.h"
>  #include "qapi/clone-visitor.h"
>  #include "tpm_util.h"
> -
> -#define DEBUG_TPM 0
> -
> -#define DPRINTF(fmt, ...) do { \
> -    if (DEBUG_TPM) { \
> -        fprintf(stderr, fmt, ## __VA_ARGS__); \
> -    } \
> -} while (0)
> +#include "trace.h"
>  
>  #define TYPE_TPM_PASSTHROUGH "tpm-passthrough"
>  #define TPM_PASSTHROUGH(obj) \
> @@ -137,7 +130,7 @@ static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd *cmd,
>  {
>      TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
>  
> -    DPRINTF("tpm_passthrough: processing command %p\n", cmd);
> +    trace_tpm_passthrough_handle_request(cmd);
>  
>      tpm_passthrough_unix_tx_bufs(tpm_pt, cmd->in, cmd->in_len,
>                                   cmd->out, cmd->out_len, &cmd->selftest_done,
> @@ -146,7 +139,7 @@ static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd *cmd,
>  
>  static void tpm_passthrough_reset(TPMBackend *tb)
>  {
> -    DPRINTF("tpm_passthrough: CALL TO TPM_RESET!\n");
> +    trace_tpm_passthrough_reset();
>  
>      tpm_passthrough_cancel_cmd(tb);
>  }
> diff --git a/hw/tpm/trace-events b/hw/tpm/trace-events
> index 336b06d..8557dd9 100644
> --- a/hw/tpm/trace-events
> +++ b/hw/tpm/trace-events
> @@ -3,3 +3,7 @@
>  # hw/tpm/tpm_crb.c
>  tpm_crb_mmio_read(uint64_t addr, unsigned size, uint32_t val) "CRB read 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32
>  tpm_crb_mmio_write(uint64_t addr, unsigned size, uint32_t val) "CRB write 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32
> +
> +# hw/tpm/tpm_passthrough.c
> +tpm_passthrough_handle_request(void *cmd) "processing command %p"
> +tpm_passthrough_reset(void) "reset"
>
diff mbox

Patch

diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index a495fe0..2589c4d 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -31,14 +31,7 @@ 
 #include "hw/hw.h"
 #include "qapi/clone-visitor.h"
 #include "tpm_util.h"
-
-#define DEBUG_TPM 0
-
-#define DPRINTF(fmt, ...) do { \
-    if (DEBUG_TPM) { \
-        fprintf(stderr, fmt, ## __VA_ARGS__); \
-    } \
-} while (0)
+#include "trace.h"
 
 #define TYPE_TPM_PASSTHROUGH "tpm-passthrough"
 #define TPM_PASSTHROUGH(obj) \
@@ -137,7 +130,7 @@  static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd *cmd,
 {
     TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
 
-    DPRINTF("tpm_passthrough: processing command %p\n", cmd);
+    trace_tpm_passthrough_handle_request(cmd);
 
     tpm_passthrough_unix_tx_bufs(tpm_pt, cmd->in, cmd->in_len,
                                  cmd->out, cmd->out_len, &cmd->selftest_done,
@@ -146,7 +139,7 @@  static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd *cmd,
 
 static void tpm_passthrough_reset(TPMBackend *tb)
 {
-    DPRINTF("tpm_passthrough: CALL TO TPM_RESET!\n");
+    trace_tpm_passthrough_reset();
 
     tpm_passthrough_cancel_cmd(tb);
 }
diff --git a/hw/tpm/trace-events b/hw/tpm/trace-events
index 336b06d..8557dd9 100644
--- a/hw/tpm/trace-events
+++ b/hw/tpm/trace-events
@@ -3,3 +3,7 @@ 
 # hw/tpm/tpm_crb.c
 tpm_crb_mmio_read(uint64_t addr, unsigned size, uint32_t val) "CRB read 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32
 tpm_crb_mmio_write(uint64_t addr, unsigned size, uint32_t val) "CRB write 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32
+
+# hw/tpm/tpm_passthrough.c
+tpm_passthrough_handle_request(void *cmd) "processing command %p"
+tpm_passthrough_reset(void) "reset"