mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Qing Wang <wangqing@vivo.com>,
	Derek Chickles <dchickles@marvell.com>,
	Satanand Burla <sburla@marvell.com>,
	Felix Manlunas <fmanlunas@marvell.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: ethernet: cavium: use div64_u64() instead of do_div()
Date: Wed, 9 Feb 2022 20:11:01 +0100	[thread overview]
Message-ID: <b8cd030f-817a-4938-5d61-8046e7ccd2f3@wanadoo.fr> (raw)
In-Reply-To: <1644395960-4232-1-git-send-email-wangqing@vivo.com>

Le 09/02/2022 à 09:39, Qing Wang a écrit :
> From: Wang Qing <wangqing@vivo.com>
> 
> do_div() does a 64-by-32 division.
> When the divisor is u64, do_div() truncates it to 32 bits, this means it
> can test non-zero and be truncated to zero for division.
> 
> fix do_div.cocci warning:
> do_div() does a 64-by-32 division, please consider using div64_u64 instead.
> 
> Signed-off-by: Wang Qing <wangqing@vivo.com>
> ---
>   drivers/net/ethernet/cavium/liquidio/lio_main.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
> index ba28aa4..8e07192
> --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
> +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
> @@ -1539,7 +1539,7 @@ static int liquidio_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
>   	 * compute the delta in terms of coprocessor clocks.
>   	 */
>   	delta = (u64)ppb << 32;
> -	do_div(delta, oct->coproc_clock_rate);
> +	div64_u64(delta, oct->coproc_clock_rate);
>   
>   	spin_lock_irqsave(&lio->ptp_lock, flags);
>   	comp = lio_pci_readq(oct, CN6XXX_MIO_PTP_CLOCK_COMP);
> @@ -1672,7 +1672,7 @@ static void liquidio_ptp_init(struct octeon_device *oct)
>   	u64 clock_comp, cfg;
>   
>   	clock_comp = (u64)NSEC_PER_SEC << 32;
> -	do_div(clock_comp, oct->coproc_clock_rate);
> +	div64_u64(clock_comp, oct->coproc_clock_rate);
>   	lio_pci_writeq(oct, clock_comp, CN6XXX_MIO_PTP_CLOCK_COMP);
>   
>   	/* Enable */

I think that all your recent patches about such conversions are broken.

See [1] were it was already reported that do_div() and div64_u64() don't 
have the same calling convention.

Looks that div64_u64() and div64_ul() works the same way.


CJ

[1]: 
https://lore.kernel.org/linux-kernel/20211117112559.jix3hmx7uwqmuryg@pengutronix.de/

      parent reply	other threads:[~2022-02-09 19:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09  8:39 Qing Wang
2022-02-09 13:30 ` patchwork-bot+netdevbpf
2022-02-09 20:01   ` Christophe JAILLET
2022-02-10  2:01     ` Jakub Kicinski
2022-02-10 18:33       ` Christophe JAILLET
2022-02-09 19:11 ` Christophe JAILLET [this message]

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=b8cd030f-817a-4938-5d61-8046e7ccd2f3@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=dchickles@marvell.com \
    --cc=fmanlunas@marvell.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sburla@marvell.com \
    --cc=wangqing@vivo.com \
    /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®