aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/smsc47b397.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/smsc47b397.c')
-rw-r--r--drivers/hwmon/smsc47b397.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index fdeeb3ab6f2f..96b9eb40f425 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -32,6 +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#include <linux/hwmon.h>
36#include <linux/err.h>
35#include <linux/init.h> 37#include <linux/init.h>
36#include <asm/io.h> 38#include <asm/io.h>
37 39
@@ -100,6 +102,7 @@ static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80};
100 102
101struct smsc47b397_data { 103struct smsc47b397_data {
102 struct i2c_client client; 104 struct i2c_client client;
105 struct class_device *class_dev;
103 struct semaphore lock; 106 struct semaphore lock;
104 107
105 struct semaphore update_lock; 108 struct semaphore update_lock;
@@ -226,8 +229,11 @@ static int smsc47b397_attach_adapter(struct i2c_adapter *adapter)
226 229
227static int smsc47b397_detach_client(struct i2c_client *client) 230static int smsc47b397_detach_client(struct i2c_client *client)
228{ 231{
232 struct smsc47b397_data *data = i2c_get_clientdata(client);
229 int err; 233 int err;
230 234
235 hwmon_device_unregister(data->class_dev);
236
231 if ((err = i2c_detach_client(client))) { 237 if ((err = i2c_detach_client(client))) {
232 dev_err(&client->dev, "Client deregistration failed, " 238 dev_err(&client->dev, "Client deregistration failed, "
233 "client not detached.\n"); 239 "client not detached.\n");
@@ -235,7 +241,7 @@ static int smsc47b397_detach_client(struct i2c_client *client)
235 } 241 }
236 242
237 release_region(client->addr, SMSC_EXTENT); 243 release_region(client->addr, SMSC_EXTENT);
238 kfree(i2c_get_clientdata(client)); 244 kfree(data);
239 245
240 return 0; 246 return 0;
241} 247}
@@ -285,6 +291,12 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
285 if ((err = i2c_attach_client(new_client))) 291 if ((err = i2c_attach_client(new_client)))
286 goto error_free; 292 goto error_free;
287 293
294 data->class_dev = hwmon_device_register(&new_client->dev);
295 if (IS_ERR(data->class_dev)) {
296 err = PTR_ERR(data->class_dev);
297 goto error_detach;
298 }
299
288 device_create_file_temp(new_client, 1); 300 device_create_file_temp(new_client, 1);
289 device_create_file_temp(new_client, 2); 301 device_create_file_temp(new_client, 2);
290 device_create_file_temp(new_client, 3); 302 device_create_file_temp(new_client, 3);
@@ -297,6 +309,8 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
297 309
298 return 0; 310 return 0;
299 311
312error_detach:
313 i2c_detach_client(new_client);
300error_free: 314error_free:
301 kfree(data); 315 kfree(data);
302error_release: 316error_release: