Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mtdchar: replace deprecated mmap hook with mmap_prepare, clean up

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.

Link: https://lkml.kernel.org/r/d036855c21962c58ace0eb24ecd6d973d77424fe.1774045440.git.ljs@kernel.org
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Acked-by: Richard Weinberger <richard@nod.at>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bodo Stroesser <bostroesser@gmail.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: David Hildenbrand <david@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Long Li <longli@microsoft.com>
Cc: Marc Dionne <marc.dionne@auristor.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Cc: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes (Oracle) and committed by
Andrew Morton
08586537 10de8b81

+3 -18
+3 -18
drivers/mtd/mtdchar.c
··· 1376 1376 /* 1377 1377 * set up a mapping for shared memory segments 1378 1378 */ 1379 - static int mtdchar_mmap(struct file *file, struct vm_area_struct *vma) 1379 + static int mtdchar_mmap_prepare(struct vm_area_desc *desc) 1380 1380 { 1381 1381 #ifdef CONFIG_MMU 1382 - struct mtd_file_info *mfi = file->private_data; 1383 - struct mtd_info *mtd = mfi->mtd; 1384 - struct map_info *map = mtd->priv; 1385 - 1386 - /* This is broken because it assumes the MTD device is map-based 1387 - and that mtd->priv is a valid struct map_info. It should be 1388 - replaced with something that uses the mtd_get_unmapped_area() 1389 - operation properly. */ 1390 - if (0 /*mtd->type == MTD_RAM || mtd->type == MTD_ROM*/) { 1391 - #ifdef pgprot_noncached 1392 - if (file->f_flags & O_DSYNC || map->phys >= __pa(high_memory)) 1393 - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 1394 - #endif 1395 - return vm_iomap_memory(vma, map->phys, map->size); 1396 - } 1397 1382 return -ENODEV; 1398 1383 #else 1399 - return vma->vm_flags & VM_SHARED ? 0 : -EACCES; 1384 + return vma_desc_test(desc, VMA_SHARED_BIT) ? 0 : -EACCES; 1400 1385 #endif 1401 1386 } 1402 1387 ··· 1396 1411 #endif 1397 1412 .open = mtdchar_open, 1398 1413 .release = mtdchar_close, 1399 - .mmap = mtdchar_mmap, 1414 + .mmap_prepare = mtdchar_mmap_prepare, 1400 1415 #ifndef CONFIG_MMU 1401 1416 .get_unmapped_area = mtdchar_get_unmapped_area, 1402 1417 .mmap_capabilities = mtdchar_mmap_capabilities,