forked from Minki/linux
hwmon: (ibmpowernv) do not use the OPAL index for hwmon attribute names
The current OPAL firmware exposes the different sensors of an IBM Power system using node names such as : sensors/amb-temp#1-data sensors/amb-temp#1-thrs cooling-fan#1-data cooling-fan#1-faulted cooling-fan#1-thrs cooling-fan#2-data ... The ibmpowernv driver, when loaded, parses these names to extract the sensor index and the sensor attribute name. Unfortunately, this scheme makes it difficult to add sensors with a different layout (specially of the same type, like temperature) as the sensor index calculated in OPAL is directly used in the hwmon sysfs interface. What this patch does is add a independent hwmon index for each sensor. The increment of the hwmon index (temp, fan, power, etc.) is kept per sensor type in the sensor_group table. The sensor_data table is used to store the association of the hwmon and OPAL indexes, as we need to have the same hwmon index for different attributes of a same sensor. Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
f9f54f16bf
commit
fcaf57b67d
@ -55,6 +55,7 @@ static struct sensor_group {
|
||||
const char *compatible;
|
||||
struct attribute_group group;
|
||||
u32 attr_count;
|
||||
u32 hwmon_index;
|
||||
} sensor_groups[] = {
|
||||
{"fan", "ibm,opal-sensor-cooling-fan"},
|
||||
{"temp", "ibm,opal-sensor-amb-temp"},
|
||||
@ -64,6 +65,8 @@ static struct sensor_group {
|
||||
|
||||
struct sensor_data {
|
||||
u32 id; /* An opaque id of the firmware for each sensor */
|
||||
u32 hwmon_index;
|
||||
u32 opal_index;
|
||||
enum sensors type;
|
||||
char name[MAX_ATTR_LEN];
|
||||
struct device_attribute dev_attr;
|
||||
@ -181,6 +184,19 @@ static int get_sensor_type(struct device_node *np)
|
||||
return MAX_SENSOR_TYPE;
|
||||
}
|
||||
|
||||
static u32 get_sensor_hwmon_index(struct sensor_data *sdata,
|
||||
struct sensor_data *sdata_table, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
if (sdata_table[i].opal_index == sdata->opal_index &&
|
||||
sdata_table[i].type == sdata->type)
|
||||
return sdata_table[i].hwmon_index;
|
||||
|
||||
return ++sensor_groups[sdata->type].hwmon_index;
|
||||
}
|
||||
|
||||
static int populate_attr_groups(struct platform_device *pdev)
|
||||
{
|
||||
struct platform_data *pdata = platform_get_drvdata(pdev);
|
||||
@ -270,8 +286,13 @@ static int create_device_attrs(struct platform_device *pdev)
|
||||
goto exit_put_node;
|
||||
}
|
||||
|
||||
sdata[count].opal_index = opal_index;
|
||||
sdata[count].hwmon_index =
|
||||
get_sensor_hwmon_index(&sdata[count], sdata, count);
|
||||
|
||||
snprintf(sdata[count].name, MAX_ATTR_LEN, "%s%d_%s",
|
||||
sensor_groups[type].name, opal_index, attr_name);
|
||||
sensor_groups[type].name, sdata[count].hwmon_index,
|
||||
attr_name);
|
||||
|
||||
sysfs_attr_init(&sdata[count].dev_attr.attr);
|
||||
sdata[count].dev_attr.attr.name = sdata[count].name;
|
||||
|
Loading…
Reference in New Issue
Block a user