Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 232875 | Differences between
and this patch

Collapse All | Expand All

(-)a/alsasound (-16 / +15 lines)
Lines 90-120 Link Here
90
	rmmod gameport 2>/dev/null
90
	rmmod gameport 2>/dev/null
91
91
92
	lsmod | grep -vq '^snd'
92
	lsmod | grep -vq '^snd'
93
}
93
}
94
94
95
unload_modules_recursive() {
95
unload_modules_topsort() {
96
	local revdeps="$(lsmod | sed -n -e "s/,/ /g" -e "s/^$1 *[0-9]* *[0-9]* \(.*\)/\1/p")"
96
	#Load the module with the least reverse dependency number--that will be zero
97
	local victim=""
98
	while { victim="$(lsmod | sort --key=3 --numeric-sort | sed -n -e '/^snd/{s/^\(snd[^ ]*\) *[0-9]* *\([0-9]*\).*/\1 \2/p;q}')"; [[ -n "$victim" ]] ; } ; do
99
		local modname=$(echo "$victim" | cut -d ' ' -f 1)
100
		local rdepnum=$(echo "$victim" | cut -d ' ' -f 2)
101
		if (( $rdepnum != 0 )) ; then
102
			ewarn "WARNING: can't rmmod $modname.  Some modules are not unloaded!"
103
			return
104
		fi
97
105
98
	for module in ${revdeps} ; do
106
		vebegin "Unloading: $modname"
99
		unload_modules_recursive "${module}"
107
		rmmod --wait "$modname"
108
		veend $?
100
	done
109
	done
101
102
	vebegin "Unloading: $1"
103
	rmmod --wait "$1"
104
	veend $?
105
}
110
}
106
111
107
unload_modules_26() {
112
unload_modules_26() {
108
	# First of all, remove the snd module and all the modules depending
113
	# Remove all snd* modules
109
	# on it, this should remove already most of ALSA modules.
114
	unload_modules_topsort
110
	lsmod | grep -q "^snd[[:space:]]" && unload_modules_recursive snd
111
112
	# Then find the remaining ones, and handle them too.
113
	for module in $(lsmod | sed -n -e 's/^\(snd[^ ]*\) .*/\1/p'); do
114
		unload_modules_recursive "${module}"
115
	done
116
115
117
	lsmod | grep -vq "^snd"
116
	lsmod | grep -vq "^snd"
118
}
117
}
119
118
120
terminate() {
119
terminate() {

Return to bug 232875