diff mbox series

[5/7] stm32mp: cmd_stm32key: add get_misc_dev function

Message ID 20210628145519.5.I38ea9658e6b3f7be161eddb47b792f8af938910e@changeid
State Accepted
Commit e00e1f394c8cb7476fe6c1abce54674b75336b70
Delegated to: Patrick Delaunay
Headers show
Series stm32mp: cmd_stm32key: updates | expand

Commit Message

Patrick DELAUNAY June 28, 2021, 12:56 p.m. UTC
Add a helper function to access to BSEC misc driver.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 arch/arm/mach-stm32mp/cmd_stm32key.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

Comments

Patrice CHOTARD July 1, 2021, 7:36 a.m. UTC | #1
Hi Patrick

On 6/28/21 2:56 PM, Patrick Delaunay wrote:
> Add a helper function to access to BSEC misc driver.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
> 
>  arch/arm/mach-stm32mp/cmd_stm32key.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32key.c b/arch/arm/mach-stm32mp/cmd_stm32key.c
> index c4cb6342fa..886c52794f 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32key.c
> +++ b/arch/arm/mach-stm32mp/cmd_stm32key.c
> @@ -14,6 +14,17 @@
>  #define STM32_OTP_HASH_KEY_START 24
>  #define STM32_OTP_HASH_KEY_SIZE 8
>  
> +static int get_misc_dev(struct udevice **dev)
> +{
> +	int ret;
> +
> +	ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(stm32mp_bsec), dev);
> +	if (ret)
> +		log_err("Can't find stm32mp_bsec driver\n");
> +
> +	return ret;
> +}
> +
>  static void read_hash_value(u32 addr)
>  {
>  	int i;
> @@ -31,13 +42,9 @@ static int fuse_hash_value(u32 addr, bool print)
>  	u32 word, val;
>  	int i, ret;
>  
> -	ret = uclass_get_device_by_driver(UCLASS_MISC,
> -					  DM_DRIVER_GET(stm32mp_bsec),
> -					  &dev);
> -	if (ret) {
> -		log_err("Can't find stm32mp_bsec driver\n");
> +	ret = get_misc_dev(&dev);
> +	if (ret)
>  		return ret;
> -	}
>  
>  	for (i = 0, word = STM32_OTP_HASH_KEY_START;
>  	     i < STM32_OTP_HASH_KEY_SIZE;
> 
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
Patrick DELAUNAY July 16, 2021, 8:28 a.m. UTC | #2
Hi,

On 6/28/21 2:56 PM, Patrick Delaunay wrote:
> Add a helper function to access to BSEC misc driver.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
>
>   arch/arm/mach-stm32mp/cmd_stm32key.c | 19 +++++++++++++------
>   1 file changed, 13 insertions(+), 6 deletions(-)
>

Applied to u-boot-stm/master, thanks!

Regards
Patrick
diff mbox series

Patch

diff --git a/arch/arm/mach-stm32mp/cmd_stm32key.c b/arch/arm/mach-stm32mp/cmd_stm32key.c
index c4cb6342fa..886c52794f 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32key.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32key.c
@@ -14,6 +14,17 @@ 
 #define STM32_OTP_HASH_KEY_START 24
 #define STM32_OTP_HASH_KEY_SIZE 8
 
+static int get_misc_dev(struct udevice **dev)
+{
+	int ret;
+
+	ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(stm32mp_bsec), dev);
+	if (ret)
+		log_err("Can't find stm32mp_bsec driver\n");
+
+	return ret;
+}
+
 static void read_hash_value(u32 addr)
 {
 	int i;
@@ -31,13 +42,9 @@  static int fuse_hash_value(u32 addr, bool print)
 	u32 word, val;
 	int i, ret;
 
-	ret = uclass_get_device_by_driver(UCLASS_MISC,
-					  DM_DRIVER_GET(stm32mp_bsec),
-					  &dev);
-	if (ret) {
-		log_err("Can't find stm32mp_bsec driver\n");
+	ret = get_misc_dev(&dev);
+	if (ret)
 		return ret;
-	}
 
 	for (i = 0, word = STM32_OTP_HASH_KEY_START;
 	     i < STM32_OTP_HASH_KEY_SIZE;