mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Breitenberger <bre@breiti.cc>
To: srini@kernel.org
Cc: alexander.sverdlin@siemens.com, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, Markus Breitenberger <bre@keba.com>,
	stable@vger.kernel.org
Subject: [PATCH] eeprom: at25: fix read_poll_timeout argument order
Date: Wed, 26 Aug 2026 14:13:34 +0200	[thread overview]
Message-ID: <20260826121334.122881-1-bre@breiti.cc> (raw)

From: Markus Breitenberger <bre@keba.com>

Commit 8ad6249c51d0 ("eeprom: at25: convert to spi-mem API") passes
the arguments to read_poll_timeout() in the wrong order. It supplies false
as sleep_us, USEC_PER_MSEC as timeout_us, and USEC_PER_MSEC * EE_TIMEOUT
as sleep_before_read.

Consequently, at25_wait_ready() busy-polls with a timeout of only 1 ms
instead of sleeping between polls and timing out after 25 ms. EEPROMs which
keep the write-in-progress bit set for longer than 1 ms are reported as
timed out, although the page may still be programmed after the driver
returns. A multi-page write is then aborted after the first page, leaving a
partial write.

This was reproduced with a 25LC080: a 32-byte write spanning two 16-byte
pages returned -ETIMEDOUT after programming only the first page.

Pass the polling interval, timeout, and sleep_before_read argument in their
proper positions.

Fixes: 8ad6249c51d0 ("eeprom: at25: convert to spi-mem API")
Cc: stable@vger.kernel.org
Signed-off-by: Markus Breitenberger <bre@keba.com>
---
 drivers/nvmem/at25.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/at25.c b/drivers/nvmem/at25.c
index bc2cfb75d9bb4..9e71c6a859471 100644
--- a/drivers/nvmem/at25.c
+++ b/drivers/nvmem/at25.c
@@ -224,8 +224,8 @@ static int at25_wait_ready(struct at25_data *at25)
 					   SPI_MEM_OP_DATA_IN(1, bounce, 1));
 
 	read_poll_timeout(spi_mem_exec_op, status,
-			  status || !(bounce[0] & AT25_SR_nRDY), false,
-			  USEC_PER_MSEC, USEC_PER_MSEC * EE_TIMEOUT,
+			  status || !(bounce[0] & AT25_SR_nRDY),
+			  USEC_PER_MSEC, USEC_PER_MSEC * EE_TIMEOUT, false,
 			  at25->spimem, &op);
 	if (status < 0)
 		return status;
-- 
2.47.3


             reply	other threads:[~2026-08-26 12:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 12:13 Markus Breitenberger [this message]
2026-08-27 13:25 ` Sverdlin, Alexander
2026-09-11 16:04 ` Francesco Valla

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=20260826121334.122881-1-bre@breiti.cc \
    --to=bre@breiti.cc \
    --cc=alexander.sverdlin@siemens.com \
    --cc=bre@keba.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srini@kernel.org \
    --cc=stable@vger.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®