diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-09-08 05:43:49 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-09-08 05:43:49 -0400 |
commit | 1d6ae775d7a948c9575658eb41184fd2e506c0df (patch) | |
tree | 8128a28e89d82f13bb8e3a2160382240c66e2816 /drivers/hwmon/lm85.c | |
parent | 739cdbf1d8f0739b80035b80d69d871e33749b86 (diff) | |
parent | caf39e87cc1182f7dae84eefc43ca14d54c78ef9 (diff) |
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'drivers/hwmon/lm85.c')
-rw-r--r-- | drivers/hwmon/lm85.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index b4d7fd418264..ab214df9624b 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -28,15 +28,15 @@ | |||
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/jiffies.h> | 29 | #include <linux/jiffies.h> |
30 | #include <linux/i2c.h> | 30 | #include <linux/i2c.h> |
31 | #include <linux/i2c-sensor.h> | 31 | #include <linux/hwmon.h> |
32 | #include <linux/i2c-vid.h> | 32 | #include <linux/hwmon-vid.h> |
33 | #include <linux/err.h> | ||
33 | 34 | ||
34 | /* Addresses to scan */ | 35 | /* Addresses to scan */ |
35 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 36 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
36 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
37 | 37 | ||
38 | /* Insmod parameters */ | 38 | /* Insmod parameters */ |
39 | SENSORS_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); | 39 | I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); |
40 | 40 | ||
41 | /* The LM85 registers */ | 41 | /* The LM85 registers */ |
42 | 42 | ||
@@ -281,15 +281,6 @@ static int ZONE_TO_REG( int zone ) | |||
281 | #define PPR_TO_REG(val,fan) (SENSORS_LIMIT((val)-1,0,3)<<(fan *2)) | 281 | #define PPR_TO_REG(val,fan) (SENSORS_LIMIT((val)-1,0,3)<<(fan *2)) |
282 | #define PPR_FROM_REG(val,fan) ((((val)>>(fan * 2))&0x03)+1) | 282 | #define PPR_FROM_REG(val,fan) ((((val)>>(fan * 2))&0x03)+1) |
283 | 283 | ||
284 | /* i2c-vid.h defines vid_from_reg() */ | ||
285 | #define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm))) | ||
286 | |||
287 | /* Unlike some other drivers we DO NOT set initial limits. Use | ||
288 | * the config file to set limits. Some users have reported | ||
289 | * motherboards shutting down when we set limits in a previous | ||
290 | * version of the driver. | ||
291 | */ | ||
292 | |||
293 | /* Chip sampling rates | 284 | /* Chip sampling rates |
294 | * | 285 | * |
295 | * Some sensors are not updated more frequently than once per second | 286 | * Some sensors are not updated more frequently than once per second |
@@ -339,6 +330,7 @@ struct lm85_autofan { | |||
339 | 330 | ||
340 | struct lm85_data { | 331 | struct lm85_data { |
341 | struct i2c_client client; | 332 | struct i2c_client client; |
333 | struct class_device *class_dev; | ||
342 | struct semaphore lock; | 334 | struct semaphore lock; |
343 | enum chips type; | 335 | enum chips type; |
344 | 336 | ||
@@ -1019,7 +1011,7 @@ int lm85_attach_adapter(struct i2c_adapter *adapter) | |||
1019 | { | 1011 | { |
1020 | if (!(adapter->class & I2C_CLASS_HWMON)) | 1012 | if (!(adapter->class & I2C_CLASS_HWMON)) |
1021 | return 0; | 1013 | return 0; |
1022 | return i2c_detect(adapter, &addr_data, lm85_detect); | 1014 | return i2c_probe(adapter, &addr_data, lm85_detect); |
1023 | } | 1015 | } |
1024 | 1016 | ||
1025 | int lm85_detect(struct i2c_adapter *adapter, int address, | 1017 | int lm85_detect(struct i2c_adapter *adapter, int address, |
@@ -1031,11 +1023,6 @@ int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1031 | int err = 0; | 1023 | int err = 0; |
1032 | const char *type_name = ""; | 1024 | const char *type_name = ""; |
1033 | 1025 | ||
1034 | if (i2c_is_isa_adapter(adapter)) { | ||
1035 | /* This chip has no ISA interface */ | ||
1036 | goto ERROR0 ; | ||
1037 | }; | ||
1038 | |||
1039 | if (!i2c_check_functionality(adapter, | 1026 | if (!i2c_check_functionality(adapter, |
1040 | I2C_FUNC_SMBUS_BYTE_DATA)) { | 1027 | I2C_FUNC_SMBUS_BYTE_DATA)) { |
1041 | /* We need to be able to do byte I/O */ | 1028 | /* We need to be able to do byte I/O */ |
@@ -1160,12 +1147,18 @@ int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1160 | goto ERROR1; | 1147 | goto ERROR1; |
1161 | 1148 | ||
1162 | /* Set the VRM version */ | 1149 | /* Set the VRM version */ |
1163 | data->vrm = i2c_which_vrm(); | 1150 | data->vrm = vid_which_vrm(); |
1164 | 1151 | ||
1165 | /* Initialize the LM85 chip */ | 1152 | /* Initialize the LM85 chip */ |
1166 | lm85_init_client(new_client); | 1153 | lm85_init_client(new_client); |
1167 | 1154 | ||
1168 | /* Register sysfs hooks */ | 1155 | /* Register sysfs hooks */ |
1156 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
1157 | if (IS_ERR(data->class_dev)) { | ||
1158 | err = PTR_ERR(data->class_dev); | ||
1159 | goto ERROR2; | ||
1160 | } | ||
1161 | |||
1169 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 1162 | device_create_file(&new_client->dev, &dev_attr_fan1_input); |
1170 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | 1163 | device_create_file(&new_client->dev, &dev_attr_fan2_input); |
1171 | device_create_file(&new_client->dev, &dev_attr_fan3_input); | 1164 | device_create_file(&new_client->dev, &dev_attr_fan3_input); |
@@ -1235,6 +1228,8 @@ int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1235 | return 0; | 1228 | return 0; |
1236 | 1229 | ||
1237 | /* Error out and cleanup code */ | 1230 | /* Error out and cleanup code */ |
1231 | ERROR2: | ||
1232 | i2c_detach_client(new_client); | ||
1238 | ERROR1: | 1233 | ERROR1: |
1239 | kfree(data); | 1234 | kfree(data); |
1240 | ERROR0: | 1235 | ERROR0: |
@@ -1243,8 +1238,10 @@ int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1243 | 1238 | ||
1244 | int lm85_detach_client(struct i2c_client *client) | 1239 | int lm85_detach_client(struct i2c_client *client) |
1245 | { | 1240 | { |
1241 | struct lm85_data *data = i2c_get_clientdata(client); | ||
1242 | hwmon_device_unregister(data->class_dev); | ||
1246 | i2c_detach_client(client); | 1243 | i2c_detach_client(client); |
1247 | kfree(i2c_get_clientdata(client)); | 1244 | kfree(data); |
1248 | return 0; | 1245 | return 0; |
1249 | } | 1246 | } |
1250 | 1247 | ||