diff options
author | Cédric Le Goater <clg@fr.ibm.com> | 2015-03-19 18:44:42 +0100 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2015-03-20 08:25:10 -0700 |
commit | c4ad47206425e8f38928413ab35f59bd294ddbc2 (patch) | |
tree | 898a904ee0382f4079e855bb86a9c5187ffffa4f /drivers | |
parent | 96124610e9f154135eb6fd9aa7a78ed756ff18a3 (diff) | |
download | linux-c4ad47206425e8f38928413ab35f59bd294ddbc2.tar.bz2 |
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: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/ibmpowernv.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c index f691e18df16b..07a8219b7f4e 100644 --- a/drivers/hwmon/ibmpowernv.c +++ b/drivers/hwmon/ibmpowernv.c @@ -169,6 +169,17 @@ static int create_hwmon_attr_name(struct device *dev, enum sensors type, 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) { struct platform_data *pdata = platform_get_drvdata(pdev); @@ -181,12 +192,9 @@ static int populate_attr_groups(struct platform_device *pdev) if (np->name == NULL) continue; - for (type = 0; type < MAX_SENSOR_TYPE; type++) - if (of_device_is_compatible(np, - sensor_groups[type].compatible)) { - sensor_groups[type].attr_count++; - break; - } + type = get_sensor_type(np); + if (type != MAX_SENSOR_TYPE) + sensor_groups[type].attr_count++; } of_node_put(opal); @@ -236,11 +244,7 @@ static int create_device_attrs(struct platform_device *pdev) if (np->name == NULL) continue; - for (type = 0; type < MAX_SENSOR_TYPE; type++) - if (of_device_is_compatible(np, - sensor_groups[type].compatible)) - break; - + type = get_sensor_type(np); if (type == MAX_SENSOR_TYPE) continue; |