diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-04-15 21:29:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-04-19 16:39:13 -0400 |
commit | 6e94d1ef37e439bf45659cc071553574ccb98080 (patch) | |
tree | ac0b5b9e98210b43a0b1e4ea62607ce41e24dbd7 /net | |
parent | cf270148662a117c04753d17324e3bd28ce0396a (diff) |
net: socket: move ktime2ts to ktime header api
Currently, ktime2ts is a small helper function that is only used in
net/socket.c. Move this helper into the ktime API as a small inline
function, so that i) it's maintained together with ktime routines,
and ii) also other files can make use of it. The function is named
ktime_to_timespec_cond() and placed into the generic part of ktime,
since we internally make use of ktime_to_timespec(). ktime_to_timespec()
itself does not check the ktime variable for zero, hence, we name
this function ktime_to_timespec_cond() for only a conditional
conversion, and adapt its users to it.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/socket.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/net/socket.c b/net/socket.c index 36883fea44f3..280283f03ccc 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -681,16 +681,6 @@ int kernel_sendmsg(struct socket *sock, struct msghdr *msg, | |||
681 | } | 681 | } |
682 | EXPORT_SYMBOL(kernel_sendmsg); | 682 | EXPORT_SYMBOL(kernel_sendmsg); |
683 | 683 | ||
684 | static int ktime2ts(ktime_t kt, struct timespec *ts) | ||
685 | { | ||
686 | if (kt.tv64) { | ||
687 | *ts = ktime_to_timespec(kt); | ||
688 | return 1; | ||
689 | } else { | ||
690 | return 0; | ||
691 | } | ||
692 | } | ||
693 | |||
694 | /* | 684 | /* |
695 | * called from sock_recv_timestamp() if sock_flag(sk, SOCK_RCVTSTAMP) | 685 | * called from sock_recv_timestamp() if sock_flag(sk, SOCK_RCVTSTAMP) |
696 | */ | 686 | */ |
@@ -723,17 +713,15 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, | |||
723 | 713 | ||
724 | 714 | ||
725 | memset(ts, 0, sizeof(ts)); | 715 | memset(ts, 0, sizeof(ts)); |
726 | if (skb->tstamp.tv64 && | 716 | if (sock_flag(sk, SOCK_TIMESTAMPING_SOFTWARE) && |
727 | sock_flag(sk, SOCK_TIMESTAMPING_SOFTWARE)) { | 717 | ktime_to_timespec_cond(skb->tstamp, ts + 0)) |
728 | skb_get_timestampns(skb, ts + 0); | ||
729 | empty = 0; | 718 | empty = 0; |
730 | } | ||
731 | if (shhwtstamps) { | 719 | if (shhwtstamps) { |
732 | if (sock_flag(sk, SOCK_TIMESTAMPING_SYS_HARDWARE) && | 720 | if (sock_flag(sk, SOCK_TIMESTAMPING_SYS_HARDWARE) && |
733 | ktime2ts(shhwtstamps->syststamp, ts + 1)) | 721 | ktime_to_timespec_cond(shhwtstamps->syststamp, ts + 1)) |
734 | empty = 0; | 722 | empty = 0; |
735 | if (sock_flag(sk, SOCK_TIMESTAMPING_RAW_HARDWARE) && | 723 | if (sock_flag(sk, SOCK_TIMESTAMPING_RAW_HARDWARE) && |
736 | ktime2ts(shhwtstamps->hwtstamp, ts + 2)) | 724 | ktime_to_timespec_cond(shhwtstamps->hwtstamp, ts + 2)) |
737 | empty = 0; | 725 | empty = 0; |
738 | } | 726 | } |
739 | if (!empty) | 727 | if (!empty) |