From 8d75eba470f991b6f9834f4d2b12e3c20996b5ad Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 12 Oct 2021 10:29:00 +0200 Subject: [PATCH] mtd/block2mtd: use bdev_read_cache_page in read_part_sector Use bdev_read_cache_page instead of open coding it. Signed-off-by: Christoph Hellwig --- drivers/mtd/devices/block2mtd.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index 9587d205be1d..e96d5f11ea43 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -43,12 +43,6 @@ struct block2mtd_dev { /* Static info about the MTD, used in cleanup_module */ static LIST_HEAD(blkmtd_device_list); - -static struct page *page_read(struct address_space *mapping, pgoff_t index) -{ - return read_mapping_page(mapping, index, NULL); -} - /* erase a specified part of the device */ static int _block2mtd_erase(struct block2mtd_dev *dev, loff_t to, size_t len) { @@ -60,7 +54,7 @@ static int _block2mtd_erase(struct block2mtd_dev *dev, loff_t to, size_t len) u_long *max; while (pages) { - page = page_read(mapping, index); + page = bdev_read_cache_page(dev->blkdev, index, GFP_NOFS); if (IS_ERR(page)) return PTR_ERR(page); @@ -114,7 +108,7 @@ static int block2mtd_read(struct mtd_info *mtd, loff_t from, size_t len, cpylen = len; // this page len = len - cpylen; - page = page_read(dev->blkdev->bd_inode->i_mapping, index); + page = bdev_read_cache_page(dev->blkdev, index, GFP_NOFS); if (IS_ERR(page)) return PTR_ERR(page); @@ -148,7 +142,7 @@ static int _block2mtd_write(struct block2mtd_dev *dev, const u_char *buf, cpylen = len; // this page len = len - cpylen; - page = page_read(mapping, index); + page = bdev_read_cache_page(dev->blkdev, index, GFP_NOFS); if (IS_ERR(page)) return PTR_ERR(page); -- 2.50.1