summaryrefslogtreecommitdiff
path: root/common/temp_sensor.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-11 10:23:16 -0700
committerGerrit <chrome-bot@google.com>2012-10-11 13:47:17 -0700
commit8f2e99da75152c428c6c92b20a13a62a5fcb40d1 (patch)
treec2d3dc52372a79a03c2d503c55ead568c066a7e1 /common/temp_sensor.c
parentd1bebbbe66f78d2dcfb9380456a80e7c2f26a662 (diff)
downloadchrome-ec-8f2e99da75152c428c6c92b20a13a62a5fcb40d1.tar.gz
link: Temp sensor read can return an error code
This will be used in a follow-up CL to return specific error codes (not powered, not calibrated, etc.) BUG=chrome-os-partner:15174 BRANCH=link TEST=manual Power on system. 'temps' should return all good temps. Power off system (into S5) Only ECInternal temp should work; others should return Error 1 'gpioset enable_vs 1' and wait a second Now all the I2C temps should display good data, but PECI will still be error 1. Change-Id: I925434e71653ad53ad76bad992a7a8fdeadb088c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35286 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/temp_sensor.c')
-rw-r--r--common/temp_sensor.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/common/temp_sensor.c b/common/temp_sensor.c
index cdad3ebd1f..333ed1d266 100644
--- a/common/temp_sensor.c
+++ b/common/temp_sensor.c
@@ -25,17 +25,16 @@
*/
extern const struct temp_sensor_t temp_sensors[TEMP_SENSOR_COUNT];
-
-int temp_sensor_read(enum temp_sensor_id id)
+int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr)
{
const struct temp_sensor_t *sensor;
if (id < 0 || id >= TEMP_SENSOR_COUNT)
- return -1;
+ return EC_ERROR_INVAL;
sensor = temp_sensors + id;
- return sensor->read(sensor->idx);
-}
+ return sensor->read(sensor->idx, temp_ptr);
+}
int temp_sensor_powered(enum temp_sensor_id id)
{
@@ -52,7 +51,6 @@ int temp_sensor_powered(enum temp_sensor_id id)
return 1;
}
-
void poll_slow_sensors(void)
{
/* Poll every second */
@@ -72,7 +70,6 @@ static void poll_fast_sensors(void)
#endif
}
-
static void update_mapped_memory(void)
{
int i, t;
@@ -94,15 +91,13 @@ static void update_mapped_memory(void)
continue;
}
- t = temp_sensor_read(i);
- if (t == -1)
+ if (temp_sensor_read(i, &t))
*mptr = EC_TEMP_SENSOR_ERROR;
else
*mptr = t - EC_TEMP_SENSOR_OFFSET;
}
}
-
void temp_sensor_task(void)
{
int i;
@@ -149,21 +144,20 @@ void temp_sensor_task(void)
static int command_temps(int argc, char **argv)
{
- int i;
- int rv = EC_SUCCESS;
- int t;
+ int t, i;
+ int rv, rv1 = EC_SUCCESS;
for (i = 0; i < TEMP_SENSOR_COUNT; ++i) {
ccprintf(" %-20s: ", temp_sensors[i].name);
- t = temp_sensor_read(i);
- if (t < 0) {
- ccprintf("Error\n");
- rv = EC_ERROR_UNKNOWN;
+ rv = temp_sensor_read(i, &t);
+ if (rv) {
+ ccprintf("Error %d\n", rv);
+ rv1 = rv;
} else
ccprintf("%d K = %d C\n", t, t - 273);
}
- return rv;
+ return rv1;
}
DECLARE_CONSOLE_COMMAND(temps, command_temps,
NULL,