[PATCH v2 04/10] zram: abolish macro SECTORS_PER_PAGE_SHIFT

From: Zhen Lei
Date: Thu May 07 2020 - 03:56:28 EST


The name of SECTORS_PER_PAGE_SHIFT is quite hard to read. So use
sectors_to_npage() to replace ">> SECTORS_PER_PAGE_SHIFT"

Suggested-by: Matthew Wilcox <willy@xxxxxxxxxxxxx>
Signed-off-by: Zhen Lei <thunder.leizhen@xxxxxxxxxx>
---
drivers/block/zram/zram_drv.c | 4 ++--
drivers/block/zram/zram_drv.h | 1 -
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index e2fbf7a847e7..918b77f9bce4 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1549,7 +1549,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio)
struct bio_vec bvec;
struct bvec_iter iter;

- index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
+ index = sectors_to_npage(bio->bi_iter.bi_sector);
offset = (bio->bi_iter.bi_sector &
(PAGE_SECTORS - 1)) << SECTOR_SHIFT;

@@ -1644,7 +1644,7 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector,
goto out;
}

- index = sector >> SECTORS_PER_PAGE_SHIFT;
+ index = sectors_to_npage(sector);
offset = (sector & (PAGE_SECTORS - 1)) << SECTOR_SHIFT;

bv.bv_page = page;
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index 10fdf413dd6e..12309175d55e 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -21,7 +21,6 @@

#include "zcomp.h"

-#define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
#define ZRAM_LOGICAL_BLOCK_SHIFT 12
#define ZRAM_LOGICAL_BLOCK_SIZE (1 << ZRAM_LOGICAL_BLOCK_SHIFT)
#define ZRAM_SECTOR_PER_LOGICAL_BLOCK \
--
2.26.0.106.g9fadedd