Blob Blame History Raw
From 7a890e520e81f662b530b148d4eed435af37daf7 Mon Sep 17 00:00:00 2001
From: Michal Suchanek <msuchanek@suse.de>
Date: Tue, 28 Aug 2018 11:31:35 +0200
Subject: [PATCH 6/7] KABI: tpm: change relinquish_locality return value back
 to void

References: bsc#1082555
Patch-mainline: no, kabi

This is not perfect. Since the timeout is now not handled locality may
be dropped in the kernel even if communication with the chip failed.
It's what the code did before the fixes, anyway.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 drivers/char/tpm/tpm-interface.c |  6 +-----
 drivers/char/tpm/tpm_crb.c       | 14 ++++++--------
 drivers/char/tpm/tpm_tis_core.c  |  4 +---
 include/linux/tpm.h              |  2 +-
 4 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index d661e14c7325..5be955020fb4 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -389,17 +389,13 @@ static int tpm_request_locality(struct tpm_chip *chip, unsigned int flags)
 
 static void tpm_relinquish_locality(struct tpm_chip *chip, unsigned int flags)
 {
-	int rc;
-
 	if (flags & TPM_TRANSMIT_RAW)
 		return;
 
 	if (!chip->ops->relinquish_locality)
 		return;
 
-	rc = chip->ops->relinquish_locality(chip, chip->locality);
-	if (rc)
-		dev_err(&chip->dev, "%s: : error %d\n", __func__, rc);
+	chip->ops->relinquish_locality(chip, chip->locality);
 
 	chip->locality = -1;
 }
diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
index 83037718787a..2057a7490c74 100644
--- a/drivers/char/tpm/tpm_crb.c
+++ b/drivers/char/tpm/tpm_crb.c
@@ -243,7 +243,7 @@ static int crb_request_locality(struct tpm_chip *chip, int loc)
 	return __crb_request_locality(&chip->dev, priv, loc);
 }
 
-static int __crb_relinquish_locality(struct device *dev,
+static void __crb_relinquish_locality(struct device *dev,
 				     struct crb_priv *priv, int loc)
 {
 	u32 mask = CRB_LOC_STATE_LOC_ASSIGNED |
@@ -251,23 +251,21 @@ static int __crb_relinquish_locality(struct device *dev,
 	u32 value = CRB_LOC_STATE_TPM_REG_VALID_STS;
 
 	if (!priv->regs_h)
-		return 0;
+		return;
 
 	iowrite32(CRB_LOC_CTRL_RELINQUISH, &priv->regs_h->loc_ctrl);
 	if (!crb_wait_for_reg_32(&priv->regs_h->loc_state, mask, value,
 				 TPM2_TIMEOUT_C)) {
-		dev_warn(dev, "TPM_LOC_STATE_x.requestAccess timed out\n");
-		return -ETIME;
+		dev_err(dev, "%s: TPM_LOC_STATE_x.requestAccess timed out\n",
+				__func__);
 	}
-
-	return 0;
 }
 
-static int crb_relinquish_locality(struct tpm_chip *chip, int loc)
+static void crb_relinquish_locality(struct tpm_chip *chip, int loc)
 {
 	struct crb_priv *priv = dev_get_drvdata(&chip->dev);
 
-	return __crb_relinquish_locality(&chip->dev, priv, loc);
+	__crb_relinquish_locality(&chip->dev, priv, loc);
 }
 
 static u8 crb_status(struct tpm_chip *chip)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 395c81d51eb7..9504284ef8fb 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -75,13 +75,11 @@ static bool check_locality(struct tpm_chip *chip, int l)
 	return false;
 }
 
-static int release_locality(struct tpm_chip *chip, int l)
+static void release_locality(struct tpm_chip *chip, int l)
 {
 	struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
 
 	tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_ACTIVE_LOCALITY);
-
-	return 0;
 }
 
 static int request_locality(struct tpm_chip *chip, int l)
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index 1841185f07d9..0add5b2d560a 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -51,7 +51,7 @@ struct tpm_class_ops {
 	int (*go_idle)(struct tpm_chip *chip);
 	int (*cmd_ready)(struct tpm_chip *chip);
 	int (*request_locality)(struct tpm_chip *chip, int loc);
-	int (*relinquish_locality)(struct tpm_chip *chip, int loc);
+	void (*relinquish_locality)(struct tpm_chip *chip, int loc);
 };
 
 #if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE)
-- 
2.13.7