public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ntp: make is_error_status() use its argument
@ 2014-05-12 13:35 George Spelvin
  2014-05-12 17:54 ` John Stultz
  0 siblings, 1 reply; 5+ messages in thread
From: George Spelvin @ 2014-05-12 13:35 UTC (permalink / raw)
  To: john.stultz; +Cc: linux, linux-kernel

It's an inline function always called with the global time_status as an
argument, so there's zero functional difference, but the non-CONFIG_SMP
version uses the passed-in argument, while the CONFIG_SMP one ignores
its argument and uses the global.
    
Make it use the argument always; shorter variable names are good.

Signed-off-by: George Spelvin <linux@horizon.com>
---
While poking about in the code, I came across this rather odd bit.
It looked worth fixing, on general principles.

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 419a52cecd..1a2aad3fff 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -165,21 +165,21 @@ static inline void pps_set_freq(s64 freq)
 
 static inline int is_error_status(int status)
 {
-	return (time_status & (STA_UNSYNC|STA_CLOCKERR))
+	return (status & (STA_UNSYNC|STA_CLOCKERR))
 		/* PPS signal lost when either PPS time or
 		 * PPS frequency synchronization requested
 		 */
-		|| ((time_status & (STA_PPSFREQ|STA_PPSTIME))
-			&& !(time_status & STA_PPSSIGNAL))
+		|| ((status & (STA_PPSFREQ|STA_PPSTIME))
+			&& !(status & STA_PPSSIGNAL))
 		/* PPS jitter exceeded when
 		 * PPS time synchronization requested */
-		|| ((time_status & (STA_PPSTIME|STA_PPSJITTER))
+		|| ((status & (STA_PPSTIME|STA_PPSJITTER))
 			== (STA_PPSTIME|STA_PPSJITTER))
 		/* PPS wander exceeded or calibration error when
 		 * PPS frequency synchronization requested
 		 */
-		|| ((time_status & STA_PPSFREQ)
-			&& (time_status & (STA_PPSWANDER|STA_PPSERROR)));
+		|| ((status & STA_PPSFREQ)
+			&& (status & (STA_PPSWANDER|STA_PPSERROR)));
 }
 
 static inline void pps_fill_timex(struct timex *txc)

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ntp: make is_error_status() use its argument
  2014-05-12 13:35 [PATCH] ntp: make is_error_status() use its argument George Spelvin
@ 2014-05-12 17:54 ` John Stultz
  2014-05-12 20:10   ` Alexander Gordeev
  2014-05-13  3:01   ` George Spelvin
  0 siblings, 2 replies; 5+ messages in thread
From: John Stultz @ 2014-05-12 17:54 UTC (permalink / raw)
  To: George Spelvin; +Cc: linux-kernel, Alexander Gordeev

On 05/12/2014 06:35 AM, George Spelvin wrote:
> It's an inline function always called with the global time_status as an
> argument, so there's zero functional difference, but the non-CONFIG_SMP
> version uses the passed-in argument, while the CONFIG_SMP one ignores
> its argument and uses the global.

CONFIG_NTP_PPS not CONFIG_SMP, right?

Good catch though, looks like the check code was re-factored out, but
someone forgot to use the local variable.

Adding Alexander since he submitted the pps logic.

If there's no objections, I'll queue this (with a more verbose commit
message) for 3.16

thanks
-john


