From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org,
Nicolas Pitre <nicolas.pitre@linaro.org>,
Stefan Richter <stefanr@s5r6.in-berlin.de>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [media] zl10353: use div_u64 instead of do_div
Date: Fri, 12 Feb 2016 14:32:20 -0200 [thread overview]
Message-ID: <20160212143220.5a440e66@recife.lan> (raw)
In-Reply-To: <1455287246-3540549-1-git-send-email-arnd@arndb.de>
Em Fri, 12 Feb 2016 15:27:18 +0100
Arnd Bergmann <arnd@arndb.de> escreveu:
> I noticed a build error in some randconfig builds in the zl10353 driver:
>
> dvb-frontends/zl10353.c:138: undefined reference to `____ilog2_NaN'
> dvb-frontends/zl10353.c:138: undefined reference to `__aeabi_uldivmod'
>
> The problem can be tracked down to the use of -fprofile-arcs (using
> CONFIG_GCOV_PROFILE_ALL) in combination with CONFIG_PROFILE_ALL_BRANCHES
> on gcc version 4.9 or higher, when it fails to reliably optimize
> constant expressions.
>
> Using div_u64() instead of do_div() makes the code slightly more
> readable by both humans and by gcc, which gives the compiler enough
> of a break to figure it all out.
I'm not against this patch, but we have 94 occurrences of do_div()
just at the media subsystem. If this is failing here, it would likely
fail with other drivers. So, I guess we should either fix do_div() or
convert all such occurrences to do_div64().
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/media/dvb-frontends/zl10353.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/dvb-frontends/zl10353.c b/drivers/media/dvb-frontends/zl10353.c
> index ef9764a02d4c..160c88710553 100644
> --- a/drivers/media/dvb-frontends/zl10353.c
> +++ b/drivers/media/dvb-frontends/zl10353.c
> @@ -135,8 +135,7 @@ static void zl10353_calc_nominal_rate(struct dvb_frontend *fe,
>
> value = (u64)10 * (1 << 23) / 7 * 125;
> value = (bw * value) + adc_clock / 2;
> - do_div(value, adc_clock);
> - *nominal_rate = value;
> + *nominal_rate = div_u64(value, adc_clock);
>
> dprintk("%s: bw %d, adc_clock %d => 0x%x\n",
> __func__, bw, adc_clock, *nominal_rate);
> @@ -163,8 +162,7 @@ static void zl10353_calc_input_freq(struct dvb_frontend *fe,
> if (ife > adc_clock / 2)
> ife = adc_clock - ife;
> }
> - value = (u64)65536 * ife + adc_clock / 2;
> - do_div(value, adc_clock);
> + value = div_u64((u64)65536 * ife + adc_clock / 2, adc_clock);
> *input_freq = -value;
>
> dprintk("%s: if2 %d, ife %d, adc_clock %d => %d / 0x%x\n",
next prev parent reply other threads:[~2016-02-12 16:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-12 14:27 [PATCH] [media] zl10353: use div_u64 instead of do_div Arnd Bergmann
2016-02-12 16:32 ` Mauro Carvalho Chehab [this message]
2016-02-12 17:04 ` Arnd Bergmann
2016-02-12 18:21 ` Nicolas Pitre
2016-02-12 21:01 ` Arnd Bergmann
2016-02-12 21:38 ` Nicolas Pitre
2016-02-12 21:45 ` Arnd Bergmann
2016-02-13 8:39 ` Ard Biesheuvel
2016-02-13 21:57 ` Nicolas Pitre
2016-02-14 7:57 ` Ard Biesheuvel
2016-02-14 16:52 ` Nicolas Pitre
2016-02-14 19:06 ` Ard Biesheuvel
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=20160212143220.5a440e66@recife.lan \
--to=mchehab@osg.samsung.com \
--cc=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=nicolas.pitre@linaro.org \
--cc=stefanr@s5r6.in-berlin.de \
/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