Author: arekm
Date: Sat Mar 24 21:49:55 2012
New Revision: 12515

Modified:
   geninitrd/trunk/functions
Log:
Our find_modules_by_class() relied on lspci and on modules.pcimap
file generated by module-init-tools. Unfortunately kmod no longer
generates modules.pcimap. Rewrite to use sysfs and modprobe only.


Modified: geninitrd/trunk/functions
==============================================================================
--- geninitrd/trunk/functions   (original)
+++ geninitrd/trunk/functions   Sat Mar 24 21:49:55 2012
@@ -171,51 +171,38 @@
 # find_modules_by_class 0106 - finds modules for SATA devices in the system
 # find_modules_by_class 0c03 - finds modules for USB controllers
 find_modules_by_class() {
-       local req_class="$1"
+       local req_class="$1" i j modaliases
 
-       pcimap="/lib/modules/$kernel/modules.pcimap"
-
-       lspci=$(find_tool /sbin/lspci)
-       if [ ! -x "$lspci" ]; then
-               warn "Failed to execute lspci. Is pciutils package installed?"
-       fi
-
-       # no pcimap, nothing to lookup from
-       if [ ! -f "$pcimap" ]; then
-                       warn "No $pcimap file. Cannot find modules for desired 
class!"
+       if [ ! -d "/sys/devices" ]; then
+               warn "No /sys/devices/ found. Is /sys mounted?"
                return
        fi
 
-       if [ -z "$lspci" ]; then
-               return
-       fi
-
-       LC_ALL=C lspci -p "$pcimap" -kvmmn | awk -vreq_class="${req_class}" '
-                                       BEGIN      { 
skip_modules[notexisting_module]=""; 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[module]=1;
-                                                  };
-                                                  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]; };
-                                       }
+       for i in $(grep -li "^0x${req_class}" /sys/devices/pci*/*/class); do
+               j=$(dirname $i)
+               modaliases="$modaliases $(cat $j/modalias)"
+       done
+       echo $modaliases | xargs modprobe --set-version $kernel -aR | awk '
+               BEGIN { skip_modules[notexisting_module]=""; modules[1]=""; 
xhci=""; ehci=""; ohci=""; uhci="" }
+               {
+                       module=$1
+                       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[module]=1;
+               }
+               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]; };
+               }
        '
 }
-
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to