All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling
@ 2023-08-24 13:28 Ilpo Järvinen
  2023-08-24 13:28   ` Ilpo Järvinen
                   ` (13 more replies)
  0 siblings, 14 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas; +Cc: linux-kernel, Ilpo Järvinen

As the first step towards converting PCI accessor function return codes
into normal errnos this series cleans up related code paths which have
complicated multi-line construct to handle the PCI error checking.

Ilpo Järvinen (14):
  alpha: Streamline convoluted PCI error handling
  MIPS: TXx9: Do PCI error checks on own line
  sh: pci: Do PCI error check on own line
  atm: iphase: Do PCI error checks on own line
  hwmon: (via686a) Do PCI error checks on own line
  hwmon: (vt8231) Do PCI error checks on own line
  I2C: ali15x3: Do PCI error checks on own line
  I2C: nforce2: Do PCI error check on own line
  I2C: sis5595: Do PCI error checks on own line
  PCI: Do error check on own line to split long if conditions
  PCI: xgene: Do PCI error check on own line
  scsi: ipr: Do PCI error checks on own line
  hwmon: (sis5595) Do PCI error checks on own line
  perf/x86/uncore: Remove unnecessary ?: operator around
    pcibios_err_to_errno() call

 arch/alpha/kernel/sys_miata.c        | 17 +++++------
 arch/mips/txx9/generic/pci.c         | 43 +++++++++++++++-------------
 arch/sh/drivers/pci/common.c         |  7 +++--
 arch/x86/events/intel/uncore_snbep.c |  2 +-
 drivers/atm/iphase.c                 | 20 +++++++------
 drivers/hwmon/sis5595.c              | 35 ++++++++++++----------
 drivers/hwmon/via686a.c              | 18 ++++++------
 drivers/hwmon/vt8231.c               | 11 +++----
 drivers/i2c/busses/i2c-ali15x3.c     | 10 +++----
 drivers/i2c/busses/i2c-nforce2.c     |  4 +--
 drivers/i2c/busses/i2c-sis5595.c     | 20 ++++++-------
 drivers/pci/controller/pci-xgene.c   |  5 ++--
 drivers/pci/pci.c                    |  9 ++++--
 drivers/pci/probe.c                  |  6 ++--
 drivers/pci/quirks.c                 |  6 ++--
 drivers/scsi/ipr.c                   | 12 +++++---
 16 files changed, 123 insertions(+), 102 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 01/14] alpha: Streamline convoluted PCI error handling
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
@ 2023-08-24 13:28   ` Ilpo Järvinen
  2023-08-24 13:28 ` [PATCH 02/14] MIPS: TXx9: Do PCI error checks on own line Ilpo Järvinen
                     ` (12 subsequent siblings)
  13 siblings, 0 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, linux-alpha, linux-kernel
  Cc: Ilpo Järvinen

miata_map_irq() handles PCI device and read config related errors in a
conditional block that is more complex than necessary.

Streamline the code flow and error handling.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 arch/alpha/kernel/sys_miata.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/arch/alpha/kernel/sys_miata.c b/arch/alpha/kernel/sys_miata.c
index e1bee8f84c58..33b2798de8fc 100644
--- a/arch/alpha/kernel/sys_miata.c
+++ b/arch/alpha/kernel/sys_miata.c
@@ -183,16 +183,17 @@ miata_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
            the 2nd 8259 controller. So we have to check for it first. */
 
 	if((slot == 7) && (PCI_FUNC(dev->devfn) == 3)) {
-		u8 irq=0;
 		struct pci_dev *pdev = pci_get_slot(dev->bus, dev->devfn & ~7);
-		if(pdev == NULL || pci_read_config_byte(pdev, 0x40,&irq) != PCIBIOS_SUCCESSFUL) {
-			pci_dev_put(pdev);
+		u8 irq = 0;
+		int ret;
+
+		if (!pdev)
 			return -1;
-		}
-		else	{
-			pci_dev_put(pdev);
-			return irq;
-		}
+
+		ret = pci_read_config_byte(pdev, 0x40, &irq);
+		pci_dev_put(pdev);
+
+		return ret == PCIBIOS_SUCCESSFUL ? irq : -1;
 	}
 
 	return COMMON_TABLE_LOOKUP;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 01/14] alpha: Streamline convoluted PCI error handling
@ 2023-08-24 13:28   ` Ilpo Järvinen
  0 siblings, 0 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, linux-alpha, linux-kernel
  Cc: Ilpo Järvinen

miata_map_irq() handles PCI device and read config related errors in a
conditional block that is more complex than necessary.

