Skip to contentSkip to conversation

power: bq20z75: Fix time and temp units

PATCH Superseded Benson Leung 3 participants 6 messages Feb 28, 2011 – Mar 16, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: bq20z75: Fix time and temp units

Corrected temperature and time to empty/full conversions. Temperature is in 0.1°C, time is in seconds.

---
 drivers/power/bq20z75.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
drivers/power/bq20z75.c +12 -6
index 4141775..998123e 100644
@@ -269,12 +269,15 @@ static void  bq20z75_unit_adjustment(struct i2c_client *client,
 {
 #define BASE_UNIT_CONVERSION		1000
 #define BATTERY_MODE_CAP_MULT_WATT	(10 * BASE_UNIT_CONVERSION)
-#define TIME_UNIT_CONVERSION		600
-#define TEMP_KELVIN_TO_CELCIUS		2731
+#define TIME_UNIT_CONVERSION		60
+#define TEMP_KELVIN_TO_CELSIUS		2731
 	switch (psp) {
 	case POWER_SUPPLY_PROP_ENERGY_NOW:
 	case POWER_SUPPLY_PROP_ENERGY_FULL:
 	case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
+		/* bq20z75 provides energy in units of 10mWh.
+		 * Convert to µW
+		 */
 		val->intval *= BATTERY_MODE_CAP_MULT_WATT;
 		break;
 
@@ -288,14 +291,17 @@ static void  bq20z75_unit_adjustment(struct i2c_client *client,
 		break;
 
 	case POWER_SUPPLY_PROP_TEMP:
-		/* bq20z75 provides battery tempreture in 0.1°K
-		 * so convert it to 0.1°C */
-		val->intval -= TEMP_KELVIN_TO_CELCIUS;
-		val->intval *= 10;
+		/* bq20z75 provides battery temperature in 0.1K
+		 * so convert it to 0.1°C
+		 */
+		val->intval -= TEMP_KELVIN_TO_CELSIUS;
 		break;
 
 	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
 	case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
+		/* bq20z75 provides time to empty and time to full in minutes.
+		 * Convert to seconds
+		 */
 		val->intval *= TIME_UNIT_CONVERSION;
 		break;
 
Signature · 1 line
1.7.1
#1 lore raw

PATCH RESEND 1/1 power: bq20z75: Fix time and temp units

Fixed incorrect comment.

#2 lore raw

PATCH 1/1 power: bq20z75: Fix time and temp units

In reply to Benson Leung

Corrected temperature and time to empty/full conversions. Temperature is in 0.1°C, time is in seconds.

Corrected units in comment. "Convert to µWh."

---
 drivers/power/bq20z75.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
drivers/power/bq20z75.c +12 -6
index 4141775..123e169 100644
@@ -269,12 +269,15 @@ static void  bq20z75_unit_adjustment(struct i2c_client *client,
 {
 #define BASE_UNIT_CONVERSION		1000
 #define BATTERY_MODE_CAP_MULT_WATT	(10 * BASE_UNIT_CONVERSION)
-#define TIME_UNIT_CONVERSION		600
-#define TEMP_KELVIN_TO_CELCIUS		2731
+#define TIME_UNIT_CONVERSION		60
+#define TEMP_KELVIN_TO_CELSIUS		2731
 	switch (psp) {
 	case POWER_SUPPLY_PROP_ENERGY_NOW:
 	case POWER_SUPPLY_PROP_ENERGY_FULL:
 	case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
+		/* bq20z75 provides energy in units of 10mWh.
+		 * Convert to µWh
+		 */
 		val->intval *= BATTERY_MODE_CAP_MULT_WATT;
 		break;
 
@@ -288,14 +291,17 @@ static void  bq20z75_unit_adjustment(struct i2c_client *client,
 		break;
 
 	case POWER_SUPPLY_PROP_TEMP:
-		/* bq20z75 provides battery tempreture in 0.1°K
-		 * so convert it to 0.1°C */
-		val->intval -= TEMP_KELVIN_TO_CELCIUS;
-		val->intval *= 10;
+		/* bq20z75 provides battery temperature in 0.1K
+		 * so convert it to 0.1°C
+		 */
+		val->intval -= TEMP_KELVIN_TO_CELSIUS;
 		break;
 
 	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
 	case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
+		/* bq20z75 provides time to empty and time to full in minutes.
+		 * Convert to seconds
+		 */
 		val->intval *= TIME_UNIT_CONVERSION;
 		break;
 
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#3 lore raw
Quoted 44 lines · Benson Leung

Corrected temperature and time to empty/full conversions. Temperature is in 0.1°C, time is in seconds.

Corrected units in comment. "Convert to µWh."

---
 drivers/power/bq20z75.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
drivers/power/bq20z75.c +9 -6
index 4141775..123e169 100644
@@ -269,12 +269,15 @@ static void  bq20z75_unit_adjustment(struct i2c_client *client,
 {
 #define BASE_UNIT_CONVERSION		1000
 #define BATTERY_MODE_CAP_MULT_WATT	(10 * BASE_UNIT_CONVERSION)
-#define TIME_UNIT_CONVERSION		600
-#define TEMP_KELVIN_TO_CELCIUS		2731
+#define TIME_UNIT_CONVERSION		60
+#define TEMP_KELVIN_TO_CELSIUS		2731
 	switch (psp) {
 	case POWER_SUPPLY_PROP_ENERGY_NOW:
 	case POWER_SUPPLY_PROP_ENERGY_FULL:
 	case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
+		/* bq20z75 provides energy in units of 10mWh.
+		 * Convert to µWh
+		 */
 		val->intval *= BATTERY_MODE_CAP_MULT_WATT;
 		break;
 
@@ -288,14 +291,17 @@ static void  bq20z75_unit_adjustment(struct i2c_client *client,
 		break;
 
 	case POWER_SUPPLY_PROP_TEMP:
-		/* bq20z75 provides battery tempreture in 0.1°K
-		 * so convert it to 0.1°C */
-		val->intval -= TEMP_KELVIN_TO_CELCIUS;
-		val->intval *= 10;
+		/* bq20z75 provides battery temperature in 0.1K
+		 * so convert it to 0.1°C
+		 */
+		val->intval -= TEMP_KELVIN_TO_CELSIUS;

drivers/power/bq20z75.c static void bq20z75_unit_adjustment(struct i2c_client *client, · line 307

Quoted 10 lines
drivers/power/bq20z75.c +3 -0
 		break;
 
 	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
 	case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
+		/* bq20z75 provides time to empty and time to full in minutes.
+		 * Convert to seconds
+		 */
 		val->intval *= TIME_UNIT_CONVERSION;
 		break;
 

LGTM

#4 lore raw

Hi Anton,

Rhyland has LGTM'd my change to the bq20z75 driver to fix temperature and time units. Can it go upstream?

Thanks,
Benson

Quoted 59 lines · Rhyland Klein
Quoted 46 lines · Benson Leung

Corrected temperature and time to empty/full conversions. Temperature is in 0.1°C, time is in seconds.

Corrected units in comment. "Convert to µWh."

---
 drivers/power/bq20z75.c |   18 ++++++++++++------

 1 files changed, 12 insertions(+), 6 deletions(-)
drivers/power/bq20z75.c +2 -2
index 4141775..123e169 100644
@@ -269,12 +269,15 @@ static void  bq20z75_unit_adjustment(struct i2c_client *client,
  {
  #define BASE_UNIT_CONVERSION         1000
  #define BATTERY_MODE_CAP_MULT_WATT   (10 * BASE_UNIT_CONVERSION)
-#define TIME_UNIT_CONVERSION         600
-#define TEMP_KELVIN_TO_CELCIUS               2731
+#define TIME_UNIT_CONVERSION         60
+#define TEMP_KELVIN_TO_CELSIUS               2731
       switch (psp) {

      case POWER_SUPPLY_PROP_ENERGY_NOW:
      case POWER_SUPPLY_PROP_ENERGY_FULL:
      case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
+             /* bq20z75 provides energy in units of 10mWh.
+              * Convert to µWh
+              */
              val->intval *= BATTERY_MODE_CAP_MULT_WATT; break;

drivers/power/bq20z75.c +0 -0
@@ -288,14 +291,17 @@ static void  bq20z75_unit_adjustment(struct i2c_client *client,
               break;
 

      case POWER_SUPPLY_PROP_TEMP:
-             /* bq20z75 provides battery tempreture in 0.1°K
-              * so convert it to 0.1°C */
-             val->intval -= TEMP_KELVIN_TO_CELCIUS;
-             val->intval *= 10;
+             /* bq20z75 provides battery temperature in 0.1K
+              * so convert it to 0.1°C
+              */
+             val->intval -= TEMP_KELVIN_TO_CELSIUS; break;

Quoted 8 lines

      case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
      case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
+             /* bq20z75 provides time to empty and time to full in minutes.
+              * Convert to seconds
+              */
              val->intval *= TIME_UNIT_CONVERSION;
              break;

LGTM

Quoted 3 lines

--
Benson Leung
Software Engineer, Chrom* OS
[email protected]

#5 lore raw
Quoted 4 lines · Benson Leung

Hi Anton,

Rhyland has LGTM'd my change to the bq20z75 driver to fix temperature and time units. Can it go upstream?

Sorry for the delay, the patch is now applied.

Thanks!

Signature · 2 lines
Anton Vorontsov
Email: [email protected]