aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83l785ts.c
diff options
context:
space:
mode:
authorMark M. Hoffman <mhoffman@lightlink.com>2005-07-15 21:39:18 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-05 12:14:08 -0400
commit943b0830cebe4711354945ed3cb44e84152aaca0 (patch)
tree1963da8d8867069617404a8f92739035c6faca02 /drivers/hwmon/w83l785ts.c
parent1236441f38b6a98caf4c7983e7efdecc2d1527b5 (diff)
[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 <mhoffman@lightlink.com> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/w83l785ts.c')
-rw-r--r--drivers/hwmon/w83l785ts.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index 4469d52aba4c..1f763499dac4 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -37,6 +37,8 @@
37#include <linux/jiffies.h> 37#include <linux/jiffies.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/i2c-sensor.h> 39#include <linux/i2c-sensor.h>
40#include <linux/hwmon.h>
41#include <linux/err.h>
40 42
41/* How many retries on register read error */ 43/* How many retries on register read error */
42#define MAX_RETRIES 5 44#define MAX_RETRIES 5
@@ -105,6 +107,7 @@ static struct i2c_driver w83l785ts_driver = {
105 107
106struct w83l785ts_data { 108struct w83l785ts_data {
107 struct i2c_client client; 109 struct i2c_client client;
110 struct class_device *class_dev;
108 struct semaphore update_lock; 111 struct semaphore update_lock;
109 char valid; /* zero until following fields are valid */ 112 char valid; /* zero until following fields are valid */
110 unsigned long last_updated; /* in jiffies */ 113 unsigned long last_updated; /* in jiffies */
@@ -239,11 +242,19 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
239 */ 242 */
240 243
241 /* Register sysfs hooks */ 244 /* Register sysfs hooks */
245 data->class_dev = hwmon_device_register(&new_client->dev);
246 if (IS_ERR(data->class_dev)) {
247 err = PTR_ERR(data->class_dev);
248 goto exit_detach;
249 }
250
242 device_create_file(&new_client->dev, &dev_attr_temp1_input); 251 device_create_file(&new_client->dev, &dev_attr_temp1_input);
243 device_create_file(&new_client->dev, &dev_attr_temp1_max); 252 device_create_file(&new_client->dev, &dev_attr_temp1_max);
244 253
245 return 0; 254 return 0;
246 255
256exit_detach:
257 i2c_detach_client(new_client);
247exit_free: 258exit_free:
248 kfree(data); 259 kfree(data);
249exit: 260exit:
@@ -252,15 +263,18 @@ exit:
252 263
253static int w83l785ts_detach_client(struct i2c_client *client) 264static int w83l785ts_detach_client(struct i2c_client *client)
254{ 265{
266 struct w83l785ts_data *data = i2c_get_clientdata(client);
255 int err; 267 int err;
256 268
269 hwmon_device_unregister(data->class_dev);
270
257 if ((err = i2c_detach_client(client))) { 271 if ((err = i2c_detach_client(client))) {
258 dev_err(&client->dev, "Client deregistration failed, " 272 dev_err(&client->dev, "Client deregistration failed, "
259 "client not detached.\n"); 273 "client not detached.\n");
260 return err; 274 return err;
261 } 275 }
262 276
263 kfree(i2c_get_clientdata(client)); 277 kfree(data);
264 return 0; 278 return 0;
265} 279}
266 280