Streamline the code flow and error handling.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 arch/alpha/kernel/sys_miata.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/arch/alpha/kernel/sys_miata.c b/arch/alpha/kernel/sys_miata.c
index e1bee8f84c58..33b2798de8fc 100644
--- a/arch/alpha/kernel/sys_miata.c
+++ b/arch/alpha/kernel/sys_miata.c
@@ -183,16 +183,17 @@ miata_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
            the 2nd 8259 controller. So we have to check for it first. */
 
 	if((slot == 7) && (PCI_FUNC(dev->devfn) == 3)) {
-		u8 irq=0;
 		struct pci_dev *pdev = pci_get_slot(dev->bus, dev->devfn & ~7);
-		if(pdev == NULL || pci_read_config_byte(pdev, 0x40,&irq) != PCIBIOS_SUCCESSFUL) {
-			pci_dev_put(pdev);
+		u8 irq = 0;
+		int ret;
+
+		if (!pdev)
 			return -1;
-		}
-		else	{
-			pci_dev_put(pdev);
-			return irq;
-		}
+
+		ret = pci_read_config_byte(pdev, 0x40, &irq);
+		pci_dev_put(pdev);
+
+		return ret == PCIBIOS_SUCCESSFUL ? irq : -1;
 	}
 
 	return COMMON_TABLE_LOOKUP;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 02/14] MIPS: TXx9: Do PCI error checks on own line
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
  2023-08-24 13:28   ` Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-24 15:20   ` Philippe Mathieu-Daudé
  2023-08-24 13:28 ` [PATCH 03/14] sh: pci: Do PCI error check " Ilpo Järvinen
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Thomas Bogendoerfer, linux-mips, linux-kernel
  Cc: Ilpo Järvinen

Instead of if conditions with line splits, use the usual error handling
pattern with a separate variable to improve readability.

The second check can use reverse logic which reduces indentation level.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 arch/mips/txx9/generic/pci.c | 43 +++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/arch/mips/txx9/generic/pci.c b/arch/mips/txx9/generic/pci.c
index e98845543b77..5ae30b78d38d 100644
--- a/arch/mips/txx9/generic/pci.c
+++ b/arch/mips/txx9/generic/pci.c
@@ -51,6 +51,7 @@ int __init txx9_pci66_check(struct pci_controller *hose, int top_bus,
 	unsigned short vid;
 	int cap66 = -1;
 	u16 stat;
+	int ret;
 
 	/* It seems SLC90E66 needs some time after PCI reset... */
 	mdelay(80);
@@ -60,9 +61,9 @@ int __init txx9_pci66_check(struct pci_controller *hose, int top_bus,
 	for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) {
 		if (PCI_FUNC(pci_devfn))
 			continue;
-		if (early_read_config_word(hose, top_bus, current_bus,
-					   pci_devfn, PCI_VENDOR_ID, &vid) !=
-		    PCIBIOS_SUCCESSFUL)
+		ret = early_read_config_word(hose, top_bus, current_bus,
+					     pci_devfn, PCI_VENDOR_ID, &vid);
+		if (ret != PCIBIOS_SUCCESSFUL)
 			continue;
 		if (vid == 0xffff)
 			continue;
@@ -343,26 +344,28 @@ static void tc35815_fixup(struct pci_dev *dev)
 
 static void final_fixup(struct pci_dev *dev)
 {
+	unsigned long timeout;
 	unsigned char bist;
+	int ret;
 
 	/* Do build-in self test */
-	if (pci_read_config_byte(dev, PCI_BIST, &bist) == PCIBIOS_SUCCESSFUL &&
-	    (bist & PCI_BIST_CAPABLE)) {
-		unsigned long timeout;
-		pci_set_power_state(dev, PCI_D0);
-		pr_info("PCI: %s BIST...", pci_name(dev));
-		pci_write_config_byte(dev, PCI_BIST, PCI_BIST_START);
-		timeout = jiffies + HZ * 2;	/* timeout after 2 sec */
-		do {
-			pci_read_config_byte(dev, PCI_BIST, &bist);
-			if (time_after(jiffies, timeout))
-				break;
-		} while (bist & PCI_BIST_START);
-		if (bist & (PCI_BIST_CODE_MASK | PCI_BIST_START))
-			pr_cont("failed. (0x%x)\n", bist);
-		else
-			pr_cont("OK.\n");
-	}
+	ret = pci_read_config_byte(dev, PCI_BIST, &bist);
+	if ((ret != PCIBIOS_SUCCESSFUL) || !(bist & PCI_BIST_CAPABLE))
+		return;
+
+	pci_set_power_state(dev, PCI_D0);
+	pr_info("PCI: %s BIST...", pci_name(dev));
+	pci_write_config_byte(dev, PCI_BIST, PCI_BIST_START);
+	timeout = jiffies + HZ * 2;	/* timeout after 2 sec */
+	do {
+		pci_read_config_byte(dev, PCI_BIST, &bist);
+		if (time_after(jiffies, timeout))
+			break;
+	} while (bist & PCI_BIST_START);
+	if (bist & (PCI_BIST_CODE_MASK | PCI_BIST_START))
+		pr_cont("failed. (0x%x)\n", bist);
+	else
+		pr_cont("OK.\n");
 }
 
 #ifdef CONFIG_TOSHIBA_FPCIB0
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 03/14] sh: pci: Do PCI error check on own line
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
  2023-08-24 13:28   ` Ilpo Järvinen
  2023-08-24 13:28 ` [PATCH 02/14] MIPS: TXx9: Do PCI error checks on own line Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-24 13:44   ` John Paul Adrian Glaubitz
  2023-08-24 13:28 ` [PATCH 04/14] atm: iphase: Do PCI error checks " Ilpo Järvinen
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, linux-sh, linux-kernel
  Cc: Ilpo Järvinen

Instead of a if condition with a line split, use the usual error
handling pattern with a separate variable to improve readability.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 arch/sh/drivers/pci/common.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/sh/drivers/pci/common.c b/arch/sh/drivers/pci/common.c
index 2fd2b77e12ce..f59e5b9a6a80 100644
--- a/arch/sh/drivers/pci/common.c
+++ b/arch/sh/drivers/pci/common.c
@@ -53,15 +53,16 @@ int __init pci_is_66mhz_capable(struct pci_channel *hose,
 	unsigned short vid;
 	int cap66 = -1;
 	u16 stat;
+	int ret;
 
 	pr_info("PCI: Checking 66MHz capabilities...\n");
 
 	for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) {
 		if (PCI_FUNC(pci_devfn))
 			continue;
-		if (early_read_config_word(hose, top_bus, current_bus,
-					   pci_devfn, PCI_VENDOR_ID, &vid) !=
-		    PCIBIOS_SUCCESSFUL)
+		ret = early_read_config_word(hose, top_bus, current_bus,
+					     pci_devfn, PCI_VENDOR_ID, &vid);
+		if (ret != PCIBIOS_SUCCESSFUL)
 			continue;
 		if (vid == 0xffff)
 			continue;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 04/14] atm: iphase: Do PCI error checks on own line
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
                   ` (2 preceding siblings ...)
  2023-08-24 13:28 ` [PATCH 03/14] sh: pci: Do PCI error check " Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-24 13:28 ` [PATCH 05/14] hwmon: (via686a) " Ilpo Järvinen
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Chas Williams, linux-atm-general,
	netdev, linux-kernel
  Cc: Ilpo Järvinen

In get_esi() PCI errors are checked inside line-split if conditions (in
addition to the file not following the coding style). To make the code
in get_esi() more readable, fix the coding style and use the usual
error handling pattern with a separate variable.

In addition, initialization of 'error' variable at declaration is not
needed.

