]> git.sur5r.net Git - u-boot/commitdiff
tpm: tpm_tis_i2c: Simplify init code
authorSimon Glass <sjg@chromium.org>
Sun, 23 Aug 2015 00:31:28 +0000 (18:31 -0600)
committerSimon Glass <sjg@chromium.org>
Mon, 31 Aug 2015 13:57:28 +0000 (07:57 -0600)
Move all the init and uninit code into one place.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Christophe Ricard<christophe-h.ricard@st.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
drivers/tpm/tpm_tis_i2c.c

index 39652a977c7402e7a339bf3ce45303420f44cf0c..9dd40dd3cf51ba4637e209192b25e32ba77f0d57 100644 (file)
@@ -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;
 }