Skip to content

Commit 60b1cca

Browse files
committed
Fixed incorrect path construction for lspci kernel driver lookup
Fixed incorrect path construction for PCI device kernel driver lookup in lspci command.
1 parent 0d44b4a commit 60b1cca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pci/pci.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ func readFromFile(f string, w, start, end int) (string, error) {
6868
return "", errors.New("invalid start:end")
6969
}
7070
return ret[start:end], nil
71-
} else {
72-
return ret, nil
7371
}
7472
}
7573
}
@@ -78,13 +76,15 @@ func readFromFile(f string, w, start, end int) (string, error) {
7876

7977
func ParsePciDevices() (PciDevices []PciDevice, err error) {
8078
var devices []string
79+
var path string
8180

8281
read := func(bus, filename string, start, end int) (string, error) {
8382
return readFromFile(filepath.Join(PATH_SYS_BUS_PCI_DEVICES, bus, filename), 1, start, end)
8483
}
8584

8685
lookupKernelDriver := func(bus string) (string, error) {
87-
read, err := readFromFile(filepath.Join(PATH_SYS_DEVICES_PCI+bus[0:7], bus, "uevent"), 1, 0, 0)
86+
path = filepath.Join(PATH_SYS_BUS_PCI_DEVICES, bus, "uevent")
87+
read, err := readFromFile(path, 1, 0, 0)
8888
if err != nil {
8989
return "", err
9090
}

0 commit comments

Comments
 (0)