SVN: geninitrd/trunk/functions
arekm
arekm at pld-linux.org
Wed Oct 26 21:52:24 CEST 2011
Author: arekm
Date: Wed Oct 26 21:52:24 2011
New Revision: 12391
Modified:
geninitrd/trunk/functions
Log:
Use lspci only for finding kernel modules. Our shell code was full of bugs. Also try to preserve xhci/ehco/ohci/uhci modules loading order.
Modified: geninitrd/trunk/functions
==============================================================================
--- geninitrd/trunk/functions (original)
+++ geninitrd/trunk/functions Wed Oct 26 21:52:24 2011
@@ -189,23 +189,33 @@
return
fi
- set -- $($lspci -n | awk -vclass=$req_class '$2 == class":" {split($3, p, ":"); printf("0x0000%s 0x0000%s\n", p[1], p[2])}')
-
- req_class="0x${req_class}00"
-
- local PCI_ANY_ID=0xffffffff pci_module vendor device subvendor subdevice class class_mask driver_data
- while read pci_module vendor device subvendor subdevice class class_mask driver_data; do
- # ignore program interface (last two digits) - we want any
- class_mask=$(($class_mask & 0xffffff00))
- # some devices (like hcd) have very specific class
- class=$(($class & $class_mask))
- [ "$(($req_class & $class_mask))" = "$class" ] || continue
- # match vendor
- [ "$1" = "$vendor" -o "$vendor" = "$PCI_ANY_ID" ] || continue
- # match device, allow PCI_ANY_ID
- [ "$2" = "$device" -o "$device" = "$PCI_ANY_ID" ] || continue
-
- echo "$pci_module"
- done < $pcimap
+ lspci -p "$pcimap" -kvmmn | awk -vreq_class="${req_class}" '
+ BEGIN { skip_modules[1]=""; modules[1]=""; xhci=""; ehci=""; ohci=""; uhci="" }
+ /^Slot:/ { found=0 }
+ /^Class:/ { if (req_class == $2) { found=1 } }
+ /^Driver:/ { if (found) {
+ module=$2;
+ if (module == "xhci_hcd") {
+ xhci="xhci_hcd"
+ } else if (module == "ehci_hcd") {
+ ehci="ehci_hcd"
+ } else if (module == "ohci_hcd") {
+ ohci="ohci_hcd"
+ } else if (module == "uhci_hcd") {
+ uhci="uhci_hcd"
+ } else if (!(module in skip_modules)) {
+ modules[cnt]=module
+ }
+ skip_modules[cnt]=module;
+ cnt++;
+ };
+ found=0
+ }
+ END {
+ # xhci/ehci/ohci/uhci hack to preserve such order
+ printf "%s %s %s %s", xhci, ehci, ohci, uhci;
+ for (i in modules) { printf "%s ", modules[i]; };
+ }
+ '
}
More information about the pld-cvs-commit
mailing list