No function changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/atm/iphase.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 324148686953..9bba8f280a4d 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -2291,19 +2291,21 @@ static int get_esi(struct atm_dev *dev)
 static int reset_sar(struct atm_dev *dev)  
 {  
 	IADEV *iadev;  
-	int i, error = 1;  
+	int i, error;
 	unsigned int pci[64];  
 	  
 	iadev = INPH_IA_DEV(dev);  
-	for(i=0; i<64; i++)  
-	  if ((error = pci_read_config_dword(iadev->pci,  
-				i*4, &pci[i])) != PCIBIOS_SUCCESSFUL)  
-  	      return error;  
+	for (i = 0; i < 64; i++) {
+		error = pci_read_config_dword(iadev->pci, i * 4, &pci[i]);
+		if (error != PCIBIOS_SUCCESSFUL)
+			return error;
+	}
 	writel(0, iadev->reg+IPHASE5575_EXT_RESET);  
-	for(i=0; i<64; i++)  
-	  if ((error = pci_write_config_dword(iadev->pci,  
-					i*4, pci[i])) != PCIBIOS_SUCCESSFUL)  
-	    return error;  
+	for (i = 0; i < 64; i++) {
+		error = pci_write_config_dword(iadev->pci, i * 4, pci[i]);
+		if (error != PCIBIOS_SUCCESSFUL)
+			return error;
+	}
 	udelay(5);  
 	return 0;  
 }  
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 05/14] hwmon: (via686a) Do PCI error checks on own line
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
                   ` (3 preceding siblings ...)
  2023-08-24 13:28 ` [PATCH 04/14] atm: iphase: Do PCI error checks " Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-25 13:18   ` Guenter Roeck
  2023-08-24 13:28 ` [PATCH 06/14] hwmon: (vt8231) " Ilpo Järvinen
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Jean Delvare, Guenter Roeck,
	linux-hwmon, linux-kernel
  Cc: Ilpo Järvinen

Instead of if conditions with line splits, use the usual error handling
pattern with a separate variable to improve readability.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/hwmon/via686a.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index 37d7374896f6..407933d6e425 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -855,16 +855,17 @@ static int via686a_pci_probe(struct pci_dev *dev,
 				       const struct pci_device_id *id)
 {
 	u16 address, val;
+	int ret;
 
 	if (force_addr) {
 		address = force_addr & ~(VIA686A_EXTENT - 1);
 		dev_warn(&dev->dev, "Forcing ISA address 0x%x\n", address);
-		if (PCIBIOS_SUCCESSFUL !=
-		    pci_write_config_word(dev, VIA686A_BASE_REG, address | 1))
+		ret = pci_write_config_word(dev, VIA686A_BASE_REG, address | 1);
+		if (ret != PCIBIOS_SUCCESSFUL)
 			return -ENODEV;
 	}
-	if (PCIBIOS_SUCCESSFUL !=
-	    pci_read_config_word(dev, VIA686A_BASE_REG, &val))
+	ret = pci_read_config_word(dev, VIA686A_BASE_REG, &val);
+	if (ret != PCIBIOS_SUCCESSFUL)
 		return -ENODEV;
 
 	address = val & ~(VIA686A_EXTENT - 1);
@@ -874,8 +875,8 @@ static int via686a_pci_probe(struct pci_dev *dev,
 		return -ENODEV;
 	}
 
-	if (PCIBIOS_SUCCESSFUL !=
-	    pci_read_config_word(dev, VIA686A_ENABLE_REG, &val))
+	ret = pci_read_config_word(dev, VIA686A_ENABLE_REG, &val);
+	if (ret != PCIBIOS_SUCCESSFUL)
 		return -ENODEV;
 	if (!(val & 0x0001)) {
 		if (!force_addr) {
@@ -886,9 +887,8 @@ static int via686a_pci_probe(struct pci_dev *dev,
 		}
 
 		dev_warn(&dev->dev, "Enabling sensors\n");
-		if (PCIBIOS_SUCCESSFUL !=
-		    pci_write_config_word(dev, VIA686A_ENABLE_REG,
-					  val | 0x0001))
+		ret = pci_write_config_word(dev, VIA686A_ENABLE_REG, val | 0x1);
+		if (ret != PCIBIOS_SUCCESSFUL)
 			return -ENODEV;
 	}
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 06/14] hwmon: (vt8231) Do PCI error checks on own line
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
                   ` (4 preceding siblings ...)
  2023-08-24 13:28 ` [PATCH 05/14] hwmon: (via686a) " Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-25 13:19   ` Guenter Roeck
  2023-08-24 13:28 ` [PATCH 07/14] I2C: ali15x3: " Ilpo Järvinen
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Roger Lucas, Jean Delvare,
	Guenter Roeck, linux-hwmon, linux-kernel
  Cc: Ilpo Järvinen

Instead of if conditions with line splits, use the usual error handling
pattern with a separate variable to improve readability.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/hwmon/vt8231.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index b7c6392ba673..16bc16d33cd1 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -971,13 +971,15 @@ static int vt8231_pci_probe(struct pci_dev *dev,
 				const struct pci_device_id *id)
 {
 	u16 address, val;
+	int ret;
+
 	if (force_addr) {
 		address = force_addr & 0xff00;
 		dev_warn(&dev->dev, "Forcing ISA address 0x%x\n",
 			 address);
 
-		if (PCIBIOS_SUCCESSFUL !=
-		    pci_write_config_word(dev, VT8231_BASE_REG, address | 1))
+		ret = pci_write_config_word(dev, VT8231_BASE_REG, address | 1);
+		if (ret != PCIBIOS_SUCCESSFUL)
 			return -ENODEV;
 	}
 
@@ -997,9 +999,8 @@ static int vt8231_pci_probe(struct pci_dev *dev,
 
 	if (!(val & 0x0001)) {
 		dev_warn(&dev->dev, "enabling sensors\n");
-		if (PCIBIOS_SUCCESSFUL !=
-			pci_write_config_word(dev, VT8231_ENABLE_REG,
-							val | 0x0001))
+		ret = pci_write_config_word(dev, VT8231_ENABLE_REG, val | 0x1);
+		if (ret != PCIBIOS_SUCCESSFUL)
 			return -ENODEV;
 	}
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 07/14] I2C: ali15x3: Do PCI error checks on own line
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
                   ` (5 preceding siblings ...)
  2023-08-24 13:28 ` [PATCH 06/14] hwmon: (vt8231) " Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-24 16:00   ` Andi Shyti
  2023-08-24 13:28 ` [PATCH 08/14] I2C: nforce2: Do PCI error check " Ilpo Järvinen
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Jean Delvare, Andi Shyti, linux-i2c,
	linux-kernel
  Cc: Ilpo Järvinen

Instead of if conditions with line splits, use the usual error handling
pattern with a separate variable to improve readability.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/i2c/busses/i2c-ali15x3.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index cc58feacd082..6fedecef9df3 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -122,6 +122,7 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
 {
 	u16 a;
 	unsigned char temp;
+	int ret;
 
 	/* Check the following things:
 		- SMB I/O address is initialized
@@ -167,12 +168,11 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
 	if(force_addr) {
 		dev_info(&ALI15X3_dev->dev, "forcing ISA address 0x%04X\n",
 			ali15x3_smba);
-		if (PCIBIOS_SUCCESSFUL != pci_write_config_word(ALI15X3_dev,
-								SMBBA,
-								ali15x3_smba))
+		ret = pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba);
+		if (ret != PCIBIOS_SUCCESSFUL)
 			goto error;
-		if (PCIBIOS_SUCCESSFUL != pci_read_config_word(ALI15X3_dev,
-								SMBBA, &a))
+		ret = pci_read_config_word(ALI15X3_dev, SMBBA, &a);
+		if (ret != PCIBIOS_SUCCESSFUL)
 			goto error;
 		if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) {
 			/* make sure it works */
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 08/14] I2C: nforce2: Do PCI error check on own line
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
                   ` (6 preceding siblings ...)
  2023-08-24 13:28 ` [PATCH 07/14] I2C: ali15x3: " Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-24 16:02   ` Andi Shyti
  2023-09-01 11:12   ` Jean Delvare
  2023-08-24 13:28 ` [PATCH 09/14] I2C: sis5595: Do PCI error checks " Ilpo Järvinen
                   ` (5 subsequent siblings)
  13 siblings, 2 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Jean Delvare, Andi Shyti, linux-i2c,
	linux-kernel
  Cc: Ilpo Järvinen

Instead of a if condition with a line split, use the usual error
handling pattern with a separate variable to improve readability.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/i2c/busses/i2c-nforce2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 777278386f58..38d203d93eee 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -327,8 +327,8 @@ static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,
 		/* Older incarnations of the device used non-standard BARs */
 		u16 iobase;
 
-		if (pci_read_config_word(dev, alt_reg, &iobase)
-		    != PCIBIOS_SUCCESSFUL) {
+		error = pci_read_config_word(dev, alt_reg, &iobase);
+		if (error != PCIBIOS_SUCCESSFUL) {
 			dev_err(&dev->dev, "Error reading PCI config for %s\n",
 				name);
 			return -EIO;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 09/14] I2C: sis5595: Do PCI error checks on own line
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
                   ` (7 preceding siblings ...)
  2023-08-24 13:28 ` [PATCH 08/14] I2C: nforce2: Do PCI error check " Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-24 16:04   ` Andi Shyti
  2023-09-01 11:16   ` Jean Delvare
  2023-08-24 13:28 ` [PATCH 10/14] PCI: Do error check on own line to split long if conditions Ilpo Järvinen
                   ` (4 subsequent siblings)
  13 siblings, 2 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Jean Delvare, Andi Shyti, linux-i2c,
	linux-kernel
  Cc: Ilpo Järvinen

Instead of if conditions with line splits, use the usual error handling
pattern with a separate variable to improve readability.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/i2c/busses/i2c-sis5595.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index c793a5c14cda..486f1e9dfb74 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -175,11 +175,11 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)
 
 	if (force_addr) {
 		dev_info(&SIS5595_dev->dev, "forcing ISA address 0x%04X\n", sis5595_base);
-		if (pci_write_config_word(SIS5595_dev, ACPI_BASE, sis5595_base)
-		    != PCIBIOS_SUCCESSFUL)
+		retval = pci_write_config_word(SIS5595_dev, ACPI_BASE, sis5595_base);
+		if (retval != PCIBIOS_SUCCESSFUL)
 			goto error;
-		if (pci_read_config_word(SIS5595_dev, ACPI_BASE, &a)
-		    != PCIBIOS_SUCCESSFUL)
+		retval = pci_read_config_word(SIS5595_dev, ACPI_BASE, &a);
+		if (retval != PCIBIOS_SUCCESSFUL)
 			goto error;
 		if ((a & ~(SIS5595_EXTENT - 1)) != sis5595_base) {
 			/* doesn't work for some chips! */
@@ -188,16 +188,16 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)
 		}
 	}
 
-	if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val)
-	    != PCIBIOS_SUCCESSFUL)
+	retval = pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val);
+	if (retval != PCIBIOS_SUCCESSFUL)
 		goto error;
 	if ((val & 0x80) == 0) {
 		dev_info(&SIS5595_dev->dev, "enabling ACPI\n");
-		if (pci_write_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, val | 0x80)
-		    != PCIBIOS_SUCCESSFUL)
+		retval = pci_write_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, val | 0x80);
+		if (retval != PCIBIOS_SUCCESSFUL)
 			goto error;
-		if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val)
-		    != PCIBIOS_SUCCESSFUL)
+		retval = pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val);
+		if (retval != PCIBIOS_SUCCESSFUL)
 			goto error;
 		if ((val & 0x80) == 0) {
 			/* doesn't work for some chips? */
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 10/14] PCI: Do error check on own line to split long if conditions
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
                   ` (8 preceding siblings ...)
  2023-08-24 13:28 ` [PATCH 09/14] I2C: sis5595: Do PCI error checks " Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-24 13:28   ` Ilpo Järvinen
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Bjorn Helgaas, linux-kernel; +Cc: Ilpo Järvinen

