mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 15:43:08 -04:00
s390 does not provide ioremap()/iounmap() when CONFIG_HAS_IOMEM is not
set (which requires CONFIG_PCI on that architecture). This causes a
build failure with Rust enabled on e.g. s390 allnoconfig:
In file included from rust/helpers/helpers.c:68:
rust/helpers/io.c:8:9: error: call to undeclared function 'ioremap'; ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]
8 | return ioremap(offset, size);
| ^
rust/helpers/io.c:19:2: error: call to undeclared function 'iounmap'; ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]
19 | iounmap(addr);
Guard the C helpers behind #ifdef CONFIG_HAS_IOMEM and cfg-gate the Rust
io::mem module, such that IoMem, ExclusiveIoMem and IoRequest are not
available without CONFIG_HAS_IOMEM.
Note that the C API is inconsistent about this. For instance,
devm_ioremap() has no stub and produces a link failure without
CONFIG_HAS_IOMEM, whereas devm_platform_ioremap_resource() provides an
inline stub returning -EINVAL.
The approach taken here (compile-time gating) matches the former, which
is slightly more appropriate since any driver performing MMIO currently
requires CONFIG_HAS_IOMEM.
Ideally, s390 should provide ioremap()/iounmap() stubs unconditionally
(as UML already does), removing the need for any config gating as
discussed in [1]; a follow-up patch for s390 is expected.
Cc: Arnd Bergmann <arnd@arndb.de>
Reported-by: Miguel Ojeda <ojeda@kernel.org>
Closes: https://lore.kernel.org/all/20260803180931.97202-1-ojeda@kernel.org [1]
Fixes: 3f70ebe638 ("s390: Enable Rust support")
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Link: https://patch.msgid.link/20260805212920.1996937-1-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
149 lines
3.0 KiB
C
149 lines
3.0 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <linux/io.h>
|
|
#include <linux/ioport.h>
|
|
|
|
#ifdef CONFIG_HAS_IOMEM
|
|
__rust_helper void __iomem *rust_helper_ioremap(phys_addr_t offset, size_t size)
|
|
{
|
|
return ioremap(offset, size);
|
|
}
|
|
|
|
__rust_helper void __iomem *rust_helper_ioremap_np(phys_addr_t offset,
|
|
size_t size)
|
|
{
|
|
return ioremap_np(offset, size);
|
|
}
|
|
|
|
__rust_helper void rust_helper_iounmap(void __iomem *addr)
|
|
{
|
|
iounmap(addr);
|
|
}
|
|
#endif /* CONFIG_HAS_IOMEM */
|
|
|
|
__rust_helper u8 rust_helper_readb(const void __iomem *addr)
|
|
{
|
|
return readb(addr);
|
|
}
|
|
|
|
__rust_helper u16 rust_helper_readw(const void __iomem *addr)
|
|
{
|
|
return readw(addr);
|
|
}
|
|
|
|
__rust_helper u32 rust_helper_readl(const void __iomem *addr)
|
|
{
|
|
return readl(addr);
|
|
}
|
|
|
|
#ifdef CONFIG_64BIT
|
|
__rust_helper u64 rust_helper_readq(const void __iomem *addr)
|
|
{
|
|
return readq(addr);
|
|
}
|
|
#endif
|
|
|
|
__rust_helper void rust_helper_writeb(u8 value, void __iomem *addr)
|
|
{
|
|
writeb(value, addr);
|
|
}
|
|
|
|
__rust_helper void rust_helper_writew(u16 value, void __iomem *addr)
|
|
{
|
|
writew(value, addr);
|
|
}
|
|
|
|
__rust_helper void rust_helper_writel(u32 value, void __iomem *addr)
|
|
{
|
|
writel(value, addr);
|
|
}
|
|
|
|
#ifdef CONFIG_64BIT
|
|
__rust_helper void rust_helper_writeq(u64 value, void __iomem *addr)
|
|
{
|
|
writeq(value, addr);
|
|
}
|
|
#endif
|
|
|
|
__rust_helper u8 rust_helper_readb_relaxed(const void __iomem *addr)
|
|
{
|
|
return readb_relaxed(addr);
|
|
}
|
|
|
|
__rust_helper u16 rust_helper_readw_relaxed(const void __iomem *addr)
|
|
{
|
|
return readw_relaxed(addr);
|
|
}
|
|
|
|
__rust_helper u32 rust_helper_readl_relaxed(const void __iomem *addr)
|
|
{
|
|
return readl_relaxed(addr);
|
|
}
|
|
|
|
#ifdef CONFIG_64BIT
|
|
__rust_helper u64 rust_helper_readq_relaxed(const void __iomem *addr)
|
|
{
|
|
return readq_relaxed(addr);
|
|
}
|
|
#endif
|
|
|
|
__rust_helper void rust_helper_writeb_relaxed(u8 value, void __iomem *addr)
|
|
{
|
|
writeb_relaxed(value, addr);
|
|
}
|
|
|
|
__rust_helper void rust_helper_writew_relaxed(u16 value, void __iomem *addr)
|
|
{
|
|
writew_relaxed(value, addr);
|
|
}
|
|
|
|
__rust_helper void rust_helper_writel_relaxed(u32 value, void __iomem *addr)
|
|
{
|
|
writel_relaxed(value, addr);
|
|
}
|
|
|
|
#ifdef CONFIG_64BIT
|
|
__rust_helper void rust_helper_writeq_relaxed(u64 value, void __iomem *addr)
|
|
{
|
|
writeq_relaxed(value, addr);
|
|
}
|
|
#endif
|
|
|
|
__rust_helper resource_size_t rust_helper_resource_size(struct resource *res)
|
|
{
|
|
return resource_size(res);
|
|
}
|
|
|
|
__rust_helper struct resource *
|
|
rust_helper_request_mem_region(resource_size_t start, resource_size_t n,
|
|
const char *name)
|
|
{
|
|
return request_mem_region(start, n, name);
|
|
}
|
|
|
|
__rust_helper void rust_helper_release_mem_region(resource_size_t start,
|
|
resource_size_t n)
|
|
{
|
|
release_mem_region(start, n);
|
|
}
|
|
|
|
__rust_helper struct resource *rust_helper_request_region(resource_size_t start,
|
|
resource_size_t n,
|
|
const char *name)
|
|
{
|
|
return request_region(start, n, name);
|
|
}
|
|
|
|
__rust_helper struct resource *
|
|
rust_helper_request_muxed_region(resource_size_t start, resource_size_t n,
|
|
const char *name)
|
|
{
|
|
return request_muxed_region(start, n, name);
|
|
}
|
|
|
|
__rust_helper void rust_helper_release_region(resource_size_t start,
|
|
resource_size_t n)
|
|
{
|
|
release_region(start, n);
|
|
}
|