mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrey Drobyshev <immortalguardian1@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: gq@cs.msu.su, giometti@enneenne.com
Subject: [PATCH 1/8] hardpps: simple fixes replacing clumsy code with abs() macro.
Date: Wed, 15 Feb 2017 17:31:02 +0300	[thread overview]
Message-ID: <1487169069-15721-2-git-send-email-immortalguardian1@gmail.com> (raw)
In-Reply-To: <1487169069-15721-1-git-send-email-immortalguardian1@gmail.com>

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

  reply	other threads:[~2017-02-15 14:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15 14:31 [PATCH 0/8] LinuxPPS: some minor fixes and improvements Andrey Drobyshev
2017-02-15 14:31 ` Andrey Drobyshev [this message]
2017-03-04  7:36   ` [PATCH 1/8] hardpps: simple fixes replacing clumsy code with abs() macro Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 2/8] ntp/pps: ignore pps_valid decreasing if there is no pps signal Andrey Drobyshev
2017-03-04  7:36   ` Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 3/8] hardpps: fix some pps_jitter issues Andrey Drobyshev
2017-03-04  7:37   ` Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 4/8] LinuxPPS: kapi: Unlock before waking up events queue in pps_event() Andrey Drobyshev
2017-03-04  7:38   ` Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 5/8] LinuxPPS: pps_parport: Do not generate assert in case of lost signal Andrey Drobyshev
2017-03-04  7:39   ` Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 6/8] LinuxPPS: pps_parport: Ignore interrupt invoked less than 0.5sec after previous Andrey Drobyshev
2017-03-04  7:40   ` Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 7/8] LinuxPPS: pps_gen_parport: Add polarity parameter for inverted signal Andrey Drobyshev
2017-03-04  7:42   ` Rodolfo Giometti
2017-02-15 14:31 ` [PATCH 8/8] LinuxPPS: pps_gen_parport: Add check for bad clocksource Andrey Drobyshev
2017-03-04  7:44   ` Rodolfo Giometti
2017-03-04  9:19     ` Alexander Gerasiov
2017-03-04 13:25       ` Rodolfo Giometti

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=1487169069-15721-2-git-send-email-immortalguardian1@gmail.com \
    --to=immortalguardian1@gmail.com \
    --cc=giometti@enneenne.com \
    --cc=gq@cs.msu.su \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®