Placing PCI error code check inside if condition usually results in
need to split lines. Combined with additional conditions the if
condition becomes messy.

Convert to the usual error handling pattern with an additional variable
to improve code readability. In addition, reverse the logic in
pci_find_vsec_capability() to get rid of &&.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/pci/pci.c    | 9 ++++++---
 drivers/pci/probe.c  | 6 +++---
 drivers/pci/quirks.c | 6 +++---
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 60230da957e0..e5a58f0fe58d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -732,15 +732,18 @@ u16 pci_find_vsec_capability(struct pci_dev *dev, u16 vendor, int cap)
 {
 	u16 vsec = 0;
 	u32 header;
+	int ret;
 
 	if (vendor != dev->vendor)
 		return 0;
 
 	while ((vsec = pci_find_next_ext_capability(dev, vsec,
 						     PCI_EXT_CAP_ID_VNDR))) {
-		if (pci_read_config_dword(dev, vsec + PCI_VNDR_HEADER,
-					  &header) == PCIBIOS_SUCCESSFUL &&
-		    PCI_VNDR_HEADER_ID(header) == cap)
+		ret = pci_read_config_dword(dev, vsec + PCI_VNDR_HEADER, &header);
+		if (ret != PCIBIOS_SUCCESSFUL)
+			continue;
+
+		if (PCI_VNDR_HEADER_ID(header) == cap)
 			return vsec;
 	}
 
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8bac3ce02609..0717ff62e54f 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1652,15 +1652,15 @@ static void pci_set_removable(struct pci_dev *dev)
 static bool pci_ext_cfg_is_aliased(struct pci_dev *dev)
 {
 #ifdef CONFIG_PCI_QUIRKS
-	int pos;
+	int pos, ret;
 	u32 header, tmp;
 
 	pci_read_config_dword(dev, PCI_VENDOR_ID, &header);
 
 	for (pos = PCI_CFG_SPACE_SIZE;
 	     pos < PCI_CFG_SPACE_EXP_SIZE; pos += PCI_CFG_SPACE_SIZE) {
-		if (pci_read_config_dword(dev, pos, &tmp) != PCIBIOS_SUCCESSFUL
-		    || header != tmp)
+		ret = pci_read_config_dword(dev, pos, &tmp);
+		if ((ret != PCIBIOS_SUCCESSFUL) || (header != tmp))
 			return false;
 	}
 
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 321156ca273d..863b9a64c1fe 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -5381,7 +5381,7 @@ int pci_dev_specific_disable_acs_redir(struct pci_dev *dev)
  */
 static void quirk_intel_qat_vf_cap(struct pci_dev *pdev)
 {
-	int pos, i = 0;
+	int pos, i = 0, ret;
 	u8 next_cap;
 	u16 reg16, *cap;
 	struct pci_cap_saved_state *state;
@@ -5427,8 +5427,8 @@ static void quirk_intel_qat_vf_cap(struct pci_dev *pdev)
 		pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD;
 
 		pdev->cfg_size = PCI_CFG_SPACE_EXP_SIZE;
-		if (pci_read_config_dword(pdev, PCI_CFG_SPACE_SIZE, &status) !=
-		    PCIBIOS_SUCCESSFUL || (status == 0xffffffff))
+		ret = pci_read_config_dword(pdev, PCI_CFG_SPACE_SIZE, &status);
+		if ((ret != PCIBIOS_SUCCESSFUL) || (status == 0xffffffff))
 			pdev->cfg_size = PCI_CFG_SPACE_SIZE;
 
 		if (pci_find_saved_cap(pdev, PCI_CAP_ID_EXP))
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 11/14] PCI: xgene: Do PCI error check on own line
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
@ 2023-08-24 13:28   ` Ilpo Järvinen
  2023-08-24 13:28 ` [PATCH 02/14] MIPS: TXx9: Do PCI error checks on own line Ilpo Järvinen
                     ` (12 subsequent siblings)
  13 siblings, 0 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Toan Le, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
	linux-arm-kernel, linux-kernel
  Cc: Ilpo Järvinen

Instead of a if condition with a line split, use the usual error
handling pattern with a separate variable to improve readability.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/pci/controller/pci-xgene.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c
index 887b4941ff32..b7f338de160b 100644
--- a/drivers/pci/controller/pci-xgene.c
+++ b/drivers/pci/controller/pci-xgene.c
@@ -163,9 +163,10 @@ static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn,
 				    int where, int size, u32 *val)
 {
 	struct xgene_pcie *port = pcie_bus_to_port(bus);
+	int ret;
 
-	if (pci_generic_config_read32(bus, devfn, where & ~0x3, 4, val) !=
-	    PCIBIOS_SUCCESSFUL)
+	ret = pci_generic_config_read32(bus, devfn, where & ~0x3, 4, val);
+	if (ret != PCIBIOS_SUCCESSFUL)
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
 	/*
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 11/14] PCI: xgene: Do PCI error check on own line
@ 2023-08-24 13:28   ` Ilpo Järvinen
  0 siblings, 0 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Toan Le, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
	linux-arm-kernel, linux-kernel
  Cc: Ilpo Järvinen

Instead of a if condition with a line split, use the usual error
handling pattern with a separate variable to improve readability.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/pci/controller/pci-xgene.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c
index 887b4941ff32..b7f338de160b 100644
--- a/drivers/pci/controller/pci-xgene.c
+++ b/drivers/pci/controller/pci-xgene.c
@@ -163,9 +163,10 @@ static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn,
 				    int where, int size, u32 *val)
 {
 	struct xgene_pcie *port = pcie_bus_to_port(bus);
+	int ret;
 
-	if (pci_generic_config_read32(bus, devfn, where & ~0x3, 4, val) !=
-	    PCIBIOS_SUCCESSFUL)
+	ret = pci_generic_config_read32(bus, devfn, where & ~0x3, 4, val);
+	if (ret != PCIBIOS_SUCCESSFUL)
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
 	/*
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 12/14] scsi: ipr: Do PCI error checks on own line
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
                   ` (10 preceding siblings ...)
  2023-08-24 13:28   ` Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-24 13:28 ` [PATCH 13/14] hwmon: (sis5595) " Ilpo Järvinen
  2023-08-24 13:28 ` [PATCH 14/14] perf/x86/uncore: Remove unnecessary ?: operator around pcibios_err_to_errno() call Ilpo Järvinen
  13 siblings, 0 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Brian King, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel
  Cc: Ilpo Järvinen

Instead of if conditions with line splits, use the usual error handling
pattern with a separate variable to improve readability.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/scsi/ipr.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 4e13797b2a4a..81e3d464d1f6 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -761,12 +761,14 @@ static void ipr_mask_and_clear_interrupts(struct ipr_ioa_cfg *ioa_cfg,
 static int ipr_save_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg)
 {
 	int pcix_cmd_reg = pci_find_capability(ioa_cfg->pdev, PCI_CAP_ID_PCIX);
+	int rc;
 
 	if (pcix_cmd_reg == 0)
 		return 0;
 
-	if (pci_read_config_word(ioa_cfg->pdev, pcix_cmd_reg + PCI_X_CMD,
-				 &ioa_cfg->saved_pcix_cmd_reg) != PCIBIOS_SUCCESSFUL) {
+	rc = pci_read_config_word(ioa_cfg->pdev, pcix_cmd_reg + PCI_X_CMD,
+				  &ioa_cfg->saved_pcix_cmd_reg);
+	if (rc != PCIBIOS_SUCCESSFUL) {
 		dev_err(&ioa_cfg->pdev->dev, "Failed to save PCI-X command register\n");
 		return -EIO;
 	}
@@ -785,10 +787,12 @@ static int ipr_save_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg)
 static int ipr_set_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg)
 {
 	int pcix_cmd_reg = pci_find_capability(ioa_cfg->pdev, PCI_CAP_ID_PCIX);
+	int rc;
 
 	if (pcix_cmd_reg) {
-		if (pci_write_config_word(ioa_cfg->pdev, pcix_cmd_reg + PCI_X_CMD,
-					  ioa_cfg->saved_pcix_cmd_reg) != PCIBIOS_SUCCESSFUL) {
+		rc = pci_write_config_word(ioa_cfg->pdev, pcix_cmd_reg + PCI_X_CMD,
+					   ioa_cfg->saved_pcix_cmd_reg);
+		if (rc != PCIBIOS_SUCCESSFUL) {
 			dev_err(&ioa_cfg->pdev->dev, "Failed to setup PCI-X command register\n");
 			return -EIO;
 		}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 13/14] hwmon: (sis5595) Do PCI error checks on own line
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
                   ` (11 preceding siblings ...)
  2023-08-24 13:28 ` [PATCH 12/14] scsi: ipr: Do PCI error checks " Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-25 13:21   ` Guenter Roeck
  2023-08-24 13:28 ` [PATCH 14/14] perf/x86/uncore: Remove unnecessary ?: operator around pcibios_err_to_errno() call Ilpo Järvinen
  13 siblings, 1 reply; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Jean Delvare, Guenter Roeck,
	linux-hwmon, linux-kernel
  Cc: Ilpo Järvinen

Instead of if conditions with line splits, use the usual error handling
pattern with a separate variable to improve readability. Handle error
print with a label instead of trying to chain everything into a single
if condtion.

No functional changes intended.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/hwmon/sis5595.c | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index b0b05fd12221..0a0479501e11 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -798,7 +798,7 @@ static int sis5595_pci_probe(struct pci_dev *dev,
 {
 	u16 address;
 	u8 enable;
-	int *i;
+	int *i, err;
 
 	for (i = blacklist; *i != 0; i++) {
 		struct pci_dev *d;
@@ -818,8 +818,8 @@ static int sis5595_pci_probe(struct pci_dev *dev,
 		pci_write_config_word(dev, SIS5595_BASE_REG, force_addr);
 	}
 
-	if (PCIBIOS_SUCCESSFUL !=
-	    pci_read_config_word(dev, SIS5595_BASE_REG, &address)) {
+	err = pci_read_config_word(dev, SIS5595_BASE_REG, &address);
+	if (err != PCIBIOS_SUCCESSFUL) {
 		dev_err(&dev->dev, "Failed to read ISA address\n");
 		return -ENODEV;
 	}
@@ -836,22 +836,23 @@ static int sis5595_pci_probe(struct pci_dev *dev,
 		return -ENODEV;
 	}
 
-	if (PCIBIOS_SUCCESSFUL !=
-	    pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable)) {
+	err = pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable);
+	if (err != PCIBIOS_SUCCESSFUL) {
 		dev_err(&dev->dev, "Failed to read enable register\n");
 		return -ENODEV;
 	}
 	if (!(enable & 0x80)) {
-		if ((PCIBIOS_SUCCESSFUL !=
-		     pci_write_config_byte(dev, SIS5595_ENABLE_REG,
-					   enable | 0x80))
-		 || (PCIBIOS_SUCCESSFUL !=
-		     pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable))
-		 || (!(enable & 0x80))) {
-			/* doesn't work for some chips! */
-			dev_err(&dev->dev, "Failed to enable HWM device\n");
-			return -ENODEV;
-		}
+		err = pci_write_config_byte(dev, SIS5595_ENABLE_REG, enable | 0x80);
+		if (err != PCIBIOS_SUCCESSFUL)
+			goto enable_fail;
+
+		err = pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable);
+		if (err != PCIBIOS_SUCCESSFUL)
+			goto enable_fail;
+
+		/* doesn't work for some chips! */
+		if (!(enable & 0x80))
+			goto enable_fail;
 	}
 
 	if (platform_driver_register(&sis5595_driver)) {
@@ -871,6 +872,10 @@ static int sis5595_pci_probe(struct pci_dev *dev,
 	 */
 	return -ENODEV;
 
+enable_fail:
+	dev_err(&dev->dev, "Failed to enable HWM device\n");
+	goto exit;
+
 exit_unregister:
 	pci_dev_put(dev);
 	platform_driver_unregister(&sis5595_driver);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 14/14] perf/x86/uncore: Remove unnecessary ?: operator around pcibios_err_to_errno() call
  2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
                   ` (12 preceding siblings ...)
  2023-08-24 13:28 ` [PATCH 13/14] hwmon: (sis5595) " Ilpo Järvinen
@ 2023-08-24 13:28 ` Ilpo Järvinen
  2023-08-24 20:12   ` [tip: perf/core] " tip-bot2 for Ilpo Järvinen
  13 siblings, 1 reply; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-24 13:28 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Ian Rogers, Adrian Hunter,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, linux-perf-users, linux-kernel
  Cc: Ilpo Järvinen

If err == 0, pcibios_err_to_errno(err) returns 0 so the ?: construct
can be removed.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 arch/x86/events/intel/uncore_snbep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index d49e90dc04a4..4d349986f76a 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -1502,7 +1502,7 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
 
 	pci_dev_put(ubox_dev);
 
-	return err ? pcibios_err_to_errno(err) : 0;
+	return pcibios_err_to_errno(err);
 }
 
 int snbep_uncore_pci_init(void)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: [PATCH 03/14] sh: pci: Do PCI error check on own line
  2023-08-24 13:28 ` [PATCH 03/14] sh: pci: Do PCI error check " Ilpo Järvinen
@ 2023-08-24 13:44   ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 29+ messages in thread
From: John Paul Adrian Glaubitz @ 2023-08-24 13:44 UTC (permalink / raw)
  To: Ilpo Järvinen, linux-pci, Bjorn Helgaas, Yoshinori Sato,
	Rich Felker, linux-sh, linux-kernel

On Thu, 2023-08-24 at 16:28 +0300, Ilpo Järvinen wrote:
> Instead of a if condition with a line split, use the usual error
> handling pattern with a separate variable to improve readability.
> 
> No functional changes intended.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>  arch/sh/drivers/pci/common.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/sh/drivers/pci/common.c b/arch/sh/drivers/pci/common.c
> index 2fd2b77e12ce..f59e5b9a6a80 100644
> --- a/arch/sh/drivers/pci/common.c
> +++ b/arch/sh/drivers/pci/common.c
> @@ -53,15 +53,16 @@ int __init pci_is_66mhz_capable(struct pci_channel *hose,
>  	unsigned short vid;
>  	int cap66 = -1;
>  	u16 stat;
> +	int ret;
>  
>  	pr_info("PCI: Checking 66MHz capabilities...\n");
>  
>  	for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) {
>  		if (PCI_FUNC(pci_devfn))
>  			continue;
> -		if (early_read_config_word(hose, top_bus, current_bus,
> -					   pci_devfn, PCI_VENDOR_ID, &vid) !=
> -		    PCIBIOS_SUCCESSFUL)
> +		ret = early_read_config_word(hose, top_bus, current_bus,
> +					     pci_devfn, PCI_VENDOR_ID, &vid);
> +		if (ret != PCIBIOS_SUCCESSFUL)
>  			continue;
>  		if (vid == 0xffff)
>  			continue;

Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 02/14] MIPS: TXx9: Do PCI error checks on own line
  2023-08-24 13:28 ` [PATCH 02/14] MIPS: TXx9: Do PCI error checks on own line Ilpo Järvinen
