lkml.org 
[lkml]   [2020]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 11/17] intel_th: pci: Drop uses of pci_read_config_*() return value
Date
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@helgaas.com>
Signed-off-by: Saheed O. Bolarinwa <refactormyself@gmail.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
\
 
 \ /
  Last update: 2020-08-01 14:25    [W:0.073 / U:0.844 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site