Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1581353

[PATCH 1/8] hardpps: simple fixes replacing clumsy code with abs() macro.

From Andrey Drobyshev <immortalguardian1@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 1/8] hardpps: simple fixes replacing clumsy code with abs() macro.
Date 2017-02-15 15:40 +0100
Message-ID <tb8Uq-1ae-3@gated-at.bofh.it> (permalink)
References <tb8Up-1ae-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Alexander GQ Gerasiov <gq@cs.msu.su>

Here are some trivial fixes, including:
  * simplify comparisons by using abs() macro
  * remove unnecessary variables
  * remove duplicate headers
  * fix typos

Signed-off-by: Alexander GQ Gerasiov <gq@cs.msu.su>
---
 kernel/time/ntp.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index edf19cc..d20891e 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -16,7 +16,6 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/rtc.h>
-#include <linux/math64.h>
 
 #include "ntp_internal.h"
 #include "timekeeping_internal.h"
@@ -874,7 +873,7 @@ static inline void pps_inc_freq_interval(void)
  */
 static long hardpps_update_freq(struct pps_normtime freq_norm)
 {
-	long delta, delta_mod;
+	long delta;
 	s64 ftemp;
 
 	/* check if the frequency interval was too long */
@@ -896,7 +895,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
 			freq_norm.sec);
 	delta = shift_right(ftemp - pps_freq, NTP_SCALE_SHIFT);
 	pps_freq = ftemp;
-	if (delta > PPS_MAXWANDER || delta < -PPS_MAXWANDER) {
+	if (abs(delta) > PPS_MAXWANDER) {
 		printk_deferred(KERN_WARNING
 				"hardpps: PPSWANDER: change=%ld\n", delta);
 		time_status |= STA_PPSWANDER;
@@ -910,10 +909,7 @@ static long hardpps_update_freq(struct pps_normtime freq_norm)
 	 * frequency changes, but is used only for performance
 	 * monitoring
 	 */
-	delta_mod = delta;
-	if (delta_mod < 0)
-		delta_mod = -delta_mod;
-	pps_stabil += (div_s64(((s64)delta_mod) <<
+	pps_stabil += (div_s64(((s64)abs(delta)) <<
 				(NTP_SCALE_SHIFT - SHIFT_USEC),
 				NSEC_PER_USEC) - pps_stabil) >> PPS_INTMIN;
 
@@ -994,10 +990,8 @@ void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_t
 	freq_norm = pps_normalize_ts(timespec64_sub(*raw_ts, pps_fbase));
 
 	/* check that the signal is in the range
-	 * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it */
-	if ((freq_norm.sec == 0) ||
-			(freq_norm.nsec > MAXFREQ * freq_norm.sec) ||
-			(freq_norm.nsec < -MAXFREQ * freq_norm.sec)) {
+	 * [1s - MAXFREQ ns, 1s + MAXFREQ ns], otherwise reject it */
+	if (abs(freq_norm.nsec) > MAXFREQ * freq_norm.sec) {
 		time_status |= STA_PPSJITTER;
 		/* restart the frequency calibration interval */
 		pps_fbase = *raw_ts;
-- 
2.1.4

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 1/8] hardpps: simple fixes replacing clumsy code with abs() macro. Andrey Drobyshev <immortalguardian1@gmail.com> - 2017-02-15 15:40 +0100

csiph-web