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.

staging: vme_user: replace deprecated mmap hook with mmap_prepare

The f_op->mmap interface is deprecated, so update driver to use its
successor, mmap_prepare.

The driver previously used vm_iomap_memory(), so this change replaces it
with its mmap_prepare equivalent, mmap_action_simple_ioremap().

Functions that wrap mmap() are also converted to wrap mmap_prepare()
instead.

Also update the documentation accordingly.

Link: https://lkml.kernel.org/r/08ecc1e1d319564fd49b9e9012f994edaff921db.1774045440.git.ljs@kernel.org
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
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: Richard Weinberger <richard@nod.at>
Cc: Ryan Roberts <ryan.roberts@arm.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
14beec03 b0085cb9

+42 -33
+1 -1
Documentation/driver-api/vme.rst
··· 107 107 108 108 In addition to simple reads and writes, :c:func:`vme_master_rmw` is provided to 109 109 do a read-modify-write transaction. Parts of a VME window can also be mapped 110 - into user space memory using :c:func:`vme_master_mmap`. 110 + into user space memory using :c:func:`vme_master_mmap_prepare`. 111 111 112 112 113 113 Slave windows
+10 -10
drivers/staging/vme_user/vme.c
··· 735 735 EXPORT_SYMBOL(vme_master_rmw); 736 736 737 737 /** 738 - * vme_master_mmap - Mmap region of VME master window. 738 + * vme_master_mmap_prepare - Mmap region of VME master window. 739 739 * @resource: Pointer to VME master resource. 740 - * @vma: Pointer to definition of user mapping. 740 + * @desc: Pointer to descriptor of user mapping. 741 741 * 742 742 * Memory map a region of the VME master window into user space. 743 743 * ··· 745 745 * resource or -EFAULT if map exceeds window size. Other generic mmap 746 746 * errors may also be returned. 747 747 */ 748 - int vme_master_mmap(struct vme_resource *resource, struct vm_area_struct *vma) 748 + int vme_master_mmap_prepare(struct vme_resource *resource, 749 + struct vm_area_desc *desc) 749 750 { 751 + const unsigned long vma_size = vma_desc_size(desc); 750 752 struct vme_bridge *bridge = find_bridge(resource); 751 753 struct vme_master_resource *image; 752 754 phys_addr_t phys_addr; 753 - unsigned long vma_size; 754 755 755 756 if (resource->type != VME_MASTER) { 756 757 dev_err(bridge->parent, "Not a master resource\n"); ··· 759 758 } 760 759 761 760 image = list_entry(resource->entry, struct vme_master_resource, list); 762 - phys_addr = image->bus_resource.start + (vma->vm_pgoff << PAGE_SHIFT); 763 - vma_size = vma->vm_end - vma->vm_start; 761 + phys_addr = image->bus_resource.start + (desc->pgoff << PAGE_SHIFT); 764 762 765 763 if (phys_addr + vma_size > image->bus_resource.end + 1) { 766 764 dev_err(bridge->parent, "Map size cannot exceed the window size\n"); 767 765 return -EFAULT; 768 766 } 769 767 770 - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 771 - 772 - return vm_iomap_memory(vma, phys_addr, vma->vm_end - vma->vm_start); 768 + desc->page_prot = pgprot_noncached(desc->page_prot); 769 + mmap_action_simple_ioremap(desc, phys_addr, vma_size); 770 + return 0; 773 771 } 774 - EXPORT_SYMBOL(vme_master_mmap); 772 + EXPORT_SYMBOL(vme_master_mmap_prepare); 775 773 776 774 /** 777 775 * vme_master_free - Free VME master window
+1 -1
drivers/staging/vme_user/vme.h
··· 151 151 ssize_t vme_master_write(struct vme_resource *resource, void *buf, size_t count, loff_t offset); 152 152 unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int mask, unsigned int compare, 153 153 unsigned int swap, loff_t offset); 154 - int vme_master_mmap(struct vme_resource *resource, struct vm_area_struct *vma); 154 + int vme_master_mmap_prepare(struct vme_resource *resource, struct vm_area_desc *desc); 155 155 void vme_master_free(struct vme_resource *resource); 156 156 157 157 struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route);
+30 -21
drivers/staging/vme_user/vme_user.c
··· 446 446 kfree(vma_priv); 447 447 } 448 448 449 - static const struct vm_operations_struct vme_user_vm_ops = { 450 - .open = vme_user_vm_open, 451 - .close = vme_user_vm_close, 452 - }; 453 - 454 - static int vme_user_master_mmap(unsigned int minor, struct vm_area_struct *vma) 449 + static int vme_user_vm_mapped(unsigned long start, unsigned long end, pgoff_t pgoff, 450 + const struct file *file, void **vm_private_data) 455 451 { 456 - int err; 452 + const unsigned int minor = iminor(file_inode(file)); 457 453 struct vme_user_vma_priv *vma_priv; 458 454 459 455 mutex_lock(&image[minor].mutex); 460 - 461 - err = vme_master_mmap(image[minor].resource, vma); 462 - if (err) { 463 - mutex_unlock(&image[minor].mutex); 464 - return err; 465 - } 466 456 467 457 vma_priv = kmalloc_obj(*vma_priv); 468 458 if (!vma_priv) { ··· 462 472 463 473 vma_priv->minor = minor; 464 474 refcount_set(&vma_priv->refcnt, 1); 465 - vma->vm_ops = &vme_user_vm_ops; 466 - vma->vm_private_data = vma_priv; 467 - 475 + *vm_private_data = vma_priv; 468 476 image[minor].mmap_count++; 469 477 470 478 mutex_unlock(&image[minor].mutex); 471 - 472 479 return 0; 473 480 } 474 481 475 - static int vme_user_mmap(struct file *file, struct vm_area_struct *vma) 482 + static const struct vm_operations_struct vme_user_vm_ops = { 483 + .mapped = vme_user_vm_mapped, 484 + .open = vme_user_vm_open, 485 + .close = vme_user_vm_close, 486 + }; 487 + 488 + static int vme_user_master_mmap_prepare(unsigned int minor, 489 + struct vm_area_desc *desc) 476 490 { 477 - unsigned int minor = iminor(file_inode(file)); 491 + int err; 492 + 493 + mutex_lock(&image[minor].mutex); 494 + 495 + err = vme_master_mmap_prepare(image[minor].resource, desc); 496 + if (!err) 497 + desc->vm_ops = &vme_user_vm_ops; 498 + 499 + mutex_unlock(&image[minor].mutex); 500 + return err; 501 + } 502 + 503 + static int vme_user_mmap_prepare(struct vm_area_desc *desc) 504 + { 505 + const struct file *file = desc->file; 506 + const unsigned int minor = iminor(file_inode(file)); 478 507 479 508 if (type[minor] == MASTER_MINOR) 480 - return vme_user_master_mmap(minor, vma); 509 + return vme_user_master_mmap_prepare(minor, desc); 481 510 482 511 return -ENODEV; 483 512 } ··· 507 498 .llseek = vme_user_llseek, 508 499 .unlocked_ioctl = vme_user_unlocked_ioctl, 509 500 .compat_ioctl = compat_ptr_ioctl, 510 - .mmap = vme_user_mmap, 501 + .mmap_prepare = vme_user_mmap_prepare, 511 502 }; 512 503 513 504 static int vme_user_match(struct vme_dev *vdev)