summaryrefslogtreecommitdiff
path: root/fs/exfat/misc.c
diff options
context:
space:
mode:
authorTetsuhiro Kohada <kohada.t2@gmail.com>2020-05-29 13:14:59 +0300
committerNamjae Jeon <namjae.jeon@samsung.com>2020-06-09 10:49:25 +0300
commit5875bf287d95314c58add01184f361cc5aa38429 (patch)
tree1de468fb69859f1d17eac04c52d125d4761af6f6 /fs/exfat/misc.c
parent476189c0ef3b658de3f6b89fd0fdeb6dc451b564 (diff)
downloadlinux-5875bf287d95314c58add01184f361cc5aa38429.tar.xz
exfat: standardize checksum calculation
To clarify that it is a 16-bit checksum, the parts related to the 16-bit checksum are renamed and change type to u16. Furthermore, replace checksum calculation in exfat_load_upcase_table() with exfat_calc_checksum32(). Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com> Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Diffstat (limited to 'fs/exfat/misc.c')
-rw-r--r--fs/exfat/misc.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/exfat/misc.c b/fs/exfat/misc.c
index b82d2dd5bd7c..17d41f3d3709 100644
--- a/fs/exfat/misc.c
+++ b/fs/exfat/misc.c
@@ -136,17 +136,15 @@ void exfat_truncate_atime(struct timespec64 *ts)
ts->tv_nsec = 0;
}
-unsigned short exfat_calc_chksum_2byte(void *data, int len,
- unsigned short chksum, int type)
+u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type)
{
int i;
- unsigned char *c = (unsigned char *)data;
+ u8 *c = (u8 *)data;
for (i = 0; i < len; i++, c++) {
- if (((i == 2) || (i == 3)) && (type == CS_DIR_ENTRY))
+ if (unlikely(type == CS_DIR_ENTRY && (i == 2 || i == 3)))
continue;
- chksum = (((chksum & 1) << 15) | ((chksum & 0xFFFE) >> 1)) +
- (unsigned short)*c;
+ chksum = ((chksum << 15) | (chksum >> 1)) + *c;
}
return chksum;
}