diff mbox series

[v2] affs: use memcpy_to_zero and remove replace kmap_atomic()

Message ID 20220721185024.5789-1-dsterba@suse.com (mailing list archive)
State New, archived
Headers show
Series [v2] affs: use memcpy_to_zero and remove replace kmap_atomic() | expand

Commit Message

David Sterba July 21, 2022, 6:50 p.m. UTC
The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible. For kmap around a memcpy there's a convenience
helper memcpy_to_page, use it.

CC: Ira Weiny <ira.weiny@intel.com>
CC: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/affs/file.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Ira Weiny July 21, 2022, 10:07 p.m. UTC | #1
On Thu, Jul 21, 2022 at 08:50:24PM +0200, David Sterba wrote:
> The use of kmap() is being deprecated in favor of kmap_local_page()
> where it is feasible. For kmap around a memcpy there's a convenience
> helper memcpy_to_page, use it.
> 
> CC: Ira Weiny <ira.weiny@intel.com>

Typo in the subject: s/memcpy_to_page/memcpy_to_zero

Other than that.

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

> CC: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  fs/affs/file.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/fs/affs/file.c b/fs/affs/file.c
> index cd00a4c68a12..45a21729f358 100644
> --- a/fs/affs/file.c
> +++ b/fs/affs/file.c
> @@ -526,7 +526,6 @@ affs_do_readpage_ofs(struct page *page, unsigned to, int create)
>  	struct inode *inode = page->mapping->host;
>  	struct super_block *sb = inode->i_sb;
>  	struct buffer_head *bh;
> -	char *data;
>  	unsigned pos = 0;
>  	u32 bidx, boff, bsize;
>  	u32 tmp;
> @@ -545,9 +544,7 @@ affs_do_readpage_ofs(struct page *page, unsigned to, int create)
>  			return PTR_ERR(bh);
>  		tmp = min(bsize - boff, to - pos);
>  		BUG_ON(pos + tmp > to || tmp > bsize);
> -		data = kmap_atomic(page);
> -		memcpy(data + pos, AFFS_DATA(bh) + boff, tmp);
> -		kunmap_atomic(data);
> +		memcpy_to_page(page, pos, AFFS_DATA(bh) + boff, tmp);
>  		affs_brelse(bh);
>  		bidx++;
>  		pos += tmp;
> -- 
> 2.36.1
>
David Sterba July 22, 2022, 9:49 p.m. UTC | #2
On Thu, Jul 21, 2022 at 03:07:38PM -0700, Ira Weiny wrote:
> On Thu, Jul 21, 2022 at 08:50:24PM +0200, David Sterba wrote:
> > The use of kmap() is being deprecated in favor of kmap_local_page()
> > where it is feasible. For kmap around a memcpy there's a convenience
> > helper memcpy_to_page, use it.
> > 
> > CC: Ira Weiny <ira.weiny@intel.com>
> 
> Typo in the subject: s/memcpy_to_page/memcpy_to_zero
> 
> Other than that.
> 
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>

Thanks, fixed.
diff mbox series

Patch

diff --git a/fs/affs/file.c b/fs/affs/file.c
index cd00a4c68a12..45a21729f358 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -526,7 +526,6 @@  affs_do_readpage_ofs(struct page *page, unsigned to, int create)
 	struct inode *inode = page->mapping->host;
 	struct super_block *sb = inode->i_sb;
 	struct buffer_head *bh;
-	char *data;
 	unsigned pos = 0;
 	u32 bidx, boff, bsize;
 	u32 tmp;
@@ -545,9 +544,7 @@  affs_do_readpage_ofs(struct page *page, unsigned to, int create)
 			return PTR_ERR(bh);
 		tmp = min(bsize - boff, to - pos);
 		BUG_ON(pos + tmp > to || tmp > bsize);
-		data = kmap_atomic(page);
-		memcpy(data + pos, AFFS_DATA(bh) + boff, tmp);
-		kunmap_atomic(data);
+		memcpy_to_page(page, pos, AFFS_DATA(bh) + boff, tmp);
 		affs_brelse(bh);
 		bidx++;
 		pos += tmp;