aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm85.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm85.c')
-rw-r--r--drivers/hwmon/lm85.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index b4d7fd418264..4203f904bbe2 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -30,6 +30,8 @@
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/i2c-sensor.h> 31#include <linux/i2c-sensor.h>
32#include <linux/i2c-vid.h> 32#include <linux/i2c-vid.h>
33#include <linux/hwmon.h>
34#include <linux/err.h>
33 35
34/* Addresses to scan */ 36/* Addresses to scan */
35static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 37static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -339,6 +341,7 @@ struct lm85_autofan {
339 341
340struct lm85_data { 342struct lm85_data {
341 struct i2c_client client; 343 struct i2c_client client;
344 struct class_device *class_dev;
342 struct semaphore lock; 345 struct semaphore lock;
343 enum chips type; 346 enum chips type;
344 347
@@ -1166,6 +1169,12 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
1166 lm85_init_client(new_client); 1169 lm85_init_client(new_client);
1167 1170
1168 /* Register sysfs hooks */ 1171 /* Register sysfs hooks */
1172 data->class_dev = hwmon_device_register(&new_client->dev);
1173 if (IS_ERR(data->class_dev)) {
1174 err = PTR_ERR(data->class_dev);
1175 goto ERROR2;
1176 }
1177
1169 device_create_file(&new_client->dev, &dev_attr_fan1_input); 1178 device_create_file(&new_client->dev, &dev_attr_fan1_input);
1170 device_create_file(&new_client->dev, &dev_attr_fan2_input); 1179 device_create_file(&new_client->dev, &dev_attr_fan2_input);
1171 device_create_file(&new_client->dev, &dev_attr_fan3_input); 1180 device_create_file(&new_client->dev, &dev_attr_fan3_input);
@@ -1235,6 +1244,8 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
1235 return 0; 1244 return 0;
1236 1245
1237 /* Error out and cleanup code */ 1246 /* Error out and cleanup code */
1247 ERROR2:
1248 i2c_detach_client(new_client);
1238 ERROR1: 1249 ERROR1:
1239 kfree(data); 1250 kfree(data);
1240 ERROR0: 1251 ERROR0:
@@ -1243,8 +1254,10 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
1243 1254
1244int lm85_detach_client(struct i2c_client *client) 1255int lm85_detach_client(struct i2c_client *client)
1245{ 1256{
1257 struct lm85_data *data = i2c_get_clientdata(client);
1258 hwmon_device_unregister(data->class_dev);
1246 i2c_detach_client(client); 1259 i2c_detach_client(client);
1247 kfree(i2c_get_clientdata(client)); 1260 kfree(data);
1248 return 0; 1261 return 0;
1249} 1262}
1250 1263