diff options
author | Cédric Le Goater <clg@fr.ibm.com> | 2015-03-19 13:44:44 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2015-03-20 11:25:12 -0400 |
commit | f9f54f16bfa1bc76d827d4a2c80f72acbee72b05 (patch) | |
tree | 1607a29188907b1a04a54fad2aadefea3bcad336 | |
parent | ccc9ac6cc9ff7c845daa930598e96be9bb978ade (diff) |
hwmon: (ibmpowernv) change create_hwmon_attr_name() prototype
It simplifies the creation of the hwmon attributes and will help when
support for a new device tree layout is added. The patch also changes
the name of the routine to parse_opal_node_name().
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/ibmpowernv.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c index 7791608a6591..adfdf59e8f6c 100644 --- a/drivers/hwmon/ibmpowernv.c +++ b/drivers/hwmon/ibmpowernv.c | |||
@@ -152,29 +152,22 @@ static const char *convert_opal_attr_name(enum sensors type, | |||
152 | * which need to be mapped as fan2_input, temp1_max respectively before | 152 | * which need to be mapped as fan2_input, temp1_max respectively before |
153 | * populating them inside hwmon device class. | 153 | * populating them inside hwmon device class. |
154 | */ | 154 | */ |
155 | static int create_hwmon_attr_name(struct device *dev, enum sensors type, | 155 | static const char *parse_opal_node_name(const char *node_name, |
156 | const char *node_name, | 156 | enum sensors type, u32 *index) |
157 | char *hwmon_attr_name) | ||
158 | { | 157 | { |
159 | char attr_suffix[MAX_ATTR_LEN]; | 158 | char attr_suffix[MAX_ATTR_LEN]; |
160 | const char *attr_name; | 159 | const char *attr_name; |
161 | u32 index; | ||
162 | int err; | 160 | int err; |
163 | 161 | ||
164 | err = get_sensor_index_attr(node_name, &index, attr_suffix); | 162 | err = get_sensor_index_attr(node_name, index, attr_suffix); |
165 | if (err) { | 163 | if (err) |
166 | dev_err(dev, "Sensor device node name '%s' is invalid\n", | 164 | return ERR_PTR(err); |
167 | node_name); | ||
168 | return err; | ||
169 | } | ||
170 | 165 | ||
171 | attr_name = convert_opal_attr_name(type, attr_suffix); | 166 | attr_name = convert_opal_attr_name(type, attr_suffix); |
172 | if (!attr_name) | 167 | if (!attr_name) |
173 | return -ENOENT; | 168 | return ERR_PTR(-ENOENT); |
174 | 169 | ||
175 | snprintf(hwmon_attr_name, MAX_ATTR_LEN, "%s%d_%s", | 170 | return attr_name; |
176 | sensor_groups[type].name, index, attr_name); | ||
177 | return 0; | ||
178 | } | 171 | } |
179 | 172 | ||
180 | static int get_sensor_type(struct device_node *np) | 173 | static int get_sensor_type(struct device_node *np) |
@@ -249,6 +242,9 @@ static int create_device_attrs(struct platform_device *pdev) | |||
249 | } | 242 | } |
250 | 243 | ||
251 | for_each_child_of_node(opal, np) { | 244 | for_each_child_of_node(opal, np) { |
245 | const char *attr_name; | ||
246 | u32 opal_index; | ||
247 | |||
252 | if (np->name == NULL) | 248 | if (np->name == NULL) |
253 | continue; | 249 | continue; |
254 | 250 | ||
@@ -265,10 +261,17 @@ static int create_device_attrs(struct platform_device *pdev) | |||
265 | 261 | ||
266 | sdata[count].id = sensor_id; | 262 | sdata[count].id = sensor_id; |
267 | sdata[count].type = type; | 263 | sdata[count].type = type; |
268 | err = create_hwmon_attr_name(&pdev->dev, type, np->name, | 264 | |
269 | sdata[count].name); | 265 | attr_name = parse_opal_node_name(np->name, type, &opal_index); |
270 | if (err) | 266 | if (IS_ERR(attr_name)) { |
267 | dev_err(&pdev->dev, "Sensor device node name '%s' is invalid\n", | ||
268 | np->name); | ||
269 | err = PTR_ERR(attr_name); | ||
271 | goto exit_put_node; | 270 | goto exit_put_node; |
271 | } | ||
272 | |||
273 | snprintf(sdata[count].name, MAX_ATTR_LEN, "%s%d_%s", | ||
274 | sensor_groups[type].name, opal_index, attr_name); | ||
272 | 275 | ||
273 | sysfs_attr_init(&sdata[count].dev_attr.attr); | 276 | sysfs_attr_init(&sdata[count].dev_attr.attr); |
274 | sdata[count].dev_attr.attr.name = sdata[count].name; | 277 | sdata[count].dev_attr.attr.name = sdata[count].name; |