The memory character driver implements several mm-specific features and is
always compiled into the kernel, so move it to mm/ where it belongs.

Among other things the driver implements /dev/mem which provides raw access
to physical memory, and /dev/zero which either allows mapping of a shmem
region (if mapped with MAP_SHARED) or, uniquely, anonymous memory (if
mapped MAP_PRIVATE).

This change lays the foundations to allow MAP_PRIVATE-/dev/zero to be
mapped precisely the same as anonymous memory is mapped as currently it is
an edge case within mm.

Also update a couple of comments that reference 'drivers/char/mem.c' to
reference 'mm/char-mem.c'.

Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
---
 MAINTAINERS                         | 4 ++--
 drivers/char/Makefile               | 2 +-
 mm/Makefile                         | 3 ++-
 drivers/char/mem.c => mm/char-mem.c | 2 +-
 mm/shmem.c                          | 2 +-
 5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2133aec4a200..ebadf4cef076 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17272,7 +17272,7 @@ F:      
Documentation/ABI/testing/sysfs-kernel-mm-memory-tiers
 F:     Documentation/ABI/testing/sysfs-kernel-mm-numa
 F:     Documentation/admin-guide/mm/
 F:     Documentation/mm/
-F:     drivers/char/mem.c
+F:     mm/char-mem.c
 F:     include/linux/cma.h
 F:     include/linux/dmapool.h
 F:     include/linux/ioremap.h
@@ -17477,7 +17477,7 @@ L:      [email protected]
 S:     Maintained
 W:     http://www.linux-mm.org
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
-F:     drivers/char/mem.c
+F:     mm/char-mem.c
 F:     include/trace/events/mmap.h
 F:     fs/proc/task_mmu.c
 F:     fs/proc/task_nommu.c
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index a46d7bf7c4c8..bb3bf66937b3 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -3,7 +3,7 @@
 # Makefile for the kernel character device drivers.
 #
 
-obj-y                          += mem.o random.o
+obj-y                          += random.o
 obj-$(CONFIG_TTY_PRINTK)       += ttyprintk.o
 obj-y                          += misc.o
 obj-$(CONFIG_TEST_MISC_MINOR)  += misc_minor_kunit.o
diff --git a/mm/Makefile b/mm/Makefile
index e7245cb88c66..2a3ec53d62ee 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -55,7 +55,8 @@ obj-y                 := filemap.o mempool.o oom_kill.o 
fadvise.o \
                           mm_init.o percpu.o slab_common.o \
                           compaction.o show_mem.o \
                           interval_tree.o list_lru.o workingset.o \
-                          debug.o gup.o mmap_lock.o vma_init.o $(mmu-y)
+                          debug.o gup.o mmap_lock.o vma_init.o char-mem.o \
+                          $(mmu-y)
 
 # Give 'page_alloc' its own module-parameter namespace
 page-alloc-y := page_alloc.o
diff --git a/drivers/char/mem.c b/mm/char-mem.c
similarity index 99%
rename from drivers/char/mem.c
rename to mm/char-mem.c
index 63253d1de5d7..d2e575545044 100644
--- a/drivers/char/mem.c
+++ b/mm/char-mem.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- *  linux/drivers/char/mem.c
+ *  mm/char-mem.c
  *
  *  Copyright (C) 1991, 1992  Linus Torvalds
  *
diff --git a/mm/shmem.c b/mm/shmem.c
index 255d69ebceba..c92ed17dbc4a 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2981,7 +2981,7 @@ unsigned long shmem_get_unmapped_area(struct file *file,
                        sb = file_inode(file)->i_sb;
                } else {
                        /*
-                        * Called directly from mm/mmap.c, or drivers/char/mem.c
+                        * Called directly from mm/mmap.c, or mm/char-mem.c
                         * for "/dev/zero", to create a shared anonymous object.
                         */
                        if (IS_ERR(shm_mnt))

-- 
2.55.0


Reply via email to