aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83781d.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/w83781d.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/w83781d.c')
-rw-r--r--drivers/hwmon/w83781d.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 0bb131ce09eb..c83ae769e362 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -40,6 +40,8 @@
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/i2c-sensor.h> 41#include <linux/i2c-sensor.h>
42#include <linux/i2c-vid.h> 42#include <linux/i2c-vid.h>
43#include <linux/hwmon.h>
44#include <linux/err.h>
43#include <asm/io.h> 45#include <asm/io.h>
44#include "lm75.h" 46#include "lm75.h"
45 47
@@ -218,6 +220,7 @@ DIV_TO_REG(long val, enum chips type)
218 allocated. */ 220 allocated. */
219struct w83781d_data { 221struct w83781d_data {
220 struct i2c_client client; 222 struct i2c_client client;
223 struct class_device *class_dev;
221 struct semaphore lock; 224 struct semaphore lock;
222 enum chips type; 225 enum chips type;
223 226
@@ -961,10 +964,10 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind,
961ERROR_SC_3: 964ERROR_SC_3:
962 i2c_detach_client(data->lm75[0]); 965 i2c_detach_client(data->lm75[0]);
963ERROR_SC_2: 966ERROR_SC_2:
964 if (NULL != data->lm75[1]) 967 if (data->lm75[1])
965 kfree(data->lm75[1]); 968 kfree(data->lm75[1]);
966ERROR_SC_1: 969ERROR_SC_1:
967 if (NULL != data->lm75[0]) 970 if (data->lm75[0])
968 kfree(data->lm75[0]); 971 kfree(data->lm75[0]);
969ERROR_SC_0: 972ERROR_SC_0:
970 return err; 973 return err;
@@ -1189,6 +1192,12 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1189 data->pwmenable[i] = 1; 1192 data->pwmenable[i] = 1;
1190 1193
1191 /* Register sysfs hooks */ 1194 /* Register sysfs hooks */
1195 data->class_dev = hwmon_device_register(&new_client->dev);
1196 if (IS_ERR(data->class_dev)) {
1197 err = PTR_ERR(data->class_dev);
1198 goto ERROR4;
1199 }
1200
1192 device_create_file_in(new_client, 0); 1201 device_create_file_in(new_client, 0);
1193 if (kind != w83783s) 1202 if (kind != w83783s)
1194 device_create_file_in(new_client, 1); 1203 device_create_file_in(new_client, 1);
@@ -1241,6 +1250,15 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1241 1250
1242 return 0; 1251 return 0;
1243 1252
1253ERROR4:
1254 if (data->lm75[1]) {
1255 i2c_detach_client(data->lm75[1]);
1256 kfree(data->lm75[1]);
1257 }
1258 if (data->lm75[0]) {
1259 i2c_detach_client(data->lm75[0]);
1260 kfree(data->lm75[0]);
1261 }
1244ERROR3: 1262ERROR3:
1245 i2c_detach_client(new_client); 1263 i2c_detach_client(new_client);
1246ERROR2: 1264ERROR2:
@@ -1255,8 +1273,13 @@ ERROR0:
1255static int 1273static int
1256w83781d_detach_client(struct i2c_client *client) 1274w83781d_detach_client(struct i2c_client *client)
1257{ 1275{
1276 struct w83781d_data *data = i2c_get_clientdata(client);
1258 int err; 1277 int err;
1259 1278
1279 /* main client */
1280 if (data)
1281 hwmon_device_unregister(data->class_dev);
1282
1260 if (i2c_is_isa_client(client)) 1283 if (i2c_is_isa_client(client))
1261 release_region(client->addr, W83781D_EXTENT); 1284 release_region(client->addr, W83781D_EXTENT);
1262 1285
@@ -1266,13 +1289,13 @@ w83781d_detach_client(struct i2c_client *client)
1266 return err; 1289 return err;
1267 } 1290 }
1268 1291
1269 if (i2c_get_clientdata(client)==NULL) { 1292 /* main client */
1270 /* subclients */ 1293 if (data)
1294 kfree(data);
1295
1296 /* subclient */
1297 else
1271 kfree(client); 1298 kfree(client);
1272 } else {
1273 /* main client */
1274 kfree(i2c_get_clientdata(client));
1275 }
1276 1299
1277 return 0; 1300 return 0;
1278} 1301}