mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Emil Renner Berthing <emil.renner.berthing@canonical.com>
To: linux-kernel@vger.kernel.org
Cc: Srinivas Kandagatla <srini@kernel.org>,
	Samuel Holland <samuel@sholland.org>,
	Dmitry Baryshkov <lumag@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH v1] nvmem: core: update cell->bytes after shifting bits
Date: Tue, 30 Sep 2025 16:22:11 +0200	[thread overview]
Message-ID: <20250930142212.521925-1-emil.renner.berthing@canonical.com> (raw)

When support for bit offsets of more than one byte was added it
unfortunately left the cell->bytes value at the number of bytes read
including the offset. Make sure to update it to the proper number of
meaningful bytes in the returned data.

Fixes: 7a06ef751077 ("nvmem: core: fix bit offsets of more than one byte")
Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
---
 drivers/nvmem/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 387c88c55259..5f6d22545e39 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1640,6 +1640,8 @@ static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void
 	/* clear msb bits if any leftover in the last byte */
 	if (cell->nbits % BITS_PER_BYTE)
 		*p &= GENMASK((cell->nbits % BITS_PER_BYTE) - 1, 0);
+
+	cell->bytes = (p - (u8 *)buf) + 1;
 }
 
 static int __nvmem_cell_read(struct nvmem_device *nvmem,
-- 
2.43.0


             reply	other threads:[~2025-09-30 14:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-30 14:22 Emil Renner Berthing [this message]
2025-11-10  8:32 ` Srinivas Kandagatla
2025-11-13 11:36   ` Emil Renner Berthing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250930142212.521925-1-emil.renner.berthing@canonical.com \
    --to=emil.renner.berthing@canonical.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=samuel@sholland.org \
    --cc=srini@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®