summaryrefslogtreecommitdiff
path: root/drivers/mtd/spi-nor
diff options
context:
space:
mode:
authorMichael Walle <michael@walle.cc>2021-03-06 00:45:52 +0100
committerTudor Ambarus <tudor.ambarus@microchip.com>2021-03-08 08:17:39 +0200
commit04fc298c7d0877695847e8662d1b5b29a19c2723 (patch)
treeb70a94043723d2fb2151037fdca69331122c34eb /drivers/mtd/spi-nor
parentff013330fbdb2782e9001787db6c0b6415cdad77 (diff)
mtd: spi-nor: use is_power_of_2()
There is already a function to check if an integer is a power of 2. Use it. Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Link: https://lore.kernel.org/r/20210305234552.19204-1-michael@walle.cc
Diffstat (limited to 'drivers/mtd/spi-nor')
-rw-r--r--drivers/mtd/spi-nor/core.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 0522304f52fa..4a315cb1c4db 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2336,11 +2336,8 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
* If page_size is a power of two, the offset can be quickly
* calculated with an AND operation. On the other cases we
* need to do a modulus operation (more expensive).
- * Power of two numbers have only one bit set and we can use
- * the instruction hweight32 to detect if we need to do a
- * modulus (do_div()) or not.
*/
- if (hweight32(nor->page_size) == 1) {
+ if (is_power_of_2(nor->page_size)) {
page_offset = addr & (nor->page_size - 1);
} else {
uint64_t aux = addr;