aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm75.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm75.c')
-rw-r--r--drivers/hwmon/lm75.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 79d7ebc9b14a..129c8f213331 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -24,6 +24,8 @@
24#include <linux/jiffies.h> 24#include <linux/jiffies.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/i2c-sensor.h> 26#include <linux/i2c-sensor.h>
27#include <linux/hwmon.h>
28#include <linux/err.h>
27#include "lm75.h" 29#include "lm75.h"
28 30
29 31
@@ -46,6 +48,7 @@ SENSORS_INSMOD_1(lm75);
46/* Each client has this additional data */ 48/* Each client has this additional data */
47struct lm75_data { 49struct lm75_data {
48 struct i2c_client client; 50 struct i2c_client client;
51 struct class_device *class_dev;
49 struct semaphore update_lock; 52 struct semaphore update_lock;
50 char valid; /* !=0 if following fields are valid */ 53 char valid; /* !=0 if following fields are valid */
51 unsigned long last_updated; /* In jiffies */ 54 unsigned long last_updated; /* In jiffies */
@@ -208,12 +211,20 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
208 lm75_init_client(new_client); 211 lm75_init_client(new_client);
209 212
210 /* Register sysfs hooks */ 213 /* Register sysfs hooks */
214 data->class_dev = hwmon_device_register(&new_client->dev);
215 if (IS_ERR(data->class_dev)) {
216 err = PTR_ERR(data->class_dev);
217 goto exit_detach;
218 }
219
211 device_create_file(&new_client->dev, &dev_attr_temp1_max); 220 device_create_file(&new_client->dev, &dev_attr_temp1_max);
212 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); 221 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
213 device_create_file(&new_client->dev, &dev_attr_temp1_input); 222 device_create_file(&new_client->dev, &dev_attr_temp1_input);
214 223
215 return 0; 224 return 0;
216 225
226exit_detach:
227 i2c_detach_client(new_client);
217exit_free: 228exit_free:
218 kfree(data); 229 kfree(data);
219exit: 230exit:
@@ -222,8 +233,10 @@ exit:
222 233
223static int lm75_detach_client(struct i2c_client *client) 234static int lm75_detach_client(struct i2c_client *client)
224{ 235{
236 struct lm75_data *data = i2c_get_clientdata(client);
237 hwmon_device_unregister(data->class_dev);
225 i2c_detach_client(client); 238 i2c_detach_client(client);
226 kfree(i2c_get_clientdata(client)); 239 kfree(data);
227 return 0; 240 return 0;
228} 241}
229 242