]>
Commit | Line | Data |
---|---|---|
fb9e3ed2 | 1 | #!/bin/sh |
2 | # | |
3 | # geninitrd mod: sata | |
4 | ||
13639229 ER |
5 | # private until only mod-sata uses the function |
6 | find_modules_by_class() { | |
7 | local class=$1 | |
8 | ||
9 | local pcimap="/lib/modules/$kernel/modules.pcimap" | |
10 | # no pcimap, nothing to lookup from | |
11 | if [ ! -f "$pcimap" ]; then | |
12 | return | |
13 | fi | |
fb9e3ed2 | 14 | |
15 | if [ ! -x /sbin/lspci ]; then | |
79348345 | 16 | warn "Failed to execute /sbin/lspci. Is pciutils package installed?" |
17 | return | |
18 | fi | |
fb9e3ed2 | 19 | |
c6bca35c | 20 | set -- $(/sbin/lspci -n | awk -vclass=$class '$2 == class":" {split($3, p, ":"); printf("0x0000%s 0x0000%s\n", p[1], p[2])}') |
13639229 ER |
21 | awk -vvendor=$1 -vdevice=$2 '$2 == vendor && $3 == device {print $1}' $pcimap |
22 | } | |
23 | ||
24 | find_modules_sata() { | |
25 | debug "Finding SATA modules (class=0x0106)" | |
26 | ||
fb9e3ed2 | 27 | # Classes (we want only 0106) |
13639229 ER |
28 | # http://pci-ids.ucw.cz/read/PD/01 |
29 | # 0100 - SCSI | |
fb9e3ed2 | 30 | # 0101 - IDE/PATA |
31 | # 0106 - SATA/AHCI | |
32 | # 0107 - SAS | |
e3c7943c | 33 | local module |
13639229 ER |
34 | module=$(find_modules_by_class 0106) |
35 | ||
36 | if [ "$module" ]; then | |
37 | # FIXME: how to handle if multiple modules returned? | |
38 | # i.e two modules can do same id | |
f27797f8 | 39 | find_module "$module" |
40 | fi | |
fb9e3ed2 | 41 | } |