aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm92.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm92.c')
-rw-r--r--drivers/hwmon/lm92.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index 215c8e40ffdd..0fb601c07519 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -45,7 +45,8 @@
45#include <linux/slab.h> 45#include <linux/slab.h>
46#include <linux/i2c.h> 46#include <linux/i2c.h>
47#include <linux/i2c-sensor.h> 47#include <linux/i2c-sensor.h>
48 48#include <linux/hwmon.h>
49#include <linux/err.h>
49 50
50/* The LM92 and MAX6635 have 2 two-state pins for address selection, 51/* The LM92 and MAX6635 have 2 two-state pins for address selection,
51 resulting in 4 possible addresses. */ 52 resulting in 4 possible addresses. */
@@ -96,6 +97,7 @@ static struct i2c_driver lm92_driver;
96/* Client data (each client gets its own) */ 97/* Client data (each client gets its own) */
97struct lm92_data { 98struct lm92_data {
98 struct i2c_client client; 99 struct i2c_client client;
100 struct class_device *class_dev;
99 struct semaphore update_lock; 101 struct semaphore update_lock;
100 char valid; /* zero until following fields are valid */ 102 char valid; /* zero until following fields are valid */
101 unsigned long last_updated; /* in jiffies */ 103 unsigned long last_updated; /* in jiffies */
@@ -359,6 +361,12 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
359 lm92_init_client(new_client); 361 lm92_init_client(new_client);
360 362
361 /* Register sysfs hooks */ 363 /* Register sysfs hooks */
364 data->class_dev = hwmon_device_register(&new_client->dev);
365 if (IS_ERR(data->class_dev)) {
366 err = PTR_ERR(data->class_dev);
367 goto exit_detach;
368 }
369
362 device_create_file(&new_client->dev, &dev_attr_temp1_input); 370 device_create_file(&new_client->dev, &dev_attr_temp1_input);
363 device_create_file(&new_client->dev, &dev_attr_temp1_crit); 371 device_create_file(&new_client->dev, &dev_attr_temp1_crit);
364 device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); 372 device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst);
@@ -370,6 +378,8 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
370 378
371 return 0; 379 return 0;
372 380
381exit_detach:
382 i2c_detach_client(new_client);
373exit_free: 383exit_free:
374 kfree(data); 384 kfree(data);
375exit: 385exit:
@@ -385,15 +395,18 @@ static int lm92_attach_adapter(struct i2c_adapter *adapter)
385 395
386static int lm92_detach_client(struct i2c_client *client) 396static int lm92_detach_client(struct i2c_client *client)
387{ 397{
398 struct lm92_data *data = i2c_get_clientdata(client);
388 int err; 399 int err;
389 400
401 hwmon_device_unregister(data->class_dev);
402
390 if ((err = i2c_detach_client(client))) { 403 if ((err = i2c_detach_client(client))) {
391 dev_err(&client->dev, "Client deregistration failed, " 404 dev_err(&client->dev, "Client deregistration failed, "
392 "client not detached.\n"); 405 "client not detached.\n");
393 return err; 406 return err;
394 } 407 }
395 408
396 kfree(i2c_get_clientdata(client)); 409 kfree(data);
397 return 0; 410 return 0;
398} 411}
399 412