@@ -189,7 +189,6 @@ static void copy_to_brd(struct brd_device *brd, const void *src,
sector_t sector, size_t n)
{
struct page *page;
- void *dst;
unsigned int offset = (sector & (PAGE_SECTORS-1)) << SECTOR_SHIFT;
size_t copy;
@@ -197,9 +196,7 @@ static void copy_to_brd(struct brd_device *brd, const void *src,
page = brd_lookup_page(brd, sector);
BUG_ON(!page);
- dst = kmap_atomic(page);
- memcpy(dst + offset, src, copy);
- kunmap_atomic(dst);
+ memcpy_to_page(page, offset, src, copy);
if (copy < n) {
src += copy;
@@ -208,9 +205,7 @@ static void copy_to_brd(struct brd_device *brd, const void *src,
page = brd_lookup_page(brd, sector);
BUG_ON(!page);
- dst = kmap_atomic(page);
- memcpy(dst, src, copy);
- kunmap_atomic(dst);
+ memcpy_to_page(page, 0, src, copy);
}
}
@@ -221,17 +216,14 @@ static void copy_from_brd(void *dst, struct brd_device *brd,
sector_t sector, size_t n)
{
struct page *page;
- void *src;
unsigned int offset = (sector & (PAGE_SECTORS-1)) << SECTOR_SHIFT;
size_t copy;
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) {
@@ -239,11 +231,9 @@ static void copy_from_brd(void *dst, struct brd_device *brd,
sector += copy >> SECTOR_SHIFT;
copy = n - copy;
page = brd_lookup_page(brd, sector);
- if (page) {
- src = kmap_atomic(page);
- memcpy(dst, src, copy);
- kunmap_atomic(src);
- } else
+ if (page)
+ memcpy_from_page(dst, page, 0, copy);
+ else
memset(dst, 0, copy);
}
}
"kmap_atomic - Atomically map a page for temporary usage - Deprecated!" Use memcpy_from_page() helper does the same job of mapping and copying except it uses non deprecated kmap_local_page() and kunmap_local() in copy_from_brd(). Use memcpy_to_page() helper does the same job of mapping and copying except it uses non deprecated kmap_local_page() and kunmap_local() in copy_to_brd(). Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com> --- drivers/block/brd.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)