All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Nguyen An Hoan <na-hoan@jinso.co.jp>,
	broonie@kernel.org, linux-renesas-soc@vger.kernel.org,
	geert+renesas@glider.be
Cc: wsa@sang-engineering.com, niklas.soderlund+renesas@ragnatech.se,
	kuninori.morimoto.gx@renesas.com,
	yoshihiro.shimoda.uh@renesas.com, magnus.damm@gmail.com,
	h-inayoshi@jinso.co.jp, nv-dung@jinso.co.jp, cv-dong@jinso.co.jp
Subject: Re: [PATCH] thermal: rcar: reduce inaccuracy in calculate rounding
Date: Thu, 30 Aug 2018 12:39:18 +0300	[thread overview]
Message-ID: <1be52c7a-9e3b-59f9-f71d-420fe0056652@cogentembedded.com> (raw)
In-Reply-To: <1535596744-16598-2-git-send-email-na-hoan@jinso.co.jp>

Hello!

On 8/30/2018 5:39 AM, Nguyen An Hoan wrote:

> From: Hoan Nguyen An <na-hoan@jinso.co.jp>
> 
> About the formula for temperature calculation
> [reg] = [temp] * a + b <=> [temp] = ([reg] - b) / a
> 
> Using "(mcelsius * tsc-> coef.aX) / 1000" instead of "DIV_ROUND_CLOSEST(mcelsius, 1000) * tsc-> coef.aX"
> to avoid and reduce inaccuracy due to rounding the integer division.
> 
> Signed-off-by: Hoan Nguyen An <na-hoan@jinso.co.jp>
> ---
>   drivers/thermal/rcar_gen3_thermal.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
> index 7aed533..dbb31b8 100644
> --- a/drivers/thermal/rcar_gen3_thermal.c
> +++ b/drivers/thermal/rcar_gen3_thermal.c
> @@ -185,11 +185,10 @@ static int rcar_gen3_thermal_get_temp(void *devdata, int *temp)
>   static int rcar_gen3_thermal_mcelsius_to_temp(struct rcar_gen3_thermal_tsc *tsc,
>   					      int mcelsius)
>   {
> -	int celsius, val1, val2;
> +	int val1, val2;
>   
> -	celsius = DIV_ROUND_CLOSEST(mcelsius, 1000);
> -	val1 = celsius * tsc->coef.a1 + tsc->coef.b1;
> -	val2 = celsius * tsc->coef.a2 + tsc->coef.b2;
> +	val1 = (mcelsius * tsc->coef.a1)/1000 + tsc->coef.b1;
> +	val2 = (mcelsius * tsc->coef.a2)/1000 + tsc->coef.b2;

    Please be consistent and enclose / in sopaces the same as you do for other 
operators.

[...]

MBR, Sergei

      parent reply	other threads:[~2018-08-30 13:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30  2:39 [PATCH] thermal: rcar: reduce inaccuracy in the calculate rounding for temperature conversion Nguyen An Hoan
2018-08-30  2:39 ` [PATCH] thermal: rcar: reduce inaccuracy in calculate rounding Nguyen An Hoan
2018-08-30  7:48   ` Geert Uytterhoeven
2018-08-30  9:39   ` Sergei Shtylyov [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=1be52c7a-9e3b-59f9-f71d-420fe0056652@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=broonie@kernel.org \
    --cc=cv-dong@jinso.co.jp \
    --cc=geert+renesas@glider.be \
    --cc=h-inayoshi@jinso.co.jp \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=na-hoan@jinso.co.jp \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=nv-dung@jinso.co.jp \
    --cc=wsa@sang-engineering.com \
    --cc=yoshihiro.shimoda.uh@renesas.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.