aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/max1619.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/max1619.c')
-rw-r--r--drivers/hwmon/max1619.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c
index 3c159f1d49ee..16bf71f3a04d 100644
--- a/drivers/hwmon/max1619.c
+++ b/drivers/hwmon/max1619.c
@@ -31,20 +31,19 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/i2c-sensor.h> 34#include <linux/hwmon.h>
35 35#include <linux/err.h>
36 36
37static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 37static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
38 0x29, 0x2a, 0x2b, 38 0x29, 0x2a, 0x2b,
39 0x4c, 0x4d, 0x4e, 39 0x4c, 0x4d, 0x4e,
40 I2C_CLIENT_END }; 40 I2C_CLIENT_END };
41static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
42 41
43/* 42/*
44 * Insmod parameters 43 * Insmod parameters
45 */ 44 */
46 45
47SENSORS_INSMOD_1(max1619); 46I2C_CLIENT_INSMOD_1(max1619);
48 47
49/* 48/*
50 * The MAX1619 registers 49 * The MAX1619 registers
@@ -104,6 +103,7 @@ static struct i2c_driver max1619_driver = {
104 103
105struct max1619_data { 104struct max1619_data {
106 struct i2c_client client; 105 struct i2c_client client;
106 struct class_device *class_dev;
107 struct semaphore update_lock; 107 struct semaphore update_lock;
108 char valid; /* zero until following fields are valid */ 108 char valid; /* zero until following fields are valid */
109 unsigned long last_updated; /* in jiffies */ 109 unsigned long last_updated; /* in jiffies */
@@ -179,7 +179,7 @@ static int max1619_attach_adapter(struct i2c_adapter *adapter)
179{ 179{
180 if (!(adapter->class & I2C_CLASS_HWMON)) 180 if (!(adapter->class & I2C_CLASS_HWMON))
181 return 0; 181 return 0;
182 return i2c_detect(adapter, &addr_data, max1619_detect); 182 return i2c_probe(adapter, &addr_data, max1619_detect);
183} 183}
184 184
185/* 185/*
@@ -275,6 +275,12 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
275 max1619_init_client(new_client); 275 max1619_init_client(new_client);
276 276
277 /* Register sysfs hooks */ 277 /* Register sysfs hooks */
278 data->class_dev = hwmon_device_register(&new_client->dev);
279 if (IS_ERR(data->class_dev)) {
280 err = PTR_ERR(data->class_dev);
281 goto exit_detach;
282 }
283
278 device_create_file(&new_client->dev, &dev_attr_temp1_input); 284 device_create_file(&new_client->dev, &dev_attr_temp1_input);
279 device_create_file(&new_client->dev, &dev_attr_temp2_input); 285 device_create_file(&new_client->dev, &dev_attr_temp2_input);
280 device_create_file(&new_client->dev, &dev_attr_temp2_min); 286 device_create_file(&new_client->dev, &dev_attr_temp2_min);
@@ -285,6 +291,8 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
285 291
286 return 0; 292 return 0;
287 293
294exit_detach:
295 i2c_detach_client(new_client);
288exit_free: 296exit_free:
289 kfree(data); 297 kfree(data);
290exit: 298exit:
@@ -308,15 +316,15 @@ static void max1619_init_client(struct i2c_client *client)
308 316
309static int max1619_detach_client(struct i2c_client *client) 317static int max1619_detach_client(struct i2c_client *client)
310{ 318{
319 struct max1619_data *data = i2c_get_clientdata(client);
311 int err; 320 int err;
312 321
313 if ((err = i2c_detach_client(client))) { 322 hwmon_device_unregister(data->class_dev);
314 dev_err(&client->dev, "Client deregistration failed, " 323
315 "client not detached.\n"); 324 if ((err = i2c_detach_client(client)))
316 return err; 325 return err;
317 }
318 326
319 kfree(i2c_get_clientdata(client)); 327 kfree(data);
320 return 0; 328 return 0;
321} 329}
322 330