nfit.c (4596f55476b5b861ca37e525460d2e43e90f1f2e) nfit.c (39611e83a28c880881f4927d7bb2f5ea4ddf4526)
1/*
2 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but

--- 870 unchanged lines hidden (view full) ---

879 nd_cmd->status = 0x3;
880 break;
881 }
882
883
884 return 0;
885}
886
1/*
2 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but

--- 870 unchanged lines hidden (view full) ---

879 nd_cmd->status = 0x3;
880 break;
881 }
882
883
884 return 0;
885}
886
887static int override_return_code(int dimm, unsigned int func, int rc)
888{
889 if ((1 << func) & dimm_fail_cmd_flags[dimm]) {
890 if (dimm_fail_cmd_code[dimm])
891 return dimm_fail_cmd_code[dimm];
892 return -EIO;
893 }
894 return rc;
895}
896
887static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func)
888{
889 int i;
890
891 /* lookup per-dimm data */
892 for (i = 0; i < ARRAY_SIZE(handle); i++)
893 if (__to_nfit_memdev(nfit_mem)->device_handle == handle[i])
894 break;
895 if (i >= ARRAY_SIZE(handle))
896 return -ENXIO;
897static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func)
898{
899 int i;
900
901 /* lookup per-dimm data */
902 for (i = 0; i < ARRAY_SIZE(handle); i++)
903 if (__to_nfit_memdev(nfit_mem)->device_handle == handle[i])
904 break;
905 if (i >= ARRAY_SIZE(handle))
906 return -ENXIO;
897
898 if ((1 << func) & dimm_fail_cmd_flags[i]) {
899 if (dimm_fail_cmd_code[i])
900 return dimm_fail_cmd_code[i];
901 return -EIO;
902 }
903
904 return i;
905}
906
907static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
908 struct nvdimm *nvdimm, unsigned int cmd, void *buf,
909 unsigned int buf_len, int *cmd_rc)
910{
911 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc);

--- 22 unchanged lines hidden (view full) ---

934 return -ENOTTY;
935
936 i = get_dimm(nfit_mem, func);
937 if (i < 0)
938 return i;
939
940 switch (func) {
941 case ND_INTEL_ENABLE_LSS_STATUS:
907 return i;
908}
909
910static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
911 struct nvdimm *nvdimm, unsigned int cmd, void *buf,
912 unsigned int buf_len, int *cmd_rc)
913{
914 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc);

--- 22 unchanged lines hidden (view full) ---

