]> xenbits.xensource.com Git - mini-os.git/commitdiff
Move tpm respgot member of struct file to device specific data
authorJuergen Gross <jgross@suse.com>
Tue, 11 Jan 2022 14:58:10 +0000 (15:58 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 12 Jan 2022 11:35:49 +0000 (11:35 +0000)
Tpmfront has a "respgot" flag in struct file, which can be moved to the
device specific data. While at it make it a bool.

The respgot flag of the tpm_tis member of struct file can be removed,
as it is never read.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
include/lib.h
include/tpmfront.h
tpm_tis.c
tpmfront.c

index f2a124e2bdb009d5f59257e75bff5dee4d978f36..d7400658398584245d62bb95a6ffa8d467c0a09c 100644 (file)
@@ -196,13 +196,11 @@ struct file {
 #ifdef CONFIG_TPMFRONT
        struct {
           struct tpmfront_dev *dev;
-          int respgot;
        } tpmfront;
 #endif
 #ifdef CONFIG_TPM_TIS
        struct {
           struct tpm_chip *dev;
-          int respgot;
        } tpm_tis;
 #endif
 #ifdef CONFIG_XENBUS
index c489faec75a469bd0593ffb8f8f1029b3a894957..b7da50e378f8a5bdd8149345423fe1a0c6cd5c19 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef TPMFRONT_H
 #define TPMFRONT_H
 
+#include <stdbool.h>
 #include <mini-os/types.h>
 #include <mini-os/os.h>
 #include <mini-os/events.h>
@@ -53,6 +54,7 @@ struct tpmfront_dev {
 
 #ifdef HAVE_LIBC
    int fd;
+   bool respgot;
 #endif
 
 };
index 8a632b13cfdc780f49c5a7c6279eed8c198ae4f9..4127118d23f766108fcab3dd0261624d50263c64 100644 (file)
--- a/tpm_tis.c
+++ b/tpm_tis.c
@@ -846,7 +846,6 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
 #ifdef HAVE_LIBC
    if(tpm->fd >= 0) {
       files[tpm->fd].read = false;
-      files[tpm->fd].tpm_tis.respgot = 0;
       files[tpm->fd].offset = 0;
    }
 #endif
@@ -1290,7 +1289,6 @@ int tpm_tis_open(struct tpm_chip* tpm)
    tpm->fd = alloc_fd(FTYPE_TPM_TIS);
    printk("tpm_tis_open() -> %d\n", tpm->fd);
    files[tpm->fd].tpm_tis.dev = tpm;
-   files[tpm->fd].tpm_tis.respgot = 0;
    return tpm->fd;
 }
 
index 8b2a910dd32f5ef446cae5e9bbf1e0dd5b732a85..be671c29714f7d4a452ae979824210c9f1a44b2f 100644 (file)
@@ -439,8 +439,8 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
 #ifdef HAVE_LIBC
    if(dev->fd >= 0) {
       files[dev->fd].read = false;
-      files[dev->fd].tpmfront.respgot = 0;
       files[dev->fd].offset = 0;
+      dev->respgot = false;
    }
 #endif
    wmb();
@@ -499,7 +499,7 @@ int i;
 #endif
 #ifdef HAVE_LIBC
    if(dev->fd >= 0) {
-      files[dev->fd].tpmfront.respgot = 1;
+      dev->respgot = true;
    }
 #endif
 quit:
@@ -539,7 +539,7 @@ int tpmfront_open(struct tpmfront_dev* dev)
    dev->fd = alloc_fd(FTYPE_TPMFRONT);
    printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd);
    files[dev->fd].tpmfront.dev = dev;
-   files[dev->fd].tpmfront.respgot = 0;
+   dev->respgot = false;
    return dev->fd;
 }
 
@@ -580,7 +580,7 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t count)
    }
 
    /* get the response if we haven't already */
-   if(files[dev->fd].tpmfront.respgot == 0) {
+   if (!dev->respgot) {
       if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
         errno = EIO;
         return -1;
@@ -610,7 +610,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
 
    /* If we have a response waiting, then read it now from the backend
     * so we can get its length*/
-   if(dev->waiting || (files[dev->fd].read && !files[dev->fd].tpmfront.respgot)) {
+   if(dev->waiting || (files[dev->fd].read && !dev->respgot)) {
       if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
         errno = EIO;
         return -1;