Skip to contentSkip to conversation

hwrng: amd - Convert PCIBIOS_* return codes to errnos

PATCH In review Ilpo Järvinen 2 participants 2 messages May 27, 2024 – Jun 7, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwrng: amd - Convert PCIBIOS_* return codes to errnos

amd_rng_mod_init() uses pci_read_config_dword() that returns PCIBIOS_* codes. The return code is then returned as is but amd_rng_mod_init() is a module_init() function that should return normal errnos.

Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal errno before returning it.

Fixes 96d63c0297cc ("[PATCH] Add AMD HW RNG driver")
---
 drivers/char/hw_random/amd-rng.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/hw_random/amd-rng.c +3 -1
index 86162a13681e..9a24d19236dc 100644
@@ -143,8 +143,10 @@ static int __init amd_rng_mod_init(void)
 
 found:
 	err = pci_read_config_dword(pdev, 0x58, &pmbase);
-	if (err)
+	if (err) {
+		err = pcibios_err_to_errno(err);
 		goto put_dev;
+	}
 
 	pmbase &= 0x0000FF00;
 	if (pmbase == 0) {
Signature · 1 line
2.39.2
maintainer
#1 lore raw
Quoted 7 lines · Ilpo Järvinen

amd_rng_mod_init() uses pci_read_config_dword() that returns PCIBIOS_* codes. The return code is then returned as is but amd_rng_mod_init() is a module_init() function that should return normal errnos.

Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal errno before returning it.

Quoted 6 lines
Fixes 96d63c0297cc ("[PATCH] Add AMD HW RNG driver")
---
 drivers/char/hw_random/amd-rng.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt