Commit c4ad4720 authored by Cédric Le Goater's avatar Cédric Le Goater Committed by Guenter Roeck

hwmon: (ibmpowernv) add a get_sensor_type() routine

It will help in adding different compatible properties, coming from a
new device tree layout for example.
Signed-off-by: default avatarCédric Le Goater <clg@fr.ibm.com>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 96124610
...@@ -169,6 +169,17 @@ static int create_hwmon_attr_name(struct device *dev, enum sensors type, ...@@ -169,6 +169,17 @@ static int create_hwmon_attr_name(struct device *dev, enum sensors type,
return 0; return 0;
} }
static int get_sensor_type(struct device_node *np)
{
enum sensors type;
for (type = 0; type < MAX_SENSOR_TYPE; type++) {
if (of_device_is_compatible(np, sensor_groups[type].compatible))
return type;
}
return MAX_SENSOR_TYPE;
}
static int populate_attr_groups(struct platform_device *pdev) static int populate_attr_groups(struct platform_device *pdev)
{ {
struct platform_data *pdata = platform_get_drvdata(pdev); struct platform_data *pdata = platform_get_drvdata(pdev);
...@@ -181,12 +192,9 @@ static int populate_attr_groups(struct platform_device *pdev) ...@@ -181,12 +192,9 @@ static int populate_attr_groups(struct platform_device *pdev)
if (np->name == NULL) if (np->name == NULL)
continue; continue;
for (type = 0; type < MAX_SENSOR_TYPE; type++) type = get_sensor_type(np);
if (of_device_is_compatible(np, if (type != MAX_SENSOR_TYPE)
sensor_groups[type].compatible)) { sensor_groups[type].attr_count++;
sensor_groups[type].attr_count++;
break;
}
} }
of_node_put(opal); of_node_put(opal);
...@@ -236,11 +244,7 @@ static int create_device_attrs(struct platform_device *pdev) ...@@ -236,11 +244,7 @@ static int create_device_attrs(struct platform_device *pdev)
if (np->name == NULL) if (np->name == NULL)
continue; continue;
for (type = 0; type < MAX_SENSOR_TYPE; type++) type = get_sensor_type(np);
if (of_device_is_compatible(np,
sensor_groups[type].compatible))
break;
if (type == MAX_SENSOR_TYPE) if (type == MAX_SENSOR_TYPE)
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment