From: Pratyush Yadav <p.yadav@ti.com>
To: Michael Walle <michael@walle.cc>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
Tudor Ambarus <tudor.ambarus@microchip.com>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>
Subject: Re: [PATCH] mtd: spi-nor: use is_power_of_2()
Date: Mon, 8 Mar 2021 14:31:28 +0530 [thread overview]
Message-ID: <20210308090126.y3scr752sdm6oi5e@ti.com> (raw)
In-Reply-To: <20210305234552.19204-1-michael@walle.cc>
On 06/03/21 12:45AM, Michael Walle wrote:
> 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>
> ---
> drivers/mtd/spi-nor/core.c | 5 +----
> 1 file changed, 1 insertion(+), 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;
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
--
Regards,
Pratyush Yadav
Texas Instruments Inc.
prev parent reply other threads:[~2021-03-08 9:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-05 23:45 Michael Walle
2021-03-08 6:20 ` Tudor Ambarus
2021-03-08 9:01 ` Pratyush Yadav [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210308090126.y3scr752sdm6oi5e@ti.com \
--to=p.yadav@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=michael@walle.cc \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=tudor.ambarus@microchip.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®