exfat: remove runtime integer division

Replace the arithmetic ops that compiles to the use of actual integer
division with bitwise ops. As the divisors involved are all power of
two, integer division is not necessary.

No functional change.

Signed-off-by: David Timber <dxdt@dev.snart.me>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
David Timber 2026-09-05 17:10:43 +00:00 committed by Namjae Jeon
parent d090f9f99a
commit 775100031a
4 changed files with 7 additions and 5 deletions

View File

@ -1309,7 +1309,8 @@ static int exfat_get_volume_label_dentry(struct super_block *sb,
es->bh = es->__bh;
es->bh[0] = bh;
es->num_bh = 1;
es->start_off = exfat_dentries_to_bytes(i) % sb->s_blocksize;
es->start_off = exfat_dentries_to_bytes(i) &
((u32)sb->s_blocksize - 1);
return 0;
}

View File

@ -232,6 +232,7 @@ struct exfat_sb_info {
unsigned int num_FAT_sectors; /* num of FAT sectors */
unsigned int root_dir; /* root dir cluster */
unsigned int dentries_per_clu; /* num of dentries per cluster */
unsigned int dentries_per_clu_bits;
unsigned int vol_flags; /* volume flags */
unsigned int vol_flags_persistent; /* volume flags to retain */
struct buffer_head *boot_bh; /* buffer_head of BOOT sector */

View File

@ -386,7 +386,7 @@ int exfat_find_empty_entry(struct inode *inode,
}
p_dir->dir = exfat_sector_to_cluster(sbi, es->bh[0]->b_blocknr);
p_dir->size -= dentry / sbi->dentries_per_clu;
p_dir->size -= dentry >> sbi->dentries_per_clu_bits;
return dentry & (sbi->dentries_per_clu - 1);
}
@ -638,7 +638,7 @@ static int exfat_find(struct inode *dir, const struct qstr *qname,
/* adjust cdir to the optimized value */
cdir.dir = hint_opt.clu;
if (cdir.flags & ALLOC_NO_FAT_CHAIN)
cdir.size -= dentry / sbi->dentries_per_clu;
cdir.size -= dentry >> sbi->dentries_per_clu_bits;
dentry = hint_opt.eidx;
info->dir = cdir;

View File

@ -519,8 +519,8 @@ static int exfat_read_boot_sector(struct super_block *sb)
EXFAT_RESERVED_CLUSTERS;
sbi->root_dir = le32_to_cpu(p_boot->root_cluster);
sbi->dentries_per_clu = 1 <<
(sbi->cluster_size_bits - DENTRY_SIZE_BITS);
sbi->dentries_per_clu_bits = sbi->cluster_size_bits - DENTRY_SIZE_BITS;
sbi->dentries_per_clu = 1 << sbi->dentries_per_clu_bits;
sbi->vol_flags = le16_to_cpu(p_boot->vol_flags);
sbi->vol_flags_persistent = sbi->vol_flags & (VOLUME_DIRTY | MEDIA_FAILURE);