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