diff options
author | Rajiv Andrade <srajiv@linux.vnet.ibm.com> | 2011-09-16 13:39:40 -0400 |
---|---|---|
committer | Rajiv Andrade <srajiv@linux.vnet.ibm.com> | 2011-11-16 06:44:55 -0500 |
commit | fd04886660208ab2e35baaca55588afa57d52c9c (patch) | |
tree | 200fd2b5a472317472f36cd452f60b1e5b42874f /drivers/char/tpm/tpm.c | |
parent | 9efa54f002cc03fdb4e9d8d508aa996af01c48d0 (diff) |
TPM: Export wait_for_stat for other vendor specific drivers
Moved wait_for_stat to tpm.c so that other drivers can use it.
Also renamed it to avoid future namespace conflicts.
Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
Diffstat (limited to 'drivers/char/tpm/tpm.c')
-rw-r--r-- | drivers/char/tpm/tpm.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index 2e12b3f9813..efd24bbb5cb 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/mutex.h> | 28 | #include <linux/mutex.h> |
29 | #include <linux/spinlock.h> | 29 | #include <linux/spinlock.h> |
30 | #include <linux/freezer.h> | ||
30 | 31 | ||
31 | #include "tpm.h" | 32 | #include "tpm.h" |
32 | 33 | ||
@@ -1057,6 +1058,46 @@ ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr, | |||
1057 | } | 1058 | } |
1058 | EXPORT_SYMBOL_GPL(tpm_store_cancel); | 1059 | EXPORT_SYMBOL_GPL(tpm_store_cancel); |
1059 | 1060 | ||
1061 | int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, | ||
1062 | wait_queue_head_t *queue) | ||
1063 | { | ||
1064 | unsigned long stop; | ||
1065 | long rc; | ||
1066 | u8 status; | ||
1067 | |||
1068 | /* check current status */ | ||
1069 | status = chip->vendor.status(chip); | ||
1070 | if ((status & mask) == mask) | ||
1071 | return 0; | ||
1072 | |||
1073 | stop = jiffies + timeout; | ||
1074 | |||
1075 | if (chip->vendor.irq) { | ||
1076 | again: | ||
1077 | timeout = stop - jiffies; | ||
1078 | if ((long)timeout <= 0) | ||
1079 | return -ETIME; | ||
1080 | rc = wait_event_interruptible_timeout(*queue, | ||
1081 | ((chip->vendor.status(chip) | ||
1082 | & mask) == mask), | ||
1083 | timeout); | ||
1084 | if (rc > 0) | ||
1085 | return 0; | ||
1086 | if (rc == -ERESTARTSYS && freezing(current)) { | ||
1087 | clear_thread_flag(TIF_SIGPENDING); | ||
1088 | goto again; | ||
1089 | } | ||
1090 | } else { | ||
1091 | do { | ||
1092 | msleep(TPM_TIMEOUT); | ||
1093 | status = chip->vendor.status(chip); | ||
1094 | if ((status & mask) == mask) | ||
1095 | return 0; | ||
1096 | } while (time_before(jiffies, stop)); | ||
1097 | } | ||
1098 | return -ETIME; | ||
1099 | } | ||
1100 | EXPORT_SYMBOL_GPL(wait_for_tpm_stat); | ||
1060 | /* | 1101 | /* |
1061 | * Device file system interface to the TPM | 1102 | * Device file system interface to the TPM |
1062 | * | 1103 | * |