Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F176910790
D59732.1793603875.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D59732.1793603875.diff
View Options
diff --git a/sys/compat/linuxkpi/common/include/linux/io.h b/sys/compat/linuxkpi/common/include/linux/io.h
--- a/sys/compat/linuxkpi/common/include/linux/io.h
+++ b/sys/compat/linuxkpi/common/include/linux/io.h
@@ -521,6 +521,20 @@
return (addr);
}
+#define devm_memremap(...) linuxkpi_devm_memremap(__VA_ARGS__)
+void *linuxkpi_devm_memremap(struct device *dev, resource_size_t offset,
+ size_t size, unsigned long flags);
+
+static inline void *
+devm_ioremap_wc(struct device *dev, resource_size_t offset,
+ resource_size_t size)
+{
+ void *addr;
+
+ addr = devm_memremap(dev, offset, size, MEMREMAP_WC);
+ return (IS_ERR(addr) ? NULL : addr);
+}
+
static inline void
memunmap(void *addr)
{
diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -65,6 +65,7 @@
#include <linux/idr.h>
#include <linux/io.h>
#include <linux/io-mapping.h>
+#include <linux/device.h>
#ifdef __i386__
DEFINE_IDR(mtrr_idr);
@@ -420,6 +421,35 @@
kfree(vmmap);
}
+static void
+lkpi_devm_memremap_unmap(struct device *dev, void *p)
+{
+ void **dr = p;
+
+ memunmap(*dr);
+}
+
+void *
+linuxkpi_devm_memremap(struct device *dev, resource_size_t offset, size_t size,
+ unsigned long flags)
+{
+ void **dr, *addr;
+
+ dr = devres_alloc(lkpi_devm_memremap_unmap, sizeof(*dr), GFP_KERNEL);
+ if (dr == NULL)
+ return (ERR_PTR(-ENOMEM));
+ addr = memremap(offset, size, flags);
+ if (addr != NULL) {
+ *dr = addr;
+ devres_add(dev, dr);
+ } else {
+ addr = ERR_PTR(-ENXIO);
+ devres_free(dr);
+ }
+
+ return (addr);
+}
+
void *
vmap(struct page **pages, unsigned int count, unsigned long flags, int prot)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 2, 7:17 AM (6 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41312415
Default Alt Text
D59732.1793603875.diff (1 KB)
Attached To
Mode
D59732: LinuxKPI: Add devm_memremap and devm_ioremap_wc functions
Attached
Detach File
Event Timeline