aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/fscpos.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/fscpos.c')
-rw-r--r--drivers/hwmon/fscpos.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c
index 301ae98bd0ad..4cb33b231124 100644
--- a/drivers/hwmon/fscpos.c
+++ b/drivers/hwmon/fscpos.c
@@ -36,6 +36,8 @@
36#include <linux/i2c.h> 36#include <linux/i2c.h>
37#include <linux/i2c-sensor.h> 37#include <linux/i2c-sensor.h>
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/hwmon.h>
40#include <linux/err.h>
39 41
40/* 42/*
41 * Addresses to scan 43 * Addresses to scan
@@ -113,6 +115,7 @@ static struct i2c_driver fscpos_driver = {
113 */ 115 */
114struct fscpos_data { 116struct fscpos_data {
115 struct i2c_client client; 117 struct i2c_client client;
118 struct class_device *class_dev;
116 struct semaphore update_lock; 119 struct semaphore update_lock;
117 char valid; /* 0 until following fields are valid */ 120 char valid; /* 0 until following fields are valid */
118 unsigned long last_updated; /* In jiffies */ 121 unsigned long last_updated; /* In jiffies */
@@ -496,6 +499,12 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
496 dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision); 499 dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision);
497 500
498 /* Register sysfs hooks */ 501 /* Register sysfs hooks */
502 data->class_dev = hwmon_device_register(&new_client->dev);
503 if (IS_ERR(data->class_dev)) {
504 err = PTR_ERR(data->class_dev);
505 goto exit_detach;
506 }
507
499 device_create_file(&new_client->dev, &dev_attr_event); 508 device_create_file(&new_client->dev, &dev_attr_event);
500 device_create_file(&new_client->dev, &dev_attr_in0_input); 509 device_create_file(&new_client->dev, &dev_attr_in0_input);
501 device_create_file(&new_client->dev, &dev_attr_in1_input); 510 device_create_file(&new_client->dev, &dev_attr_in1_input);
@@ -526,6 +535,8 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
526 535
527 return 0; 536 return 0;
528 537
538exit_detach:
539 i2c_detach_client(new_client);
529exit_free: 540exit_free:
530 kfree(data); 541 kfree(data);
531exit: 542exit:
@@ -534,14 +545,17 @@ exit:
534 545
535static int fscpos_detach_client(struct i2c_client *client) 546static int fscpos_detach_client(struct i2c_client *client)
536{ 547{
548 struct fscpos_data *data = i2c_get_clientdata(client);
537 int err; 549 int err;
538 550
551 hwmon_device_unregister(data->class_dev);
552
539 if ((err = i2c_detach_client(client))) { 553 if ((err = i2c_detach_client(client))) {
540 dev_err(&client->dev, "Client deregistration failed, client" 554 dev_err(&client->dev, "Client deregistration failed, client"
541 " not detached.\n"); 555 " not detached.\n");
542 return err; 556 return err;
543 } 557 }
544 kfree(i2c_get_clientdata(client)); 558 kfree(data);
545 return 0; 559 return 0;
546} 560}
547 561