edac: shell: Use new EDAC API in shell

Use new EDAC API in shell.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2021-04-06 18:16:05 +03:00 committed by Anas Nashif
commit 0eb48e30c6

View file

@ -62,6 +62,7 @@ static int cmd_edac_info(const struct shell *shell, size_t argc, char **argv)
{
const struct device *dev;
uint64_t error;
int ret;
dev = device_get_binding(DEVICE_NAME);
if (!dev) {
@ -71,27 +72,38 @@ static int cmd_edac_info(const struct shell *shell, size_t argc, char **argv)
shell_fprintf(shell, SHELL_NORMAL, "Show EDAC status\n");
error = edac_ecc_error_log_get(dev);
ret = edac_ecc_error_log_get(dev, &error);
if (ret) {
shell_error(shell, "Error getting ecc error log");
return ret;
}
shell_fprintf(shell, SHELL_NORMAL, "ECC Error Log 0x%llx\n", error);
if (error) {
decode_ecc_error(shell, error);
}
error = edac_parity_error_log_get(dev);
ret = edac_parity_error_log_get(dev, &error);
if (ret) {
shell_error(shell, "Error getting parity error log");
return ret;
}
shell_fprintf(shell, SHELL_NORMAL, "Parity Error Log 0x%llx\n", error);
shell_fprintf(shell, SHELL_NORMAL,
"Errors correctable: %d Errors uncorrectable %d\n",
edac_errors_cor_get(dev), edac_errors_uc_get(dev));
return 0;
return ret;
}
#if defined(CONFIG_EDAC_ERROR_INJECT)
static int cmd_inject_addr(const struct shell *shell, size_t argc, char **argv)
{
const struct device *dev;
int ret;
dev = device_get_binding(DEVICE_NAME);
if (!dev) {
@ -107,7 +119,13 @@ static int cmd_inject_addr(const struct shell *shell, size_t argc, char **argv)
}
if (argc == 1) {
uint64_t addr = edac_inject_get_param1(dev);
uint64_t addr;
ret = edac_inject_get_param1(dev, &addr);
if (ret) {
shell_error(shell, "Error getting address");
return ret;
}
shell_fprintf(shell, SHELL_NORMAL,
"Injection address base: 0x%lx\n", addr);
@ -116,15 +134,21 @@ static int cmd_inject_addr(const struct shell *shell, size_t argc, char **argv)
shell_fprintf(shell, SHELL_NORMAL,
"Set injection address base to: %s\n", argv[1]);
edac_inject_set_param1(dev, value);
ret = edac_inject_set_param1(dev, value);
if (ret) {
shell_error(shell, "Error setting address");
return ret;
}
}
return 0;
return ret;
}
static int cmd_inject_mask(const struct shell *shell, size_t argc, char **argv)
{
const struct device *dev;
int ret;
dev = device_get_binding(DEVICE_NAME);
if (!dev) {
@ -140,7 +164,13 @@ static int cmd_inject_mask(const struct shell *shell, size_t argc, char **argv)
}
if (argc == 1) {
uint64_t mask = edac_inject_get_param2(dev);
uint64_t mask;
ret = edac_inject_get_param2(dev, &mask);
if (ret) {
shell_error(shell, "Error getting mask");
return ret;
}
shell_fprintf(shell, SHELL_NORMAL,
"Injection address mask: 0x%lx\n", mask);
@ -150,10 +180,14 @@ static int cmd_inject_mask(const struct shell *shell, size_t argc, char **argv)
shell_fprintf(shell, SHELL_NORMAL,
"Set injection address mask to %lx\n", value);
return edac_inject_set_param2(dev, value);
ret = edac_inject_set_param2(dev, value);
if (ret) {
shell_error(shell, "Error setting mask");
return ret;
}
}
return 0;
return ret;
}
static int cmd_inject_trigger(const struct shell *shell, size_t argc,
@ -207,6 +241,7 @@ static int cmd_inject_error_type_show(const struct shell *shell, size_t argc,
{
const struct device *dev;
uint32_t error_type;
int ret;
dev = device_get_binding(DEVICE_NAME);
if (!dev) {
@ -214,12 +249,16 @@ static int cmd_inject_error_type_show(const struct shell *shell, size_t argc,
return -ENODEV;
}
error_type = edac_inject_get_error_type(dev);
ret = edac_inject_get_error_type(dev, &error_type);
if (ret) {
shell_error(shell, "Error getting error type");
return ret;
}
shell_fprintf(shell, SHELL_NORMAL, "Injection error type: %s\n",
get_error_type(error_type));
return 0;
return ret;
}
static int set_error_type(const struct shell *shell, uint32_t error_type)
@ -297,6 +336,7 @@ static int cmd_ecc_error_show(const struct shell *shell, size_t argc,
{
const struct device *dev;
uint64_t error;
int ret;
dev = device_get_binding(DEVICE_NAME);
if (!dev) {
@ -304,14 +344,19 @@ static int cmd_ecc_error_show(const struct shell *shell, size_t argc,
return -ENODEV;
}
error = edac_ecc_error_log_get(dev);
ret = edac_ecc_error_log_get(dev, &error);
if (ret) {
shell_error(shell, "Error getting error log");
return ret;
}
shell_fprintf(shell, SHELL_NORMAL, "ECC Error: 0x%lx\n", error);
if (error) {
decode_ecc_error(shell, error);
}
return 0;
return ret;
}
static int cmd_ecc_error_clear(const struct shell *shell, size_t argc,
@ -343,6 +388,7 @@ static int cmd_parity_error_show(const struct shell *shell, size_t argc,
{
const struct device *dev;
uint64_t error;
int ret;
dev = device_get_binding(DEVICE_NAME);
if (!dev) {
@ -350,7 +396,12 @@ static int cmd_parity_error_show(const struct shell *shell, size_t argc,
return -ENODEV;
}
error = edac_parity_error_log_get(dev);
ret = edac_parity_error_log_get(dev, &error);
if (ret) {
shell_error(shell, "Error getting parity error log");
return ret;
}
shell_fprintf(shell, SHELL_NORMAL, "Parity Error: 0x%lx\n", error);
return 0;