937 return -ENOTTY;
938
939 i = get_dimm(nfit_mem, func);
940 if (i < 0)
941 return i;
942
943 switch (func) {
944 case ND_INTEL_ENABLE_LSS_STATUS:
942 return nd_intel_test_cmd_set_lss_status(t,
945 rc = nd_intel_test_cmd_set_lss_status(t,
943 buf, buf_len);
946 buf, buf_len);
947 break;
944 case ND_INTEL_FW_GET_INFO:
948 case ND_INTEL_FW_GET_INFO:
945 return nd_intel_test_get_fw_info(t, buf,
949 rc = nd_intel_test_get_fw_info(t, buf,
946 buf_len, i - t->dcr_idx);
950 buf_len, i - t->dcr_idx);
951 break;
947 case ND_INTEL_FW_START_UPDATE:
952 case ND_INTEL_FW_START_UPDATE:
948 return nd_intel_test_start_update(t, buf,
953 rc = nd_intel_test_start_update(t, buf,
949 buf_len, i - t->dcr_idx);
954 buf_len, i - t->dcr_idx);
955 break;
950 case ND_INTEL_FW_SEND_DATA:
956 case ND_INTEL_FW_SEND_DATA:
951 return nd_intel_test_send_data(t, buf,
957 rc = nd_intel_test_send_data(t, buf,
952 buf_len, i - t->dcr_idx);
958 buf_len, i - t->dcr_idx);
959 break;
953 case ND_INTEL_FW_FINISH_UPDATE:
960 case ND_INTEL_FW_FINISH_UPDATE:
954 return nd_intel_test_finish_fw(t, buf,
961 rc = nd_intel_test_finish_fw(t, buf,
955 buf_len, i - t->dcr_idx);
962 buf_len, i - t->dcr_idx);
963 break;
956 case ND_INTEL_FW_FINISH_QUERY:
964 case ND_INTEL_FW_FINISH_QUERY:
957 return nd_intel_test_finish_query(t, buf,
965 rc = nd_intel_test_finish_query(t, buf,
958 buf_len, i - t->dcr_idx);
966 buf_len, i - t->dcr_idx);
967 break;
959 case ND_INTEL_SMART:
968 case ND_INTEL_SMART:
960 return nfit_test_cmd_smart(buf, buf_len,
969 rc = nfit_test_cmd_smart(buf, buf_len,
961 &t->smart[i - t->dcr_idx]);
970 &t->smart[i - t->dcr_idx]);
971 break;
962 case ND_INTEL_SMART_THRESHOLD:
972 case ND_INTEL_SMART_THRESHOLD:
963 return nfit_test_cmd_smart_threshold(buf,
973 rc = nfit_test_cmd_smart_threshold(buf,
964 buf_len,
965 &t->smart_threshold[i -
966 t->dcr_idx]);
974 buf_len,
975 &t->smart_threshold[i -
976 t->dcr_idx]);
977 break;
967 case ND_INTEL_SMART_SET_THRESHOLD:
978 case ND_INTEL_SMART_SET_THRESHOLD:
968 return nfit_test_cmd_smart_set_threshold(buf,
979 rc = nfit_test_cmd_smart_set_threshold(buf,
969 buf_len,
970 &t->smart_threshold[i -
971 t->dcr_idx],
972 &t->smart[i - t->dcr_idx],
973 &t->pdev.dev, t->dimm_dev[i]);
980 buf_len,
981 &t->smart_threshold[i -
982 t->dcr_idx],
983 &t->smart[i - t->dcr_idx],
984 &t->pdev.dev, t->dimm_dev[i]);
985 break;
974 case ND_INTEL_SMART_INJECT:
986 case ND_INTEL_SMART_INJECT:
975 return nfit_test_cmd_smart_inject(buf,
987 rc = nfit_test_cmd_smart_inject(buf,
976 buf_len,
977 &t->smart_threshold[i -
978 t->dcr_idx],
979 &t->smart[i - t->dcr_idx],
980 &t->pdev.dev, t->dimm_dev[i]);
988 buf_len,
989 &t->smart_threshold[i -
990 t->dcr_idx],
991 &t->smart[i - t->dcr_idx],
992 &t->pdev.dev, t->dimm_dev[i]);
993 break;
981 default:
982 return -ENOTTY;
983 }
994 default:
995 return -ENOTTY;
996 }
997 return override_return_code(i, func, rc);
984 }
985
986 if (!test_bit(cmd, &cmd_mask)
987 || !test_bit(func, &nfit_mem->dsm_mask))
988 return -ENOTTY;
989
990 i = get_dimm(nfit_mem, func);
991 if (i < 0)

--- 9 unchanged lines hidden (view full) ---

1001 break;
1002 case ND_CMD_SET_CONFIG_DATA:
1003 rc = nfit_test_cmd_set_config_data(buf, buf_len,
1004 t->label[i - t->dcr_idx]);
1005 break;
1006 default:
1007 return -ENOTTY;
1008 }
998 }
999
1000 if (!test_bit(cmd, &cmd_mask)
1001 || !test_bit(func, &nfit_mem->dsm_mask))
1002 return -ENOTTY;
1003
1004 i = get_dimm(nfit_mem, func);
1005 if (i < 0)

--- 9 unchanged lines hidden (view full) ---

1015 break;
1016 case ND_CMD_SET_CONFIG_DATA:
1017 rc = nfit_test_cmd_set_config_data(buf, buf_len,
1018 t->label[i - t->dcr_idx]);
1019 break;
1020 default:
1021 return -ENOTTY;
1022 }
1023 return override_return_code(i, func, rc);
1009 } else {
1010 struct ars_state *ars_state = &t->ars_state;
1011 struct nd_cmd_pkg *call_pkg = buf;
1012
1013 if (!nd_desc)
1014 return -ENOTTY;
1015
1016 if (cmd == ND_CMD_CALL) {

--- 1878 unchanged lines hidden ---
1024 } else {
1025 struct ars_state *ars_state = &t->ars_state;
1026 struct nd_cmd_pkg *call_pkg = buf;
1027
1028 if (!nd_desc)
1029 return -ENOTTY;
1030
1031 if (cmd == ND_CMD_CALL) {

--- 1878 unchanged lines hidden ---