diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2015-02-28 10:32:20 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2015-03-04 16:02:20 +0800 |
commit | e9e83d2f03dc947e665177af53414347fdcc03a1 (patch) | |
tree | 353df11837ddcc4b6b74d5d867699798dc8ec86d /hw/ipmi | |
parent | a736f60aaed6bb33047646949df7ab08697a896c (diff) | |
download | skiboot-e9e83d2f03dc947e665177af53414347fdcc03a1.zip skiboot-e9e83d2f03dc947e665177af53414347fdcc03a1.tar.gz skiboot-e9e83d2f03dc947e665177af53414347fdcc03a1.tar.bz2 |
hw/ipmi: Fix sensor type mappings
We're doing the IPMI sensor type mapping the wrong way around; we want
to map sensor types to sensor IDs.
Also, change the #defines to property reflect that they're types.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'hw/ipmi')
-rw-r--r-- | hw/ipmi/ipmi-sensor.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/hw/ipmi/ipmi-sensor.c b/hw/ipmi/ipmi-sensor.c index cdaf5fb..a3112ee 100644 --- a/hw/ipmi/ipmi-sensor.c +++ b/hw/ipmi/ipmi-sensor.c @@ -24,8 +24,8 @@ #define IPMI_SET_ASSERTION (1 << 5) #define IPMI_ASSERTION_STATE(state) (1 << state) -#define FW_PROGRESS_SENSOR 0x0F -#define BOOT_COUNT_SENSOR 0xAA +#define FW_PROGRESS_SENSOR_TYPE 0x0F +#define BOOT_COUNT_SENSOR_TYPE 0xAA /* Ghetto. TODO: Do something smarter */ int16_t sensors[255]; @@ -40,10 +40,17 @@ int ipmi_set_boot_count(void) { struct set_sensor_req req; struct ipmi_msg *msg; + int sensor_id; + + sensor_id = sensors[BOOT_COUNT_SENSOR_TYPE]; + if (sensor_id < 0) { + prlog(PR_DEBUG, "SENSOR: boot count set but not present\n"); + return OPAL_HARDWARE; + } memset(&req, 0, sizeof(req)); - req.sensor = BOOT_COUNT_SENSOR; + req.sensor = sensor_id; /* Set assertion bit */ req.operation = IPMI_SET_ASSERTION; /* Set state 2 */ @@ -59,7 +66,7 @@ int ipmi_set_boot_count(void) int ipmi_set_fw_progress_sensor(uint8_t state) { - int fw_sensor_id = sensors[FW_PROGRESS_SENSOR]; + int fw_sensor_id = sensors[FW_PROGRESS_SENSOR_TYPE]; if (fw_sensor_id < 0) { prlog(PR_DEBUG, "SENSOR: fw progress set but not present\n"); @@ -102,23 +109,26 @@ int ipmi_set_sensor(uint8_t sensor, uint8_t *reading, size_t len) void ipmi_sensor_init(void) { + const struct dt_property *type_prop, *num_prop; + uint8_t num, type; struct dt_node *n; - const struct dt_property *type, *num; memset(sensors, -1, sizeof(sensors)); dt_for_each_compatible(dt_root, n, "ibm,ipmi-sensor") { - type = dt_find_property(n, "ipmi-sensor-type"); - if (!type) { + type_prop = dt_find_property(n, "ipmi-sensor-type"); + if (!type_prop) { prerror("IPMI: sensor doesn't have ipmi-sensor-type\n"); continue; } - num = dt_find_property(n, "reg"); - if (!num) { + num_prop = dt_find_property(n, "reg"); + if (!num_prop) { prerror("IPMI: sensor doesn't have reg property\n"); continue; } - sensors[(uint8_t)num->prop[0]] = type->prop[0]; + num = (uint8_t)dt_property_get_cell(num_prop, 0); + type = (uint8_t)dt_property_get_cell(type_prop, 0); + sensors[type] = num; } } |