Skip to content

Commit 7a0a6d0

Browse files
Joy Chakrabortygregkh
authored andcommitted
nvmem: meson-efuse: Fix return value of nvmem callbacks
Read/write callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure. meson_efuse_read() and meson_efuse_write() call into meson_sm_call_read() and meson_sm_call_write() respectively which return the number of bytes read or written on success as per their api description. Fix to return error if meson_sm_call_read()/meson_sm_call_write() returns an error else return 0. Fixes: a29a63b ("nvmem: meson-efuse: simplify read callback") Cc: [email protected] Signed-off-by: Joy Chakraborty <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 28b0087 commit 7a0a6d0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/nvmem/meson-efuse.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,24 @@ static int meson_efuse_read(void *context, unsigned int offset,
1818
void *val, size_t bytes)
1919
{
2020
struct meson_sm_firmware *fw = context;
21+
int ret;
2122

22-
return meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset,
23-
bytes, 0, 0, 0);
23+
ret = meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset,
24+
bytes, 0, 0, 0);
25+
26+
return ret < 0 ? ret : 0;
2427
}
2528

2629
static int meson_efuse_write(void *context, unsigned int offset,
2730
void *val, size_t bytes)
2831
{
2932
struct meson_sm_firmware *fw = context;
33+
int ret;
34+
35+
ret = meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset,
36+
bytes, 0, 0, 0);
3037

31-
return meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset,
32-
bytes, 0, 0, 0);
38+
return ret < 0 ? ret : 0;
3339
}
3440

3541
static const struct of_device_id meson_efuse_match[] = {

0 commit comments

Comments
 (0)