Replace the deprecated mmap callback with mmap_prepare.

Commit f5cf8f07423b ("mtd: Disable mtdchar mmap on MMU systems") commented
out the CONFIG_MMU part of this function back in 2012, so after ~14 years
it's probably reasonable to remove this altogether rather than updating
dead code.

Signed-off-by: Lorenzo Stoakes (Oracle) <[email protected]>
---
 drivers/mtd/mtdchar.c | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 55a43682c567..bf01e6ac7293 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1376,27 +1376,12 @@ static unsigned mtdchar_mmap_capabilities(struct file 
*file)
 /*
  * set up a mapping for shared memory segments
  */
-static int mtdchar_mmap(struct file *file, struct vm_area_struct *vma)
+static int mtdchar_mmap_prepare(struct vm_area_desc *desc)
 {
 #ifdef CONFIG_MMU
-       struct mtd_file_info *mfi = file->private_data;
-       struct mtd_info *mtd = mfi->mtd;
-       struct map_info *map = mtd->priv;
-
-        /* This is broken because it assumes the MTD device is map-based
-          and that mtd->priv is a valid struct map_info.  It should be
-          replaced with something that uses the mtd_get_unmapped_area()
-          operation properly. */
-       if (0 /*mtd->type == MTD_RAM || mtd->type == MTD_ROM*/) {
-#ifdef pgprot_noncached
-               if (file->f_flags & O_DSYNC || map->phys >= __pa(high_memory))
-                       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-#endif
-               return vm_iomap_memory(vma, map->phys, map->size);
-       }
        return -ENODEV;
 #else
-       return vma->vm_flags & VM_SHARED ? 0 : -EACCES;
+       return vma_desc_test(desc, VMA_SHARED_BIT) ? 0 : -EACCES;
 #endif
 }
 
@@ -1411,7 +1396,7 @@ static const struct file_operations mtd_fops = {
 #endif
        .open           = mtdchar_open,
        .release        = mtdchar_close,
-       .mmap           = mtdchar_mmap,
+       .mmap_prepare   = mtdchar_mmap_prepare,
 #ifndef CONFIG_MMU
        .get_unmapped_area = mtdchar_get_unmapped_area,
        .mmap_capabilities = mtdchar_mmap_capabilities,
-- 
2.53.0


Reply via email to