diff options
Diffstat (limited to 'drivers/hwmon/lm92.c')
-rw-r--r-- | drivers/hwmon/lm92.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 215c8e40ffd..0fb601c0751 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -45,7 +45,8 @@ #include <linux/slab.h> #include <linux/i2c.h> #include <linux/i2c-sensor.h> - +#include <linux/hwmon.h> +#include <linux/err.h> /* The LM92 and MAX6635 have 2 two-state pins for address selection, resulting in 4 possible addresses. */ @@ -96,6 +97,7 @@ static struct i2c_driver lm92_driver; /* Client data (each client gets its own) */ struct lm92_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -359,6 +361,12 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) lm92_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp1_crit); device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); @@ -370,6 +378,8 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -385,15 +395,18 @@ static int lm92_attach_adapter(struct i2c_adapter *adapter) static int lm92_detach_client(struct i2c_client *client) { + struct lm92_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } |