From: Guenter Roeck <guenter.roeck@ericsson.com>
To: Ashish Jangam <Ashish.Jangam@kpitcummins.com>
Cc: Randy Dunlap <randy.dunlap@oracle.com>,
Dajun Chen <Dajun.Chen@diasemi.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>
Subject: Re: [PATCHv3 6/11] HWMON: Fixed point conversion gives linktime error
Date: Fri, 20 May 2011 07:00:45 -0700 [thread overview]
Message-ID: <20110520140045.GC23076@ericsson.com> (raw)
In-Reply-To: <E2CAE7F7B064EA49B5CE7EE9A4BB167D151BDC3D33@KCINPUNHJCMS01.kpit.com>
On Fri, May 20, 2011 at 06:57:18AM -0400, Ashish Jangam wrote:
> Hi,
>
> As requested approximation of battery temperature calculation with fixed point conversion is tried but it causes couple of link time errors, like undefined reference to __aeabi_i2d at sprintf(). Have a look at the function da9052_read_tbat(); we feel that this function should not be supported else there will be a prerequisite to the support the required floating point library. Enabling FPE_NWFPE support in the kernel gives the same link time errors.
>
You have defined
#define LOGN2 0.693147181
and use it, which makes the entire calculation a floating point calculation
and defeats the purpose. The idea would have been to define something like
#define CAL_LOG2(nr) ((int)((ilog2(nr) - ilog2(100)) * 693147181LL / 1000000000LL))
Also, there is no need for rounding, say, 0.003355705 to 0.0034, or 2.5 to 3.
Add a few digits, like above, and remove them afterwards.
x * 2.5 = x * 5 / 2.
x * 33.55705 = x * 3355705 / 100000
Just be careful that you don't get overflows.
Guenter
prev parent reply other threads:[~2011-05-20 14:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-20 10:57 Ashish Jangam
2011-05-20 14:00 ` Guenter Roeck [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=20110520140045.GC23076@ericsson.com \
--to=guenter.roeck@ericsson.com \
--cc=Ashish.Jangam@kpitcummins.com \
--cc=Dajun.Chen@diasemi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=randy.dunlap@oracle.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
Powered by JetHome