@samitouri / QOSamiQemu / commits / 60ab4a0437

hw/tpm: Factor tpm_ppi_enabled() out

Factor out tpm_ppi_enabled() before modifying it in a unique place. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Message-Id: <20260317120241.16320-2-philmd@linaro.org>

Philippe Mathieu-Daudé committed Mar 17, 2026 at 12:26 UTC 60ab4a04379632294a57ed1878371bbfba418568
3 files changed +11 -2
hw/acpi/tpm.c
+1 -1
@@ -25,7 +25,7 @@ void tpm_build_ppi_acpi(TPMIf *tpm, Aml *dev)
25 Aml *method, *field, *ifctx, *ifctx2, *ifctx3, *func_mask,
26 *not_implemented, *pak, *tpm2, *tpm3, *pprm, *pprq, *zero, *one;
27
28 - if (!object_property_get_bool(OBJECT(tpm), "ppi", &error_abort)) {
28 + if (!tpm_ppi_enabled(tpm)) {
29 return;
30 }
31
hw/i386/acpi-build.c
+1 -1
@@ -2218,7 +2218,7 @@ void acpi_setup(void)
2218 tables.tcpalog->data, acpi_data_len(tables.tcpalog));
2219
2220 tpm = tpm_find();
2221 - if (tpm && object_property_get_bool(OBJECT(tpm), "ppi", &error_abort)) {
2221 + if (tpm_ppi_enabled(tpm)) {
2222 tpm_config = (FwCfgTPMConfig) {
2223 .tpmppi_address = cpu_to_le32(TPM_PPI_ADDR_BASE),
2224 .tpm_version = tpm_get_version(tpm),
include/system/tpm.h
+9
@@ -13,6 +13,7 @@
13 #define QEMU_TPM_H
14
15 #include "qapi/qapi-types-tpm.h"
16 +#include "qapi/error.h"
17 #include "qom/object.h"
18
19 #ifdef CONFIG_TPM
@@ -78,6 +79,14 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)
79 return TPM_IF_GET_CLASS(ti)->get_version(ti);
80 }
81
82 +static inline bool tpm_ppi_enabled(TPMIf *ti)
83 +{
84 + if (!ti) {
85 + return false;
86 + }
87 + return object_property_get_bool(OBJECT(ti), "ppi", &error_abort);
88 +}
89 +
90 #else /* CONFIG_TPM */
91
92 #define tpm_init() (0)