]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
add setup so detection results could be later tweaked for testing
authorElan Ruusamäe <glen@pld-linux.org>
Thu, 10 Feb 2011 11:32:57 +0000 (11:32 +0000)
committerElan Ruusamäe <glen@pld-linux.org>
Thu, 10 Feb 2011 11:32:57 +0000 (11:32 +0000)
svn-id: @12132

mod-sata.sh

index b25c33d88b6e0f6129360876e5d0981211981a19..ea2df44f9667cea8fc67dcf1af2e891fba1e2bae 100644 (file)
@@ -2,22 +2,32 @@
 #
 # geninitrd mod: sata
 
+# setup geninitrd module
+# @access      public
+setup_mod_sata() {
+       lspci=$(find_tool /sbin/lspci)
+
+       pcimap="/lib/modules/$kernel/modules.pcimap"
+
+       if [ ! -x "$lspci" ]; then
+               warn "Failed to execute lspci. Is pciutils package installed?"
+       fi
+}
+
 # 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?"
+       if [ -z "$lspci" ]; then
                return
        fi
 
-       set -- $(/sbin/lspci -n | awk -vclass=$class '$2 == class":" {split($3, p, ":"); printf("0x0000%s 0x0000%s\n", p[1], p[2])}')
+       set -- $($lspci -n | 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
 }
 
@@ -30,15 +40,12 @@ find_modules_sata() {
        # 0101 - IDE/PATA
        # 0106 - SATA/AHCI
        # 0107 - SAS
-       local m modules
-       modules=$(find_modules_by_class 0106)
-
-       if [ "$modules" ]; then
-               # FIXME: how to handle if multiple modules returned?
-               # i.e two modules can do same id
-               # currently we load all of them...
-               for m in $modules; do
-                       find_module $m
-               done
-       fi
+       local m modules=$(find_modules_by_class 0106)
+
+       # FIXME: how to handle if multiple modules returned?
+       # i.e two modules can do same id
+       # currently we load all of them...
+       for m in $modules; do
+               find_module $m
+       done
 }
This page took 0.055526 seconds and 4 git commands to generate.