aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ds1621.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/ds1621.c')
-rw-r--r--drivers/hwmon/ds1621.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index 5360d58804f6..9ed21ac46e97 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -27,6 +27,8 @@
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-sensor.h> 29#include <linux/i2c-sensor.h>
30#include <linux/hwmon.h>
31#include <linux/err.h>
30#include "lm75.h" 32#include "lm75.h"
31 33
32/* Addresses to scan */ 34/* Addresses to scan */
@@ -71,6 +73,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
71/* Each client has this additional data */ 73/* Each client has this additional data */
72struct ds1621_data { 74struct ds1621_data {
73 struct i2c_client client; 75 struct i2c_client client;
76 struct class_device *class_dev;
74 struct semaphore update_lock; 77 struct semaphore update_lock;
75 char valid; /* !=0 if following fields are valid */ 78 char valid; /* !=0 if following fields are valid */
76 unsigned long last_updated; /* In jiffies */ 79 unsigned long last_updated; /* In jiffies */
@@ -250,6 +253,12 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
250 ds1621_init_client(new_client); 253 ds1621_init_client(new_client);
251 254
252 /* Register sysfs hooks */ 255 /* Register sysfs hooks */
256 data->class_dev = hwmon_device_register(&new_client->dev);
257 if (IS_ERR(data->class_dev)) {
258 err = PTR_ERR(data->class_dev);
259 goto exit_detach;
260 }
261
253 device_create_file(&new_client->dev, &dev_attr_alarms); 262 device_create_file(&new_client->dev, &dev_attr_alarms);
254 device_create_file(&new_client->dev, &dev_attr_temp1_input); 263 device_create_file(&new_client->dev, &dev_attr_temp1_input);
255 device_create_file(&new_client->dev, &dev_attr_temp1_min); 264 device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -259,6 +268,8 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
259 268
260/* OK, this is not exactly good programming practice, usually. But it is 269/* OK, this is not exactly good programming practice, usually. But it is
261 very code-efficient in this case. */ 270 very code-efficient in this case. */
271 exit_detach:
272 i2c_detach_client(new_client);
262 exit_free: 273 exit_free:
263 kfree(data); 274 kfree(data);
264 exit: 275 exit:
@@ -267,15 +278,18 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
267 278
268static int ds1621_detach_client(struct i2c_client *client) 279static int ds1621_detach_client(struct i2c_client *client)
269{ 280{
281 struct ds1621_data *data = i2c_get_clientdata(client);
270 int err; 282 int err;
271 283
284 hwmon_device_unregister(data->class_dev);
285
272 if ((err = i2c_detach_client(client))) { 286 if ((err = i2c_detach_client(client))) {
273 dev_err(&client->dev, "Client deregistration failed, " 287 dev_err(&client->dev, "Client deregistration failed, "
274 "client not detached.\n"); 288 "client not detached.\n");
275 return err; 289 return err;
276 } 290 }
277 291
278 kfree(i2c_get_clientdata(client)); 292 kfree(data);
279 293
280 return 0; 294 return 0;
281} 295}