@ 2023-08-24 15:20   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 29+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-08-24 15:20 UTC (permalink / raw)
  To: Ilpo Järvinen, linux-pci, Bjorn Helgaas,
	Thomas Bogendoerfer, linux-mips, linux-kernel

On 24/8/23 15:28, Ilpo Järvinen wrote:
> Instead of if conditions with line splits, use the usual error handling
> pattern with a separate variable to improve readability.
> 
> The second check can use reverse logic which reduces indentation level.
> 
> No functional changes intended.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>   arch/mips/txx9/generic/pci.c | 43 +++++++++++++++++++-----------------
>   1 file changed, 23 insertions(+), 20 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 07/14] I2C: ali15x3: Do PCI error checks on own line
  2023-08-24 13:28 ` [PATCH 07/14] I2C: ali15x3: " Ilpo Järvinen
@ 2023-08-24 16:00   ` Andi Shyti
  2023-08-25  8:34     ` Ilpo Järvinen
  0 siblings, 1 reply; 29+ messages in thread
From: Andi Shyti @ 2023-08-24 16:00 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: linux-pci, Bjorn Helgaas, Jean Delvare, linux-i2c, linux-kernel

Hi Ilpo,

On Thu, Aug 24, 2023 at 04:28:25PM +0300, Ilpo Järvinen wrote:
> Instead of if conditions with line splits, use the usual error handling
> pattern with a separate variable to improve readability.
> 
> No functional changes intended.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>  drivers/i2c/busses/i2c-ali15x3.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
> index cc58feacd082..6fedecef9df3 100644
> --- a/drivers/i2c/busses/i2c-ali15x3.c
> +++ b/drivers/i2c/busses/i2c-ali15x3.c
> @@ -122,6 +122,7 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
>  {
>  	u16 a;
>  	unsigned char temp;
> +	int ret;

can you please add this ret declaration inside the
"if (force_addr)"?

Andi

>  
>  	/* Check the following things:
>  		- SMB I/O address is initialized
> @@ -167,12 +168,11 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
>  	if(force_addr) {
>  		dev_info(&ALI15X3_dev->dev, "forcing ISA address 0x%04X\n",
>  			ali15x3_smba);
> -		if (PCIBIOS_SUCCESSFUL != pci_write_config_word(ALI15X3_dev,
> -								SMBBA,
> -								ali15x3_smba))
> +		ret = pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba);
> +		if (ret != PCIBIOS_SUCCESSFUL)
>  			goto error;
> -		if (PCIBIOS_SUCCESSFUL != pci_read_config_word(ALI15X3_dev,
> -								SMBBA, &a))
> +		ret = pci_read_config_word(ALI15X3_dev, SMBBA, &a);
> +		if (ret != PCIBIOS_SUCCESSFUL)
>  			goto error;
>  		if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) {
>  			/* make sure it works */
> -- 
> 2.30.2
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 08/14] I2C: nforce2: Do PCI error check on own line
  2023-08-24 13:28 ` [PATCH 08/14] I2C: nforce2: Do PCI error check " Ilpo Järvinen
