diff options
| -rw-r--r-- | drivers/hwmon/ibmpowernv.c | 36 |
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, | |||
| 127 | return 0; | 127 | return 0; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | static const char *convert_opal_attr_name(enum sensors type, | ||
| 131 | const char *opal_attr) | ||
| 132 | { | ||
| 133 | const char *attr_name = NULL; | ||
| 134 | |||
| 135 | if (!strcmp(opal_attr, DT_FAULT_ATTR_SUFFIX)) { | ||
| 136 | attr_name = "fault"; | ||
| 137 | } else if (!strcmp(opal_attr, DT_DATA_ATTR_SUFFIX)) { | ||
| 138 | attr_name = "input"; | ||
| 139 | } else if (!strcmp(opal_attr, DT_THRESHOLD_ATTR_SUFFIX)) { | ||
| 140 | if (type == TEMP) | ||
| 141 | attr_name = "max"; | ||
| 142 | else if (type == FAN) | ||
| 143 | attr_name = "min"; | ||
| 144 | } | ||
| 145 | |||
| 146 | return attr_name; | ||
| 147 | } | ||
| 148 | |||
| 130 | /* | 149 | /* |
| 131 | * This function translates the DT node name into the 'hwmon' attribute name. | 150 | * This function translates the DT node name into the 'hwmon' attribute name. |
| 132 | * IBMPOWERNV device node appear like cooling-fan#2-data, amb-temp#1-thrs etc. | 151 | * 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, | |||
| 138 | char *hwmon_attr_name) | 157 | char *hwmon_attr_name) |
| 139 | { | 158 | { |
| 140 | char attr_suffix[MAX_ATTR_LEN]; | 159 | char attr_suffix[MAX_ATTR_LEN]; |
| 141 | char *attr_name; | 160 | const char *attr_name; |
| 142 | u32 index; | 161 | u32 index; |
| 143 | int err; | 162 | int err; |
| 144 | 163 | ||
| @@ -149,20 +168,9 @@ static int create_hwmon_attr_name(struct device *dev, enum sensors type, | |||
| 149 | return err; | 168 | return err; |
| 150 | } | 169 | } |
| 151 | 170 | ||
| 152 | if (!strcmp(attr_suffix, DT_FAULT_ATTR_SUFFIX)) { | 171 | attr_name = convert_opal_attr_name(type, attr_suffix); |
| 153 | attr_name = "fault"; | 172 | if (!attr_name) |
| 154 | } else if (!strcmp(attr_suffix, DT_DATA_ATTR_SUFFIX)) { | ||
| 155 | attr_name = "input"; | ||
| 156 | } else if (!strcmp(attr_suffix, DT_THRESHOLD_ATTR_SUFFIX)) { | ||
| 157 | if (type == TEMP) | ||
| 158 | attr_name = "max"; | ||
| 159 | else if (type == FAN) | ||
| 160 | attr_name = "min"; | ||
| 161 | else | ||
| 162 | return -ENOENT; | ||
| 163 | } else { | ||
| 164 | return -ENOENT; | 173 | return -ENOENT; |
| 165 | } | ||
| 166 | 174 | ||
| 167 | snprintf(hwmon_attr_name, MAX_ATTR_LEN, "%s%d_%s", | 175 | snprintf(hwmon_attr_name, MAX_ATTR_LEN, "%s%d_%s", |
| 168 | sensor_groups[type].name, index, attr_name); | 176 | sensor_groups[type].name, index, attr_name); |
