Skip to content

Commit b447597

Browse files
alobakindavem330
authored andcommitted
bitmap: make bitmap_{get,set}_value8() use bitmap_{read,write}()
Now that we have generic bitmap_read() and bitmap_write(), which are inline and try to take care of non-bound-crossing and aligned cases to keep them optimized, collapse bitmap_{get,set}_value8() into simple wrappers around the former ones. bloat-o-meter shows no difference in vmlinux and -2 bytes for gpio-pca953x.ko, which says the optimization didn't suffer due to that change. The converted helpers have the value width embedded and always compile-time constant and that helps a lot. Suggested-by: Yury Norov <yury.norov@gmail.com> Signed-off-by: Yury Norov <yury.norov@gmail.com> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a37fbe6 commit b447597

File tree

1 file changed

+5
-33
lines changed

1 file changed

+5
-33
lines changed

include/linux/bitmap.h

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -727,39 +727,6 @@ static inline void bitmap_from_u64(unsigned long *dst, u64 mask)
727727
bitmap_from_arr64(dst, &mask, 64);
728728
}
729729

730-
/**
731-
* bitmap_get_value8 - get an 8-bit value within a memory region
732-
* @map: address to the bitmap memory region
733-
* @start: bit offset of the 8-bit value; must be a multiple of 8
734-
*
735-
* Returns the 8-bit value located at the @start bit offset within the @src
736-
* memory region.
737-
*/
738-
static inline unsigned long bitmap_get_value8(const unsigned long *map,
739-
unsigned long start)
740-
{
741-
const size_t index = BIT_WORD(start);
742-
const unsigned long offset = start % BITS_PER_LONG;
743-
744-
return (map[index] >> offset) & 0xFF;
745-
}
746-
747-
/**
748-
* bitmap_set_value8 - set an 8-bit value within a memory region
749-
* @map: address to the bitmap memory region
750-
* @value: the 8-bit value; values wider than 8 bits may clobber bitmap
751-
* @start: bit offset of the 8-bit value; must be a multiple of 8
752-
*/
753-
static inline void bitmap_set_value8(unsigned long *map, unsigned long value,
754-
unsigned long start)
755-
{
756-
const size_t index = BIT_WORD(start);
757-
const unsigned long offset = start % BITS_PER_LONG;
758-
759-
map[index] &= ~(0xFFUL << offset);
760-
map[index] |= value << offset;
761-
}
762-
763730
/**
764731
* bitmap_read - read a value of n-bits from the memory region
765732
* @map: address to the bitmap memory region
@@ -833,6 +800,11 @@ static inline void bitmap_write(unsigned long *map, unsigned long value,
833800
map[index + 1] |= (value >> space);
834801
}
835802

803+
#define bitmap_get_value8(map, start) \
804+
bitmap_read(map, start, BITS_PER_BYTE)
805+
#define bitmap_set_value8(map, value, start) \
806+
bitmap_write(map, value, start, BITS_PER_BYTE)
807+
836808
#endif /* __ASSEMBLY__ */
837809

838810
#endif /* __LINUX_BITMAP_H */

0 commit comments

Comments
 (0)