diff options
author | Len Brown <len.brown@intel.com> | 2005-09-08 01:45:47 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2005-09-08 01:45:47 -0400 |
commit | 64e47488c913ac704d465a6af86a26786d1412a5 (patch) | |
tree | d3b0148592963dcde26e4bb35ddfec8b1eaf8e23 /drivers/hwmon/asb100.c | |
parent | 4a35a46bf1cda4737c428380d1db5d15e2590d18 (diff) | |
parent | caf39e87cc1182f7dae84eefc43ca14d54c78ef9 (diff) |
Merge linux-2.6 with linux-acpi-2.6
Diffstat (limited to 'drivers/hwmon/asb100.c')
-rw-r--r-- | drivers/hwmon/asb100.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 70d996d6fe0a..8e34855a6274 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c | |||
@@ -39,8 +39,9 @@ | |||
39 | #include <linux/module.h> | 39 | #include <linux/module.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/i2c.h> | 41 | #include <linux/i2c.h> |
42 | #include <linux/i2c-sensor.h> | 42 | #include <linux/hwmon.h> |
43 | #include <linux/i2c-vid.h> | 43 | #include <linux/hwmon-vid.h> |
44 | #include <linux/err.h> | ||
44 | #include <linux/init.h> | 45 | #include <linux/init.h> |
45 | #include <linux/jiffies.h> | 46 | #include <linux/jiffies.h> |
46 | #include "lm75.h" | 47 | #include "lm75.h" |
@@ -54,11 +55,8 @@ | |||
54 | /* I2C addresses to scan */ | 55 | /* I2C addresses to scan */ |
55 | static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END }; | 56 | static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END }; |
56 | 57 | ||
57 | /* ISA addresses to scan (none) */ | ||
58 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
59 | |||
60 | /* Insmod parameters */ | 58 | /* Insmod parameters */ |
61 | SENSORS_INSMOD_1(asb100); | 59 | I2C_CLIENT_INSMOD_1(asb100); |
62 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " | 60 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " |
63 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); | 61 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); |
64 | 62 | ||
@@ -183,6 +181,7 @@ static u8 DIV_TO_REG(long val) | |||
183 | dynamically allocated, at the same time the client itself is allocated. */ | 181 | dynamically allocated, at the same time the client itself is allocated. */ |
184 | struct asb100_data { | 182 | struct asb100_data { |
185 | struct i2c_client client; | 183 | struct i2c_client client; |
184 | struct class_device *class_dev; | ||
186 | struct semaphore lock; | 185 | struct semaphore lock; |
187 | enum chips type; | 186 | enum chips type; |
188 | 187 | ||
@@ -621,7 +620,7 @@ static int asb100_attach_adapter(struct i2c_adapter *adapter) | |||
621 | { | 620 | { |
622 | if (!(adapter->class & I2C_CLASS_HWMON)) | 621 | if (!(adapter->class & I2C_CLASS_HWMON)) |
623 | return 0; | 622 | return 0; |
624 | return i2c_detect(adapter, &addr_data, asb100_detect); | 623 | return i2c_probe(adapter, &addr_data, asb100_detect); |
625 | } | 624 | } |
626 | 625 | ||
627 | static int asb100_detect_subclients(struct i2c_adapter *adapter, int address, | 626 | static int asb100_detect_subclients(struct i2c_adapter *adapter, int address, |
@@ -714,14 +713,6 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
714 | struct i2c_client *new_client; | 713 | struct i2c_client *new_client; |
715 | struct asb100_data *data; | 714 | struct asb100_data *data; |
716 | 715 | ||
717 | /* asb100 is SMBus only */ | ||
718 | if (i2c_is_isa_adapter(adapter)) { | ||
719 | pr_debug("asb100.o: detect failed, " | ||
720 | "cannot attach to legacy adapter!\n"); | ||
721 | err = -ENODEV; | ||
722 | goto ERROR0; | ||
723 | } | ||
724 | |||
725 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | 716 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
726 | pr_debug("asb100.o: detect failed, " | 717 | pr_debug("asb100.o: detect failed, " |
727 | "smbus byte data not supported!\n"); | 718 | "smbus byte data not supported!\n"); |
@@ -821,6 +812,12 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
821 | data->fan_min[2] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(2)); | 812 | data->fan_min[2] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(2)); |
822 | 813 | ||
823 | /* Register sysfs hooks */ | 814 | /* Register sysfs hooks */ |
815 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
816 | if (IS_ERR(data->class_dev)) { | ||
817 | err = PTR_ERR(data->class_dev); | ||
818 | goto ERROR3; | ||
819 | } | ||
820 | |||
824 | device_create_file_in(new_client, 0); | 821 | device_create_file_in(new_client, 0); |
825 | device_create_file_in(new_client, 1); | 822 | device_create_file_in(new_client, 1); |
826 | device_create_file_in(new_client, 2); | 823 | device_create_file_in(new_client, 2); |
@@ -847,6 +844,11 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) | |||
847 | 844 | ||
848 | return 0; | 845 | return 0; |
849 | 846 | ||
847 | ERROR3: | ||
848 | i2c_detach_client(data->lm75[1]); | ||
849 | i2c_detach_client(data->lm75[0]); | ||
850 | kfree(data->lm75[1]); | ||
851 | kfree(data->lm75[0]); | ||
850 | ERROR2: | 852 | ERROR2: |
851 | i2c_detach_client(new_client); | 853 | i2c_detach_client(new_client); |
852 | ERROR1: | 854 | ERROR1: |
@@ -857,21 +859,23 @@ ERROR0: | |||
857 | 859 | ||
858 | static int asb100_detach_client(struct i2c_client *client) | 860 | static int asb100_detach_client(struct i2c_client *client) |
859 | { | 861 | { |
862 | struct asb100_data *data = i2c_get_clientdata(client); | ||
860 | int err; | 863 | int err; |
861 | 864 | ||
862 | if ((err = i2c_detach_client(client))) { | 865 | /* main client */ |
863 | dev_err(&client->dev, "client deregistration failed; " | 866 | if (data) |
864 | "client not detached.\n"); | 867 | hwmon_device_unregister(data->class_dev); |
868 | |||
869 | if ((err = i2c_detach_client(client))) | ||
865 | return err; | 870 | return err; |
866 | } | ||
867 | 871 | ||
868 | if (i2c_get_clientdata(client)==NULL) { | 872 | /* main client */ |
869 | /* subclients */ | 873 | if (data) |
874 | kfree(data); | ||
875 | |||
876 | /* subclient */ | ||
877 | else | ||
870 | kfree(client); | 878 | kfree(client); |
871 | } else { | ||
872 | /* main client */ | ||
873 | kfree(i2c_get_clientdata(client)); | ||
874 | } | ||
875 | 879 | ||
876 | return 0; | 880 | return 0; |
877 | } | 881 | } |
@@ -969,7 +973,7 @@ static void asb100_init_client(struct i2c_client *client) | |||
969 | 973 | ||
970 | vid = asb100_read_value(client, ASB100_REG_VID_FANDIV) & 0x0f; | 974 | vid = asb100_read_value(client, ASB100_REG_VID_FANDIV) & 0x0f; |
971 | vid |= (asb100_read_value(client, ASB100_REG_CHIPID) & 0x01) << 4; | 975 | vid |= (asb100_read_value(client, ASB100_REG_CHIPID) & 0x01) << 4; |
972 | data->vrm = i2c_which_vrm(); | 976 | data->vrm = vid_which_vrm(); |
973 | vid = vid_from_reg(vid, data->vrm); | 977 | vid = vid_from_reg(vid, data->vrm); |
974 | 978 | ||
975 | /* Start monitoring */ | 979 | /* Start monitoring */ |