lib/axmap: Inline ulog64()
authorBart Van Assche <bart.vanassche@wdc.com>
Wed, 22 Aug 2018 20:35:19 +0000 (13:35 -0700)
committerBart Van Assche <bvanassche@acm.org>
Thu, 23 Aug 2018 01:59:24 +0000 (18:59 -0700)
Since the function ulog64() only has one caller and since it can be
replaced by a single closed-form expression, inline that function.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
lib/axmap.c

index 4a907fec22d2f8a2723121d8236d7a56be6db01c..0d8fbf8dfaef93d99aac516dfe290074c5d27349 100644 (file)
@@ -83,14 +83,6 @@ struct axmap {
        uint64_t nr_bits;
 };
 
-static inline unsigned long ulog64(unsigned long val, unsigned int log)
-{
-       while (log-- && val)
-               val >>= UNIT_SHIFT;
-
-       return val;
-}
-
 /* Remove all elements from the @axmap set */
 void axmap_reset(struct axmap *axmap)
 {
@@ -202,7 +194,7 @@ static bool axmap_handler_topdown(struct axmap *axmap, uint64_t bit_nr,
        int i;
 
        for (i = axmap->nr_levels - 1; i >= 0; i--) {
-               unsigned long index = ulog64(bit_nr, i);
+               unsigned long index = bit_nr >> (UNIT_SHIFT * i);
                unsigned long offset = index >> UNIT_SHIFT;
                unsigned int bit = index & BLOCKS_PER_UNIT_MASK;