The return value of pci_read_config_*() may not indicate a device error. However, the value read by these functions is more likely to indicate this kind of error. This presents two overlapping ways of reporting errors and complicates error checking. It is possible to move to one single way of checking for error if the dependency on the return value of these functions is removed, then it can later be made to return void. Remove all uses of the return value of pci_read_config_*(). Check the actual value read for ~0. In this case, ~0 is an invalid value thus it indicates some kind of error. Suggested-by: Bjorn Helgaas <bjorn@xxxxxxxxxxx> Signed-off-by: Saheed O. Bolarinwa <refactormyself@xxxxxxxxx> --- drivers/char/hw_random/amd-rng.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c index 9959c762da2f..e7bf17eedaa0 100644 --- a/drivers/char/hw_random/amd-rng.c +++ b/drivers/char/hw_random/amd-rng.c @@ -141,9 +141,9 @@ static int __init mod_init(void) return -ENODEV; found: - err = pci_read_config_dword(pdev, 0x58, &pmbase); - if (err) - return err; + pci_read_config_dword(pdev, 0x58, &pmbase); + if (pmbase == (u32)~0) + return -ENODEV; pmbase &= 0x0000FF00; if (pmbase == 0) -- 2.18.4