Commit 86e80575 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Gabriel Krisman Bertazi

f2fs: simplify f2fs_sb_read_encoding

Return the encoding table as the return value instead of as an argument,
and don't bother with the encoding flags as the caller can handle that
trivially.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarGabriel Krisman Bertazi <krisman@collabora.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarGabriel Krisman Bertazi <krisman@collabora.com>
parent aa8bf298
...@@ -264,24 +264,17 @@ static const struct f2fs_sb_encodings { ...@@ -264,24 +264,17 @@ static const struct f2fs_sb_encodings {
{F2FS_ENC_UTF8_12_1, "utf8", "12.1.0"}, {F2FS_ENC_UTF8_12_1, "utf8", "12.1.0"},
}; };
static int f2fs_sb_read_encoding(const struct f2fs_super_block *sb, static const struct f2fs_sb_encodings *
const struct f2fs_sb_encodings **encoding, f2fs_sb_read_encoding(const struct f2fs_super_block *sb)
__u16 *flags)
{ {
__u16 magic = le16_to_cpu(sb->s_encoding); __u16 magic = le16_to_cpu(sb->s_encoding);
int i; int i;
for (i = 0; i < ARRAY_SIZE(f2fs_sb_encoding_map); i++) for (i = 0; i < ARRAY_SIZE(f2fs_sb_encoding_map); i++)
if (magic == f2fs_sb_encoding_map[i].magic) if (magic == f2fs_sb_encoding_map[i].magic)
break; return &f2fs_sb_encoding_map[i];
if (i >= ARRAY_SIZE(f2fs_sb_encoding_map))
return -EINVAL;
*encoding = &f2fs_sb_encoding_map[i]; return NULL;
*flags = le16_to_cpu(sb->s_encoding_flags);
return 0;
} }
struct kmem_cache *f2fs_cf_name_slab; struct kmem_cache *f2fs_cf_name_slab;
...@@ -3843,13 +3836,14 @@ static int f2fs_setup_casefold(struct f2fs_sb_info *sbi) ...@@ -3843,13 +3836,14 @@ static int f2fs_setup_casefold(struct f2fs_sb_info *sbi)
struct unicode_map *encoding; struct unicode_map *encoding;
__u16 encoding_flags; __u16 encoding_flags;
if (f2fs_sb_read_encoding(sbi->raw_super, &encoding_info, encoding_info = f2fs_sb_read_encoding(sbi->raw_super);
&encoding_flags)) { if (!encoding_info) {
f2fs_err(sbi, f2fs_err(sbi,
"Encoding requested by superblock is unknown"); "Encoding requested by superblock is unknown");
return -EINVAL; return -EINVAL;
} }
encoding_flags = le16_to_cpu(sbi->raw_super->s_encoding_flags);
encoding = utf8_load(encoding_info->version); encoding = utf8_load(encoding_info->version);
if (IS_ERR(encoding)) { if (IS_ERR(encoding)) {
f2fs_err(sbi, f2fs_err(sbi,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment