[PATCH 2/3] nvmem: sprd: Fix programming errors in efuse caused by incorrect parameters
From: Yanxin Huang
Date: Fri Dec 08 2023 - 01:12:35 EST
The second argument to sprd_efuse_raw_prog() is the efuse index block
data, but the data passed in is the efuse block offset, which can cause
efuse to be programmed to the wrong block.
Fixes: 096030e7f449 ("nvmem: sprd: Add Spreadtrum SoCs eFuse support")
Signed-off-by: Yanxin Huang <yanxin.huang@xxxxxxxxxx>
---
drivers/nvmem/sprd-efuse.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/sprd-efuse.c b/drivers/nvmem/sprd-efuse.c
index 24b63620d217..f0880f8fc56d 100644
--- a/drivers/nvmem/sprd-efuse.c
+++ b/drivers/nvmem/sprd-efuse.c
@@ -326,6 +326,7 @@ static int sprd_efuse_write(void *context, u32 offset, void *val, size_t bytes)
{
struct sprd_efuse *efuse = context;
bool blk_double = efuse->data->blk_double;
+ u32 index = offset / SPRD_EFUSE_BLOCK_WIDTH + efuse->data->blk_offset;
bool lock;
int ret;
@@ -350,7 +351,7 @@ static int sprd_efuse_write(void *context, u32 offset, void *val, size_t bytes)
else
lock = true;
- ret = sprd_efuse_raw_prog(efuse, offset, blk_double, lock, val);
+ ret = sprd_efuse_raw_prog(efuse, index, blk_double, lock, val);
clk_disable_unprepare(efuse->clk);
--
2.17.1