]> git.proxmox.com Git - mirror_qemu.git/commit
tpm: Clean up model registration & lookup
authorMarkus Armbruster <armbru@redhat.com>
Thu, 24 Aug 2017 08:45:59 +0000 (10:45 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Mon, 4 Sep 2017 11:09:13 +0000 (13:09 +0200)
commit00bbf50a50e6d6e1a4542db1c1205291395c4105
treebe3ffb2ba802bd2ccff2d71f932e74aa4f186cdd
parenta9a72aeefbd3ef8bcbbeeccaf174ee10db2978ac
tpm: Clean up model registration & lookup

We have a strict separation between enum TpmModel and tpm_models[]:

* TpmModel may have any number of members.  It just happens to have one.

* tpm_register_model() uses the first empty slot in tpm_models[].

  If you register more than tpm_models[] has space,
  tpn_register_model() fails.  Its caller silently ignores the
  failure.

  Register the same TpmModel more than once has no effect other than
  wasting tpm_models[] slots: tpm_model_is_registered() is happy with
  the first one it finds.

Since we only ever register one model, and tpm_models[] has space for
just that one, this contraption even works.

Turn tpm_models[] into a straight map from enum TpmType to bool.  Much
simpler.

Cc: Stefan Berger <stefanb@us.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-5-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[Commit message typo fixed]
include/sysemu/tpm_backend.h
tpm.c