Thread (17 messages) 17 messages, 7 authors, 2026-04-02
COLD57d

[PATCH 5/8] spi: use rest_of_page() macro where appropriate

From: Yury Norov <hidden>
Date: 2026-03-04 01:27:48
Also in: dm-devel, dri-devel, intel-gfx, kvm, linux-block, linux-crypto, linux-ext4, linux-f2fs-devel, linux-fsdevel, linux-mm, linux-nfs, linux-perf-users, linux-riscv, linux-s390, linux-sound, linux-spi, linux-xfs, linuxppc-dev, lkml, v9fs, virtualization
Subsystem: arm primecell ssp pl022 spi driver, spi subsystem, the rest · Maintainers: Linus Walleij, Mark Brown, Linus Torvalds

Switch SPI code to using the macro. No functional changes intended.

Signed-off-by: Yury Norov <redacted>
---
 drivers/spi/spi-pl022.c | 3 +--
 drivers/spi/spi.c       | 4 +---
 2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index c82cc522776d..78fce33ff422 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -761,8 +761,7 @@ static void setup_dma_scatter(struct pl022 *pl022,
 			 * we just feed in this, else we stuff in as much
 			 * as we can.
 			 */
-			mapbytes = min_t(int, bytesleft,
-					 PAGE_SIZE - offset_in_page(bufp));
+			mapbytes = min_t(int, bytesleft, rest_of_page(bufp));
 
 			sg_set_page(sg, virt_to_page(bufp),
 				    mapbytes, offset_in_page(bufp));
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 61f7bde8c7fb..cd4a18f3afaf 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1162,9 +1162,7 @@ static int spi_map_buf_attrs(struct spi_controller *ctlr, struct device *dev,
 			 * the desc_len and the remaining buffer length that
 			 * fits in a page.
 			 */
-			min = min_t(size_t, desc_len,
-				    min_t(size_t, len,
-					  PAGE_SIZE - offset_in_page(buf)));
+			min = min_t(size_t, desc_len, min_t(size_t, len, rest_of_page(buf)));
 			if (vmalloced_buf)
 				vm_page = vmalloc_to_page(buf);
 			else
-- 
2.43.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help