diff options
author | Cédric Le Goater <clg@fr.ibm.com> | 2015-03-19 13:44:42 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2015-03-20 11:25:10 -0400 |
commit | c4ad47206425e8f38928413ab35f59bd294ddbc2 (patch) | |
tree | 898a904ee0382f4079e855bb86a9c5187ffffa4f | |
parent | 96124610e9f154135eb6fd9aa7a78ed756ff18a3 (diff) |
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>
-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, | |||
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | static int get_sensor_type(struct device_node *np) | ||
173 | { | ||
174 | enum sensors type; | ||
175 | |||
176 | for (type = 0; type < MAX_SENSOR_TYPE; type++) { | ||
177 | if (of_device_is_compatible(np, sensor_groups[type].compatible)) | ||
178 | return type; | ||
179 | } | ||
180 | return MAX_SENSOR_TYPE; | ||
181 | } | ||
182 | |||
172 | static int populate_attr_groups(struct platform_device *pdev) | 183 | static int populate_attr_groups(struct platform_device *pdev) |
173 | { | 184 | { |
174 | struct platform_data *pdata = platform_get_drvdata(pdev); | 185 | struct platform_data *pdata = platform_get_drvdata(pdev); |
@@ -181,12 +192,9 @@ static int populate_attr_groups(struct platform_device *pdev) | |||
181 | if (np->name == NULL) | 192 | if (np->name == NULL) |
182 | continue; | 193 | continue; |
183 | 194 | ||
184 | for (type = 0; type < MAX_SENSOR_TYPE; type++) | 195 | type = get_sensor_type(np); |
185 | if (of_device_is_compatible(np, | 196 | if (type != MAX_SENSOR_TYPE) |
186 | sensor_groups[type].compatible)) { | 197 | sensor_groups[type].attr_count++; |
187 | sensor_groups[type].attr_count++; | ||
188 | break; | ||
189 | } | ||
190 | } | 198 | } |
191 | 199 | ||
192 | of_node_put(opal); | 200 | of_node_put(opal); |
@@ -236,11 +244,7 @@ static int create_device_attrs(struct platform_device *pdev) | |||
236 | if (np->name == NULL) | 244 | if (np->name == NULL) |
237 | continue; | 245 | continue; |
238 | 246 | ||
239 | for (type = 0; type < MAX_SENSOR_TYPE; type++) | 247 | type = get_sensor_type(np); |
240 | if (of_device_is_compatible(np, | ||
241 | sensor_groups[type].compatible)) | ||
242 | break; | ||
243 | |||
244 | if (type == MAX_SENSOR_TYPE) | 248 | if (type == MAX_SENSOR_TYPE) |
245 | continue; | 249 | continue; |
246 | 250 | ||