@ 2023-08-24 16:02   ` Andi Shyti
  2023-09-01 11:12   ` Jean Delvare
  1 sibling, 0 replies; 29+ messages in thread
From: Andi Shyti @ 2023-08-24 16:02 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: linux-pci, Bjorn Helgaas, Jean Delvare, linux-i2c, linux-kernel

Hi Ilpo,

On Thu, Aug 24, 2023 at 04:28:26PM +0300, Ilpo Järvinen wrote:
> Instead of a if condition with a line split, use the usual error
> handling pattern with a separate variable to improve readability.
> 
> No functional changes intended.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

Andi

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 09/14] I2C: sis5595: Do PCI error checks on own line
  2023-08-24 13:28 ` [PATCH 09/14] I2C: sis5595: Do PCI error checks " Ilpo Järvinen
@ 2023-08-24 16:04   ` Andi Shyti
  2023-09-01 11:16   ` Jean Delvare
  1 sibling, 0 replies; 29+ messages in thread
From: Andi Shyti @ 2023-08-24 16:04 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: linux-pci, Bjorn Helgaas, Jean Delvare, linux-i2c, linux-kernel

Hi Ilpo,

On Thu, Aug 24, 2023 at 04:28:27PM +0300, Ilpo Järvinen wrote:
> Instead of if conditions with line splits, use the usual error handling
> pattern with a separate variable to improve readability.
> 
> No functional changes intended.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

Thanks,
Andi

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [tip: perf/core] perf/x86/uncore: Remove unnecessary ?: operator around pcibios_err_to_errno() call
  2023-08-24 13:28 ` [PATCH 14/14] perf/x86/uncore: Remove unnecessary ?: operator around pcibios_err_to_errno() call Ilpo Järvinen
