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

Collapse All | Expand All

(-)pci-parm.orig (-34 / +43 lines)
Lines 1-4 Link Here
1
#!/sbin/runscript
1
#!/sbin/runscript
2
# (C) 2008 Gentoo Foundation
3
# Distributed under the terms of the GPLv2
2
# read this article to know what to do
4
# read this article to know what to do
3
# http://gentoo.org/doc/en/articles/hardware-stability-p2.xml#doc_chap3_pre2
5
# http://gentoo.org/doc/en/articles/hardware-stability-p2.xml#doc_chap3_pre2
4
6
Lines 22-75 Link Here
22
24
23
do_setpci() {
25
do_setpci() {
24
	#ewarn "do_setpci: /usr/sbin/setpci $SETPCI_OPT $@"
26
	#ewarn "do_setpci: /usr/sbin/setpci $SETPCI_OPT $@"
25
	SWITCH=$1
27
	x=
26
	if [ "$SWITCH" = "-d" ]; then
28
	case $1 in
27
		DESC="(vendor)"
29
	-d) DESC=vendor
28
	else
30
;;	-s) DESC=bus
29
		DESC="(bus)"
31
;;	-x) x=1; shift; false
30
	fi
32
;;	*) DESC=bus; SWITCH=-s
31
	shift
33
#		[ "$VERBOSE" = yes ] && ewarn "do_setpci $*"
34
		false
35
;;	esac && { SWITCH=$1; shift; }
32
	SPEC_ID=$1
36
	SPEC_ID=$1
33
	shift
37
	shift
34
	ebegin "Setting PCI params for $DESC $SPEC_ID to $@"
38
	[ -n "$SWITCH" -a -n "$SPEC_ID" -a -n "$1" ] || {
35
	/usr/sbin/setpci $SETPCI_OPT $SWITCH $SPEC_ID $@
39
		eerror "Bad call to: do_setpci $SWITCH $SPEC_ID $1"
36
	eend $?
40
		return 1
37
	SWITCH=""
41
	}
38
	SPEC_ID=""
42
	ebegin "Setting PCI params for ($DESC) $SPEC_ID to $@"
43
	/usr/sbin/setpci $SETPCI_OPT "$SWITCH" "$SPEC_ID" "$@"
44
	r=$?
45
	[ -n "$x" ] && unset -v SPEC_ID || unset -v SWITCH SPEC_ID
46
	eend "$r"
47
	return "$r"
48
}
49
50
dopci_array() {
51
	case $1 in
52
	-d) DESC=vendor
53
;;	-s) DESC=bus
54
;;	*) eerror "Unknown type to: dopci_array $*";return 1
55
;;	esac
56
	SWITCH=$1; shift
57
	i=0
58
	while true; do
59
		eval opt="\$${1}_$i"
60
		[ -n "$opt" ] || break
61
		do_setpci -x $opt || return 1
62
		i=$(($i+1))
63
	done
64
	unset -v opt i SWITCH
39
}
65
}
40
66
41
start() {
67
start() {
42
	if get_bootparam "nopciparm" ; then
68
	if get_bootparam nopciparm; then
43
		ewarn "Skipping pciparm init as requested in kernel cmdline"
69
		ewarn "Skipping pciparm init as requested in kernel cmdline"
44
		return 0
70
		return 0
45
	fi
71
	fi
46
72
47
	checkconfig || return 1
73
	checkconfig || return 1
48
	
74
	
49
	SETPCI_OPT=""
75
	if [ "$VERBOSE" = yes ]; then
50
	if [ "$VERBOSE" = "yes" ]; then
76
		SETPCI_OPT=' -v'
51
		SETPCI_OPT="$SETPCI_OPT -v"
77
	else SETPCI_OPT=
52
	fi
78
	fi
53
79
54
	if [ -n "$PCIPARM_ALL" ]; then
80
	if [ -n "$PCIPARM_ALL" ]; then
55
		do_setpci -d '*:*' $PCIPARM_ALL
81
		do_setpci -d '*:*' $PCIPARM_ALL
56
	fi
82
	fi
57
	SEQ_BUS=0
83
	dopci_array -s PCIPARM_BUS && dopci_array -d PCIPARM_VENDOR
58
	while true; do
59
		BUS_OPT=`eval echo '$'PCIPARM_BUS_${SEQ_BUS}`
60
		if [ -z "$BUS_OPT" ]; then
61
			break
62
		fi
63
		do_setpci -s $BUS_OPT
64
		SEQ_BUS=$(($SEQ_BUS+1))
65
	done
66
	SEQ_VENDOR=0
67
	while true; do
68
		VENDOR_OPT=`eval echo '$'PCIPARM_VENDOR_${SEQ_VENDOR}`
69
		if [ -z "$VENDOR_OPT" ]; then
70
			break
71
		fi
72
		do_setpci -d $VENDOR_OPT
73
		SEQ_VENDOR=$(($SEQ_VENDOR+1))
74
	done
75
}
84
}

Return to bug 173347