From 943b0830cebe4711354945ed3cb44e84152aaca0 Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Fri, 15 Jul 2005 21:39:18 -0400 Subject: [PATCH] I2C hwmon: add hwmon sysfs class to drivers This patch modifies sensors chip drivers to make use of the new sysfs class "hwmon". Signed-off-by: Mark M. Hoffman Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/w83627ehf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'drivers/hwmon/w83627ehf.c') diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 250f6b059a54..956e7f830aa6 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include "lm75.h" @@ -177,6 +179,7 @@ temp1_to_reg(int temp) struct w83627ehf_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; struct semaphore update_lock; @@ -723,6 +726,12 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) data->has_fan |= (1 << 4); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&client->dev, &dev_attr_fan1_input); device_create_file(&client->dev, &dev_attr_fan1_min); device_create_file(&client->dev, &dev_attr_fan1_div); @@ -756,6 +765,8 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(client); exit_free: kfree(data); exit_release: @@ -773,15 +784,18 @@ static int w83627ehf_attach_adapter(struct i2c_adapter *adapter) static int w83627ehf_detach_client(struct i2c_client *client) { + struct w83627ehf_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; } release_region(client->addr, REGION_LENGTH); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } -- cgit v1.2.3