fat: new inline functions to determine the FAT variant (32, 16 or 12)
[sfrench/cifs-2.6.git] / fs / fat / inode.c
index 8d0de1aac4eb98467c2d6028392c4ee6d3de02d0..79bb0e73a65f48b2de5f7e3645748b535e81b6d1 100644 (file)
@@ -686,7 +686,7 @@ static void fat_set_state(struct super_block *sb,
 
        b = (struct fat_boot_sector *) bh->b_data;
 
-       if (sbi->fat_bits == 32) {
+       if (is_fat32(sbi)) {
                if (set)
                        b->fat32.state |= FAT_STATE_DIRTY;
                else
@@ -1396,7 +1396,7 @@ static int fat_read_root(struct inode *inode)
        inode->i_mode = fat_make_mode(sbi, ATTR_DIR, S_IRWXUGO);
        inode->i_op = sbi->dir_ops;
        inode->i_fop = &fat_dir_operations;
-       if (sbi->fat_bits == 32) {
+       if (is_fat32(sbi)) {
                MSDOS_I(inode)->i_start = sbi->root_cluster;
                error = fat_calc_dir_size(inode);
                if (error < 0)
@@ -1423,7 +1423,7 @@ static unsigned long calc_fat_clusters(struct super_block *sb)
        struct msdos_sb_info *sbi = MSDOS_SB(sb);
 
        /* Divide first to avoid overflow */
-       if (sbi->fat_bits != 12) {
+       if (!is_fat12(sbi)) {
                unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
                return ent_per_sec * sbi->fat_length;
        }
@@ -1743,7 +1743,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
        }
 
        /* interpret volume ID as a little endian 32 bit integer */
-       if (sbi->fat_bits == 32)
+       if (is_fat32(sbi))
                sbi->vol_id = bpb.fat32_vol_id;
        else /* fat 16 or 12 */
                sbi->vol_id = bpb.fat16_vol_id;
@@ -1769,11 +1769,11 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 
        total_clusters = (total_sectors - sbi->data_start) / sbi->sec_per_clus;
 
-       if (sbi->fat_bits != 32)
+       if (!is_fat32(sbi))
                sbi->fat_bits = (total_clusters > MAX_FAT12) ? 16 : 12;
 
        /* some OSes set FAT_STATE_DIRTY and clean it on unmount. */
-       if (sbi->fat_bits == 32)
+       if (is_fat32(sbi))
                sbi->dirty = bpb.fat32_state & FAT_STATE_DIRTY;
        else /* fat 16 or 12 */
                sbi->dirty = bpb.fat16_state & FAT_STATE_DIRTY;