summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChromeOS Developer <dparker@chromium.org>2013-12-06 13:41:42 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-12-09 18:29:09 +0000
commitf7627170596ecda5206a3dc6b7e259ee5a03fd3c (patch)
tree3342946d5d212e4f185cc13c21a8a7f7eb3c912d
parent61f1b8aea9e5b624b569f2f86bc90a00918f9799 (diff)
downloadchrome-ec-f7627170596ecda5206a3dc6b7e259ee5a03fd3c.tar.gz
Clean up g781 temp sensor function names
BUG=None BRANCH=None TEST=Manual. Run the following console commands: g781 - verify temps and status look sane. temps - verify local and remote values for the 781 are listed g781 settemp 0x05 80 - verify local high alarm set to 80C g781 setbyte 0x09 0x80 - verify config register is 1000 0000 Change-Id: Ia437647fd052295dfd8901c2ef241ff69c0d950e Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/179152 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--driver/temp_sensor/g781.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/driver/temp_sensor/g781.c b/driver/temp_sensor/g781.c
index a28bce8de8..c178a37ace 100644
--- a/driver/temp_sensor/g781.c
+++ b/driver/temp_sensor/g781.c
@@ -13,15 +13,15 @@
#include "hooks.h"
#include "util.h"
-static int g781_temp_val_local;
-static int g781_temp_val_remote;
+static int temp_val_local;
+static int temp_val_remote;
/**
* Determine whether the sensor is powered.
*
* @return non-zero the g781 sensor is powered.
*/
-static int g781_has_power(void)
+static int has_power(void)
{
#ifdef CONFIG_TEMP_SENSOR_POWER_GPIO
return gpio_get_level(CONFIG_TEMP_SENSOR_POWER_GPIO);
@@ -30,22 +30,22 @@ static int g781_has_power(void)
#endif
}
-static int g781_read8(const int offset, int *data_ptr)
+static int raw_read8(const int offset, int *data_ptr)
{
return i2c_read8(I2C_PORT_THERMAL, G781_I2C_ADDR, offset, data_ptr);
}
-static int g781_write8(const int offset, int data)
+static int raw_write8(const int offset, int data)
{
return i2c_write8(I2C_PORT_THERMAL, G781_I2C_ADDR, offset, data);
}
-static int g781_get_temp(const int offset, int *temp_ptr)
+static int get_temp(const int offset, int *temp_ptr)
{
int rv;
int temp_raw = 0;
- rv = g781_read8(offset, &temp_raw);
+ rv = raw_read8(offset, &temp_raw);
if (rv < 0)
return rv;
@@ -53,25 +53,25 @@ static int g781_get_temp(const int offset, int *temp_ptr)
return EC_SUCCESS;
}
-static int g781_set_temp(const int offset, int temp)
+static int set_temp(const int offset, int temp)
{
if (temp < -127 || temp > 127)
return EC_ERROR_INVAL;
- return g781_write8(offset, (uint8_t)temp);
+ return raw_write8(offset, (uint8_t)temp);
}
int g781_get_val(int idx, int *temp_ptr)
{
- if (!g781_has_power())
+ if (!has_power())
return EC_ERROR_NOT_POWERED;
switch (idx) {
case G781_IDX_INTERNAL:
- *temp_ptr = g781_temp_val_local;
+ *temp_ptr = temp_val_local;
break;
case G781_IDX_EXTERNAL:
- *temp_ptr = g781_temp_val_remote;
+ *temp_ptr = temp_val_remote;
break;
default:
return EC_ERROR_UNKNOWN;
@@ -80,71 +80,71 @@ int g781_get_val(int idx, int *temp_ptr)
return EC_SUCCESS;
}
-static void g781_temp_sensor_poll(void)
+static void temp_sensor_poll(void)
{
- if (!g781_has_power())
+ if (!has_power())
return;
- g781_get_temp(G781_TEMP_LOCAL, &g781_temp_val_local);
- g781_temp_val_local = C_TO_K(g781_temp_val_local);
+ get_temp(G781_TEMP_LOCAL, &temp_val_local);
+ temp_val_local = C_TO_K(temp_val_local);
- g781_get_temp(G781_TEMP_REMOTE, &g781_temp_val_remote);
- g781_temp_val_remote = C_TO_K(g781_temp_val_remote);
+ get_temp(G781_TEMP_REMOTE, &temp_val_remote);
+ temp_val_remote = C_TO_K(temp_val_remote);
}
-DECLARE_HOOK(HOOK_SECOND, g781_temp_sensor_poll, HOOK_PRIO_TEMP_SENSOR);
+DECLARE_HOOK(HOOK_SECOND, temp_sensor_poll, HOOK_PRIO_TEMP_SENSOR);
-static int g781_show_status(void)
+static int print_status(void)
{
int value;
int rv;
- rv = g781_get_temp(G781_TEMP_LOCAL, &value);
+ rv = get_temp(G781_TEMP_LOCAL, &value);
if (rv < 0)
return rv;
ccprintf("Local Temp: %3dC\n", value);
- rv = g781_get_temp(G781_LOCAL_TEMP_THERM_LIMIT, &value);
+ rv = get_temp(G781_LOCAL_TEMP_THERM_LIMIT, &value);
if (rv < 0)
return rv;
ccprintf(" Therm Trip: %3dC\n", value);
- rv = g781_get_temp(G781_LOCAL_TEMP_HIGH_LIMIT_R, &value);
+ rv = get_temp(G781_LOCAL_TEMP_HIGH_LIMIT_R, &value);
if (rv < 0)
return rv;
ccprintf(" High Alarm: %3dC\n", value);
- rv = g781_get_temp(G781_LOCAL_TEMP_LOW_LIMIT_R, &value);
+ rv = get_temp(G781_LOCAL_TEMP_LOW_LIMIT_R, &value);
if (rv < 0)
return rv;
ccprintf(" Low Alarm: %3dC\n", value);
- rv = g781_get_temp(G781_TEMP_REMOTE, &value);
+ rv = get_temp(G781_TEMP_REMOTE, &value);
if (rv < 0)
return rv;
ccprintf("Remote Temp: %3dC\n", value);
- rv = g781_get_temp(G781_REMOTE_TEMP_THERM_LIMIT, &value);
+ rv = get_temp(G781_REMOTE_TEMP_THERM_LIMIT, &value);
if (rv < 0)
return rv;
ccprintf(" Therm Trip: %3dC\n", value);
- rv = g781_get_temp(G781_REMOTE_TEMP_HIGH_LIMIT_R, &value);
+ rv = get_temp(G781_REMOTE_TEMP_HIGH_LIMIT_R, &value);
if (rv < 0)
return rv;
ccprintf(" High Alarm: %3dC\n", value);
- rv = g781_get_temp(G781_REMOTE_TEMP_LOW_LIMIT_R, &value);
+ rv = get_temp(G781_REMOTE_TEMP_LOW_LIMIT_R, &value);
if (rv < 0)
return rv;
ccprintf(" Low Alarm: %3dC\n", value);
- rv = g781_read8(G781_STATUS, &value);
+ rv = raw_read8(G781_STATUS, &value);
if (rv < 0)
return rv;
ccprintf("\nSTATUS: %08b\n", value);
- rv = g781_read8(G781_CONFIGURATION_R, &value);
+ rv = raw_read8(G781_CONFIGURATION_R, &value);
if (rv < 0)
return rv;
ccprintf("CONFIG: %08b\n", value);
@@ -160,14 +160,14 @@ static int command_g781(int argc, char **argv)
int offset;
int rv;
- if (!g781_has_power()) {
+ if (!has_power()) {
ccprintf("ERROR: Temp sensor not powered.\n");
return EC_ERROR_NOT_POWERED;
}
/* If no args just print status */
if (argc == 1)
- return g781_show_status();
+ return print_status();
if (argc < 3)
return EC_ERROR_PARAM_COUNT;
@@ -178,7 +178,7 @@ static int command_g781(int argc, char **argv)
return EC_ERROR_PARAM2;
if (!strcasecmp(command, "getbyte")) {
- rv = g781_read8(offset, &data);
+ rv = raw_read8(offset, &data);
if (rv < 0)
return rv;
ccprintf("Byte at offset 0x%02x is %08b\n", offset, data);
@@ -195,10 +195,10 @@ static int command_g781(int argc, char **argv)
if (!strcasecmp(command, "settemp")) {
ccprintf("Setting 0x%02x to %dC\n", offset, data);
- rv = g781_set_temp(offset, data);
+ rv = set_temp(offset, data);
} else if (!strcasecmp(command, "setbyte")) {
ccprintf("Setting 0x%02x to 0x%02x\n", offset, data);
- rv = g781_write8(offset, data);
+ rv = raw_write8(offset, data);
} else
return EC_ERROR_PARAM1;