The previous patches dropped most of the calls to the helper function _unload_module(). The last left caller is _unload_modules(). Reimplement it to call _patient_rmmod() instead. Then remove _unload_module(). Signed-off-by: Shin'ichiro Kawasaki --- check | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/check b/check index 6a156b3..cd247a0 100755 --- a/check +++ b/check @@ -581,25 +581,14 @@ _patient_rmmod() return $mod_ret } -# Arguments: module to unload ($1) and retry count ($2). -_unload_module() { - local i m=$1 rc=${2:-1} reason - - [ ! -e "/sys/module/$m" ] && return 0 - for ((i=rc;i>0;i--)); do - reason=$(modprobe -r "$m" 2>&1) - [ ! -e "/sys/module/$m" ] && return 0 - sleep .1 - done - echo "${reason}" >&2 - return 1 -} - _unload_modules() { - local i + local i reason for ((i=${#MODULES_TO_UNLOAD[@]}; i > 0; i--)); do - _unload_module "${MODULES_TO_UNLOAD[i-1]}" 10 + if ! reason=$(_patient_rmmod "${MODULES_TO_UNLOAD[i-1]}" \ + 2>&1); then + echo "${reason}" >&2 + fi done unset MODULES_TO_UNLOAD -- 2.52.0