linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kaitao Cheng <pilgrimtao@gmail.com>
To: axboe@kernel.dk
Cc: damien.lemoal@wdc.com, bvanassche@acm.org, ming.lei@redhat.com,
	martin.petersen@oracle.com, satyat@google.com,
	chaitanya.kulkarni@wdc.com, houtao1@huawei.com,
	asml.silence@gmail.com, ajay.joshi@wdc.com,
	linux-kernel@vger.kernel.org, songmuchun@bytedance.com,
	Kaitao Cheng <pilgrimtao@gmail.com>
Subject: [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits()
Date: Sat, 23 May 2020 23:50:48 +0800	[thread overview]
Message-ID: <20200523155048.29369-1-pilgrimtao@gmail.com> (raw)

blksize_bits() can be achieved through ilog2(), and ilog2() is
more efficient.

Signed-off-by: Kaitao Cheng <pilgrimtao@gmail.com>
---
 include/linux/blkdev.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 2b33166b9daf..cce96abac4d4 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1505,12 +1505,7 @@ static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
 /* assumes size > 256 */
 static inline unsigned int blksize_bits(unsigned int size)
 {
-	unsigned int bits = 8;
-	do {
-		bits++;
-		size >>= 1;
-	} while (size > 256);
-	return bits;
+	return ilog2(size);
 }
 
 static inline unsigned int block_size(struct block_device *bdev)
-- 
2.20.1


             reply	other threads:[~2020-05-23 15:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-23 15:50 Kaitao Cheng [this message]
2020-05-23 17:07 ` [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits() Jens Axboe
2020-05-23 18:33 ` Bart Van Assche
2020-05-23 18:50   ` Jens Axboe

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=20200523155048.29369-1-pilgrimtao@gmail.com \
    --to=pilgrimtao@gmail.com \
    --cc=ajay.joshi@wdc.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=damien.lemoal@wdc.com \
    --cc=houtao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    --cc=satyat@google.com \
    --cc=songmuchun@bytedance.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;
as well as URLs for NNTP newsgroup(s).