diff mbox series

[04/10] tpm: Move the TPM version detection functions to the uclass driver

Message ID 20220224180552.26901-5-sughosh.ganu@linaro.org
State Superseded
Headers show
Series tpm: rng: Move TPM RNG functionality to driver model | expand

Commit Message

Sughosh Ganu Feb. 24, 2022, 6:05 p.m. UTC
Make the TPM version detection functions as external symbols and move
them to the TPM uclass driver. These are useful functions to check the
TPM device version and should not be static functions.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
 drivers/tpm/tpm-uclass.c | 11 +++++++++++
 include/tpm_api.h        | 20 ++++++++++++++++++++
 lib/tpm_api.c            | 10 ----------
 3 files changed, 31 insertions(+), 10 deletions(-)

Comments

Heinrich Schuchardt Feb. 24, 2022, 6:57 p.m. UTC | #1
On 2/24/22 19:05, Sughosh Ganu wrote:
> Make the TPM version detection functions as external symbols and move
> them to the TPM uclass driver. These are useful functions to check the
> TPM device version and should not be static functions.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> ---
>   drivers/tpm/tpm-uclass.c | 11 +++++++++++
>   include/tpm_api.h        | 20 ++++++++++++++++++++
>   lib/tpm_api.c            | 10 ----------
>   3 files changed, 31 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/tpm/tpm-uclass.c b/drivers/tpm/tpm-uclass.c
> index f67fe1019b..8619da89d8 100644
> --- a/drivers/tpm/tpm-uclass.c
> +++ b/drivers/tpm/tpm-uclass.c
> @@ -11,10 +11,21 @@
>   #include <log.h>
>   #include <linux/delay.h>
>   #include <linux/unaligned/be_byteshift.h>
> +#include <tpm_api.h>
>   #include <tpm-v1.h>
>   #include <tpm-v2.h>
>   #include "tpm_internal.h"
>
> +bool is_tpm1(struct udevice *dev)
> +{
> +	return IS_ENABLED(CONFIG_TPM_V1) && tpm_get_version(dev) == TPM_V1;
> +}
> +
> +bool is_tpm2(struct udevice *dev)
> +{
> +	return IS_ENABLED(CONFIG_TPM_V2) && tpm_get_version(dev) == TPM_V2;
> +}
> +
>   int tpm_open(struct udevice *dev)
>   {
>   	struct tpm_ops *ops = tpm_get_ops(dev);
> diff --git a/include/tpm_api.h b/include/tpm_api.h
> index fb6ee14e23..c19639a688 100644
> --- a/include/tpm_api.h
> +++ b/include/tpm_api.h
> @@ -11,6 +11,26 @@
>   #include <tpm-v1.h>
>   #include <tpm-v2.h>
>
> +/**
> + * is_tpm1() - Check if it is a tpmv1 device
> + * @param dev		TPM device
> + *
> + * Check if the TPM device is a TPMv1 device
> + *
> + * Return: 1 if TPMv1, 0 otherwise
> + */
> +bool is_tpm1(struct udevice *dev);
> +
> +/**
> + * is_tpm2() - Check if it is a tpmv2 device
> + * @param dev		TPM device
> + *
> + * Check if the TPM device is a TPMv2 device
> + *
> + * Return: 1 if TPMv2, 0 otherwise
> + */
> +bool is_tpm2(struct udevice *dev);
> +
>   /**
>    * Issue a TPM_Startup command.
>    *
> diff --git a/lib/tpm_api.c b/lib/tpm_api.c
> index b762202866..9dd9606fa8 100644
> --- a/lib/tpm_api.c
> +++ b/lib/tpm_api.c
> @@ -11,16 +11,6 @@
>   #include <tpm-v2.h>
>   #include <tpm_api.h>
>
> -static bool is_tpm1(struct udevice *dev)
> -{
> -	return IS_ENABLED(CONFIG_TPM_V1) && tpm_get_version(dev) == TPM_V1;
> -}
> -
> -static bool is_tpm2(struct udevice *dev)
> -{
> -	return IS_ENABLED(CONFIG_TPM_V2) && tpm_get_version(dev) == TPM_V2;
> -}
> -
>   int tpm_startup(struct udevice *dev, enum tpm_startup_type mode)
>   {
>   	if (is_tpm1(dev)) {
diff mbox series

Patch

diff --git a/drivers/tpm/tpm-uclass.c b/drivers/tpm/tpm-uclass.c
index f67fe1019b..8619da89d8 100644
--- a/drivers/tpm/tpm-uclass.c
+++ b/drivers/tpm/tpm-uclass.c
@@ -11,10 +11,21 @@ 
 #include <log.h>
 #include <linux/delay.h>
 #include <linux/unaligned/be_byteshift.h>
+#include <tpm_api.h>
 #include <tpm-v1.h>
 #include <tpm-v2.h>
 #include "tpm_internal.h"
 
+bool is_tpm1(struct udevice *dev)
+{
+	return IS_ENABLED(CONFIG_TPM_V1) && tpm_get_version(dev) == TPM_V1;
+}
+
+bool is_tpm2(struct udevice *dev)
+{
+	return IS_ENABLED(CONFIG_TPM_V2) && tpm_get_version(dev) == TPM_V2;
+}
+
 int tpm_open(struct udevice *dev)
 {
 	struct tpm_ops *ops = tpm_get_ops(dev);
diff --git a/include/tpm_api.h b/include/tpm_api.h
index fb6ee14e23..c19639a688 100644
--- a/include/tpm_api.h
+++ b/include/tpm_api.h
@@ -11,6 +11,26 @@ 
 #include <tpm-v1.h>
 #include <tpm-v2.h>
 
+/**
+ * is_tpm1() - Check if it is a tpmv1 device
+ * @param dev		TPM device
+ *
+ * Check if the TPM device is a TPMv1 device
+ *
+ * Return: 1 if TPMv1, 0 otherwise
+ */
+bool is_tpm1(struct udevice *dev);
+
+/**
+ * is_tpm2() - Check if it is a tpmv2 device
+ * @param dev		TPM device
+ *
+ * Check if the TPM device is a TPMv2 device
+ *
+ * Return: 1 if TPMv2, 0 otherwise
+ */
+bool is_tpm2(struct udevice *dev);
+
 /**
  * Issue a TPM_Startup command.
  *
diff --git a/lib/tpm_api.c b/lib/tpm_api.c
index b762202866..9dd9606fa8 100644
--- a/lib/tpm_api.c
+++ b/lib/tpm_api.c
@@ -11,16 +11,6 @@ 
 #include <tpm-v2.h>
 #include <tpm_api.h>
 
-static bool is_tpm1(struct udevice *dev)
-{
-	return IS_ENABLED(CONFIG_TPM_V1) && tpm_get_version(dev) == TPM_V1;
-}
-
-static bool is_tpm2(struct udevice *dev)
-{
-	return IS_ENABLED(CONFIG_TPM_V2) && tpm_get_version(dev) == TPM_V2;
-}
-
 int tpm_startup(struct udevice *dev, enum tpm_startup_type mode)
 {
 	if (is_tpm1(dev)) {