@ 2023-08-24 20:12   ` tip-bot2 for Ilpo Järvinen
  0 siblings, 0 replies; 29+ messages in thread
From: tip-bot2 for Ilpo Järvinen @ 2023-08-24 20:12 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: ilpo.jarvinen, Ingo Molnar, x86, linux-kernel

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     2c65477f14a359db9f1edee5dd8e683d3dae69e2
Gitweb:        https://git.kernel.org/tip/2c65477f14a359db9f1edee5dd8e683d3dae69e2
Author:        Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
AuthorDate:    Thu, 24 Aug 2023 16:28:32 +03:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Thu, 24 Aug 2023 21:25:24 +02:00

perf/x86/uncore: Remove unnecessary ?: operator around pcibios_err_to_errno() call

If err == 0, pcibios_err_to_errno(err) returns 0 so the ?: construct
can be removed.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230824132832.78705-15-ilpo.jarvinen@linux.intel.com
---
 arch/x86/events/intel/uncore_snbep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index d49e90d..4d34998 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -1502,7 +1502,7 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
 
 	pci_dev_put(ubox_dev);
 
-	return err ? pcibios_err_to_errno(err) : 0;
+	return pcibios_err_to_errno(err);
 }
 
 int snbep_uncore_pci_init(void)

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* Re: [PATCH 07/14] I2C: ali15x3: Do PCI error checks on own line
  2023-08-24 16:00   ` Andi Shyti
@ 2023-08-25  8:34     ` Ilpo Järvinen
  0 siblings, 0 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2023-08-25  8:34 UTC (permalink / raw)
  To: Andi Shyti; +Cc: linux-pci, Bjorn Helgaas, Jean Delvare, linux-i2c, LKML

[-- Attachment #1: Type: text/plain, Size: 1766 bytes --]

On Thu, 24 Aug 2023, Andi Shyti wrote:
> On Thu, Aug 24, 2023 at 04:28:25PM +0300, Ilpo Järvinen wrote:
> > Instead of if conditions with line splits, use the usual error handling
> > pattern with a separate variable to improve readability.
> > 
> > No functional changes intended.
> > 
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> > ---
> >  drivers/i2c/busses/i2c-ali15x3.c | 10 +++++-----
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
> > index cc58feacd082..6fedecef9df3 100644
> > --- a/drivers/i2c/busses/i2c-ali15x3.c
> > +++ b/drivers/i2c/busses/i2c-ali15x3.c
> > @@ -122,6 +122,7 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
> >  {
> >  	u16 a;
> >  	unsigned char temp;
> > +	int ret;
> 
> can you please add this ret declaration inside the
> "if (force_addr)"?

Sure.

Thanks for taking a look.

-- 
 i.


> >  	/* Check the following things:
> >  		- SMB I/O address is initialized
> > @@ -167,12 +168,11 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
> >  	if(force_addr) {
> >  		dev_info(&ALI15X3_dev->dev, "forcing ISA address 0x%04X\n",
> >  			ali15x3_smba);
> > -		if (PCIBIOS_SUCCESSFUL != pci_write_config_word(ALI15X3_dev,
> > -								SMBBA,
> > -								ali15x3_smba))
> > +		ret = pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba);
> > +		if (ret != PCIBIOS_SUCCESSFUL)
> >  			goto error;
> > -		if (PCIBIOS_SUCCESSFUL != pci_read_config_word(ALI15X3_dev,
> > -								SMBBA, &a))
> > +		ret = pci_read_config_word(ALI15X3_dev, SMBBA, &a);
> > +		if (ret != PCIBIOS_SUCCESSFUL)
> >  			goto error;
> >  		if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) {
> >  			/* make sure it works */

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 05/14] hwmon: (via686a) Do PCI error checks on own line
  2023-08-24 13:28 ` [PATCH 05/14] hwmon: (via686a) " Ilpo Järvinen
@ 2023-08-25 13:18   ` Guenter Roeck
  0 siblings, 0 replies; 29+ messages in thread
From: Guenter Roeck @ 2023-08-25 13:18 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: linux-pci, Bjorn Helgaas, Jean Delvare, linux-hwmon, linux-kernel

On Thu, Aug 24, 2023 at 04:28:23PM +0300, Ilpo Järvinen wrote:
> Instead of if conditions with line splits, use the usual error handling
> pattern with a separate variable to improve readability.
> 
> No functional changes intended.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 06/14] hwmon: (vt8231) Do PCI error checks on own line
  2023-08-24 13:28 ` [PATCH 06/14] hwmon: (vt8231) " Ilpo Järvinen
@ 2023-08-25 13:19   ` Guenter Roeck
  0 siblings, 0 replies; 29+ messages in thread
From: Guenter Roeck @ 2023-08-25 13:19 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: linux-pci, Bjorn Helgaas, Roger Lucas, Jean Delvare, linux-hwmon,
	linux-kernel

On Thu, Aug 24, 2023 at 04:28:24PM +0300, Ilpo Järvinen wrote:
> Instead of if conditions with line splits, use the usual error handling
> pattern with a separate variable to improve readability.
> 
> No functional changes intended.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 13/14] hwmon: (sis5595) Do PCI error checks on own line
  2023-08-24 13:28 ` [PATCH 13/14] hwmon: (sis5595) " Ilpo Järvinen
@ 2023-08-25 13:21   ` Guenter Roeck
  0 siblings, 0 replies; 29+ messages in thread
From: Guenter Roeck @ 2023-08-25 13:21 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: linux-pci, Bjorn Helgaas, Jean Delvare, linux-hwmon, linux-kernel

On Thu, Aug 24, 2023 at 04:28:31PM +0300, Ilpo Järvinen wrote:
> Instead of if conditions with line splits, use the usual error handling
> pattern with a separate variable to improve readability. Handle error
> print with a label instead of trying to chain everything into a single
> if condtion.

s/condtion/condition/

Applied, after fixing that up.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 08/14] I2C: nforce2: Do PCI error check on own line
  2023-08-24 13:28 ` [PATCH 08/14] I2C: nforce2: Do PCI error check " Ilpo Järvinen
  2023-08-24 16:02   ` Andi Shyti
@ 2023-09-01 11:12   ` Jean Delvare
  1 sibling, 0 replies; 29+ messages in thread
