Commit 4329510c22af1d0cfcc291dc4ce6274abebfe170
Exists in
master
and in
4 other branches
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging
* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging: hwmon: (pmbus) Fix temperature limit register access
Showing 1 changed file Side-by-side Diff
drivers/hwmon/pmbus_core.c
... | ... | @@ -752,7 +752,7 @@ |
752 | 752 | static void pmbus_add_sensor(struct pmbus_data *data, |
753 | 753 | const char *name, const char *type, int seq, |
754 | 754 | int page, int reg, enum pmbus_sensor_classes class, |
755 | - bool update) | |
755 | + bool update, bool readonly) | |
756 | 756 | { |
757 | 757 | struct pmbus_sensor *sensor; |
758 | 758 | |
... | ... | @@ -765,7 +765,7 @@ |
765 | 765 | sensor->reg = reg; |
766 | 766 | sensor->class = class; |
767 | 767 | sensor->update = update; |
768 | - if (update) | |
768 | + if (readonly) | |
769 | 769 | PMBUS_ADD_GET_ATTR(data, sensor->name, sensor, |
770 | 770 | data->num_sensors); |
771 | 771 | else |
772 | 772 | |
... | ... | @@ -916,14 +916,14 @@ |
916 | 916 | |
917 | 917 | i0 = data->num_sensors; |
918 | 918 | pmbus_add_label(data, "in", in_index, "vin", 0); |
919 | - pmbus_add_sensor(data, "in", "input", in_index, | |
920 | - 0, PMBUS_READ_VIN, PSC_VOLTAGE_IN, true); | |
919 | + pmbus_add_sensor(data, "in", "input", in_index, 0, | |
920 | + PMBUS_READ_VIN, PSC_VOLTAGE_IN, true, true); | |
921 | 921 | if (pmbus_check_word_register(client, 0, |
922 | 922 | PMBUS_VIN_UV_WARN_LIMIT)) { |
923 | 923 | i1 = data->num_sensors; |
924 | 924 | pmbus_add_sensor(data, "in", "min", in_index, |
925 | 925 | 0, PMBUS_VIN_UV_WARN_LIMIT, |
926 | - PSC_VOLTAGE_IN, false); | |
926 | + PSC_VOLTAGE_IN, false, false); | |
927 | 927 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { |
928 | 928 | pmbus_add_boolean_reg(data, "in", "min_alarm", |
929 | 929 | in_index, |
... | ... | @@ -937,7 +937,7 @@ |
937 | 937 | i1 = data->num_sensors; |
938 | 938 | pmbus_add_sensor(data, "in", "lcrit", in_index, |
939 | 939 | 0, PMBUS_VIN_UV_FAULT_LIMIT, |
940 | - PSC_VOLTAGE_IN, false); | |
940 | + PSC_VOLTAGE_IN, false, false); | |
941 | 941 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { |
942 | 942 | pmbus_add_boolean_reg(data, "in", "lcrit_alarm", |
943 | 943 | in_index, |
... | ... | @@ -951,7 +951,7 @@ |
951 | 951 | i1 = data->num_sensors; |
952 | 952 | pmbus_add_sensor(data, "in", "max", in_index, |
953 | 953 | 0, PMBUS_VIN_OV_WARN_LIMIT, |
954 | - PSC_VOLTAGE_IN, false); | |
954 | + PSC_VOLTAGE_IN, false, false); | |
955 | 955 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { |
956 | 956 | pmbus_add_boolean_reg(data, "in", "max_alarm", |
957 | 957 | in_index, |
... | ... | @@ -965,7 +965,7 @@ |
965 | 965 | i1 = data->num_sensors; |
966 | 966 | pmbus_add_sensor(data, "in", "crit", in_index, |
967 | 967 | 0, PMBUS_VIN_OV_FAULT_LIMIT, |
968 | - PSC_VOLTAGE_IN, false); | |
968 | + PSC_VOLTAGE_IN, false, false); | |
969 | 969 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { |
970 | 970 | pmbus_add_boolean_reg(data, "in", "crit_alarm", |
971 | 971 | in_index, |
... | ... | @@ -988,7 +988,7 @@ |
988 | 988 | if (info->func[0] & PMBUS_HAVE_VCAP) { |
989 | 989 | pmbus_add_label(data, "in", in_index, "vcap", 0); |
990 | 990 | pmbus_add_sensor(data, "in", "input", in_index, 0, |
991 | - PMBUS_READ_VCAP, PSC_VOLTAGE_IN, true); | |
991 | + PMBUS_READ_VCAP, PSC_VOLTAGE_IN, true, true); | |
992 | 992 | in_index++; |
993 | 993 | } |
994 | 994 | |
995 | 995 | |
... | ... | @@ -1004,13 +1004,13 @@ |
1004 | 1004 | i0 = data->num_sensors; |
1005 | 1005 | pmbus_add_label(data, "in", in_index, "vout", page + 1); |
1006 | 1006 | pmbus_add_sensor(data, "in", "input", in_index, page, |
1007 | - PMBUS_READ_VOUT, PSC_VOLTAGE_OUT, true); | |
1007 | + PMBUS_READ_VOUT, PSC_VOLTAGE_OUT, true, true); | |
1008 | 1008 | if (pmbus_check_word_register(client, page, |
1009 | 1009 | PMBUS_VOUT_UV_WARN_LIMIT)) { |
1010 | 1010 | i1 = data->num_sensors; |
1011 | 1011 | pmbus_add_sensor(data, "in", "min", in_index, page, |
1012 | 1012 | PMBUS_VOUT_UV_WARN_LIMIT, |
1013 | - PSC_VOLTAGE_OUT, false); | |
1013 | + PSC_VOLTAGE_OUT, false, false); | |
1014 | 1014 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { |
1015 | 1015 | pmbus_add_boolean_reg(data, "in", "min_alarm", |
1016 | 1016 | in_index, |
... | ... | @@ -1025,7 +1025,7 @@ |
1025 | 1025 | i1 = data->num_sensors; |
1026 | 1026 | pmbus_add_sensor(data, "in", "lcrit", in_index, page, |
1027 | 1027 | PMBUS_VOUT_UV_FAULT_LIMIT, |
1028 | - PSC_VOLTAGE_OUT, false); | |
1028 | + PSC_VOLTAGE_OUT, false, false); | |
1029 | 1029 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { |
1030 | 1030 | pmbus_add_boolean_reg(data, "in", "lcrit_alarm", |
1031 | 1031 | in_index, |
... | ... | @@ -1040,7 +1040,7 @@ |
1040 | 1040 | i1 = data->num_sensors; |
1041 | 1041 | pmbus_add_sensor(data, "in", "max", in_index, page, |
1042 | 1042 | PMBUS_VOUT_OV_WARN_LIMIT, |
1043 | - PSC_VOLTAGE_OUT, false); | |
1043 | + PSC_VOLTAGE_OUT, false, false); | |
1044 | 1044 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { |
1045 | 1045 | pmbus_add_boolean_reg(data, "in", "max_alarm", |
1046 | 1046 | in_index, |
... | ... | @@ -1055,7 +1055,7 @@ |
1055 | 1055 | i1 = data->num_sensors; |
1056 | 1056 | pmbus_add_sensor(data, "in", "crit", in_index, page, |
1057 | 1057 | PMBUS_VOUT_OV_FAULT_LIMIT, |
1058 | - PSC_VOLTAGE_OUT, false); | |
1058 | + PSC_VOLTAGE_OUT, false, false); | |
1059 | 1059 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { |
1060 | 1060 | pmbus_add_boolean_reg(data, "in", "crit_alarm", |
1061 | 1061 | in_index, |
1062 | 1062 | |
... | ... | @@ -1088,14 +1088,14 @@ |
1088 | 1088 | if (info->func[0] & PMBUS_HAVE_IIN) { |
1089 | 1089 | i0 = data->num_sensors; |
1090 | 1090 | pmbus_add_label(data, "curr", in_index, "iin", 0); |
1091 | - pmbus_add_sensor(data, "curr", "input", in_index, | |
1092 | - 0, PMBUS_READ_IIN, PSC_CURRENT_IN, true); | |
1091 | + pmbus_add_sensor(data, "curr", "input", in_index, 0, | |
1092 | + PMBUS_READ_IIN, PSC_CURRENT_IN, true, true); | |
1093 | 1093 | if (pmbus_check_word_register(client, 0, |
1094 | 1094 | PMBUS_IIN_OC_WARN_LIMIT)) { |
1095 | 1095 | i1 = data->num_sensors; |
1096 | 1096 | pmbus_add_sensor(data, "curr", "max", in_index, |
1097 | 1097 | 0, PMBUS_IIN_OC_WARN_LIMIT, |
1098 | - PSC_CURRENT_IN, false); | |
1098 | + PSC_CURRENT_IN, false, false); | |
1099 | 1099 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { |
1100 | 1100 | pmbus_add_boolean_reg(data, "curr", "max_alarm", |
1101 | 1101 | in_index, |
... | ... | @@ -1108,7 +1108,7 @@ |
1108 | 1108 | i1 = data->num_sensors; |
1109 | 1109 | pmbus_add_sensor(data, "curr", "crit", in_index, |
1110 | 1110 | 0, PMBUS_IIN_OC_FAULT_LIMIT, |
1111 | - PSC_CURRENT_IN, false); | |
1111 | + PSC_CURRENT_IN, false, false); | |
1112 | 1112 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) |
1113 | 1113 | pmbus_add_boolean_reg(data, "curr", |
1114 | 1114 | "crit_alarm", |
1115 | 1115 | |
... | ... | @@ -1131,13 +1131,13 @@ |
1131 | 1131 | i0 = data->num_sensors; |
1132 | 1132 | pmbus_add_label(data, "curr", in_index, "iout", page + 1); |
1133 | 1133 | pmbus_add_sensor(data, "curr", "input", in_index, page, |
1134 | - PMBUS_READ_IOUT, PSC_CURRENT_OUT, true); | |
1134 | + PMBUS_READ_IOUT, PSC_CURRENT_OUT, true, true); | |
1135 | 1135 | if (pmbus_check_word_register(client, page, |
1136 | 1136 | PMBUS_IOUT_OC_WARN_LIMIT)) { |
1137 | 1137 | i1 = data->num_sensors; |
1138 | 1138 | pmbus_add_sensor(data, "curr", "max", in_index, page, |
1139 | 1139 | PMBUS_IOUT_OC_WARN_LIMIT, |
1140 | - PSC_CURRENT_OUT, false); | |
1140 | + PSC_CURRENT_OUT, false, false); | |
1141 | 1141 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) { |
1142 | 1142 | pmbus_add_boolean_reg(data, "curr", "max_alarm", |
1143 | 1143 | in_index, |
... | ... | @@ -1151,7 +1151,7 @@ |
1151 | 1151 | i1 = data->num_sensors; |
1152 | 1152 | pmbus_add_sensor(data, "curr", "lcrit", in_index, page, |
1153 | 1153 | PMBUS_IOUT_UC_FAULT_LIMIT, |
1154 | - PSC_CURRENT_OUT, false); | |
1154 | + PSC_CURRENT_OUT, false, false); | |
1155 | 1155 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) { |
1156 | 1156 | pmbus_add_boolean_reg(data, "curr", |
1157 | 1157 | "lcrit_alarm", |
... | ... | @@ -1166,7 +1166,7 @@ |
1166 | 1166 | i1 = data->num_sensors; |
1167 | 1167 | pmbus_add_sensor(data, "curr", "crit", in_index, page, |
1168 | 1168 | PMBUS_IOUT_OC_FAULT_LIMIT, |
1169 | - PSC_CURRENT_OUT, false); | |
1169 | + PSC_CURRENT_OUT, false, false); | |
1170 | 1170 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) { |
1171 | 1171 | pmbus_add_boolean_reg(data, "curr", |
1172 | 1172 | "crit_alarm", |
1173 | 1173 | |
... | ... | @@ -1199,13 +1199,13 @@ |
1199 | 1199 | i0 = data->num_sensors; |
1200 | 1200 | pmbus_add_label(data, "power", in_index, "pin", 0); |
1201 | 1201 | pmbus_add_sensor(data, "power", "input", in_index, |
1202 | - 0, PMBUS_READ_PIN, PSC_POWER, true); | |
1202 | + 0, PMBUS_READ_PIN, PSC_POWER, true, true); | |
1203 | 1203 | if (pmbus_check_word_register(client, 0, |
1204 | 1204 | PMBUS_PIN_OP_WARN_LIMIT)) { |
1205 | 1205 | i1 = data->num_sensors; |
1206 | 1206 | pmbus_add_sensor(data, "power", "max", in_index, |
1207 | 1207 | 0, PMBUS_PIN_OP_WARN_LIMIT, PSC_POWER, |
1208 | - false); | |
1208 | + false, false); | |
1209 | 1209 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) |
1210 | 1210 | pmbus_add_boolean_reg(data, "power", |
1211 | 1211 | "alarm", |
... | ... | @@ -1228,7 +1228,7 @@ |
1228 | 1228 | i0 = data->num_sensors; |
1229 | 1229 | pmbus_add_label(data, "power", in_index, "pout", page + 1); |
1230 | 1230 | pmbus_add_sensor(data, "power", "input", in_index, page, |
1231 | - PMBUS_READ_POUT, PSC_POWER, true); | |
1231 | + PMBUS_READ_POUT, PSC_POWER, true, true); | |
1232 | 1232 | /* |
1233 | 1233 | * Per hwmon sysfs API, power_cap is to be used to limit output |
1234 | 1234 | * power. |
... | ... | @@ -1241,7 +1241,8 @@ |
1241 | 1241 | if (pmbus_check_word_register(client, page, PMBUS_POUT_MAX)) { |
1242 | 1242 | i1 = data->num_sensors; |
1243 | 1243 | pmbus_add_sensor(data, "power", "cap", in_index, page, |
1244 | - PMBUS_POUT_MAX, PSC_POWER, false); | |
1244 | + PMBUS_POUT_MAX, PSC_POWER, | |
1245 | + false, false); | |
1245 | 1246 | need_alarm = true; |
1246 | 1247 | } |
1247 | 1248 | if (pmbus_check_word_register(client, page, |
... | ... | @@ -1249,7 +1250,7 @@ |
1249 | 1250 | i1 = data->num_sensors; |
1250 | 1251 | pmbus_add_sensor(data, "power", "max", in_index, page, |
1251 | 1252 | PMBUS_POUT_OP_WARN_LIMIT, PSC_POWER, |
1252 | - false); | |
1253 | + false, false); | |
1253 | 1254 | need_alarm = true; |
1254 | 1255 | } |
1255 | 1256 | if (need_alarm && (info->func[page] & PMBUS_HAVE_STATUS_IOUT)) |
... | ... | @@ -1264,7 +1265,7 @@ |
1264 | 1265 | i1 = data->num_sensors; |
1265 | 1266 | pmbus_add_sensor(data, "power", "crit", in_index, page, |
1266 | 1267 | PMBUS_POUT_OP_FAULT_LIMIT, PSC_POWER, |
1267 | - false); | |
1268 | + false, false); | |
1268 | 1269 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) |
1269 | 1270 | pmbus_add_boolean_reg(data, "power", |
1270 | 1271 | "crit_alarm", |
... | ... | @@ -1302,7 +1303,7 @@ |
1302 | 1303 | i0 = data->num_sensors; |
1303 | 1304 | pmbus_add_sensor(data, "temp", "input", in_index, page, |
1304 | 1305 | pmbus_temp_registers[t], |
1305 | - PSC_TEMPERATURE, true); | |
1306 | + PSC_TEMPERATURE, true, true); | |
1306 | 1307 | |
1307 | 1308 | /* |
1308 | 1309 | * PMBus provides only one status register for TEMP1-3. |
... | ... | @@ -1323,7 +1324,7 @@ |
1323 | 1324 | i1 = data->num_sensors; |
1324 | 1325 | pmbus_add_sensor(data, "temp", "min", in_index, |
1325 | 1326 | page, PMBUS_UT_WARN_LIMIT, |
1326 | - PSC_TEMPERATURE, true); | |
1327 | + PSC_TEMPERATURE, true, false); | |
1327 | 1328 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { |
1328 | 1329 | pmbus_add_boolean_cmp(data, "temp", |
1329 | 1330 | "min_alarm", in_index, i1, i0, |
... | ... | @@ -1338,7 +1339,7 @@ |
1338 | 1339 | pmbus_add_sensor(data, "temp", "lcrit", |
1339 | 1340 | in_index, page, |
1340 | 1341 | PMBUS_UT_FAULT_LIMIT, |
1341 | - PSC_TEMPERATURE, true); | |
1342 | + PSC_TEMPERATURE, true, false); | |
1342 | 1343 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { |
1343 | 1344 | pmbus_add_boolean_cmp(data, "temp", |
1344 | 1345 | "lcrit_alarm", in_index, i1, i0, |
... | ... | @@ -1352,7 +1353,7 @@ |
1352 | 1353 | i1 = data->num_sensors; |
1353 | 1354 | pmbus_add_sensor(data, "temp", "max", in_index, |
1354 | 1355 | page, PMBUS_OT_WARN_LIMIT, |
1355 | - PSC_TEMPERATURE, true); | |
1356 | + PSC_TEMPERATURE, true, false); | |
1356 | 1357 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { |
1357 | 1358 | pmbus_add_boolean_cmp(data, "temp", |
1358 | 1359 | "max_alarm", in_index, i0, i1, |
... | ... | @@ -1366,7 +1367,7 @@ |
1366 | 1367 | i1 = data->num_sensors; |
1367 | 1368 | pmbus_add_sensor(data, "temp", "crit", in_index, |
1368 | 1369 | page, PMBUS_OT_FAULT_LIMIT, |
1369 | - PSC_TEMPERATURE, true); | |
1370 | + PSC_TEMPERATURE, true, false); | |
1370 | 1371 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { |
1371 | 1372 | pmbus_add_boolean_cmp(data, "temp", |
1372 | 1373 | "crit_alarm", in_index, i0, i1, |
... | ... | @@ -1421,7 +1422,8 @@ |
1421 | 1422 | |
1422 | 1423 | i0 = data->num_sensors; |
1423 | 1424 | pmbus_add_sensor(data, "fan", "input", in_index, page, |
1424 | - pmbus_fan_registers[f], PSC_FAN, true); | |
1425 | + pmbus_fan_registers[f], PSC_FAN, true, | |
1426 | + true); | |
1425 | 1427 | |
1426 | 1428 | /* |
1427 | 1429 | * Each fan status register covers multiple fans, |