public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Kang Minchul <tegongkang@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
Cc: Dan Carpenter <error27@gmail.com>,
	Sidong Yang <realwakka@gmail.com>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	Kang Minchul <tegongkang@gmail.com>
Subject: [PATCH] staging: pi433: Use div64_u64 instead of do_div
Date: Wed, 19 Oct 2022 18:40:15 +0900	[thread overview]
Message-ID: <20221019094015.832398-1-tegongkang@gmail.com> (raw)

This commit removes warning generated by cocci as follows:

do_div() does a 64-by-32 division, please consider using div64_u64 instead.

Using div64_u64 instead of do_div can avoid potential truncation.

Signed-off-by: Kang Minchul <tegongkang@gmail.com>
---
 drivers/staging/pi433/rf69.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 8c7fab6a46bb..683dd94489f9 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -252,11 +252,11 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation)
 
 	// calculat f step
 	f_step = F_OSC * factor;
-	do_div(f_step, 524288); //  524288 = 2^19
+	div64_u64(f_step, 524288); //  524288 = 2^19
 
 	// calculate register settings
 	f_reg = deviation * factor;
-	do_div(f_reg, f_step);
+	div64_u64(f_reg, f_step);
 
 	msb = (f_reg & 0xff00) >> 8;
 	lsb = (f_reg & 0xff);
@@ -291,7 +291,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency)
 
 	// calculat f step
 	f_step = F_OSC * factor;
-	do_div(f_step, 524288); //  524288 = 2^19
+	div64_u64(f_step, 524288); //  524288 = 2^19
 
 	// check input value
 	f_max = div_u64(f_step * 8388608, factor);
@@ -302,7 +302,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency)
 
 	// calculate reg settings
 	f_reg = frequency * factor;
-	do_div(f_reg, f_step);
+	div64_u64(f_reg, f_step);
 
 	msb = (f_reg & 0xff0000) >> 16;
 	mid = (f_reg & 0xff00)   >>  8;
-- 
2.34.1


             reply	other threads:[~2022-10-19  9:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19  9:40 Kang Minchul [this message]
2022-10-19 10:31 ` [PATCH] staging: pi433: Use div64_u64 instead of do_div David Laight
2022-10-19 14:20   ` Kang Minchul

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=20221019094015.832398-1-tegongkang@gmail.com \
    --to=tegongkang@gmail.com \
    --cc=error27@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=paulo.miguel.almeida.rodenas@gmail.com \
    --cc=realwakka@gmail.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