[PATCH] tpm/tpm_i2c_infineon: ensure no ongoing commands on shutdown
From: Andrey Pronin
Date: Fri Jan 13 2017 - 19:10:21 EST
Resetting TPM while processing a command may lead to issues
on the next boot. Ensure that we don't have any ongoing
commands, and that no further commands can be sent to the chip
by unregistering the device in the shutdown handler.
tpm_chip_unregister() waits for the completion of an ongoing
command, if any, and then clears out chip->ops and unregisters
sysfs entities.
Signed-off-by: Andrey Pronin <apronin@xxxxxxxxxxxx>
---
drivers/char/tpm/tpm_i2c_infineon.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index 62ee44e57ddc..0c829fe26561 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -689,14 +689,18 @@ static int tpm_tis_i2c_probe(struct i2c_client *client,
return rc;
}
-static int tpm_tis_i2c_remove(struct i2c_client *client)
+static void tpm_tis_i2c_shutdown(struct i2c_client *client)
{
struct tpm_chip *chip = tpm_dev.chip;
tpm_chip_unregister(chip);
release_locality(chip, tpm_dev.locality, 1);
tpm_dev.client = NULL;
+}
+static int tpm_tis_i2c_remove(struct i2c_client *client)
+{
+ tpm_tis_i2c_shutdown(client);
return 0;
}
@@ -704,6 +708,7 @@ static struct i2c_driver tpm_tis_i2c_driver = {
.id_table = tpm_tis_i2c_table,
.probe = tpm_tis_i2c_probe,
.remove = tpm_tis_i2c_remove,
+ .shutdown = tpm_tis_i2c_shutdown,
.driver = {
.name = "tpm_i2c_infineon",
.pm = &tpm_tis_i2c_ops,
--
2.11.0.483.g087da7b7c-goog