Skip to content

Commit b071419

Browse files
committed
nvmem: core: returning bytes read is successful read too
1 parent e60b5f5 commit b071419

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
@@ -1243,6 +1243,10 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
12431243

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

1246+
/* returning bytes read is successful read too */
1247+
if (rc == cell->bytes)
1248+
rc = 0;
1249+
12461250
if (rc)
12471251
return rc;
12481252

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

13111315
/* setup the first byte with lsb bits from nvmem */
13121316
rc = nvmem_reg_read(nvmem, cell->offset, &v, 1);
1317+
/* returning bytes read is successful read too */
1318+
if (rc == 1)
1319+
rc = 0;
13131320
if (rc)
13141321
goto err;
13151322
*b++ |= GENMASK(bit_offset - 1, 0) & v;
@@ -1330,6 +1337,9 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
13301337
/* setup the last byte with msb bits from nvmem */
13311338
rc = nvmem_reg_read(nvmem,
13321339
cell->offset + cell->bytes - 1, &v, 1);
1340+
/* returning bytes read is successful read too */
1341+
if (rc == 1)
1342+
rc = 0;
13331343
if (rc)
13341344
goto err;
13351345
*p |= GENMASK(7, (nbits + bit_offset) % BITS_PER_BYTE) & v;

0 commit comments

Comments
 (0)