io.c 3.0 KB

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