linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: aquantia: Fix build error wihtout CONFIG_PTP_1588_CLOCK
@ 2019-10-25 13:37 YueHaibing
  2019-10-25 15:06 ` [EXT] " Igor Russkikh
  2019-10-26  8:09 ` Simon Horman
  0 siblings, 2 replies; 6+ messages in thread
From: YueHaibing @ 2019-10-25 13:37 UTC (permalink / raw)
  To: epomozov, igor.russkikh, davem, dmitry.bezrukov, sergey.samoilenko
  Cc: netdev, linux-kernel, YueHaibing

If PTP_1588_CLOCK is n, building fails:

drivers/net/ethernet/aquantia/atlantic/aq_ptp.c: In function aq_ptp_adjfine:
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c:279:11:
 error: implicit declaration of function scaled_ppm_to_ppb [-Werror=implicit-function-declaration]
           scaled_ppm_to_ppb(scaled_ppm));

Just cp scaled_ppm_to_ppb() from ptp_clock.c to fix this.

Fixes: 910479a9f793 ("net: aquantia: add basic ptp_clock callbacks")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/aquantia/atlantic/aq_ptp.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
index 3ec0841..80c001d 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
@@ -262,6 +262,26 @@ static void aq_ptp_tx_timeout_check(struct aq_ptp_s *aq_ptp)
 	}
 }
 
