Skip to content

Commit 7dd57db

Browse files
superm1bp3tk0v
authored andcommitted
x86/amd_nb, hwmon: (k10temp): Simplify amd_pci_dev_to_node_id()
amd_pci_dev_to_node_id() tries to find the AMD node ID of a device by searching and counting devices. The AMD node ID of an AMD node device is simply its slot number minus the AMD node 0 slot number. Simplify this function and move it to k10temp.c. [ Yazen: Update commit message and simplify function. ] Signed-off-by: Mario Limonciello <[email protected]> Co-developed-by: Yazen Ghannam <[email protected]> Signed-off-by: Yazen Ghannam <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Acked-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 49b96fc commit 7dd57db

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

arch/x86/include/asm/amd_nb.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,6 @@ u16 amd_nb_num(void);
8282
bool amd_nb_has_feature(unsigned int feature);
8383
struct amd_northbridge *node_to_amd_nb(int node);
8484

85-
static inline u16 amd_pci_dev_to_node_id(struct pci_dev *pdev)
86-
{
87-
struct pci_dev *misc;
88-
int i;
89-
90-
for (i = 0; i != amd_nb_num(); i++) {
91-
misc = node_to_amd_nb(i)->misc;
92-
93-
if (pci_domain_nr(misc->bus) == pci_domain_nr(pdev->bus) &&
94-
PCI_SLOT(misc->devfn) == PCI_SLOT(pdev->devfn))
95-
return i;
96-
}
97-
98-
WARN(1, "Unable to find AMD Northbridge id for %s\n", pci_name(pdev));
99-
return 0;
100-
}
101-
10285
static inline bool amd_gart_present(void)
10386
{
10487
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)

drivers/hwmon/k10temp.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ static void read_tempreg_nb_f15(struct pci_dev *pdev, u32 *regval)
150150
F15H_M60H_REPORTED_TEMP_CTRL_OFFSET, regval);
151151
}
152152

153+
static u16 amd_pci_dev_to_node_id(struct pci_dev *pdev)
154+
{
155+
return PCI_SLOT(pdev->devfn) - AMD_NODE0_PCI_SLOT;
156+
}
157+
153158
static void read_tempreg_nb_zen(struct pci_dev *pdev, u32 *regval)
154159
{
155160
if (amd_smn_read(amd_pci_dev_to_node_id(pdev),

0 commit comments

Comments
 (0)