gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/pci/lookup.go (about)

     1  // Copyright 2012-2017 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package pci
     6  
     7  // Lookup takes PCI hex (as strings) vendor and device ID values and returns human
     8  // readable labels for both the vendor and device. Returns the input ID value if
     9  // if label is not found in the ids map.
    10  func Lookup(ids map[string]Vendor, vendor string, device string) (string, string) {
    11  
    12  	if v, f1 := ids[vendor]; f1 {
    13  		if d, f2 := v.Devices[device]; f2 {
    14  			return v.Name, string(d)
    15  		}
    16  		// If entry for device doesn't exist return the hex ID
    17  		return v.Name, device
    18  	}
    19  	// If entry for vendor doesn't exist both hex IDs
    20  	return vendor, device
    21  }