]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
Use lspci only for finding kernel modules. Our shell code was full of bugs. Also...
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Wed, 26 Oct 2011 19:52:24 +0000 (19:52 +0000)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Wed, 26 Oct 2011 19:52:24 +0000 (19:52 +0000)
svn-id: @12391

functions

index 4b04123e37c5f944ec0cc338cbb9869b16b4d71d..0c3f65173f850007c21c0c4861b4399ce4ed1775 100644 (file)
--- a/functions
+++ b/functions
@@ -189,23 +189,33 @@ find_modules_by_class() {
                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]; };
+                                       }
+       '
 }
 
This page took 0.03611 seconds and 4 git commands to generate.