linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: linux-pci@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: [PATCH 12/12] PCI: Simplify pcie_capability_clear_and_set_word() control flow
Date: Thu, 24 Aug 2023 14:37:12 -0500	[thread overview]
Message-ID: <20230824193712.542167-13-helgaas@kernel.org> (raw)
In-Reply-To: <20230824193712.542167-1-helgaas@kernel.org>

From: Bjorn Helgaas <bhelgaas@google.com>

Return early for errors in pcie_capability_clear_and_set_word_unlocked()
and pcie_capability_clear_and_set_dword() to simplify the control flow.

No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/pci/access.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 0b2e90d2f04f..6554a2e89d36 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -504,13 +504,12 @@ int pcie_capability_clear_and_set_word_unlocked(struct pci_dev *dev, int pos,
 	u16 val;
 
 	ret = pcie_capability_read_word(dev, pos, &val);
-	if (!ret) {
-		val &= ~clear;
-		val |= set;
-		ret = pcie_capability_write_word(dev, pos, val);
-	}
+	if (ret)
+		return ret;
 
-	return ret;
+	val &= ~clear;
+	val |= set;
+	return pcie_capability_write_word(dev, pos, val);
 }
 EXPORT_SYMBOL(pcie_capability_clear_and_set_word_unlocked);
 
@@ -535,13 +534,12 @@ int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
 	u32 val;
 
 	ret = pcie_capability_read_dword(dev, pos, &val);
-	if (!ret) {
-		val &= ~clear;
-		val |= set;
-		ret = pcie_capability_write_dword(dev, pos, val);
-	}
+	if (ret)
+		return ret;
 
-	return ret;
+	val &= ~clear;
+	val |= set;
+	return pcie_capability_write_dword(dev, pos, val);
 }
 EXPORT_SYMBOL(pcie_capability_clear_and_set_dword);
 
-- 
2.34.1


  parent reply	other threads:[~2023-08-24 19:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24 19:37 [PATCH 00/12] PCI: Miscellaneous cleanups Bjorn Helgaas
2023-08-24 19:37 ` [PATCH 01/12] PCI: mvebu: Remove unused struct mvebu_pcie.busn Bjorn Helgaas
2023-08-24 19:39   ` Pali Rohár
2023-08-24 20:21     ` Bjorn Helgaas
2023-08-24 19:37 ` [PATCH 02/12] PCI: Unexport pcie_port_bus_type Bjorn Helgaas
2023-08-24 19:37 ` [PATCH 03/12] PCI: Remove unnecessary initializations Bjorn Helgaas
2023-08-24 19:37 ` [PATCH 04/12] PCI: Fix printk field formatting Bjorn Helgaas
2023-08-24 19:37 ` [PATCH 05/12] PCI: Use consistent put_user() pointer types Bjorn Helgaas
2023-08-24 19:37 ` [PATCH 06/12] PCI/AER: Simplify AER_RECOVER_RING_SIZE definition Bjorn Helgaas
2023-08-24 19:37 ` [PATCH 07/12] PCI: Simplify pci_pio_to_address() Bjorn Helgaas
2023-08-24 19:37 ` [PATCH 08/12] PCI: Simplify pci_dev_driver() Bjorn Helgaas
2023-08-24 19:37 ` [PATCH 09/12] PCI: Fix pci_bus_resetable(), pci_slot_resetable() name typos Bjorn Helgaas
2023-08-24 19:37 ` [PATCH 10/12] PCI: Fix typos in docs and comments Bjorn Helgaas
2023-08-24 21:20   ` Randy Dunlap
2023-08-24 19:37 ` [PATCH 11/12] PCI: Fix code formatting inconsistencies Bjorn Helgaas
2023-08-24 19:37 ` Bjorn Helgaas [this message]
2023-08-25  8:09   ` [PATCH 12/12] PCI: Simplify pcie_capability_clear_and_set_word() control flow Ilpo Järvinen
2023-08-25  9:01 ` [PATCH 00/12] PCI: Miscellaneous cleanups Ilpo Järvinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230824193712.542167-13-helgaas@kernel.org \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).