Skip to content

Commit

Permalink
hwmon: (ibmpowernv) introduce a legacy_compatibles array
Browse files Browse the repository at this point in the history
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: Cédric Le Goater <clg@kaod.org>
Tested-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
legoater authored and groeck committed Jun 20, 2017
1 parent 677252a commit 3ab5216
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions drivers/hwmon/ibmpowernv.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,27 @@ enum sensors {

#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 {
const char *name;
const char *compatible;
const char *name; /* matches property 'sensor-type' */
struct attribute_group group;
u32 attr_count;
u32 hwmon_index;
} sensor_groups[] = {
{"fan", "ibm,opal-sensor-cooling-fan"},
{"temp", "ibm,opal-sensor-amb-temp"},
{"in", "ibm,opal-sensor-power-supply"},
{"power", "ibm,opal-sensor-power"}
{ "fan" },
{ "temp" },
{ "in" },
{ "power" }
};

struct sensor_data {
Expand Down Expand Up @@ -239,8 +249,8 @@ static int get_sensor_type(struct device_node *np)
enum sensors type;
const char *str;

for (type = 0; type < MAX_SENSOR_TYPE; type++) {
if (of_device_is_compatible(np, sensor_groups[type].compatible))
for (type = 0; type < ARRAY_SIZE(legacy_compatibles); type++) {
if (of_device_is_compatible(np, legacy_compatibles[type]))
return type;
}

Expand Down

0 comments on commit 3ab5216

Please sign in to comment.