Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

append chip address to isa devices (just like pci devices) #191

Merged
merged 3 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/hwmon/hwmon.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,17 @@ func computeIdentifier(chip gosensors.Chip) (name string) {
identifier := name
switch chip.Bus.Type {
case BusTypeIsa:
identifier = fmt.Sprintf("%s-isa-%d", identifier, chip.Bus.Nr)
identifier = fmt.Sprintf("%s-isa-%d%03x", name, chip.Bus.Nr, chip.Addr)
case BusTypePci:
identifier = fmt.Sprintf("%s-pci-%d%x", identifier, chip.Bus.Nr, chip.Addr)
identifier = fmt.Sprintf("%s-pci-%d%03x", name, chip.Bus.Nr, chip.Addr)
case BusTypeVirtual:
identifier = fmt.Sprintf("%s-virtual-%d", identifier, chip.Bus.Nr)
identifier = fmt.Sprintf("%s-virtual-%d", name, chip.Bus.Nr)
case BusTypeAcpi:
identifier = fmt.Sprintf("%s-acpi-%d", identifier, chip.Bus.Nr)
identifier = fmt.Sprintf("%s-acpi-%d", name, chip.Bus.Nr)
case BusTypeHid:
identifier = fmt.Sprintf("%s-hid-%d-%d", identifier, chip.Bus.Nr, chip.Addr)
identifier = fmt.Sprintf("%s-hid-%d-%d", name, chip.Bus.Nr, chip.Addr)
case BusTypeScsi:
identifier = fmt.Sprintf("%s-scsi-%d-%d", identifier, chip.Bus.Nr, chip.Addr)
identifier = fmt.Sprintf("%s-scsi-%d-%d", name, chip.Bus.Nr, chip.Addr)
}

return identifier
Expand Down
7 changes: 4 additions & 3 deletions internal/hwmon/hwmon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ func TestComputeIdentifierIsa(t *testing.T) {
// GIVEN
c := gosensors.Chip{
Prefix: "ucsi_source_psy_USBC000:002",
Addr: 0x0f1,
Bus: gosensors.Bus{
Type: BusTypeIsa,
Nr: 1,
},
Path: "/sys/class/hwmon/hwmon7",
}
expected := fmt.Sprintf("%s-isa-%d", c.Prefix, c.Bus.Nr)
expected := "ucsi_source_psy_USBC000:002-isa-10f1"

// WHEN
result := computeIdentifier(c)
Expand All @@ -30,14 +31,14 @@ func TestComputeIdentifierPci(t *testing.T) {
// GIVEN
c := gosensors.Chip{
Prefix: "nvme",
Addr: 5,
Addr: 0x5,
Bus: gosensors.Bus{
Type: BusTypePci,
Nr: 1,
},
Path: "/sys/class/hwmon/hwmon4",
}
expected := fmt.Sprintf("%s-pci-%d%x", c.Prefix, c.Bus.Nr, c.Addr)
expected := "nvme-pci-1005"

// WHEN
result := computeIdentifier(c)
Expand Down