Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934569Ab1ETOBa (ORCPT ); Fri, 20 May 2011 10:01:30 -0400 Received: from imr3.ericy.com ([198.24.6.13]:45370 "EHLO imr3.ericy.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933765Ab1ETOB1 (ORCPT ); Fri, 20 May 2011 10:01:27 -0400 Date: Fri, 20 May 2011 07:00:45 -0700 From: Guenter Roeck To: Ashish Jangam CC: Randy Dunlap , Dajun Chen , "linux-kernel@vger.kernel.org" , "lm-sensors@lm-sensors.org" Subject: Re: [PATCHv3 6/11] HWMON: Fixed point conversion gives linktime error Message-ID: <20110520140045.GC23076@ericsson.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1320 Lines: 28 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/