Author: arekm
Date: Wed Mar 28 10:23:55 2012
New Revision: 12520
Modified:
geninitrd/trunk/functions
Log:
Unfortunately module-init-tools modprobe doesn't work with new way. Provide old
find_modules_by_class() for mit and new for kmod.
Modified: geninitrd/trunk/functions
==============================================================================
--- geninitrd/trunk/functions (original)
+++ geninitrd/trunk/functions Wed Mar 28 10:23:55 2012
@@ -167,10 +167,21 @@
printf "/dev/mapper/%s" $(dm_name "$node")
}
-# find modules by class eg
+# find modules by class
# 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() {
+ if (modprobe --version | grep -q "^kmod"); then
+ find_modules_by_class_kmod $@
+ else
+ find_modules_by_class_mit $@
+ fi
+}
+
+# find modules by class (kmod version)
+# 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_kmod() {
local req_class="$1" i j modaliases
if [ ! -d "/sys/devices" ]; then
@@ -206,3 +217,56 @@
}
'
}
+
+# find modules by class (module-init-tools version)
+# 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_mit() {
+ local req_class="$1"
+
+ 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!"
+ 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]; };
+ }
+ '
+}
+
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit