aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/smsc47m1.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/smsc47m1.c')
-rw-r--r--drivers/hwmon/smsc47m1.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 7166ad0b2fda..de7c7f804d66 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -31,6 +31,8 @@
31#include <linux/jiffies.h> 31#include <linux/jiffies.h>
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/i2c-sensor.h> 33#include <linux/i2c-sensor.h>
34#include <linux/hwmon.h>
35#include <linux/err.h>
34#include <linux/init.h> 36#include <linux/init.h>
35#include <asm/io.h> 37#include <asm/io.h>
36 38
@@ -108,6 +110,7 @@ superio_exit(void)
108 110
109struct smsc47m1_data { 111struct smsc47m1_data {
110 struct i2c_client client; 112 struct i2c_client client;
113 struct class_device *class_dev;
111 struct semaphore lock; 114 struct semaphore lock;
112 115
113 struct semaphore update_lock; 116 struct semaphore update_lock;
@@ -461,6 +464,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind)
461 function. */ 464 function. */
462 smsc47m1_update_device(&new_client->dev, 1); 465 smsc47m1_update_device(&new_client->dev, 1);
463 466
467 /* Register sysfs hooks */
468 data->class_dev = hwmon_device_register(&new_client->dev);
469 if (IS_ERR(data->class_dev)) {
470 err = PTR_ERR(data->class_dev);
471 goto error_detach;
472 }
473
464 if (fan1) { 474 if (fan1) {
465 device_create_file(&new_client->dev, &dev_attr_fan1_input); 475 device_create_file(&new_client->dev, &dev_attr_fan1_input);
466 device_create_file(&new_client->dev, &dev_attr_fan1_min); 476 device_create_file(&new_client->dev, &dev_attr_fan1_min);
@@ -494,6 +504,8 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind)
494 504
495 return 0; 505 return 0;
496 506
507error_detach:
508 i2c_detach_client(new_client);
497error_free: 509error_free:
498 kfree(data); 510 kfree(data);
499error_release: 511error_release:
@@ -503,8 +515,11 @@ error_release:
503 515
504static int smsc47m1_detach_client(struct i2c_client *client) 516static int smsc47m1_detach_client(struct i2c_client *client)
505{ 517{
518 struct smsc47m1_data *data = i2c_get_clientdata(client);
506 int err; 519 int err;
507 520
521 hwmon_device_unregister(data->class_dev);
522
508 if ((err = i2c_detach_client(client))) { 523 if ((err = i2c_detach_client(client))) {
509 dev_err(&client->dev, "Client deregistration failed, " 524 dev_err(&client->dev, "Client deregistration failed, "
510 "client not detached.\n"); 525 "client not detached.\n");
@@ -512,7 +527,7 @@ static int smsc47m1_detach_client(struct i2c_client *client)
512 } 527 }
513 528
514 release_region(client->addr, SMSC_EXTENT); 529 release_region(client->addr, SMSC_EXTENT);
515 kfree(i2c_get_clientdata(client)); 530 kfree(data);
516 531
517 return 0; 532 return 0;
518} 533}