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.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c
index 3c159f1d49ee..56c34c2d3619 100644
--- a/drivers/hwmon/max1619.c
+++ b/drivers/hwmon/max1619.c
@@ -32,7 +32,8 @@
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/i2c-sensor.h>
35 35#include <linux/hwmon.h>
36#include <linux/err.h>
36 37
37static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 38static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
38 0x29, 0x2a, 0x2b, 39 0x29, 0x2a, 0x2b,
@@ -104,6 +105,7 @@ static struct i2c_driver max1619_driver = {
104 105
105struct max1619_data { 106struct max1619_data {
106 struct i2c_client client; 107 struct i2c_client client;
108 struct class_device *class_dev;
107 struct semaphore update_lock; 109 struct semaphore update_lock;
108 char valid; /* zero until following fields are valid */ 110 char valid; /* zero until following fields are valid */
109 unsigned long last_updated; /* in jiffies */ 111 unsigned long last_updated; /* in jiffies */
@@ -275,6 +277,12 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
275 max1619_init_client(new_client); 277 max1619_init_client(new_client);
276 278
277 /* Register sysfs hooks */ 279 /* Register sysfs hooks */
280 data->class_dev = hwmon_device_register(&new_client->dev);
281 if (IS_ERR(data->class_dev)) {
282 err = PTR_ERR(data->class_dev);
283 goto exit_detach;
284 }
285
278 device_create_file(&new_client->dev, &dev_attr_temp1_input); 286 device_create_file(&new_client->dev, &dev_attr_temp1_input);
279 device_create_file(&new_client->dev, &dev_attr_temp2_input); 287 device_create_file(&new_client->dev, &dev_attr_temp2_input);
280 device_create_file(&new_client->dev, &dev_attr_temp2_min); 288 device_create_file(&new_client->dev, &dev_attr_temp2_min);
@@ -285,6 +293,8 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
285 293
286 return 0; 294 return 0;
287 295
296exit_detach:
297 i2c_detach_client(new_client);
288exit_free: 298exit_free:
289 kfree(data); 299 kfree(data);
290exit: 300exit:
@@ -308,15 +318,18 @@ static void max1619_init_client(struct i2c_client *client)
308 318
309static int max1619_detach_client(struct i2c_client *client) 319static int max1619_detach_client(struct i2c_client *client)
310{ 320{
321 struct max1619_data *data = i2c_get_clientdata(client);
311 int err; 322 int err;
312 323
324 hwmon_device_unregister(data->class_dev);
325
313 if ((err = i2c_detach_client(client))) { 326 if ((err = i2c_detach_client(client))) {
314 dev_err(&client->dev, "Client deregistration failed, " 327 dev_err(&client->dev, "Client deregistration failed, "
315 "client not detached.\n"); 328 "client not detached.\n");
316 return err; 329 return err;
317 } 330 }
318 331
319 kfree(i2c_get_clientdata(client)); 332 kfree(data);
320 return 0; 333 return 0;
321} 334}
322 335