From: Ira Weiny <ira.weiny@xxxxxxxxx> Remove kmap/mem*()/kunmap pattern and use memcpy_to/from_page() Cc: Kirti Wankhede <kwankhede@xxxxxxxxxx> Signed-off-by: Ira Weiny <ira.weiny@xxxxxxxxx> --- samples/vfio-mdev/mbochs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c index e03068917273..54fe04f63c66 100644 --- a/samples/vfio-mdev/mbochs.c +++ b/samples/vfio-mdev/mbochs.c @@ -30,6 +30,7 @@ #include <linux/iommu.h> #include <linux/sysfs.h> #include <linux/mdev.h> +#include <linux/pagemap.h> #include <linux/pci.h> #include <linux/dma-buf.h> #include <linux/highmem.h> @@ -442,7 +443,6 @@ static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count, struct device *dev = mdev_dev(mdev); struct page *pg; loff_t poff; - char *map; int ret = 0; mutex_lock(&mdev_state->ops_lock); @@ -479,12 +479,10 @@ static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count, pos -= MBOCHS_MMIO_BAR_OFFSET; poff = pos & ~PAGE_MASK; pg = __mbochs_get_page(mdev_state, pos >> PAGE_SHIFT); - map = kmap(pg); if (is_write) - memcpy(map + poff, buf, count); + memcpy_to_page(pg, poff, buf, count); else - memcpy(buf, map + poff, count); - kunmap(pg); + memcpy_from_page(buf, pg, poff, count); put_page(pg); } else { -- 2.28.0.rc0.12.gb6a658bd00c9