[PATCH 3/8] misc: pci_endpoint_test: Use ALIGN() on DMA addresses

From: Jack Wallner

Date: Sun Nov 29 2026 - 03:56:55 EST


PTR_ALIGN() is meant for pointers. The copy, write and read tests pass
it a dma_addr_t in four places. That compiles because PTR_ALIGN() casts
its argument to unsigned long and back.

A later patch in this series makes PTR_ALIGN() do pointer arithmetic on
its argument so that the compiler can keep track of the object size.
With that change these four lines get -Wint-to-pointer-cast and
-Wpointer-to-int-cast warnings on 32-bit kernels with a 64-bit
dma_addr_t (x86 with PAE, for example).

Use ALIGN(), which works in the type of its argument. There is no change
on 64-bit kernels. On a 32-bit kernel with a 64-bit dma_addr_t the old
form would drop the upper 32 bits of the address. I have not seen that
happen and did not try to trigger it: this is a cleanup and a
prerequisite for the PTR_ALIGN() change, not a fix for a reported
problem.

Compile tested only, including i386 allmodconfig, which has a 64-bit
dma_addr_t.

The change and this changelog were written by an AI coding assistant
(Claude, run in Claude Code) at my direction. See the cover letter for
how it was used and tested.

Signed-off-by: Jack Wallner <jackwallner@xxxxxxxxx>
---
drivers/misc/pci_endpoint_test.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index dd49ca7f4..17d53375e 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -750,7 +750,7 @@ static int pci_endpoint_test_copy(struct pci_endpoint_test *test,
}

if (alignment && !IS_ALIGNED(orig_src_phys_addr, alignment)) {
- src_phys_addr = PTR_ALIGN(orig_src_phys_addr, alignment);
+ src_phys_addr = ALIGN(orig_src_phys_addr, alignment);
offset = src_phys_addr - orig_src_phys_addr;
src_addr = orig_src_addr + offset;
} else {
@@ -782,7 +782,7 @@ static int pci_endpoint_test_copy(struct pci_endpoint_test *test,
}

if (alignment && !IS_ALIGNED(orig_dst_phys_addr, alignment)) {
- dst_phys_addr = PTR_ALIGN(orig_dst_phys_addr, alignment);
+ dst_phys_addr = ALIGN(orig_dst_phys_addr, alignment);
offset = dst_phys_addr - orig_dst_phys_addr;
dst_addr = orig_dst_addr + offset;
} else {
@@ -884,7 +884,7 @@ static int pci_endpoint_test_write(struct pci_endpoint_test *test,
}

if (alignment && !IS_ALIGNED(orig_phys_addr, alignment)) {
- phys_addr = PTR_ALIGN(orig_phys_addr, alignment);
+ phys_addr = ALIGN(orig_phys_addr, alignment);
offset = phys_addr - orig_phys_addr;
addr = orig_addr + offset;
} else {
@@ -979,7 +979,7 @@ static int pci_endpoint_test_read(struct pci_endpoint_test *test,
}

if (alignment && !IS_ALIGNED(orig_phys_addr, alignment)) {
- phys_addr = PTR_ALIGN(orig_phys_addr, alignment);
+ phys_addr = ALIGN(orig_phys_addr, alignment);
offset = phys_addr - orig_phys_addr;
addr = orig_addr + offset;
} else {
--
2.43.0