diff options
author | Luca Tettamanti <kronos.it@gmail.com> | 2010-01-10 14:52:33 -0500 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2010-01-10 14:52:33 -0500 |
commit | 8ba406be53713efdd705666e2178cfe486fcfb27 (patch) | |
tree | 0cb1f3e049468889098a1878372f6d404b6d6aaa /drivers/hwmon | |
parent | bb595c923bc51dff9cdd112de18deb57ac7945d2 (diff) |
hwmon: (asus_atk0110) Refactor interface probe code
The behaviour is unmodified, this makes easier to override the heuristic (which
is probably needed for some boards).
Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/asus_atk0110.c | 98 |
1 files changed, 44 insertions, 54 deletions
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c index 5a3ee00c0e7d..11739819badd 100644 --- a/drivers/hwmon/asus_atk0110.c +++ b/drivers/hwmon/asus_atk0110.c | |||
@@ -1047,76 +1047,75 @@ remove: | |||
1047 | return err; | 1047 | return err; |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | static int atk_check_old_if(struct atk_data *data) | 1050 | static int atk_probe_if(struct atk_data *data) |
1051 | { | 1051 | { |
1052 | struct device *dev = &data->acpi_dev->dev; | 1052 | struct device *dev = &data->acpi_dev->dev; |
1053 | acpi_handle ret; | 1053 | acpi_handle ret; |
1054 | acpi_status status; | 1054 | acpi_status status; |
1055 | int err = 0; | ||
1055 | 1056 | ||
1056 | /* RTMP: read temperature */ | 1057 | /* RTMP: read temperature */ |
1057 | status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_TMP, &ret); | 1058 | status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_TMP, &ret); |
1058 | if (status != AE_OK) { | 1059 | if (ACPI_SUCCESS(status)) |
1060 | data->rtmp_handle = ret; | ||
1061 | else | ||
1059 | dev_dbg(dev, "method " METHOD_OLD_READ_TMP " not found: %s\n", | 1062 | dev_dbg(dev, "method " METHOD_OLD_READ_TMP " not found: %s\n", |
1060 | acpi_format_exception(status)); | 1063 | acpi_format_exception(status)); |
1061 | return -ENODEV; | ||
1062 | } | ||
1063 | data->rtmp_handle = ret; | ||
1064 | 1064 | ||
1065 | /* RVLT: read voltage */ | 1065 | /* RVLT: read voltage */ |
1066 | status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_VLT, &ret); | 1066 | status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_VLT, &ret); |
1067 | if (status != AE_OK) { | 1067 | if (ACPI_SUCCESS(status)) |
1068 | data->rvlt_handle = ret; | ||
1069 | else | ||
1068 | dev_dbg(dev, "method " METHOD_OLD_READ_VLT " not found: %s\n", | 1070 | dev_dbg(dev, "method " METHOD_OLD_READ_VLT " not found: %s\n", |
1069 | acpi_format_exception(status)); | 1071 | acpi_format_exception(status)); |
1070 | return -ENODEV; | ||
1071 | } | ||
1072 | data->rvlt_handle = ret; | ||
1073 | 1072 | ||
1074 | /* RFAN: read fan status */ | 1073 | /* RFAN: read fan status */ |
1075 | status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_FAN, &ret); | 1074 | status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_FAN, &ret); |
1076 | if (status != AE_OK) { | 1075 | if (ACPI_SUCCESS(status)) |
1076 | data->rfan_handle = ret; | ||
1077 | else | ||
1077 | dev_dbg(dev, "method " METHOD_OLD_READ_FAN " not found: %s\n", | 1078 | dev_dbg(dev, "method " METHOD_OLD_READ_FAN " not found: %s\n", |
1078 | acpi_format_exception(status)); | 1079 | acpi_format_exception(status)); |
1079 | return -ENODEV; | ||
1080 | } | ||
1081 | data->rfan_handle = ret; | ||
1082 | |||
1083 | return 0; | ||
1084 | } | ||
1085 | |||
1086 | static int atk_check_new_if(struct atk_data *data) | ||
1087 | { | ||
1088 | struct device *dev = &data->acpi_dev->dev; | ||
1089 | acpi_handle ret; | ||
1090 | acpi_status status; | ||
1091 | 1080 | ||
1092 | /* Enumeration */ | 1081 | /* Enumeration */ |
1093 | status = acpi_get_handle(data->atk_handle, METHOD_ENUMERATE, &ret); | 1082 | status = acpi_get_handle(data->atk_handle, METHOD_ENUMERATE, &ret); |
1094 | if (status != AE_OK) { | 1083 | if (ACPI_SUCCESS(status)) |
1084 | data->enumerate_handle = ret; | ||
1085 | else | ||
1095 | dev_dbg(dev, "method " METHOD_ENUMERATE " not found: %s\n", | 1086 | dev_dbg(dev, "method " METHOD_ENUMERATE " not found: %s\n", |
1096 | acpi_format_exception(status)); | 1087 | acpi_format_exception(status)); |
1097 | return -ENODEV; | ||
1098 | } | ||
1099 | data->enumerate_handle = ret; | ||
1100 | 1088 | ||
1101 | /* De-multiplexer (read) */ | 1089 | /* De-multiplexer (read) */ |
1102 | status = acpi_get_handle(data->atk_handle, METHOD_READ, &ret); | 1090 | status = acpi_get_handle(data->atk_handle, METHOD_READ, &ret); |
1103 | if (status != AE_OK) { | 1091 | if (ACPI_SUCCESS(status)) |
1092 | data->read_handle = ret; | ||
1093 | else | ||
1104 | dev_dbg(dev, "method " METHOD_READ " not found: %s\n", | 1094 | dev_dbg(dev, "method " METHOD_READ " not found: %s\n", |
1105 | acpi_format_exception(status)); | 1095 | acpi_format_exception(status)); |
1106 | return -ENODEV; | ||
1107 | } | ||
1108 | data->read_handle = ret; | ||
1109 | 1096 | ||
1110 | /* De-multiplexer (write) */ | 1097 | /* De-multiplexer (write) */ |
1111 | status = acpi_get_handle(data->atk_handle, METHOD_WRITE, &ret); | 1098 | status = acpi_get_handle(data->atk_handle, METHOD_WRITE, &ret); |
1112 | if (status != AE_OK) { | 1099 | if (ACPI_SUCCESS(status)) |
1113 | dev_dbg(dev, "method " METHOD_READ " not found: %s\n", | 1100 | data->write_handle = ret; |
1101 | else | ||
1102 | dev_dbg(dev, "method " METHOD_WRITE " not found: %s\n", | ||
1114 | acpi_format_exception(status)); | 1103 | acpi_format_exception(status)); |
1115 | return -ENODEV; | ||
1116 | } | ||
1117 | data->write_handle = ret; | ||
1118 | 1104 | ||
1119 | return 0; | 1105 | /* Check for hwmon methods: first check "old" style methods; note that |
1106 | * both may be present: in this case we stick to the old interface; | ||
1107 | * analysis of multiple DSDTs indicates that when both interfaces | ||
1108 | * are present the new one (GGRP/GITM) is not functional. | ||
1109 | */ | ||
1110 | if (data->rtmp_handle && data->rvlt_handle && data->rfan_handle) | ||
1111 | data->old_interface = true; | ||
1112 | else if (data->enumerate_handle && data->read_handle && | ||
1113 | data->write_handle) | ||
1114 | data->old_interface = false; | ||
1115 | else | ||
1116 | err = -ENODEV; | ||
1117 | |||
1118 | return err; | ||
1120 | } | 1119 | } |
1121 | 1120 | ||
1122 | static int atk_add(struct acpi_device *device) | 1121 | static int atk_add(struct acpi_device *device) |
@@ -1155,28 +1154,19 @@ static int atk_add(struct acpi_device *device) | |||
1155 | } | 1154 | } |
1156 | ACPI_FREE(buf.pointer); | 1155 | ACPI_FREE(buf.pointer); |
1157 | 1156 | ||
1158 | /* Check for hwmon methods: first check "old" style methods; note that | 1157 | err = atk_probe_if(data); |
1159 | * both may be present: in this case we stick to the old interface; | 1158 | if (err) { |
1160 | * analysis of multiple DSDTs indicates that when both interfaces | 1159 | dev_err(&device->dev, "No usable hwmon interface detected\n"); |
1161 | * are present the new one (GGRP/GITM) is not functional. | 1160 | goto out; |
1162 | */ | ||
1163 | err = atk_check_old_if(data); | ||
1164 | if (!err) { | ||
1165 | dev_dbg(&device->dev, "Using old hwmon interface\n"); | ||
1166 | data->old_interface = true; | ||
1167 | } else { | ||
1168 | err = atk_check_new_if(data); | ||
1169 | if (err) | ||
1170 | goto out; | ||
1171 | |||
1172 | dev_dbg(&device->dev, "Using new hwmon interface\n"); | ||
1173 | data->old_interface = false; | ||
1174 | } | 1161 | } |
1175 | 1162 | ||
1176 | if (data->old_interface) | 1163 | if (data->old_interface) { |
1164 | dev_dbg(&device->dev, "Using old hwmon interface\n"); | ||
1177 | err = atk_enumerate_old_hwmon(data); | 1165 | err = atk_enumerate_old_hwmon(data); |
1178 | else | 1166 | } else { |
1167 | dev_dbg(&device->dev, "Using new hwmon interface\n"); | ||
1179 | err = atk_enumerate_new_hwmon(data); | 1168 | err = atk_enumerate_new_hwmon(data); |
1169 | } | ||
1180 | if (err < 0) | 1170 | if (err < 0) |
1181 | goto out; | 1171 | goto out; |
1182 | if (err == 0) { | 1172 | if (err == 0) { |