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/w83627hf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'drivers/hwmon/w83627hf.c') diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index bd87a42..da2f499 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -44,6 +44,8 @@ #include #include #include +#include +#include #include #include "lm75.h" @@ -277,6 +279,7 @@ static inline u8 DIV_TO_REG(long val) dynamically allocated, at the same time when a new client is allocated. */ struct w83627hf_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; enum chips type; @@ -1102,6 +1105,12 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address, data->fan_min[2] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(3)); /* 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 ERROR3; + } + device_create_file_in(new_client, 0); if (kind != w83697hf) device_create_file_in(new_client, 1); @@ -1152,6 +1161,8 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address, return 0; + ERROR3: + i2c_detach_client(new_client); ERROR2: kfree(data); ERROR1: @@ -1162,8 +1173,11 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address, static int w83627hf_detach_client(struct i2c_client *client) { + struct w83627hf_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"); @@ -1171,7 +1185,7 @@ static int w83627hf_detach_client(struct i2c_client *client) } release_region(client->addr, WINB_EXTENT); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } -- cgit v1.1