SVN: geninitrd/trunk/mod-sata.sh

glen glen at pld-linux.org
Thu Feb 10 12:32:58 CET 2011


Author: glen
Date: Thu Feb 10 12:32:57 2011
New Revision: 12132

Modified:
   geninitrd/trunk/mod-sata.sh
Log:
add setup so detection results could be later tweaked for testing

Modified: geninitrd/trunk/mod-sata.sh
==============================================================================
--- geninitrd/trunk/mod-sata.sh	(original)
+++ geninitrd/trunk/mod-sata.sh	Thu Feb 10 12:32:57 2011
@@ -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 @@
 	# 0101 - IDE/PATA
 	# 0106 - SATA/AHCI
 	# 0107 - SAS
-	local m modules
-	modules=$(find_modules_by_class 0106)
+	local m 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
+	# 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
 }


More information about the pld-cvs-commit mailing list