1 // SPDX-License-Identifier: GPL-2.0 2 3 #include <linux/io.h> 4 #include <linux/ioport.h> 5 6 #ifdef CONFIG_HAS_IOMEM 7 __rust_helper void __iomem *rust_helper_ioremap(phys_addr_t offset, size_t size) 8 { 9 return ioremap(offset, size); 10 } 11 12 __rust_helper void __iomem *rust_helper_ioremap_np(phys_addr_t offset, 13 size_t size) 14 { 15 return ioremap_np(offset, size); 16 } 17 18 __rust_helper void rust_helper_iounmap(void __iomem *addr) 19 { 20 iounmap(addr); 21 } 22 #endif /* CONFIG_HAS_IOMEM */ 23 24 __rust_helper u8 rust_helper_readb(const void __iomem *addr) 25 { 26 return readb(addr); 27 } 28 29 __rust_helper u16 rust_helper_readw(const void __iomem *addr) 30 { 31 return readw(addr); 32 } 33 34 __rust_helper u32 rust_helper_readl(const void __iomem *addr) 35 { 36 return readl(addr); 37 } 38 39 #ifdef CONFIG_64BIT 40 __rust_helper u64 rust_helper_readq(const void __iomem *addr) 41 { 42 return readq(addr); 43 } 44 #endif 45 46 __rust_helper void rust_helper_writeb(u8 value, void __iomem *addr) 47 { 48 writeb(value, addr); 49 } 50 51 __rust_helper void rust_helper_writew(u16 value, void __iomem *addr) 52 { 53 writew(value, addr); 54 } 55 56 __rust_helper void rust_helper_writel(u32 value, void __iomem *addr) 57 { 58 writel(value, addr); 59 } 60 61 #ifdef CONFIG_64BIT 62 __rust_helper void rust_helper_writeq(u64 value, void __iomem *addr) 63 { 64 writeq(value, addr); 65 } 66 #endif 67 68 __rust_helper u8 rust_helper_readb_relaxed(const void __iomem *addr) 69 { 70 return readb_relaxed(addr); 71 } 72 73 __rust_helper u16 rust_helper_readw_relaxed(const void __iomem *addr) 74 { 75 return readw_relaxed(addr); 76 } 77 78 __rust_helper u32 rust_helper_readl_relaxed(const void __iomem *addr) 79 { 80 return readl_relaxed(addr); 81 } 82 83 #ifdef CONFIG_64BIT 84 __rust_helper u64 rust_helper_readq_relaxed(const void __iomem *addr) 85 { 86 return readq_relaxed(addr); 87 } 88 #endif 89 90 __rust_helper void rust_helper_writeb_relaxed(u8 value, void __iomem *addr) 91 { 92 writeb_relaxed(value, addr); 93 } 94 95 __rust_helper void rust_helper_writew_relaxed(u16 value, void __iomem *addr) 96 { 97 writew_relaxed(value, addr); 98 } 99 100 __rust_helper void rust_helper_writel_relaxed(u32 value, void __iomem *addr) 101 { 102 writel_relaxed(value, addr); 103 } 104 105 #ifdef CONFIG_64BIT 106 __rust_helper void rust_helper_writeq_relaxed(u64 value, void __iomem *addr) 107 { 108 writeq_relaxed(value, addr); 109 } 110 #endif 111 112 __rust_helper resource_size_t rust_helper_resource_size(struct resource *res) 113 { 114 return resource_size(res); 115 } 116 117 __rust_helper struct resource * 118 rust_helper_request_mem_region(resource_size_t start, resource_size_t n, 119 const char *name) 120 { 121 return request_mem_region(start, n, name); 122 } 123 124 __rust_helper void rust_helper_release_mem_region(resource_size_t start, 125 resource_size_t n) 126 { 127 release_mem_region(start, n); 128 } 129 130 __rust_helper struct resource *rust_helper_request_region(resource_size_t start, 131 resource_size_t n, 132 const char *name) 133 { 134 return request_region(start, n, name); 135 } 136 137 __rust_helper struct resource * 138 rust_helper_request_muxed_region(resource_size_t start, resource_size_t n, 139 const char *name) 140 { 141 return request_muxed_region(start, n, name); 142 } 143 144 __rust_helper void rust_helper_release_region(resource_size_t start, 145 resource_size_t n) 146 { 147 release_region(start, n); 148 } 149