Skip to content

Commit

Permalink
nvmem: core: returning bytes read is successful read too
Browse files Browse the repository at this point in the history
  • Loading branch information
scpcom committed Aug 7, 2022
1 parent e60b5f5 commit b071419
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/nvmem/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,10 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,

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

/* returning bytes read is successful read too */
if (rc == cell->bytes)
rc = 0;

if (rc)
return rc;

Expand Down Expand Up @@ -1310,6 +1314,9 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,

/* setup the first byte with lsb bits from nvmem */
rc = nvmem_reg_read(nvmem, cell->offset, &v, 1);
/* returning bytes read is successful read too */
if (rc == 1)
rc = 0;
if (rc)
goto err;
*b++ |= GENMASK(bit_offset - 1, 0) & v;
Expand All @@ -1330,6 +1337,9 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
/* setup the last byte with msb bits from nvmem */
rc = nvmem_reg_read(nvmem,
cell->offset + cell->bytes - 1, &v, 1);
/* returning bytes read is successful read too */
if (rc == 1)
rc = 0;
if (rc)
goto err;
*p |= GENMASK(7, (nbits + bit_offset) % BITS_PER_BYTE) & v;
Expand Down

0 comments on commit b071419

Please sign in to comment.