aboutsummaryrefslogtreecommitdiff
path: root/include/sysemu
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-08-24 10:45:58 +0200
committerMarkus Armbruster <armbru@redhat.com>2017-09-04 13:09:13 +0200
commita9a72aeefbd3ef8bcbbeeccaf174ee10db2978ac (patch)
tree9e52ed84125a31bd428eb126a894d23a77d1c415 /include/sysemu
parent06c60b6c468ca7cde004fe7c3ce35de312855f55 (diff)
tpm: Clean up driver registration & lookup
We have a strict separation between enum TpmType and be_drivers[]: * TpmType may have any number of members. It just happens to have one. * tpm_register_driver() uses the first empty slot in be_drivers[]. If you register more than tpm_models[] has space, tpm_register_driver() fails. Its caller silently ignores the failure. If you register more than one with a given TpmType, tpm_display_backend_drivers() will shows all of them, but tpm_driver_find_by_type() and tpm_get_backend_driver() will find only the one one that registered first. Since we only ever register one driver, and be_drivers[] has space for just that one, this contraption even works. Turn be_drivers[] into a straight map from enum TpmType to driver. Much simpler, and has a decent chance to actually work should we ever acquire additional drivers. While there, use qapi_enum_parse() in tpm_get_backend_driver(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20170822132255.23945-8-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Rebased, superfluous initializer dropped, commit message rewritten] Cc: Stefan Berger <stefanb@us.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1503564371-26090-4-git-send-email-armbru@redhat.com>
Diffstat (limited to 'include/sysemu')
-rw-r--r--include/sysemu/tpm_backend.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h
index b58f52d39f..1d21c6b19b 100644
--- a/include/sysemu/tpm_backend.h
+++ b/include/sysemu/tpm_backend.h
@@ -227,6 +227,6 @@ TPMBackend *qemu_find_tpm(const char *id);
const TPMDriverOps *tpm_get_backend_driver(const char *type);
int tpm_register_model(enum TpmModel model);
-int tpm_register_driver(const TPMDriverOps *tdo);
+void tpm_register_driver(const TPMDriverOps *tdo);
#endif