提交 3ab52160 编写于 作者: C Cédric Le Goater 提交者: Guenter Roeck

hwmon: (ibmpowernv) introduce a legacy_compatibles array

Today, the type of a PowerNV sensor system is determined with the
"compatible" property for legacy Firmwares and with the "sensor-type"
for newer ones. The same array of strings is used for both to do the
matching and this raises some issue to introduce new sensor types.

Let's introduce two different arrays (legacy and current) to make
things easier for new sensor types.
Signed-off-by: NCédric Le Goater <clg@kaod.org>
Tested-by: NShilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
上级 677252a1
...@@ -55,17 +55,27 @@ enum sensors { ...@@ -55,17 +55,27 @@ enum sensors {
#define INVALID_INDEX (-1U) #define INVALID_INDEX (-1U)
/*
* 'compatible' string properties for sensor types as defined in old
* PowerNV firmware (skiboot). These are ordered as 'enum sensors'.
*/
static const char * const legacy_compatibles[] = {
"ibm,opal-sensor-cooling-fan",
"ibm,opal-sensor-amb-temp",
"ibm,opal-sensor-power-supply",
"ibm,opal-sensor-power"
};
static struct sensor_group { static struct sensor_group {
const char *name; const char *name; /* matches property 'sensor-type' */
const char *compatible;
struct attribute_group group; struct attribute_group group;
u32 attr_count; u32 attr_count;
u32 hwmon_index; u32 hwmon_index;
} sensor_groups[] = { } sensor_groups[] = {
{"fan", "ibm,opal-sensor-cooling-fan"}, { "fan" },
{"temp", "ibm,opal-sensor-amb-temp"}, { "temp" },
{"in", "ibm,opal-sensor-power-supply"}, { "in" },
{"power", "ibm,opal-sensor-power"} { "power" }
}; };
struct sensor_data { struct sensor_data {
...@@ -239,8 +249,8 @@ static int get_sensor_type(struct device_node *np) ...@@ -239,8 +249,8 @@ static int get_sensor_type(struct device_node *np)
enum sensors type; enum sensors type;
const char *str; const char *str;
for (type = 0; type < MAX_SENSOR_TYPE; type++) { for (type = 0; type < ARRAY_SIZE(legacy_compatibles); type++) {
if (of_device_is_compatible(np, sensor_groups[type].compatible)) if (of_device_is_compatible(np, legacy_compatibles[type]))
return type; return type;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册