All pastes #446727 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-04-18 17:05 UTC
rendered paste body
--- ds2760_battery.c.old	2007-04-13 18:18:11.000000000 +0200
+++ ds2760_battery.c	2007-04-18 18:13:25.000000000 +0200
@@ -125,6 +125,10 @@
 		       (unsigned int)di->w1_dev);
 		return 1;
 	}
+	
+	if ((di->raw[DS2760_VOLTAGE_MSB] == 0xff && di->raw[DS2760_VOLTAGE_LSB] == 0xff) ||
+	    (di->raw[DS2760_VOLTAGE_MSB] == 0x00 && di->raw[DS2760_VOLTAGE_LSB] == 0x00))
+		return 1;
 
 	di->update_time = jiffies;
 
@@ -140,7 +144,7 @@
 	di->current_raw =
 	    (((signed char)di->raw[DS2760_CURRENT_MSB]) << 5) |
 	                  (di->raw[DS2760_CURRENT_LSB] >> 3);
-	di->current_mA = (di->current_raw / 2) + (di->current_raw / 8);
+	di->current_mA = - (di->current_raw / 2) + (di->current_raw / 8);
 
 	/* DS2760 reports accumulated current in signed units of 0.25mAh. */
 	di->accum_current_raw =
@@ -192,7 +196,7 @@
 		di->rem_capacity = 100;
 
 	if (di->current_mA)
-		di->life_min = -((di->accum_current_mAh - di->empty_mAh) *
+		di->life_min = ((di->accum_current_mAh - di->empty_mAh) *
 		                 60) / di->current_mA;
 	else
 		di->life_min = 0;
@@ -210,18 +214,18 @@
 		di->full_counter = 0;
 
 	if (battery_is_external_power_supplied(&di->batt_cdev)) {
-		if (di->current_mA > 10) {
+		if (di->current_mA < -10) {
 			di->charge_status = BATTERY_STATUS_CHARGING;
 			di->full_counter = 0;
 		}
-		else if (di->current_mA < -5) {
+		else if (di->current_mA > 5) {
 			if (di->charge_status != BATTERY_STATUS_DISCHARGING)
 				printk(KERN_WARNING "%s: not enough power to "
 				       "charge\n", di->bi->name);
 			di->charge_status = BATTERY_STATUS_DISCHARGING;
 			di->full_counter = 0;
 		}
-		else if (di->current_mA < 10 &&
+		else if (di->current_mA > -10 &&
 		            di->charge_status != BATTERY_STATUS_FULL) {
 
 			/* Don't consider the battery to be full unless