Message ID | 20201001205141.8885-2-erez.geva.ext@siemens.com |
---|---|
State | New |
Headers | show |
Series | TC-ETF support PTP clocks series | expand |
Erez, On Thu, Oct 01 2020 at 22:51, Erez Geva wrote: thanks for your patches. First of all subject lines follow the scheme: subsystem: Short description The short description should be a sentence > Add function to check whether a clock ID refer to > a file descriptor of a POSIX dynamic clock. The changelog should not primarily describe what the patch does, it should describe why or which problem it is solving. Thanks, tglx
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 896c16d2c5fb..7cb551bbb763 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -57,6 +57,11 @@ static inline int clockid_to_fd(const clockid_t clk) return ~(clk >> 3); } +static inline bool is_clockid_fd_clock(const clockid_t clk) +{ + return (clk < 0) && ((clk & CLOCKFD_MASK) == CLOCKFD); +} + #ifdef CONFIG_POSIX_TIMERS /** diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index bf540f5a4115..806465233303 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -1400,7 +1400,7 @@ static const struct k_clock *clockid_to_kclock(const clockid_t id) clockid_t idx = id; if (id < 0) { - return (id & CLOCKFD_MASK) == CLOCKFD ? + return is_clockid_fd_clock(id) ? &clock_posix_dynamic : &clock_posix_cpu; }
Add function to check whether a clock ID refer to a file descriptor of a POSIX dynamic clock. Signed-off-by: Erez Geva <erez.geva.ext@siemens.com> --- include/linux/posix-timers.h | 5 +++++ kernel/time/posix-timers.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)