Skip to content

Commit 35df797

Browse files
yghannambp3tk0v
authored andcommitted
x86/amd_node: Update __amd_smn_rw() error paths
Use guard(mutex) and convert PCI error codes to common ones. Suggested-by: Tom Lendacky <[email protected]> Signed-off-by: Yazen Ghannam <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d6caeaf commit 35df797

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

arch/x86/kernel/amd_node.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,28 +136,24 @@ static int __amd_smn_rw(u16 node, u32 address, u32 *value, bool write)
136136
int err = -ENODEV;
137137

138138
if (node >= amd_nb_num())
139-
goto out;
139+
return err;
140140

141141
root = node_to_amd_nb(node)->root;
142142
if (!root)
143-
goto out;
143+
return err;
144144

145-
mutex_lock(&smn_mutex);
145+
guard(mutex)(&smn_mutex);
146146

147147
err = pci_write_config_dword(root, 0x60, address);
148148
if (err) {
149149
pr_warn("Error programming SMN address 0x%x.\n", address);
150-
goto out_unlock;
150+
return pcibios_err_to_errno(err);
151151
}
152152

153153
err = (write ? pci_write_config_dword(root, 0x64, *value)
154154
: pci_read_config_dword(root, 0x64, value));
155155

156-
out_unlock:
157-
mutex_unlock(&smn_mutex);
158-
159-
out:
160-
return err;
156+
return pcibios_err_to_errno(err);
161157
}
162158

163159
int __must_check amd_smn_read(u16 node, u32 address, u32 *value)

0 commit comments

Comments
 (0)