+static s32 scaled_ppm_to_ppb(long ppm)
+{
+	/*
+	 * The 'freq' field in the 'struct timex' is in parts per
+	 * million, but with a 16 bit binary fractional field.
+	 *
+	 * We want to calculate
+	 *
+	 *    ppb = scaled_ppm * 1000 / 2^16
+	 *
+	 * which simplifies to
+	 *
+	 *    ppb = scaled_ppm * 125 / 2^13
+	 */
+	s64 ppb = 1 + ppm;
+	ppb *= 125;
+	ppb >>= 13;
+	return (s32) ppb;
+}
+
 /* aq_ptp_adjfine
  * @ptp: the ptp clock structure
  * @ppb: parts per billion adjustment from base
-- 
2.7.4



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

* Re: [EXT] [PATCH net-next] net: aquantia: Fix build error wihtout CONFIG_PTP_1588_CLOCK
  2019-10-25 13:37 [PATCH net-next] net: aquantia: Fix build error wihtout CONFIG_PTP_1588_CLOCK YueHaibing
@ 2019-10-25 15:06 ` Igor Russkikh
  2019-10-26  8:09 ` Simon Horman
  1 sibling, 0 replies; 6+ messages in thread
From: Igor Russkikh @ 2019-10-25 15:06 UTC (permalink / raw)
  To: YueHaibing, Egor Pomozov, davem, Dmitry Bezrukov, Sergey Samoilenko
  Cc: netdev, linux-kernel


> If PTP_1588_CLOCK is n, building fails:
> 
> drivers/net/ethernet/aquantia/atlantic/aq_ptp.c: In function aq_ptp_adjfine:
> drivers/net/ethernet/aquantia/atlantic/aq_ptp.c:279:11:
>  error: implicit declaration of function scaled_ppm_to_ppb [-Werror=implicit-function-declaration]
>            scaled_ppm_to_ppb(scaled_ppm));

Hi Yue,

Thanks for noticing this. It seems I've added scaled_ppm_to_ppb usage but did
not checked PTP_1588_CLOCK=n case after that.

> 
> Just cp scaled_ppm_to_ppb() from ptp_clock.c to fix this.

I'm honestly not sure if duplicating the code is a good way here.
I'll think on how to exclude at_ptp at all on such a config.

Regards,
  Igor

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

* Re: [PATCH net-next] net: aquantia: Fix build error wihtout CONFIG_PTP_1588_CLOCK
  2019-10-25 13:37 [PATCH net-next] net: aquantia: Fix build error wihtout CONFIG_PTP_1588_CLOCK YueHaibing
  2019-10-25 15:06 ` [EXT] " Igor Russkikh
@ 2019-10-26  8:09 ` Simon Horman
  2019-10-26  8:57   ` Yuehaibing
  1 sibling, 1 reply; 6+ messages in thread
From: Simon Horman @ 2019-10-26  8:09 UTC (permalink / raw)
  To: YueHaibing
  Cc: epomozov, igor.russkikh, davem, dmitry.bezrukov,
	sergey.samoilenko, netdev, linux-kernel

On Fri, Oct 25, 2019 at 09:37:26PM +0800, YueHaibing wrote:
> If PTP_1588_CLOCK is n, building fails:
> 
> drivers/net/ethernet/aquantia/atlantic/aq_ptp.c: In function aq_ptp_adjfine:
> drivers/net/ethernet/aquantia/atlantic/aq_ptp.c:279:11:
>  error: implicit declaration of function scaled_ppm_to_ppb [-Werror=implicit-function-declaration]
>            scaled_ppm_to_ppb(scaled_ppm));
> 
> Just cp scaled_ppm_to_ppb() from ptp_clock.c to fix this.
> 
> Fixes: 910479a9f793 ("net: aquantia: add basic ptp_clock callbacks")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Hi YueHaibing,

thanks for your patch.

What is the motivation for not using the existing copy of this function?

> ---
>  drivers/net/ethernet/aquantia/atlantic/aq_ptp.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
> index 3ec0841..80c001d 100644
> --- a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
> +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
> @@ -262,6 +262,26 @@ static void aq_ptp_tx_timeout_check(struct aq_ptp_s *aq_ptp)
>  	}
>  }
>  
> +static s32 scaled_ppm_to_ppb(long ppm)
> +{
> +	/*
> +	 * The 'freq' field in the 'struct timex' is in parts per
> +	 * million, but with a 16 bit binary fractional field.
> +	 *
> +	 * We want to calculate
> +	 *
> +	 *    ppb = scaled_ppm * 1000 / 2^16
> +	 *
> +	 * which simplifies to
> +	 *
> +	 *    ppb = scaled_ppm * 125 / 2^13
> +	 */
> +	s64 ppb = 1 + ppm;
> +	ppb *= 125;
> +	ppb >>= 13;
> +	return (s32) ppb;
> +}
> +
>  /* aq_ptp_adjfine
>   * @ptp: the ptp clock structure
>   * @ppb: parts per billion adjustment from base
> -- 
> 2.7.4
> 
> 

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

* Re: [PATCH net-next] net: aquantia: Fix build error wihtout CONFIG_PTP_1588_CLOCK
  2019-10-26  8:09 ` Simon Horman
@ 2019-10-26  8:57   ` Yuehaibing
  2019-10-26 11:09     ` [EXT] " Igor Russkikh
  0 siblings, 1 reply; 6+ messages in thread
From: Yuehaibing @ 2019-10-26  8:57 UTC (permalink / raw)
  To: Simon Horman
  Cc: epomozov, igor.russkikh, davem, dmitry.bezrukov,
	sergey.samoilenko, netdev, linux-kernel

On 2019/10/26 16:09, Simon Horman wrote:
> On Fri, Oct 25, 2019 at 09:37:26PM +0800, YueHaibing wrote:
>> If PTP_1588_CLOCK is n, building fails:
>>
>> drivers/net/ethernet/aquantia/atlantic/aq_ptp.c: In function aq_ptp_adjfine:
>> drivers/net/ethernet/aquantia/atlantic/aq_ptp.c:279:11:
>>  error: implicit declaration of function scaled_ppm_to_ppb [-Werror=implicit-function-declaration]
>>            scaled_ppm_to_ppb(scaled_ppm));
>>
>> Just cp scaled_ppm_to_ppb() from ptp_clock.c to fix this.
>>
>> Fixes: 910479a9f793 ("net: aquantia: add basic ptp_clock callbacks")
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> 
> Hi YueHaibing,
> 
> thanks for your patch.
> 
> What is the motivation for not using the existing copy of this function?

I'm not sure if PTP_1588_CLOCK is needed at this config,
using the existing function need to PTP_1588_CLOCK is selected.

> 
>> ---
>>  drivers/net/ethernet/aquantia/atlantic/aq_ptp.c | 20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
>> index 3ec0841..80c001d 100644
>> --- a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
>> +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
>> @@ -262,6 +262,26 @@ static void aq_ptp_tx_timeout_check(struct aq_ptp_s *aq_ptp)
>>  	}
>>  }
>>  
>> +static s32 scaled_ppm_to_ppb(long ppm)
>> +{
>> +	/*
>> +	 * The 'freq' field in the 'struct timex' is in parts per
>> +	 * million, but with a 16 bit binary fractional field.
>> +	 *
>> +	 * We want to calculate
>> +	 *
>> +	 *    ppb = scaled_ppm * 1000 / 2^16
>> +	 *
>> +	 * which simplifies to
>> +	 *
>> +	 *    ppb = scaled_ppm * 125 / 2^13
>> +	 */
>> +	s64 ppb = 1 + ppm;
>> +	ppb *= 125;
>> +	ppb >>= 13;
>> +	return (s32) ppb;
>> +}
>> +
>>  /* aq_ptp_adjfine
>>   * @ptp: the ptp clock structure
>>   * @ppb: parts per billion adjustment from base
>> -- 
>> 2.7.4
>>
>>
> 
> .
> 


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

* Re: [EXT] Re: [PATCH net-next] net: aquantia: Fix build error wihtout CONFIG_PTP_1588_CLOCK
  2019-10-26  8:57   ` Yuehaibing
@ 2019-10-26 11:09     ` Igor Russkikh
  2019-10-28  7:49       ` Yuehaibing
  0 siblings, 1 reply; 6+ messages in thread
From: Igor Russkikh @ 2019-10-26 11:09 UTC (permalink / raw)
  To: Yuehaibing, Simon Horman
  Cc: Egor Pomozov, davem, Dmitry Bezrukov, Sergey Samoilenko, netdev,
	linux-kernel


>> Hi YueHaibing,
>>
>> thanks for your patch.
>>
>> What is the motivation for not using the existing copy of this function?
> 
> I'm not sure if PTP_1588_CLOCK is needed at this config,
> using the existing function need to PTP_1588_CLOCK is selected.

Hi YueHaibing,

Please checkout this patch: https://patchwork.ozlabs.org/patch/1184620/

It fixes the problem without duplicating the function.

Regards,
  Igor

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

* Re: [EXT] Re: [PATCH net-next] net: aquantia: Fix build error wihtout CONFIG_PTP_1588_CLOCK
  2019-10-26 11:09     ` [EXT] " Igor Russkikh
@ 2019-10-28  7:49       ` Yuehaibing
  0 siblings, 0 replies; 6+ messages in thread
From: Yuehaibing @ 2019-10-28  7:49 UTC (permalink / raw)
  To: Igor Russkikh, Simon Horman
  Cc: Egor Pomozov, davem, Dmitry Bezrukov, Sergey Samoilenko, netdev,
	linux-kernel

On 2019/10/26 19:09, Igor Russkikh wrote:
> 
>>> Hi YueHaibing,
>>>
>>> thanks for your patch.
>>>
>>> What is the motivation for not using the existing copy of this function?
>>
>> I'm not sure if PTP_1588_CLOCK is needed at this config,
>> using the existing function need to PTP_1588_CLOCK is selected.
> 
> Hi YueHaibing,
> 
> Please checkout this patch: https://patchwork.ozlabs.org/patch/1184620/
> 
> It fixes the problem without duplicating the function.

Yes, this fix the issue.

> 
> Regards,
>   Igor
> 
> 


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

end of thread, other threads:[~2019-10-28  7:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 13:37 [PATCH net-next] net: aquantia: Fix build error wihtout CONFIG_PTP_1588_CLOCK YueHaibing
2019-10-25 15:06 ` [EXT] " Igor Russkikh
2019-10-26  8:09 ` Simon Horman
2019-10-26  8:57   ` Yuehaibing
2019-10-26 11:09     ` [EXT] " Igor Russkikh
2019-10-28  7:49       ` Yuehaibing

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).