]> git.pld-linux.org Git - projects/geninitrd.git/blobdiff - mod-sata.sh
no need to mess with magic values, let the "magic" be value
[projects/geninitrd.git] / mod-sata.sh
index dc196def0914be3d86d93f62d24f7bf9870dc083..949c8a6d19c1851b3a30043f8a19f9060d841b9f 100644 (file)
@@ -1,25 +1,7 @@
 #!/bin/sh
-#
-# geninitrd mod: sata
-
-# private until only mod-sata uses the function
-find_modules_by_class() {
-       local class=$1
-
-       local pcimap="/lib/modules/$kernel/modules.pcimap"
-       # no pcimap, nothing to lookup from
-       if [ ! -f "$pcimap" ]; then
-               return
-       fi
-
-       if [ ! -x /sbin/lspci ]; then
-               warn "Failed to execute /sbin/lspci. Is pciutils package installed?"
-               return
-       fi
+SATA_RCSID='$Revision$ $Date::                            $'
 
-       set -- $(/sbin/lspci -n -p $pcimap | awk -vclass=$class '$2 == class":" {split($3, p, ":"); printf("0x0000%s 0x0000%s\n", p[1], p[2])}')
-       awk -vvendor=$1 -vdevice=$2 '$2 == vendor && $3 == device {print $1}' $pcimap
-}
+# geninitrd mod: sata
 
 find_modules_sata() {
        debug "Finding SATA modules (class=0x0106)"
@@ -30,12 +12,20 @@ find_modules_sata() {
        # 0101 - IDE/PATA
        # 0106 - SATA/AHCI
        # 0107 - SAS
-       local module
-       module=$(find_modules_by_class 0106)
+       local m modules=$(find_modules_by_class 0106)
+
+       # sort modules that ones who depend on libata are first
+       # this is best we could think of now :)
+       local left right
+       for m in $modules; do
+               if NEW_MODINFO=1 modinfo -k $kernel -F depends $m | grep -q libata; then
+                       left="$left $m"
+               else
+                       right="$right $m"
+               fi
+       done
 
-       if [ "$module" ]; then
-               # FIXME: how to handle if multiple modules returned?
-               # i.e two modules can do same id
-               find_module "$module"
-       fi
+       for m in $left $right; do
+               find_module $m
+       done
 }
This page took 0.08189 seconds and 4 git commands to generate.