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/hwtracing/intel_th/pci.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c index 21fdf0b93516..176c9088038e 100644 --- a/drivers/hwtracing/intel_th/pci.c +++ b/drivers/hwtracing/intel_th/pci.c @@ -32,13 +32,13 @@ static int intel_th_pci_activate(struct intel_th *th) { struct pci_dev *pdev = to_pci_dev(th->dev); u32 npkdsc; - int err; + int err = -ENODEV; if (!INTEL_TH_CAP(th, tscu_enable)) return 0; - err = pci_read_config_dword(pdev, PCI_REG_NPKDSC, &npkdsc); - if (!err) { + pci_read_config_dword(pdev, PCI_REG_NPKDSC, &npkdsc); + if (npkdsc != (u32)~0) { npkdsc |= NPKDSC_TSACT; err = pci_write_config_dword(pdev, PCI_REG_NPKDSC, npkdsc); } @@ -53,13 +53,13 @@ static void intel_th_pci_deactivate(struct intel_th *th) { struct pci_dev *pdev = to_pci_dev(th->dev); u32 npkdsc; - int err; + int err = -ENODEV; if (!INTEL_TH_CAP(th, tscu_enable)) return; - err = pci_read_config_dword(pdev, PCI_REG_NPKDSC, &npkdsc); - if (!err) { + pci_read_config_dword(pdev, PCI_REG_NPKDSC, &npkdsc); + if (npkdsc != (u32)~0) { npkdsc |= NPKDSC_TSACT; err = pci_write_config_dword(pdev, PCI_REG_NPKDSC, npkdsc); } -- 2.18.4