]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
stm32mp: cmd_stm32key: add get_misc_dev function
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Mon, 28 Jun 2021 12:56:01 +0000 (14:56 +0200)
committerPatrick Delaunay <patrick.delaunay@foss.st.com>
Fri, 16 Jul 2021 07:28:46 +0000 (09:28 +0200)
Add a helper function to access to BSEC misc driver.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
arch/arm/mach-stm32mp/cmd_stm32key.c

index c4cb6342fa718d01de3cfe35326190c02c42777c..886c52794f2fd104831fcec3427bee902fe87ca6 100644 (file)
 #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;