View Single Post
  #1023 (permalink)  
Old 01-17-2012, 01:02 AM
anish88's Avatar
anish88
PPCGeeks Regular
Offline
Location: Chicago
 
Join Date: Dec 2008
Posts: 115
Reputation: 35
anish88 is just getting started
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Re: [TESTING] - NAND OMGB (1.2.3)

Quote:
Originally Posted by [ACL] View Post
Ahh, you are correct. Well the hack was to avoid these nasty div by 0 we used to get in the logs.

Code:
diff --git a/arch/arm/mach-msm/htc_battery_smem.c b/arch/arm/mach-msm/htc_battery_smem.c
index 1d9e750..7967b28 100644
--- a/arch/arm/mach-msm/htc_battery_smem.c
+++ b/arch/arm/mach-msm/htc_battery_smem.c
@@ -1371,7 +1371,12 @@ static int htc_rhod_batt_corr( struct battery_info_reply *buffer )
        
         /* TODO: temp algo is not ok..if someone have the timte -> must look into the driver */
        buffer->batt_tempRAW = ( buffer->batt_tempRAW * 5200 ) / htc_adc_range;
-       av_index = ( buffer->batt_tempRAW * 18 ) / ( 2600 - buffer->batt_tempRAW );
+       /* HACK: This is a giant hack since if batt_tempRAW = 2600 we get a div by 0 */
+       if (buffer->batt_tempRAW < 2600) {
+               av_index = ( buffer->batt_tempRAW * 18 ) / ( 2600 - buffer->batt_tempRAW );
+       } else { 
+               av_index =1347;
+       }
        buffer->batt_tempRAW = htc_battery_temperature_lut( av_index );
        if ( buffer->batt_tempRAW < 250 ) /* fixed til so long we can get constant values - otherwise the algo wouln'T work good */
                buffer->batt_tempRAW = 250;
I'll prioritise this if everyone is getting less and less batt time now.
I'd be interested for sure. I have never gotten good battery life.
Reply With Quote