nvmem: core: update raw_len if the bit reading is required
[ Upstream commit 6786484223d5705bf7f919c1e5055d478ebeec32 ] 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 <dmitry.baryshkov@linaro.org> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20250411112251.68002-11-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
497f19cacb
commit
35d77c8d88
@@ -456,9 +456,11 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
|
|||||||
cell->nbits = info->nbits;
|
cell->nbits = info->nbits;
|
||||||
cell->np = info->np;
|
cell->np = info->np;
|
||||||
|
|
||||||
if (cell->nbits)
|
if (cell->nbits) {
|
||||||
cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset,
|
cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset,
|
||||||
BITS_PER_BYTE);
|
BITS_PER_BYTE);
|
||||||
|
cell->raw_len = ALIGN(cell->bytes, nvmem->word_size);
|
||||||
|
}
|
||||||
|
|
||||||
if (!IS_ALIGNED(cell->offset, nvmem->stride)) {
|
if (!IS_ALIGNED(cell->offset, nvmem->stride)) {
|
||||||
dev_err(&nvmem->dev,
|
dev_err(&nvmem->dev,
|
||||||
|
Reference in New Issue
Block a user