Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F172220507
D59732.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D59732.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,21 @@
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
@@ -66,6 +66,7 @@
#include <linux/idr.h>
#include <linux/io.h>
#include <linux/io-mapping.h>
+#include <linux/device.h>
#ifdef __i386__
DEFINE_IDR(mtrr_idr);
@@ -434,6 +435,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 (NULL);
+ 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
Thu, Sep 17, 11:31 PM (9 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39102407
Default Alt Text
D59732.diff (1 KB)
Attached To
Mode
D59732: LinuxKPI: Add devm_memremap and devm_ioremap_wc functions
Attached
Detach File
Event Timeline
Log In to Comment