diff mbox

[v2,07/12] tpm: tpm_tis: Add post_probe phy handler

Message ID 1460577351-24632-8-git-send-email-christophe-h.ricard@st.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christophe Ricard April 13, 2016, 7:55 p.m. UTC
Add post_probe phy handler in order to execute additional proprietary
operations after tpm2_probe. For the case of tpm_tis using LPC, itpm
workaround probing.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
---
 drivers/char/tpm/tpm_tis.c      | 29 +++++++++++++++++++++--------
 drivers/char/tpm/tpm_tis_core.h |  1 +
 2 files changed, 22 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index a641af0..a82a09f 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -610,6 +610,7 @@  static const struct tpm_class_ops tpm_tis = {
 static struct tpm_tis_phy_ops tis_phy_ops = {
 	.data_expect_mask = TPM_STS_DATA_EXPECT,
 	.data_expect_val = TPM_STS_DATA_EXPECT,
+	.post_probe = tpm_tis_post_probe,
 };
 
 static int tpm_mem_read_bytes(struct tpm_chip *chip, u32 addr, u16 len,
@@ -807,6 +808,23 @@  static void tpm_tis_probe_irq(struct tpm_chip *chip, u32 intmask)
 		return;
 }
 
+static int tpm_tis_post_probe(struct tpm_chip *chip)
+{
+	int probe;
+
+	if (!itpm) {
+		probe = probe_itpm(chip);
+		if (probe < 0)
+			return  -ENODEV;
+		itpm = !!probe;
+	}
+
+	if (itpm)
+		dev_info(chip->dev.parent, "Intel iTPM workaround enabled\n");
+
+	return 0;
+}
+
 static bool interrupts = true;
 module_param(interrupts, bool, 0444);
 MODULE_PARM_DESC(interrupts, "Enable interrupts");
@@ -910,19 +928,14 @@  static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
 		 (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
 		 vendor >> 16, rid);
 
-	if (!itpm) {
-		probe = probe_itpm(chip);
-		if (probe < 0) {
+	if (priv->post_probe) {
+		rc = priv->post_probe(chip);
+		if (rc < 0) {
 			rc = -ENODEV;
 			goto out_err;
 		}
-		itpm = !!probe;
 	}
 
-	if (itpm)
-		dev_info(dev, "Intel iTPM workaround enabled\n");
-
-
 	/* Figure out the capabilities */
 	rc = tpm_read32(chip, TPM_INTF_CAPS(priv->locality), &intfcaps);
 	if (rc < 0)
diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
index cba82f8..dc5c136 100644
--- a/drivers/char/tpm/tpm_tis_core.h
+++ b/drivers/char/tpm/tpm_tis_core.h
@@ -52,6 +52,7 @@  struct tpm_tis_data {
 	const struct tpm_tis_class_lowlevel *lowlevel;
 	const struct tpm_tis_phy_ops *phy_ops;
 	void *phy_id;
+	int (*post_probe)(struct tpm_chip *chip);
 };
 
 static inline int tpm_read_bytes(struct tpm_chip *chip, u32 addr, u16 len,