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/gl520sm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'drivers/hwmon/gl520sm.c') diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 80ae8d30c2a..ce482e17e03 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include /* Type of the extra sensor */ static unsigned short extra_sensor_type; @@ -120,6 +122,7 @@ static struct i2c_driver gl520_driver = { /* Client data */ struct gl520_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until the following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -571,6 +574,12 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) gl520_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_vid(new_client, 0); device_create_file_in(new_client, 0); @@ -592,6 +601,8 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -639,15 +650,18 @@ static void gl520_init_client(struct i2c_client *client) static int gl520_detach_client(struct i2c_client *client) { + struct gl520_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; } -- cgit v1.2.3-18-g5258