>     
> Make it use the argument always; shorter variable names are good.
>
> Signed-off-by: George Spelvin <linux@horizon.com>
> ---
> While poking about in the code, I came across this rather odd bit.
> It looked worth fixing, on general principles.
>
> diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
> index 419a52cecd..1a2aad3fff 100644
> --- a/kernel/time/ntp.c
> +++ b/kernel/time/ntp.c
> @@ -165,21 +165,21 @@ static inline void pps_set_freq(s64 freq)
>  
>  static inline int is_error_status(int status)
>  {
> -	return (time_status & (STA_UNSYNC|STA_CLOCKERR))
> +	return (status & (STA_UNSYNC|STA_CLOCKERR))
>  		/* PPS signal lost when either PPS time or
>  		 * PPS frequency synchronization requested
>  		 */
> -		|| ((time_status & (STA_PPSFREQ|STA_PPSTIME))
> -			&& !(time_status & STA_PPSSIGNAL))
> +		|| ((status & (STA_PPSFREQ|STA_PPSTIME))
> +			&& !(status & STA_PPSSIGNAL))
>  		/* PPS jitter exceeded when
>  		 * PPS time synchronization requested */
> -		|| ((time_status & (STA_PPSTIME|STA_PPSJITTER))
> +		|| ((status & (STA_PPSTIME|STA_PPSJITTER))
>  			== (STA_PPSTIME|STA_PPSJITTER))
>  		/* PPS wander exceeded or calibration error when
>  		 * PPS frequency synchronization requested
>  		 */
> -		|| ((time_status & STA_PPSFREQ)
> -			&& (time_status & (STA_PPSWANDER|STA_PPSERROR)));
> +		|| ((status & STA_PPSFREQ)
> +			&& (status & (STA_PPSWANDER|STA_PPSERROR)));
>  }
>  
>  static inline void pps_fill_timex(struct timex *txc)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ntp: make is_error_status() use its argument
  2014-05-12 17:54 ` John Stultz
@ 2014-05-12 20:10   ` Alexander Gordeev
  2014-05-13  3:01   ` George Spelvin
  1 sibling, 0 replies; 5+ messages in thread
From: Alexander Gordeev @ 2014-05-12 20:10 UTC (permalink / raw)
  To: John Stultz; +Cc: George Spelvin, linux-kernel

No objections from me, of course. Good catch.

В Mon, 12 May 2014 10:54:29 -0700
John Stultz <john.stultz@linaro.org> пишет:

> On 05/12/2014 06:35 AM, George Spelvin wrote:
> > It's an inline function always called with the global time_status
> > as an argument, so there's zero functional difference, but the
> > non-CONFIG_SMP version uses the passed-in argument, while the
> > CONFIG_SMP one ignores its argument and uses the global.
> 
> CONFIG_NTP_PPS not CONFIG_SMP, right?
> 
> Good catch though, looks like the check code was re-factored out, but
> someone forgot to use the local variable.
> 
> Adding Alexander since he submitted the pps logic.
> 
> If there's no objections, I'll queue this (with a more verbose commit
> message) for 3.16
> 
> thanks
> -john
> 
> 
> >     
> > Make it use the argument always; shorter variable names are good.
> >
> > Signed-off-by: George Spelvin <linux@horizon.com>
> > ---
> > While poking about in the code, I came across this rather odd bit.
> > It looked worth fixing, on general principles.
> >
> > diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
> > index 419a52cecd..1a2aad3fff 100644
> > --- a/kernel/time/ntp.c
> > +++ b/kernel/time/ntp.c
> > @@ -165,21 +165,21 @@ static inline void pps_set_freq(s64 freq)
> >  
> >  static inline int is_error_status(int status)
> >  {
> > -	return (time_status & (STA_UNSYNC|STA_CLOCKERR))
> > +	return (status & (STA_UNSYNC|STA_CLOCKERR))
> >  		/* PPS signal lost when either PPS time or
> >  		 * PPS frequency synchronization requested
> >  		 */
> > -		|| ((time_status & (STA_PPSFREQ|STA_PPSTIME))
> > -			&& !(time_status & STA_PPSSIGNAL))
> > +		|| ((status & (STA_PPSFREQ|STA_PPSTIME))
> > +			&& !(status & STA_PPSSIGNAL))
> >  		/* PPS jitter exceeded when
> >  		 * PPS time synchronization requested */
> > -		|| ((time_status & (STA_PPSTIME|STA_PPSJITTER))
> > +		|| ((status & (STA_PPSTIME|STA_PPSJITTER))
> >  			== (STA_PPSTIME|STA_PPSJITTER))
> >  		/* PPS wander exceeded or calibration error when
> >  		 * PPS frequency synchronization requested
> >  		 */
> > -		|| ((time_status & STA_PPSFREQ)
> > -			&& (time_status &
> > (STA_PPSWANDER|STA_PPSERROR)));
> > +		|| ((status & STA_PPSFREQ)
> > +			&& (status &
> > (STA_PPSWANDER|STA_PPSERROR))); }
> >  
> >  static inline void pps_fill_timex(struct timex *txc)
> 



-- 
  Alexander

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ntp: make is_error_status() use its argument
  2014-05-12 17:54 ` John Stultz
  2014-05-12 20:10   ` Alexander Gordeev
@ 2014-05-13  3:01   ` George Spelvin
  2014-05-13  3:15     ` John Stultz
  1 sibling, 1 reply; 5+ messages in thread
From: George Spelvin @ 2014-05-13  3:01 UTC (permalink / raw)
  To: john.stultz, linux; +Cc: lasaine, linux-kernel

> CONFIG_NTP_PPS not CONFIG_SMP, right?

D'oh, yes.  I just noticed that there were two versions and one was
broken.  Somehow my search for the enclosing #ifdef was completely broken.
(I could swear I saw CONFIG_SMP, but looking now it's not even mentioned
in the file; maybe I switched editor windows?)

> Adding Alexander since he submitted the pps logic.

Thank you; some of these issues of code provenance and "who the heck do
I notify about this?" are a bit laborious to infer even with the help
of the git logs.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ntp: make is_error_status() use its argument
  2014-05-13  3:01   ` George Spelvin
@ 2014-05-13  3:15     ` John Stultz
  0 siblings, 0 replies; 5+ messages in thread
From: John Stultz @ 2014-05-13  3:15 UTC (permalink / raw)
  To: George Spelvin; +Cc: lasaine, linux-kernel

On 05/12/2014 08:01 PM, George Spelvin wrote:
>> CONFIG_NTP_PPS not CONFIG_SMP, right?
> D'oh, yes.  I just noticed that there were two versions and one was
> broken.  Somehow my search for the enclosing #ifdef was completely broken.
> (I could swear I saw CONFIG_SMP, but looking now it's not even mentioned
> in the file; maybe I switched editor windows?)

No worries. :)

>
>> Adding Alexander since he submitted the pps logic.
> Thank you; some of these issues of code provenance and "who the heck do
> I notify about this?" are a bit laborious to infer even with the help
> of the git logs.
tig blame <filename> is pretty amazing for this sort of thing.

thanks
-john


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-13  3:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-12 13:35 [PATCH] ntp: make is_error_status() use its argument George Spelvin
2014-05-12 17:54 ` John Stultz
2014-05-12 20:10   ` Alexander Gordeev
2014-05-13  3:01   ` George Spelvin
2014-05-13  3:15     ` John Stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox