From: Daniel Borkmann <dborkman@redhat.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org
Subject: [PATCH net-next v3 2/6] ktime: add ms_to_ktime() and ktime_add_ms() helpers
Date: Tue, 25 Jun 2013 18:17:26 +0200 [thread overview]
Message-ID: <1372177050-17829-3-git-send-email-dborkman@redhat.com> (raw)
In-Reply-To: <1372177050-17829-1-git-send-email-dborkman@redhat.com>
Add two ktime helper functions that i) convert a given msec value to
a ktime structure and ii) that adds a msec value to a ktime structure.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
include/linux/ktime.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index bbca128..b4fa5e4 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -323,6 +323,11 @@ static inline ktime_t ktime_add_us(const ktime_t kt, const u64 usec)
return ktime_add_ns(kt, usec * 1000);
}
+static inline ktime_t ktime_add_ms(const ktime_t kt, const u64 msec)
+{
+ return ktime_add_ns(kt, msec * NSEC_PER_MSEC);
+}
+
static inline ktime_t ktime_sub_us(const ktime_t kt, const u64 usec)
{
return ktime_sub_ns(kt, usec * 1000);
@@ -366,7 +371,15 @@ extern void ktime_get_ts(struct timespec *ts);
static inline ktime_t ns_to_ktime(u64 ns)
{
static const ktime_t ktime_zero = { .tv64 = 0 };
+
return ktime_add_ns(ktime_zero, ns);
}
+static inline ktime_t ms_to_ktime(u64 ms)
+{
+ static const ktime_t ktime_zero = { .tv64 = 0 };
+
+ return ktime_add_ms(ktime_zero, ms);
+}
+
#endif
--
1.7.11.7
next prev parent reply other threads:[~2013-06-25 16:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-25 16:17 [PATCH net-next v3 0/6] Further SCTP changes Daniel Borkmann
2013-06-25 16:17 ` [PATCH net-next v3 1/6] net: sctp: remove TEST_FRAME ifdef Daniel Borkmann
2013-06-25 16:17 ` Daniel Borkmann [this message]
2013-06-25 16:17 ` [PATCH net-next v3 3/6] net: sctp: migrate cookie life from timeval to ktime Daniel Borkmann
2013-06-25 16:17 ` [PATCH net-next v3 4/6] net: sctp: minor: sctp_seq_dump_local_addrs add missing newline Daniel Borkmann
2013-06-25 16:17 ` [PATCH net-next v3 5/6] net: sctp: decouple cleaning some socket data from endpoint Daniel Borkmann
2013-06-25 16:17 ` [PATCH net-next v3 6/6] net: sctp: simplify sctp_get_port Daniel Borkmann
2013-06-25 17:54 ` [PATCH net-next v3 0/6] Further SCTP changes Vlad Yasevich
2013-06-25 23:31 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372177050-17829-3-git-send-email-dborkman@redhat.com \
--to=dborkman@redhat.com \
--cc=davem@davemloft.net \
--cc=linux-sctp@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).