From a53b79a25502b78d6e8b00b90f0fde14c9ccb20d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 22 Aug 2015 18:31:28 -0600 Subject: tpm: tpm_tis_i2c: Simplify init code Move all the init and uninit code into one place. Signed-off-by: Simon Glass Acked-by: Christophe Ricard Reviewed-by: Heiko Schocher --- drivers/tpm/tpm_tis_i2c.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/drivers/tpm/tpm_tis_i2c.c b/drivers/tpm/tpm_tis_i2c.c index 39652a977c..9dd40dd3cf 100644 --- a/drivers/tpm/tpm_tis_i2c.c +++ b/drivers/tpm/tpm_tis_i2c.c @@ -608,27 +608,6 @@ out: return rc; } -static int tpm_open_dev(struct udevice *dev) -{ - int rc; - - debug("%s: start\n", __func__); - if (g_chip.is_open) - return -EBUSY; - rc = tpm_tis_i2c_init(dev); - if (rc < 0) - g_chip.is_open = 0; - return rc; -} - -static void tpm_close(void) -{ - if (g_chip.is_open) { - release_locality(&g_chip, g_chip.locality, 1); - g_chip.is_open = 0; - } -} - /** * Decode TPM configuration. * @@ -712,7 +691,12 @@ int tis_open(void) if (!g_chip.inited) return -1; - rc = tpm_open_dev(g_chip.dev); + debug("%s: start\n", __func__); + if (g_chip.is_open) + return -EBUSY; + rc = tpm_tis_i2c_init(g_chip.dev); + if (rc < 0) + g_chip.is_open = 0; return rc; } @@ -722,7 +706,10 @@ int tis_close(void) if (!g_chip.inited) return -1; - tpm_close(); + if (g_chip.is_open) { + release_locality(&g_chip, g_chip.locality, 1); + g_chip.is_open = 0; + } return 0; } -- cgit