projects
/
linux-block.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ff01333
)
mtd: spi-nor: use is_power_of_2()
author
Michael Walle
<michael@walle.cc>
Fri, 5 Mar 2021 23:45:52 +0000
(
00:45
+0100)
committer
Tudor Ambarus
<tudor.ambarus@microchip.com>
Mon, 8 Mar 2021 06:17:39 +0000
(08:17 +0200)
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
drivers/mtd/spi-nor/core.c
patch
|
blob
|
blame
|
history
diff --git
a/drivers/mtd/spi-nor/core.c
b/drivers/mtd/spi-nor/core.c
index 0522304f52fade53e77fc4e4afcb23e490d7db04..4a315cb1c4dbf9ccc25ce577ce29a1be2de56bce 100644
(file)
--- 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;