aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/ibmpowernv.c67
1 files changed, 19 insertions, 48 deletions
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
index 6a30eeea94be..c7577b8f17a8 100644
--- a/drivers/hwmon/ibmpowernv.c
+++ b/drivers/hwmon/ibmpowernv.c
@@ -74,9 +74,6 @@ struct platform_data {
74 u32 sensors_count; /* Total count of sensors from each group */ 74 u32 sensors_count; /* Total count of sensors from each group */
75}; 75};
76 76
77/* Platform device representing all the ibmpowernv sensors */
78static struct platform_device *pdevice;
79
80static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr, 77static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr,
81 char *buf) 78 char *buf)
82{ 79{
@@ -99,7 +96,7 @@ static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr,
99 return sprintf(buf, "%u\n", x); 96 return sprintf(buf, "%u\n", x);
100} 97}
101 98
102static int __init get_sensor_index_attr(const char *name, u32 *index, 99static int get_sensor_index_attr(const char *name, u32 *index,
103 char *attr) 100 char *attr)
104{ 101{
105 char *hash_pos = strchr(name, '#'); 102 char *hash_pos = strchr(name, '#');
@@ -136,7 +133,7 @@ static int __init get_sensor_index_attr(const char *name, u32 *index,
136 * which need to be mapped as fan2_input, temp1_max respectively before 133 * which need to be mapped as fan2_input, temp1_max respectively before
137 * populating them inside hwmon device class. 134 * populating them inside hwmon device class.
138 */ 135 */
139static int __init create_hwmon_attr_name(struct device *dev, enum sensors type, 136static int create_hwmon_attr_name(struct device *dev, enum sensors type,
140 const char *node_name, 137 const char *node_name,
141 char *hwmon_attr_name) 138 char *hwmon_attr_name)
142{ 139{
@@ -172,7 +169,7 @@ static int __init create_hwmon_attr_name(struct device *dev, enum sensors type,
172 return 0; 169 return 0;
173} 170}
174 171
175static int __init populate_attr_groups(struct platform_device *pdev) 172static int populate_attr_groups(struct platform_device *pdev)
176{ 173{
177 struct platform_data *pdata = platform_get_drvdata(pdev); 174 struct platform_data *pdata = platform_get_drvdata(pdev);
178 const struct attribute_group **pgroups = pdata->attr_groups; 175 const struct attribute_group **pgroups = pdata->attr_groups;
@@ -180,11 +177,6 @@ static int __init populate_attr_groups(struct platform_device *pdev)
180 enum sensors type; 177 enum sensors type;
181 178
182 opal = of_find_node_by_path("/ibm,opal/sensors"); 179 opal = of_find_node_by_path("/ibm,opal/sensors");
183 if (!opal) {
184 dev_dbg(&pdev->dev, "Opal node 'sensors' not found\n");
185 return -ENODEV;
186 }
187
188 for_each_child_of_node(opal, np) { 180 for_each_child_of_node(opal, np) {
189 if (np->name == NULL) 181 if (np->name == NULL)
190 continue; 182 continue;
@@ -221,7 +213,7 @@ static int __init populate_attr_groups(struct platform_device *pdev)
221 * to the name required by the higher 'hwmon' driver like fan1_input, temp1_max 213 * to the name required by the higher 'hwmon' driver like fan1_input, temp1_max
222 * etc.. 214 * etc..
223 */ 215 */
224static int __init create_device_attrs(struct platform_device *pdev) 216static int create_device_attrs(struct platform_device *pdev)
225{ 217{
226 struct platform_data *pdata = platform_get_drvdata(pdev); 218 struct platform_data *pdata = platform_get_drvdata(pdev);
227 const struct attribute_group **pgroups = pdata->attr_groups; 219 const struct attribute_group **pgroups = pdata->attr_groups;
@@ -280,7 +272,7 @@ exit_put_node:
280 return err; 272 return err;
281} 273}
282 274
283static int __init ibmpowernv_probe(struct platform_device *pdev) 275static int ibmpowernv_probe(struct platform_device *pdev)
284{ 276{
285 struct platform_data *pdata; 277 struct platform_data *pdata;
286 struct device *hwmon_dev; 278 struct device *hwmon_dev;
@@ -309,52 +301,31 @@ static int __init ibmpowernv_probe(struct platform_device *pdev)
309 return PTR_ERR_OR_ZERO(hwmon_dev); 301 return PTR_ERR_OR_ZERO(hwmon_dev);
310} 302}
311 303
304static const struct platform_device_id opal_sensor_driver_ids[] = {
305 {
306 .name = "opal-sensor",
307 },
308 { }
309};
310MODULE_DEVICE_TABLE(platform, opal_sensor_driver_ids);
311
312static struct platform_driver ibmpowernv_driver = { 312static struct platform_driver ibmpowernv_driver = {
313 .driver = { 313 .probe = ibmpowernv_probe,
314 .owner = THIS_MODULE, 314 .id_table = opal_sensor_driver_ids,
315 .name = DRVNAME, 315 .driver = {
316 .owner = THIS_MODULE,
317 .name = DRVNAME,
316 }, 318 },
317}; 319};
318 320
319static int __init ibmpowernv_init(void) 321static int __init ibmpowernv_init(void)
320{ 322{
321 int err; 323 return platform_driver_register(&ibmpowernv_driver);
322
323 pdevice = platform_device_alloc(DRVNAME, 0);
324 if (!pdevice) {
325 pr_err("Device allocation failed\n");
326 err = -ENOMEM;
327 goto exit;
328 }
329
330 err = platform_device_add(pdevice);
331 if (err) {
332 pr_err("Device addition failed (%d)\n", err);
333 goto exit_device_put;
334 }
335
336 err = platform_driver_probe(&ibmpowernv_driver, ibmpowernv_probe);
337 if (err) {
338 if (err != -ENODEV)
339 pr_err("Platform driver probe failed (%d)\n", err);
340
341 goto exit_device_del;
342 }
343
344 return 0;
345
346exit_device_del:
347 platform_device_del(pdevice);
348exit_device_put:
349 platform_device_put(pdevice);
350exit:
351 return err;
352} 324}
353 325
354static void __exit ibmpowernv_exit(void) 326static void __exit ibmpowernv_exit(void)
355{ 327{
356 platform_driver_unregister(&ibmpowernv_driver); 328 platform_driver_unregister(&ibmpowernv_driver);
357 platform_device_unregister(pdevice);
358} 329}
359 330
360MODULE_AUTHOR("Neelesh Gupta <neelegup@linux.vnet.ibm.com>"); 331MODULE_AUTHOR("Neelesh Gupta <neelegup@linux.vnet.ibm.com>");