Skip to content

Commit ddf4dc8

Browse files
committed
nvmem: core: returning bytes read is successful read too
1 parent 8cca039 commit ddf4dc8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/nvmem/core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,10 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
944944

945945
rc = nvmem_reg_read(nvmem, cell->offset, buf, cell->bytes);
946946

947+
/* returning bytes read is successful read too */
948+
if (rc == cell->bytes)
949+
rc = 0;
950+
947951
if (rc)
948952
return rc;
949953

@@ -1011,6 +1015,9 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
10111015

10121016
/* setup the first byte with lsb bits from nvmem */
10131017
rc = nvmem_reg_read(nvmem, cell->offset, &v, 1);
1018+
/* returning bytes read is successful read too */
1019+
if (rc == 1)
1020+
rc = 0;
10141021
if (rc)
10151022
goto err;
10161023
*b++ |= GENMASK(bit_offset - 1, 0) & v;
@@ -1031,6 +1038,9 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
10311038
/* setup the last byte with msb bits from nvmem */
10321039
rc = nvmem_reg_read(nvmem,
10331040
cell->offset + cell->bytes - 1, &v, 1);
1041+
/* returning bytes read is successful read too */
1042+
if (rc == 1)
1043+
rc = 0;
10341044
if (rc)
10351045
goto err;
10361046
*p |= GENMASK(7, (nbits + bit_offset) % BITS_PER_BYTE) & v;

0 commit comments

Comments
 (0)