mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] eeprom: at25: fix read_poll_timeout argument order
@ 2026-08-26 12:13 Markus Breitenberger
  2026-08-27 13:25 ` Sverdlin, Alexander
  2026-09-11 16:04 ` Francesco Valla
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Breitenberger @ 2026-08-26 12:13 UTC (permalink / raw)
  To: srini
  Cc: alexander.sverdlin, gregkh, linux-kernel, Markus Breitenberger, stable

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-11 17:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-26 12:13 [PATCH] eeprom: at25: fix read_poll_timeout argument order Markus Breitenberger
2026-08-27 13:25 ` Sverdlin, Alexander
2026-09-11 16:04 ` Francesco Valla

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®