Skip to content

Commit

Permalink
drivers: hwinfo: shell: fix error message when no hardware support
Browse files Browse the repository at this point in the history
When there is no implementation for a particular hardware information
device, the API return -ENOSYS, while the hardware information shell
checks for -ENOTSUP. This returns a non-user friendly message:

  uart:~$ hwinfo devid
  Error: -88

The API can't be changed easily without breaking things, so let's change
the shell instead. This gives:

  uart:~$ hwinfo devid
  Not supported by hardware

Signed-off-by: Aurelien Jarno <[email protected]>
  • Loading branch information
aurel32 authored and fabiobaltieri committed May 6, 2024
1 parent 1188305 commit 3da6563
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/hwinfo/hwinfo_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ static int cmd_get_device_id(const struct shell *sh, size_t argc, char **argv)

length = hwinfo_get_device_id(dev_id, sizeof(dev_id));

if (length == -ENOTSUP) {
if (length == -ENOSYS) {
shell_error(sh, "Not supported by hardware");
return -ENOTSUP;
return -ENOSYS;
} else if (length < 0) {
shell_error(sh, "Error: %zd", length);
return length;
Expand Down Expand Up @@ -138,7 +138,7 @@ static int cmd_show_reset_cause(const struct shell *sh, size_t argc,
ARG_UNUSED(argv);

res = hwinfo_get_reset_cause(&cause);
if (res == -ENOTSUP) {
if (res == -ENOSYS) {
shell_error(sh, "Not supported by hardware");
return res;
} else if (res != 0) {
Expand All @@ -165,7 +165,7 @@ static int cmd_clear_reset_cause(const struct shell *sh, size_t argc,
ARG_UNUSED(argv);

res = hwinfo_clear_reset_cause();
if (res == -ENOTSUP) {
if (res == -ENOSYS) {
shell_error(sh, "Not supported by hardware");
} else if (res != 0) {
shell_error(sh, "Error clearing the reset causes [%d]", res);
Expand All @@ -185,7 +185,7 @@ static int cmd_supported_reset_cause(const struct shell *sh, size_t argc,
ARG_UNUSED(argv);

res = hwinfo_get_supported_reset_cause(&cause);
if (res == -ENOTSUP) {
if (res == -ENOSYS) {
shell_error(sh, "Not supported by hardware");
} else if (res != 0) {
shell_error(sh, "Could not get the supported reset causes [%d]", res);
Expand Down

0 comments on commit 3da6563

Please sign in to comment.