|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 11/18] mini-os: move tpm respgot member of struct file to device specific data
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@xxxxxxxx>
Reviewed-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
---
include/lib.h | 2 --
include/tpmfront.h | 2 ++
tpm_tis.c | 2 --
tpmfront.c | 10 +++++-----
4 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/include/lib.h b/include/lib.h
index f2a124e..d740065 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -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
diff --git a/include/tpmfront.h b/include/tpmfront.h
index c489fae..b7da50e 100644
--- a/include/tpmfront.h
+++ b/include/tpmfront.h
@@ -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
};
diff --git a/tpm_tis.c b/tpm_tis.c
index 8a632b1..4127118 100644
--- 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;
}
diff --git a/tpmfront.c b/tpmfront.c
index 8b2a910..be671c2 100644
--- a/tpmfront.c
+++ b/tpmfront.c
@@ -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;
--
2.26.2
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |