[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200801112446.149549-12-refactormyself@gmail.com>
Date: Sat, 1 Aug 2020 13:24:40 +0200
From: "Saheed O. Bolarinwa" <refactormyself@...il.com>
To: helgaas@...nel.org,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: "Saheed O. Bolarinwa" <refactormyself@...il.com>,
bjorn@...gaas.com, skhan@...uxfoundation.org,
linux-kernel-mentees@...ts.linuxfoundation.org,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [RFC PATCH 11/17] intel_th: pci: Drop uses of pci_read_config_*() return value
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@...gaas.com>
Signed-off-by: Saheed O. Bolarinwa <refactormyself@...il.com>
---
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
Powered by blists - more mailing lists