lkml.org 
[lkml]   [2020]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 17/17] samples: Use memcpy_to/from_page()
Date
From: Ira Weiny <ira.weiny@intel.com>

Remove kmap/mem*()/kunmap pattern and use memcpy_to/from_page()

Cc: Kirti Wankhede <kwankhede@nvidia.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
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
\
 
 \ /
  Last update: 2020-11-24 07:40    [W:1.182 / U:0.740 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site