Skip to contentSkip to conversation

battery: max17042: Fix temperature unit to milli centigrade.

PATCH In review Jonghwa Lee 3 participants 8 messages Oct 25, 2013 – Oct 29, 2013 Suspend to RAM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 battery: max17042: Fix temperature unit to milli centigrade.

Standard temp node represents temperature of power supply class in milli centigrade. So fix max17042 fuel gauge driver to follow the standard. (deci-centigrade --> milli-centigrade)

---
 drivers/power/max17042_battery.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/max17042_battery.c +2 -2
index d664ef5..892ecfc 100644
@@ -220,9 +220,9 @@ static int max17042_get_property(struct power_supply *psy,
 			val->intval = (0x7fff & ~val->intval) + 1;
 			val->intval *= -1;
 		}
-		/* The value is converted into deci-centigrade scale */
+		/* The value is converted into milli-centigrade scale */
 		/* Units of LSB = 1 / 256 degree Celsius */
-		val->intval = val->intval * 10 / 256;
+		val->intval = val->intval * 1000 / 256;
 		break;
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
 		if (chip->pdata->enable_current_sense) {
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 3 lines · Jonghwa Lee

Standard temp node represents temperature of power supply class in milli centigrade. So fix max17042 fuel gauge driver to follow the standard. (deci-centigrade --> milli-centigrade)

Maybe I am confused, but the doc says:

* All voltages, currents, charges, energies, time and temperatures in uV,
* µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise
* stated

So, the current code seems to be correct.

Thanks,

Anton

Quoted 24 lines
---
 drivers/power/max17042_battery.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/max17042_battery.c +2 -2
index d664ef5..892ecfc 100644
@@ -220,9 +220,9 @@ static int max17042_get_property(struct power_supply *psy,
 			val->intval = (0x7fff & ~val->intval) + 1;
 			val->intval *= -1;
 		}
-		/* The value is converted into deci-centigrade scale */
+		/* The value is converted into milli-centigrade scale */
 		/* Units of LSB = 1 / 256 degree Celsius */
-		val->intval = val->intval * 10 / 256;
+		val->intval = val->intval * 1000 / 256;
 		break;
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
 		if (chip->pdata->enable_current_sense) {
Signature · 1 line
1.7.9.5
#2 lore raw

Hi,

Quoted 5 lines · Anton Vorontsov
Quoted 3 lines · Jonghwa Lee

Standard temp node represents temperature of power supply class in milli centigrade. So fix max17042 fuel gauge driver to follow the standard. (deci-centigrade --> milli-centigrade)

Quoted 8 lines

Maybe I am confused, but the doc says:

* All voltages, currents, charges, energies, time and temperatures in uV,
* µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise
* stated

So, the current code seems to be correct.

Honestly, I missed the above paragraph you showed rather I read following one.

TEMP - temperature of the power supply.
TEMP_ALERT_MIN - minimum battery temperature alert value in milli centigrade. TEMP_ALERT_MAX - maximum battery temperature alert value in milli centigrade. TEMP_AMBIENT - ambient temperature.
TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert value in milli centigrade.
TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert value in milli centigrade.

So, we use different unit for properties related temperature, right? current temperature is in tenth of centigrade and threshold temperatures and ambient temperature are in milli centigrade. Wouldn't it have to be in same unit?

Thanks,
Jonghwa

Quoted 29 lines

Thanks,

Anton

Quoted 24 lines
---
 drivers/power/max17042_battery.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/max17042_battery.c +2 -2
index d664ef5..892ecfc 100644
@@ -220,9 +220,9 @@ static int max17042_get_property(struct power_supply *psy,
 			val->intval = (0x7fff & ~val->intval) + 1;
 			val->intval *= -1;
 		}
-		/* The value is converted into deci-centigrade scale */
+		/* The value is converted into milli-centigrade scale */
 		/* Units of LSB = 1 / 256 degree Celsius */
-		val->intval = val->intval * 10 / 256;
+		val->intval = val->intval * 1000 / 256;
 		break;
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
 		if (chip->pdata->enable_current_sense) {
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 1/1 power_supply: Fix documentation for TEMP_*ALERT* properties

All temperatures should be in tenth degrees Celsius.

bq24190_charger.c probably should be fixed.

---

Quoted 17 lines · On Mon, Oct 28, 2013 at 11:00:52AM +0900, [email protected] wrote:
Quoted 5 lines

* All voltages, currents, charges, energies, time and temperatures in uV,
* µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise
* stated

So, the current code seems to be correct.

Honestly, I missed the above paragraph you showed rather I read following one.

TEMP - temperature of the power supply.
TEMP_ALERT_MIN - minimum battery temperature alert value in milli centigrade. TEMP_ALERT_MAX - maximum battery temperature alert value in milli centigrade. TEMP_AMBIENT - ambient temperature.
TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert value in milli centigrade.
TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert value in milli centigrade.

Quoted 3 lines

So, we use different unit for properties related temperature, right? current temperature is in tenth of centigrade and threshold temperatures and ambient temperature are in milli centigrade. Wouldn't it have to be in same unit?

:( They should. Thanks for spotting.

The patch down below should fix the issue...

Documentation/power/power_supply_class.txt | 8 ++++----

 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/power/power_supply_class.txt +4 -4
index 3f10b39..89a8816 100644
@@ -135,11 +135,11 @@ CAPACITY_LEVEL - capacity level. This corresponds to
 POWER_SUPPLY_CAPACITY_LEVEL_*.
 
 TEMP - temperature of the power supply.
-TEMP_ALERT_MIN - minimum battery temperature alert value in milli centigrade.
-TEMP_ALERT_MAX - maximum battery temperature alert value in milli centigrade.
+TEMP_ALERT_MIN - minimum battery temperature alert.
+TEMP_ALERT_MAX - maximum battery temperature alert.
 TEMP_AMBIENT - ambient temperature.
-TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert value in milli centigrade.
-TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert value in milli centigrade.
+TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert.
+TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert.
 
 TIME_TO_EMPTY - seconds left for battery to be considered empty (i.e.
 while battery powers a load)
Signature · 1 line
1.8.3.1
#4 lore raw

Re: [PATCH] power_supply: Fix documentation for TEMP_*ALERT* properties

Quoted 2 lines · Anton Vorontsov

All temperatures should be in tenth degrees Celsius.

Let me tell you one thing that thermal framework uses milli centigrade for temperature. And also we have some relation with thermal framework already in power suppply core. So, what do think of using milli centigrade in power supply class either?

Thanks,
Jonghwa

Quoted 56 lines

bq24190_charger.c probably should be fixed.

---

Quoted 17 lines · On Mon, Oct 28, 2013 at 11:00:52AM +0900, [email protected] wrote:
Quoted 5 lines

* All voltages, currents, charges, energies, time and temperatures in uV,
* µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise
* stated

So, the current code seems to be correct.

Honestly, I missed the above paragraph you showed rather I read following one.

TEMP - temperature of the power supply.
TEMP_ALERT_MIN - minimum battery temperature alert value in milli centigrade. TEMP_ALERT_MAX - maximum battery temperature alert value in milli centigrade. TEMP_AMBIENT - ambient temperature.
TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert value in milli centigrade.
TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert value in milli centigrade.

Quoted 3 lines

So, we use different unit for properties related temperature, right? current temperature is in tenth of centigrade and threshold temperatures and ambient temperature are in milli centigrade. Wouldn't it have to be in same unit?

:( They should. Thanks for spotting.

The patch down below should fix the issue...

Documentation/power/power_supply_class.txt | 8 ++++----

 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/power/power_supply_class.txt +4 -4
index 3f10b39..89a8816 100644
@@ -135,11 +135,11 @@ CAPACITY_LEVEL - capacity level. This corresponds to
 POWER_SUPPLY_CAPACITY_LEVEL_*.
 
 TEMP - temperature of the power supply.
-TEMP_ALERT_MIN - minimum battery temperature alert value in milli centigrade.
-TEMP_ALERT_MAX - maximum battery temperature alert value in milli centigrade.
+TEMP_ALERT_MIN - minimum battery temperature alert.
+TEMP_ALERT_MAX - maximum battery temperature alert.
 TEMP_AMBIENT - ambient temperature.
-TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert value in milli centigrade.
-TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert value in milli centigrade.
+TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert.
+TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert.
 
 TIME_TO_EMPTY - seconds left for battery to be considered empty (i.e.
 while battery powers a load)
#5 lore raw

Re: [PATCH] power_supply: Fix documentation for TEMP_*ALERT* properties

Quoted 6 lines · On Mon, Oct 28, 2013 at 03:22:53PM +0900, [email protected] wrote:
Quoted 1 line

All temperatures should be in tenth degrees Celsius.

Let me tell you one thing that thermal framework uses milli centigrade for temperature. And also we have some relation with thermal framework already in power suppply core. So, what do think of using milli centigrade in power supply class either?

Since tenth degrees stuff has been exposed to the userland for 5+ years we can't just change it. So, no.

If for any reason you need a higher precision temperatures (do you?), then you are welcome to introduce a set of new properties with a _MILLI affix.

Anton

#6 lore raw

Re: [PATCH] power_supply: Fix documentation for TEMP_*ALERT* properties

In reply to Anton Vorontsov
Quoted 3 lines · Anton Vorontsov

All temperatures should be in tenth degrees Celsius.

bq24190_charger.c probably should be fixed.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Quoted 57 lines

---

Quoted 17 lines · On Mon, Oct 28, 2013 at 11:00:52AM +0900, [email protected] wrote:
Quoted 5 lines

* All voltages, currents, charges, energies, time and temperatures in uV,
* µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise
* stated

So, the current code seems to be correct.

Honestly, I missed the above paragraph you showed rather I read following one.

TEMP - temperature of the power supply.
TEMP_ALERT_MIN - minimum battery temperature alert value in milli centigrade. TEMP_ALERT_MAX - maximum battery temperature alert value in milli centigrade. TEMP_AMBIENT - ambient temperature.
TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert value in milli centigrade.
TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert value in milli centigrade.

Quoted 3 lines

So, we use different unit for properties related temperature, right? current temperature is in tenth of centigrade and threshold temperatures and ambient temperature are in milli centigrade. Wouldn't it have to be in same unit?

:( They should. Thanks for spotting.

The patch down below should fix the issue...

Documentation/power/power_supply_class.txt | 8 ++++----

 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/power/power_supply_class.txt +4 -4
index 3f10b39..89a8816 100644
@@ -135,11 +135,11 @@ CAPACITY_LEVEL - capacity level. This corresponds to
 POWER_SUPPLY_CAPACITY_LEVEL_*.
 
 TEMP - temperature of the power supply.
-TEMP_ALERT_MIN - minimum battery temperature alert value in milli centigrade.
-TEMP_ALERT_MAX - maximum battery temperature alert value in milli centigrade.
+TEMP_ALERT_MIN - minimum battery temperature alert.
+TEMP_ALERT_MAX - maximum battery temperature alert.
 TEMP_AMBIENT - ambient temperature.
-TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert value in milli centigrade.
-TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert value in milli centigrade.
+TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert.
+TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert.
 
 TIME_TO_EMPTY - seconds left for battery to be considered empty (i.e.
 while battery powers a load)
Signature · 1 line
1.8.3.1

I missed the beginning of this thread so I may be missing something but the bq24190_charger driver already uses tenth of degrees Celcius for POWER_SUPPLY_PROP_TEMP_ALERT_MAX. IIUC, that's correct so there's is nothing to fix in the bq24190_charger.c driver, correct?

Mark
--

#7 lore raw

Re: [PATCH] power_supply: Fix documentation for TEMP_*ALERT* properties

Quoted 4 lines · Mark A. Greer
Quoted 3 lines · Anton Vorontsov

All temperatures should be in tenth degrees Celsius.

bq24190_charger.c probably should be fixed.

...

Quoted 4 lines

I missed the beginning of this thread so I may be missing something but the bq24190_charger driver already uses tenth of degrees Celcius for POWER_SUPPLY_PROP_TEMP_ALERT_MAX. IIUC, that's correct so there's is nothing to fix in the bq24190_charger.c driver, correct?

Yup, correct. Thanks a lot for confirming!

Anton