cifsd: clean-up codes using chechpatch.pl --strict
[linux-block.git] / fs / cifsd / time_wrappers.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *   Copyright (C) 2019 Samsung Electronics Co., Ltd.
4  */
5
6 #ifndef __KSMBD_TIME_WRAPPERS_H
7 #define __KSMBD_TIME_WRAPPERS_H
8
9 /*
10  * A bunch of ugly hacks to workaoround all the API differences
11  * between different kernel versions.
12  */
13
14 #define NTFS_TIME_OFFSET        ((u64)(369 * 365 + 89) * 24 * 3600 * 10000000)
15
16 /* Convert the Unix UTC into NT UTC. */
17 static inline u64 ksmbd_UnixTimeToNT(struct timespec64 t)
18 {
19         /* Convert to 100ns intervals and then add the NTFS time offset. */
20         return (u64)t.tv_sec * 10000000 + t.tv_nsec / 100 + NTFS_TIME_OFFSET;
21 }
22
23 struct timespec64 ksmbd_NTtimeToUnix(__le64 ntutc);
24
25 #define KSMBD_TIME_TO_TM        time64_to_tm
26
27 static inline long long ksmbd_systime(void)
28 {
29         struct timespec64 ts;
30
31         ktime_get_real_ts64(&ts);
32         return ksmbd_UnixTimeToNT(ts);
33 }
34 #endif /* __KSMBD_TIME_WRAPPERS_H */