]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ARM: meson: fixup error on efuse commands return
authorJerome Brunet <jbrunet@baylibre.com>
Thu, 4 Aug 2022 14:41:38 +0000 (16:41 +0200)
committerNeil Armstrong <narmstrong@baylibre.com>
Mon, 8 Aug 2022 07:56:38 +0000 (09:56 +0200)
All `sm efuseread/efusewrite` commands exit with an error, even if the fuse
have actually been dealt with correctly.

This is because the smc call return the size it actually processed but this
result is checked against 0.

Return failure in do_efuse_read/write if the return value of
meson_sm_read/write_efuse() is not the requested size.

Fixes: 52195ba5f579 ("ARM: amlogic: add sm efuse write support and cmd for read/write efuse")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://lore.kernel.org/r/20220804144138.33809-1-jbrunet@baylibre.com
arch/arm/mach-meson/sm.c

index 6c28c0f5e445f36c5dbe6543071ce3fe6798a39c..d6eb910689f41ff39783e2476f6c39986a0c88a3 100644 (file)
@@ -82,10 +82,7 @@ ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size)
 
        smc_call(&regs);
 
-       if (regs.regs[0] == 0)
-               return -1;
-
-       return 0;
+       return regs.regs[0];
 }
 
 #define SM_CHIP_ID_LENGTH      119
@@ -222,7 +219,7 @@ static int do_efuse_read(struct cmd_tbl *cmdtp, int flag, int argc,
         address = simple_strtoul(argv[3], NULL, 0);
 
        ret = meson_sm_read_efuse(offset, (void *)address, size);
-       if (ret)
+       if (ret != size)
                return CMD_RET_FAILURE;
 
        return CMD_RET_SUCCESS;
@@ -243,7 +240,7 @@ static int do_efuse_write(struct cmd_tbl *cmdtp, int flag, int argc,
         address = simple_strtoul(argv[3], NULL, 0);
 
        ret = meson_sm_write_efuse(offset, (void *)address, size);
-       if (ret)
+       if (ret != size)
                return CMD_RET_FAILURE;
 
        return CMD_RET_SUCCESS;