From: Jean Delvare @ 2023-09-01 11:12 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: linux-pci, Bjorn Helgaas, Andi Shyti, linux-i2c, linux-kernel

On Thu, 24 Aug 2023 16:28:26 +0300, Ilpo Järvinen wrote:
> Instead of a if condition with a line split, use the usual error
> handling pattern with a separate variable to improve readability.
> 
> No functional changes intended.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>  drivers/i2c/busses/i2c-nforce2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
> index 777278386f58..38d203d93eee 100644
> --- a/drivers/i2c/busses/i2c-nforce2.c
> +++ b/drivers/i2c/busses/i2c-nforce2.c
> @@ -327,8 +327,8 @@ static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,
>  		/* Older incarnations of the device used non-standard BARs */
>  		u16 iobase;
>  
> -		if (pci_read_config_word(dev, alt_reg, &iobase)
> -		    != PCIBIOS_SUCCESSFUL) {
> +		error = pci_read_config_word(dev, alt_reg, &iobase);
> +		if (error != PCIBIOS_SUCCESSFUL) {
>  			dev_err(&dev->dev, "Error reading PCI config for %s\n",
>  				name);
>  			return -EIO;

Reviewed-by: Jean Delvare <jdelvare@suse.de>

Thanks,
-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 09/14] I2C: sis5595: Do PCI error checks on own line
  2023-08-24 13:28 ` [PATCH 09/14] I2C: sis5595: Do PCI error checks " Ilpo Järvinen
  2023-08-24 16:04   ` Andi Shyti
@ 2023-09-01 11:16   ` Jean Delvare
  1 sibling, 0 replies; 29+ messages in thread
From: Jean Delvare @ 2023-09-01 11:16 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: linux-pci, Bjorn Helgaas, Andi Shyti, linux-i2c, linux-kernel

On Thu, 24 Aug 2023 16:28:27 +0300, Ilpo Järvinen wrote:
> Instead of if conditions with line splits, use the usual error handling
> pattern with a separate variable to improve readability.
> 
> No functional changes intended.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>  drivers/i2c/busses/i2c-sis5595.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
> index c793a5c14cda..486f1e9dfb74 100644
> --- a/drivers/i2c/busses/i2c-sis5595.c
> +++ b/drivers/i2c/busses/i2c-sis5595.c
> @@ -175,11 +175,11 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)
>  
>  	if (force_addr) {
>  		dev_info(&SIS5595_dev->dev, "forcing ISA address 0x%04X\n", sis5595_base);
> -		if (pci_write_config_word(SIS5595_dev, ACPI_BASE, sis5595_base)
> -		    != PCIBIOS_SUCCESSFUL)
> +		retval = pci_write_config_word(SIS5595_dev, ACPI_BASE, sis5595_base);
> +		if (retval != PCIBIOS_SUCCESSFUL)
>  			goto error;
> -		if (pci_read_config_word(SIS5595_dev, ACPI_BASE, &a)
> -		    != PCIBIOS_SUCCESSFUL)
> +		retval = pci_read_config_word(SIS5595_dev, ACPI_BASE, &a);
> +		if (retval != PCIBIOS_SUCCESSFUL)
>  			goto error;
>  		if ((a & ~(SIS5595_EXTENT - 1)) != sis5595_base) {
>  			/* doesn't work for some chips! */
> @@ -188,16 +188,16 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)
>  		}
>  	}
>  
> -	if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val)
> -	    != PCIBIOS_SUCCESSFUL)
> +	retval = pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val);
> +	if (retval != PCIBIOS_SUCCESSFUL)
>  		goto error;
>  	if ((val & 0x80) == 0) {
>  		dev_info(&SIS5595_dev->dev, "enabling ACPI\n");
> -		if (pci_write_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, val | 0x80)
> -		    != PCIBIOS_SUCCESSFUL)
> +		retval = pci_write_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, val | 0x80);
> +		if (retval != PCIBIOS_SUCCESSFUL)
>  			goto error;
> -		if (pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val)
> -		    != PCIBIOS_SUCCESSFUL)
> +		retval = pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val);
> +		if (retval != PCIBIOS_SUCCESSFUL)
>  			goto error;
>  		if ((val & 0x80) == 0) {
>  			/* doesn't work for some chips? */

Reviewed-by: Jean Delvare <jdelvare@suse.de>

Thanks,
-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2023-09-01 11:17 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-24 13:28 [PATCH 00/14] PCI/treewide: Cleanup/streamline PCI error code handling Ilpo Järvinen
2023-08-24 13:28 ` [PATCH 01/14] alpha: Streamline convoluted PCI error handling Ilpo Järvinen
2023-08-24 13:28   ` Ilpo Järvinen
2023-08-24 13:28 ` [PATCH 02/14] MIPS: TXx9: Do PCI error checks on own line Ilpo Järvinen
2023-08-24 15:20   ` Philippe Mathieu-Daudé
2023-08-24 13:28 ` [PATCH 03/14] sh: pci: Do PCI error check " Ilpo Järvinen
2023-08-24 13:44   ` John Paul Adrian Glaubitz
2023-08-24 13:28 ` [PATCH 04/14] atm: iphase: Do PCI error checks " Ilpo Järvinen
2023-08-24 13:28 ` [PATCH 05/14] hwmon: (via686a) " Ilpo Järvinen
2023-08-25 13:18   ` Guenter Roeck
2023-08-24 13:28 ` [PATCH 06/14] hwmon: (vt8231) " Ilpo Järvinen
2023-08-25 13:19   ` Guenter Roeck
2023-08-24 13:28 ` [PATCH 07/14] I2C: ali15x3: " Ilpo Järvinen
2023-08-24 16:00   ` Andi Shyti
2023-08-25  8:34     ` Ilpo Järvinen
2023-08-24 13:28 ` [PATCH 08/14] I2C: nforce2: Do PCI error check " Ilpo Järvinen
2023-08-24 16:02   ` Andi Shyti
2023-09-01 11:12   ` Jean Delvare
2023-08-24 13:28 ` [PATCH 09/14] I2C: sis5595: Do PCI error checks " Ilpo Järvinen
2023-08-24 16:04   ` Andi Shyti
2023-09-01 11:16   ` Jean Delvare
2023-08-24 13:28 ` [PATCH 10/14] PCI: Do error check on own line to split long if conditions Ilpo Järvinen
2023-08-24 13:28 ` [PATCH 11/14] PCI: xgene: Do PCI error check on own line Ilpo Järvinen
2023-08-24 13:28   ` Ilpo Järvinen
2023-08-24 13:28 ` [PATCH 12/14] scsi: ipr: Do PCI error checks " Ilpo Järvinen
2023-08-24 13:28 ` [PATCH 13/14] hwmon: (sis5595) " Ilpo Järvinen
2023-08-25 13:21   ` Guenter Roeck
2023-08-24 13:28 ` [PATCH 14/14] perf/x86/uncore: Remove unnecessary ?: operator around pcibios_err_to_errno() call Ilpo Järvinen
2023-08-24 20:12   ` [tip: perf/core] " tip-bot2 for Ilpo Järvinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.