From: Hans Verkuil <hverkuil@xs4all.nl>
To: Qing Wang <wangqing@vivo.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: dvb-frontends: use div64_u64() instead of do_div()
Date: Fri, 18 Feb 2022 11:49:42 +0100 [thread overview]
Message-ID: <c78ed114-b838-e030-a235-f4de9c88e71e@xs4all.nl> (raw)
In-Reply-To: <1644395896-4036-1-git-send-email-wangqing@vivo.com>
On 09/02/2022 09:38, Qing Wang wrote:
> 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/media/dvb-frontends/tda10048.c | 2 +-
> drivers/media/dvb-frontends/tda18271c2dd.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c
> index d1d206e..1ce2e67
> --- a/drivers/media/dvb-frontends/tda10048.c
> +++ b/drivers/media/dvb-frontends/tda10048.c
> @@ -344,7 +344,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz,
> z = 7 * sample_freq_hz;
> do_div(t, z);
> t += 5;
> - do_div(t, 10);
> + div64_u64(t, 10);
This makes no sense, I think you intended to convert the previous do_div(t, z).
>
> tda10048_writereg(state, TDA10048_TIME_WREF_LSB, (u8)t);
> tda10048_writereg(state, TDA10048_TIME_WREF_MID1, (u8)(t >> 8));
> diff --git a/drivers/media/dvb-frontends/tda18271c2dd.c b/drivers/media/dvb-frontends/tda18271c2dd.c
> index a3483448..fd92878
> --- a/drivers/media/dvb-frontends/tda18271c2dd.c
> +++ b/drivers/media/dvb-frontends/tda18271c2dd.c
> @@ -328,7 +328,7 @@ static int CalcMainPLL(struct tda_state *state, u32 freq)
>
> OscFreq = (u64) freq * (u64) Div;
> OscFreq *= (u64) 16384;
> - do_div(OscFreq, (u64)16000000);
> + do_div(OscFreq, 16000000);
> MainDiv = OscFreq;
>
> state->m_Regs[MPD] = PostDiv & 0x77;
> @@ -352,7 +352,7 @@ static int CalcCalPLL(struct tda_state *state, u32 freq)
> OscFreq = (u64)freq * (u64)Div;
> /* CalDiv = u32( OscFreq * 16384 / 16000000 ); */
> OscFreq *= (u64)16384;
> - do_div(OscFreq, (u64)16000000);
> + do_div(OscFreq, 16000000);
> CalDiv = OscFreq;
>
> state->m_Regs[CPD] = PostDiv;
The changes here do not match with the subject line of this patch.
I think it is best to split this into two patches, one for each source.
Regards,
Hans
prev parent reply other threads:[~2022-02-18 10:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-09 8:38 Qing Wang
2022-02-18 10:49 ` Hans Verkuil [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=c78ed114-b838-e030-a235-f4de9c88e71e@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--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®