From: Jerry Snitselaar <jsnitsel@redhat.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
linux-integrity@vger.kernel.org
Cc: Jerry Snitselaar <jsnitsel@redhat.com>
Subject: [RFC PATCH 1/1] tpm: don't return bool from update_timeouts
Date: Tue, 29 Jan 2019 10:41:45 -0700 [thread overview]
Message-ID: <20190129174145.1482-2-jsnitsel@redhat.com> (raw)
In-Reply-To: <20190129174145.1482-1-jsnitsel@redhat.com>
Set tpm_chip->timeouts_adjusted directly in the update_timeouts
code instead of returning bool. Return rc of tpm read instead,
which can be return an error in the case of the spi driver.
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
drivers/char/tpm/tpm1-cmd.c | 3 +--
drivers/char/tpm/tpm_tis_core.c | 8 ++++----
include/linux/tpm.h | 2 +-
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-cmd.c
index 6f306338953b..bda9a16b44f6 100644
--- a/drivers/char/tpm/tpm1-cmd.c
+++ b/drivers/char/tpm/tpm1-cmd.c
@@ -380,8 +380,7 @@ int tpm1_get_timeouts(struct tpm_chip *chip)
* of misreporting.
*/
if (chip->ops->update_timeouts)
- chip->timeout_adjusted =
- chip->ops->update_timeouts(chip, timeout_eff);
+ chip->ops->update_timeouts(chip, timeout_eff);
if (!chip->timeout_adjusted) {
/* Restore default if chip reported 0 */
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index bf7e49cfa643..57c5b6712563 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -521,13 +521,15 @@ static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = {
(TIS_SHORT_TIMEOUT*1000), (TIS_SHORT_TIMEOUT*1000) } },
};
-static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
+static int tpm_tis_update_timeouts(struct tpm_chip *chip,
unsigned long *timeout_cap)
{
struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
int i, rc;
u32 did_vid;
+ chip->timeout_adjusted = false;
+
if (chip->ops->clk_enable != NULL)
chip->ops->clk_enable(chip, true);
@@ -540,11 +542,9 @@ static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
continue;
memcpy(timeout_cap, vendor_timeout_overrides[i].timeout_us,
sizeof(vendor_timeout_overrides[i].timeout_us));
- rc = true;
+ chip->timeout_adjusted = true;
}
- rc = false;
-
out:
if (chip->ops->clk_enable != NULL)
chip->ops->clk_enable(chip, false);
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index b49a55cf775f..d18df4b6247f 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -41,7 +41,7 @@ struct tpm_class_ops {
int (*send) (struct tpm_chip *chip, u8 *buf, size_t len);
void (*cancel) (struct tpm_chip *chip);
u8 (*status) (struct tpm_chip *chip);
- bool (*update_timeouts)(struct tpm_chip *chip,
+ int (*update_timeouts)(struct tpm_chip *chip,
unsigned long *timeout_cap);
int (*go_idle)(struct tpm_chip *chip);
int (*cmd_ready)(struct tpm_chip *chip);
--
2.20.1.98.gecbdaf0899
next prev parent reply other threads:[~2019-01-29 17:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-29 17:41 [RFC PATCH 0/1] tpm: don't return bool from update_timeouts Jerry Snitselaar
2019-01-29 17:41 ` Jerry Snitselaar [this message]
2019-01-29 19:22 ` [RFC PATCH 1/1] " Jarkko Sakkinen
2019-01-29 19:50 ` Jerry Snitselaar
2019-01-29 21:12 ` Jarkko Sakkinen
2019-01-29 18:31 ` [RFC PATCH 0/1] " Jarkko Sakkinen
2019-01-29 20:14 ` [RFC PATCH v2 1/1] " Jerry Snitselaar
2019-01-30 21:23 ` Jarkko Sakkinen
2019-01-30 21:24 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190129174145.1482-2-jsnitsel@redhat.com \
--to=jsnitsel@redhat.com \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=linux-integrity@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).