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.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index 5360d58804f6..b0199e063d0e 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -26,16 +26,16 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
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/hwmon.h>
30#include <linux/err.h>
30#include "lm75.h" 31#include "lm75.h"
31 32
32/* Addresses to scan */ 33/* Addresses to scan */
33static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 34static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
34 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 35 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
35static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
36 36
37/* Insmod parameters */ 37/* Insmod parameters */
38SENSORS_INSMOD_1(ds1621); 38I2C_CLIENT_INSMOD_1(ds1621);
39static int polarity = -1; 39static int polarity = -1;
40module_param(polarity, int, 0); 40module_param(polarity, int, 0);
41MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low"); 41MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low");
@@ -71,6 +71,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
71/* Each client has this additional data */ 71/* Each client has this additional data */
72struct ds1621_data { 72struct ds1621_data {
73 struct i2c_client client; 73 struct i2c_client client;
74 struct class_device *class_dev;
74 struct semaphore update_lock; 75 struct semaphore update_lock;
75 char valid; /* !=0 if following fields are valid */ 76 char valid; /* !=0 if following fields are valid */
76 unsigned long last_updated; /* In jiffies */ 77 unsigned long last_updated; /* In jiffies */
@@ -179,10 +180,10 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max);
179 180
180static int ds1621_attach_adapter(struct i2c_adapter *adapter) 181static int ds1621_attach_adapter(struct i2c_adapter *adapter)
181{ 182{
182 return i2c_detect(adapter, &addr_data, ds1621_detect); 183 return i2c_probe(adapter, &addr_data, ds1621_detect);
183} 184}
184 185
185/* This function is called by i2c_detect */ 186/* This function is called by i2c_probe */
186int ds1621_detect(struct i2c_adapter *adapter, int address, 187int ds1621_detect(struct i2c_adapter *adapter, int address,
187 int kind) 188 int kind)
188{ 189{
@@ -250,6 +251,12 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
250 ds1621_init_client(new_client); 251 ds1621_init_client(new_client);
251 252
252 /* Register sysfs hooks */ 253 /* Register sysfs hooks */
254 data->class_dev = hwmon_device_register(&new_client->dev);
255 if (IS_ERR(data->class_dev)) {
256 err = PTR_ERR(data->class_dev);
257 goto exit_detach;
258 }
259
253 device_create_file(&new_client->dev, &dev_attr_alarms); 260 device_create_file(&new_client->dev, &dev_attr_alarms);
254 device_create_file(&new_client->dev, &dev_attr_temp1_input); 261 device_create_file(&new_client->dev, &dev_attr_temp1_input);
255 device_create_file(&new_client->dev, &dev_attr_temp1_min); 262 device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -259,6 +266,8 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
259 266
260/* OK, this is not exactly good programming practice, usually. But it is 267/* OK, this is not exactly good programming practice, usually. But it is
261 very code-efficient in this case. */ 268 very code-efficient in this case. */
269 exit_detach:
270 i2c_detach_client(new_client);
262 exit_free: 271 exit_free:
263 kfree(data); 272 kfree(data);
264 exit: 273 exit:
@@ -267,15 +276,15 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
267 276
268static int ds1621_detach_client(struct i2c_client *client) 277static int ds1621_detach_client(struct i2c_client *client)
269{ 278{
279 struct ds1621_data *data = i2c_get_clientdata(client);
270 int err; 280 int err;
271 281
272 if ((err = i2c_detach_client(client))) { 282 hwmon_device_unregister(data->class_dev);
273 dev_err(&client->dev, "Client deregistration failed, " 283
274 "client not detached.\n"); 284 if ((err = i2c_detach_client(client)))
275 return err; 285 return err;
276 }
277 286
278 kfree(i2c_get_clientdata(client)); 287 kfree(data);
279 288
280 return 0; 289 return 0;
281} 290}