2 RCSID='$Revision: 12159 $ $Date: 2011-02-17 23:16:30 +0100 (czw) $'
6 # setup geninitrd module
9 lspci=$(find_tool /sbin/lspci)
11 pcimap="/lib/modules/$kernel/modules.pcimap"
13 if [ ! -x "$lspci" ]; then
14 warn "Failed to execute lspci. Is pciutils package installed?"
18 # private until only mod-sata uses the function
19 find_modules_by_class() {
22 # no pcimap, nothing to lookup from
23 if [ ! -f "$pcimap" ]; then
27 if [ -z "$lspci" ]; then
31 set -- $($lspci -n | awk -vclass=$class '$2 == class":" {split($3, p, ":"); printf("0x0000%s 0x0000%s\n", p[1], p[2])}')
33 local PCI_ANY_ID=0x0000ffff pci_module vendor device subvendor subdevice class class_mask driver_data
34 while read pci_module vendor device subvendor subdevice class class_mask driver_data; do
36 [ "$1" = "$vendor" ] || continue
37 # match device, allow PCI_ANY_ID
38 [ "$2" = "$device" -o $device = $PCI_ANY_ID ] || continue
45 debug "Finding SATA modules (class=0x0106)"
47 # Classes (we want only 0106)
48 # http://pci-ids.ucw.cz/read/PD/01
53 local m modules=$(find_modules_by_class 0106)
55 # sort modules that ones who depend on libata are first
56 # this is best we could think of now :)
59 if NEW_MODINFO=1 modinfo -k $kernel -F depends $m | grep -q libata; then
66 for m in $left $right; do