Skip to content

Commit 6786484

Browse files
lumaggregkh
authored andcommitted
nvmem: core: update raw_len if the bit reading is required
If NVMEM cell uses bit offset or specifies bit truncation, update raw_len manually (following the cell->bytes update), ensuring that the NVMEM access is still word-aligned. Signed-off-by: Dmitry Baryshkov <[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 13bcd44 commit 6786484

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/nvmem/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,11 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
594594
cell->nbits = info->nbits;
595595
cell->np = info->np;
596596

597-
if (cell->nbits)
597+
if (cell->nbits) {
598598
cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset,
599599
BITS_PER_BYTE);
600+
cell->raw_len = ALIGN(cell->bytes, nvmem->word_size);
601+
}
600602

601603
if (!IS_ALIGNED(cell->offset, nvmem->stride)) {
602604
dev_err(&nvmem->dev,

0 commit comments

Comments
 (0)