diff --git a/tools/kmod/sof_remove.sh b/tools/kmod/sof_remove.sh index 5988a1e3..84389ad3 100755 --- a/tools/kmod/sof_remove.sh +++ b/tools/kmod/sof_remove.sh @@ -6,7 +6,7 @@ remove_module() { local MODULE="$1" - if lsmod | grep -q "^${MODULE}[[:blank:]]"; then + if grep -q "^${MODULE}[[:blank:]]" /proc/modules; then printf 'RMMOD\t%s\n' "$MODULE" sudo rmmod "$MODULE" else @@ -26,6 +26,13 @@ exit_handler() "$(basename "$0")" systemctl --user list-units --all '*pulse*' || true fi + + if test "$exit_status" -ne 0; then + lsmod | grep -e sof -e snd -e sound -e drm + # rmmod can fail silently, for instance when "Used by" is -1 + printf "%s FAILED\n" "$0" + fi + return "$exit_status" }