[RFC PATCH 1/8] brd: use memcpy_from_page() in copy_from_brd()

Chaitanya Kulkarni
2021-02-07T19:06:31Z

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
drivers/block/brd.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index cb5c872ac9b2..d41b7d489e9f 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -226,11 +226,9 @@ static void copy_from_brd(void *dst, struct brd_device *brd,

copy = min_t(size_t, n, PAGE_SIZE - offset);
page = brd_lookup_page(brd, sector);
- if (page) {
- src = kmap_atomic(page);
- memcpy(dst, src + offset, copy);
- kunmap_atomic(src);
- } else
+ if (page)
+ memcpy_from_page(dst, page, offset, copy);
+ else
memset(dst, 0, copy);

if (copy < n) {
--
2.22.1