summaryrefslogtreecommitdiff
path: root/drivers/hwmon/ibmpowernv.c
diff options
context:
space:
mode:
authorCédric Le Goater <clg@fr.ibm.com>2015-03-19 20:44:43 +0300
committerGuenter Roeck <linux@roeck-us.net>2015-03-20 18:25:11 +0300
commitccc9ac6cc9ff7c845daa930598e96be9bb978ade (patch)
tree7fa8a32f47703532707a36b8dd0c0a31757f93cf /drivers/hwmon/ibmpowernv.c
parentc4ad47206425e8f38928413ab35f59bd294ddbc2 (diff)
downloadlinux-ccc9ac6cc9ff7c845daa930598e96be9bb978ade.tar.xz
hwmon: (ibmpowernv) add a convert_opal_attr_name() routine
It simplifies the create_hwmon_attr_name() routine and it clearly isolates the conversion done between the OPAL node names and hwmon attributes names. Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/ibmpowernv.c')
-rw-r--r--drivers/hwmon/ibmpowernv.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
index 07a8219b7f4e..7791608a6591 100644
--- a/drivers/hwmon/ibmpowernv.c
+++ b/drivers/hwmon/ibmpowernv.c
@@ -127,6 +127,25 @@ static int get_sensor_index_attr(const char *name, u32 *index,
return 0;
}
+static const char *convert_opal_attr_name(enum sensors type,
+ const char *opal_attr)
+{
+ const char *attr_name = NULL;
+
+ if (!strcmp(opal_attr, DT_FAULT_ATTR_SUFFIX)) {
+ attr_name = "fault";
+ } else if (!strcmp(opal_attr, DT_DATA_ATTR_SUFFIX)) {
+ attr_name = "input";
+ } else if (!strcmp(opal_attr, DT_THRESHOLD_ATTR_SUFFIX)) {
+ if (type == TEMP)
+ attr_name = "max";
+ else if (type == FAN)
+ attr_name = "min";
+ }
+
+ return attr_name;
+}
+
/*
* This function translates the DT node name into the 'hwmon' attribute name.
* IBMPOWERNV device node appear like cooling-fan#2-data, amb-temp#1-thrs etc.
@@ -138,7 +157,7 @@ static int create_hwmon_attr_name(struct device *dev, enum sensors type,
char *hwmon_attr_name)
{
char attr_suffix[MAX_ATTR_LEN];
- char *attr_name;
+ const char *attr_name;
u32 index;
int err;
@@ -149,20 +168,9 @@ static int create_hwmon_attr_name(struct device *dev, enum sensors type,
return err;
}
- if (!strcmp(attr_suffix, DT_FAULT_ATTR_SUFFIX)) {
- attr_name = "fault";
- } else if (!strcmp(attr_suffix, DT_DATA_ATTR_SUFFIX)) {
- attr_name = "input";
- } else if (!strcmp(attr_suffix, DT_THRESHOLD_ATTR_SUFFIX)) {
- if (type == TEMP)
- attr_name = "max";
- else if (type == FAN)
- attr_name = "min";
- else
- return -ENOENT;
- } else {
+ attr_name = convert_opal_attr_name(type, attr_suffix);
+ if (!attr_name)
return -ENOENT;
- }
snprintf(hwmon_attr_name, MAX_ATTR_LEN, "%s%d_%s",
sensor_groups[type].name, index, attr_name);