linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits()
@ 2020-05-23 15:50 Kaitao Cheng
  2020-05-23 17:07 ` Jens Axboe
  2020-05-23 18:33 ` Bart Van Assche
  0 siblings, 2 replies; 4+ messages in thread
From: Kaitao Cheng @ 2020-05-23 15:50 UTC (permalink / raw)
  To: axboe
  Cc: damien.lemoal, bvanassche, ming.lei, martin.petersen, satyat,
	chaitanya.kulkarni, houtao1, asml.silence, ajay.joshi,
	linux-kernel, songmuchun, Kaitao Cheng

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-23 18:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-23 15:50 [PATCH] linux/blkdev.h: Use ilog2() directly in blksize_bits() Kaitao Cheng
2020-05-23 17:07 ` Jens Axboe
2020-05-23 18:33 ` Bart Van Assche
2020-05-23 18:50   ` Jens Axboe

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).