From 4e5bb38d6b8d4b2efbb7a5789c9cb5decb68cf17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20A=2E=20Fern=C3=A1ndez?= Date: Sat, 26 Oct 2019 21:07:39 -0300 Subject: [PATCH] apfs: use __set_bit_le() to set bitmap bits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the spirit of the previous patch, use the __set_bit_le() provided by the kernel to simplify apfs_chunk_mark_used(). There is no endianness issue this time, but it's still better to use the common code. Also change the type of the bitmap from u8* to char*, for consistency with apfs_chunk_find_free(). Signed-off-by: Ernesto A. Fernández --- fs/apfs/spaceman.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/apfs/spaceman.c b/fs/apfs/spaceman.c index 563a7559be93..d17865cd1f32 100644 --- a/fs/apfs/spaceman.c +++ b/fs/apfs/spaceman.c @@ -213,13 +213,12 @@ static u64 apfs_chunk_find_free(struct super_block *sb, char *bitmap, u64 addr) * @bitmap: allocation bitmap for the chunk * @bno: block number (must belong to the chunk) */ -static void apfs_chunk_mark_used(struct super_block *sb, u8 *bitmap, u64 bno) +static inline void apfs_chunk_mark_used(struct super_block *sb, char *bitmap, + u64 bno) { - int index = bno & ((sb->s_blocksize * 8) - 1); - u8 *byte_p = bitmap + (index / 8); - u8 bit = 1 << index % 8; + int bitcount = sb->s_blocksize * 8; - *byte_p |= bit; + __set_bit_le(bno & (bitcount - 1), bitmap); } /**