]> git.pld-linux.org Git - projects/geninitrd.git/blob - mod-sata.sh
Left side expands to decimal while right side was in hex. Convert right side to decimal.
[projects/geninitrd.git] / mod-sata.sh
1 #!/bin/sh
2 SATA_RCSID='$Revision$ $Date::                            $'
3
4 # geninitrd mod: sata
5
6 # setup geninitrd module
7 # @access       public
8 setup_mod_sata() {
9         lspci=$(find_tool /sbin/lspci)
10
11         pcimap="/lib/modules/$kernel/modules.pcimap"
12
13         if [ ! -x "$lspci" ]; then
14                 warn "Failed to execute lspci. Is pciutils package installed?"
15         fi
16 }
17
18 # private until only mod-sata uses the function
19 find_modules_by_class() {
20         local req_class=$1
21
22         # no pcimap, nothing to lookup from
23         if [ ! -f "$pcimap" ]; then
24                 return
25         fi
26
27         if [ -z "$lspci" ]; then
28                 return
29         fi
30
31         set -- $($lspci -n | awk -vclass=$req_class '$2 == class":" {split($3, p, ":"); printf("0x0000%s 0x0000%s\n", p[1], p[2])}')
32
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
35                 # match class
36                 [ "$(($req_class & $class_mask))" = "$(($class))" ] || continue
37                 # match vendor
38                 [ "$1" = "$vendor" ] || continue
39                 # match device, allow PCI_ANY_ID
40                 [ "$2" = "$device" -o $device = $PCI_ANY_ID ] || continue
41
42                 echo "$pci_module"
43         done < $pcimap
44 }
45
46 find_modules_sata() {
47         debug "Finding SATA modules (class=0x0106)"
48
49         # Classes (we want only 0106)
50         # http://pci-ids.ucw.cz/read/PD/01
51         # 0100 - SCSI
52         # 0101 - IDE/PATA
53         # 0106 - SATA/AHCI
54         # 0107 - SAS
55         local m modules=$(find_modules_by_class 0106)
56
57         # sort modules that ones who depend on libata are first
58         # this is best we could think of now :)
59         local left right
60         for m in $modules; do
61                 if NEW_MODINFO=1 modinfo -k $kernel -F depends $m | grep -q libata; then
62                         left="$left $m"
63                 else
64                         right="$right $m"
65                 fi
66         done
67
68         for m in $left $right; do
69                 find_module $m
70         done
71 }
This page took 0.064259 seconds and 4 git commands to generate.