From: Zhang Rui <rui.zhang@intel.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Joe Perches <joe@perches.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Eduardo Valentin <eduardo.valentin@ti.com>
Subject: Re: [PATCH] thermal: Fix KELVIN_TO_CELSIUS macro
Date: Thu, 03 Apr 2014 10:40:41 +0800 [thread overview]
Message-ID: <1396492841.2357.21.camel@rzhang1-mobl4> (raw)
In-Reply-To: <532FC307.7050202@roeck-us.net>
On Sun, 2014-03-23 at 22:30 -0700, Guenter Roeck wrote:
> On 03/23/2014 09:25 PM, Joe Perches wrote:
> > On Sun, 2014-03-23 at 21:14 -0700, Guenter Roeck wrote:
> >> It is always a good idea to use paranthesis around macro parameters
> >> to avoid undesired side effects.
> >>
> >> In this specific case, KELVIN_TO_CELSIUS() is used in
> >> drivers/platform/x86/asus-wmi.c with parameter "value & 0xFFFF",
> >> which due to operator evaluation order causes more or less random
> >> results.
> >
> > Maybe it's better to use a statement expression to avoid
> > multiple calculations of t
> >
> > Maybe;
> >
> > #define KELVIN_TO_CELSIUS(t) \
> > ({ \
> > long _t = (long)(t) - 2732; \
> > _t >= 0 ? (_t + 5) / 10 : (_t - 5) / 10; \
> > })
> >
> >
>
> Possibly, but I only want to have a bug fixed which should possibly be applied
> to -stable at some point. As such, I prefer the minimalistic approach.
> Anything more fancy on top of that can be submitted as separate patch.
>
I agreed. I will take this patch and push it for stable kernel.
thanks,
rui
prev parent reply other threads:[~2014-04-03 2:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-24 4:14 [PATCH] thermal: Fix KELVIN_TO_CELSIUS macro Guenter Roeck
2014-03-24 4:25 ` Joe Perches
2014-03-24 5:30 ` Guenter Roeck
2014-04-03 2:40 ` Zhang Rui [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=1396492841.2357.21.camel@rzhang1-mobl4 \
--to=rui.zhang@intel.com \
--cc=eduardo.valentin@ti.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@roeck-us.net \
/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;
as well as URLs for NNTP newsgroup(s).