From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matteo Croce Subject: [PATCH net v2 1/2] jiffies: add utility function to calculate delta in ms Date: Tue, 31 Jul 2018 18:03:32 +0200 Message-ID: <20180731160333.12215-2-mcroce@redhat.com> References: <20180731160333.12215-1-mcroce@redhat.com> Cc: Pablo Neira Ayuso , Florian Westphal , netfilter-devel@vger.kernel.org, Eric Dumazet To: Wensong Zhang , Simon Horman , Julian Anastasov , lvs-devel@vger.kernel.org, netdev@vger.kernel.org, Jozsef Kadlecsik Return-path: Received: from mail-wm0-f68.google.com ([74.125.82.68]:55109 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732419AbeGaRoi (ORCPT ); Tue, 31 Jul 2018 13:44:38 -0400 Received: by mail-wm0-f68.google.com with SMTP id c14-v6so3679534wmb.4 for ; Tue, 31 Jul 2018 09:03:38 -0700 (PDT) In-Reply-To: <20180731160333.12215-1-mcroce@redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: add jiffies_delta_to_msecs() helper func to calculate the delta between two times and eventually 0 if negative. Suggested-by: Eric Dumazet Signed-off-by: Matteo Croce --- include/linux/jiffies.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index a27cf6652327..fa928242567d 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h @@ -447,6 +447,11 @@ static inline clock_t jiffies_delta_to_clock_t(long delta) return jiffies_to_clock_t(max(0L, delta)); } +static inline unsigned int jiffies_delta_to_msecs(long delta) +{ + return jiffies_to_msecs(max(0L, delta)); +} + extern unsigned long clock_t_to_jiffies(unsigned long x); extern u64 jiffies_64_to_clock_t(u64 x); extern u64 nsec_to_clock_t(u64 x); -- 2.17.1