linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: linux-pci@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [PATCH 12/12] PCI: Simplify pcie_capability_clear_and_set_word() control flow
Date: Fri, 25 Aug 2023 11:09:14 +0300 (EEST)	[thread overview]
Message-ID: <8f5f10be-333a-9d88-7acf-1cbb2b11680@linux.intel.com> (raw)
In-Reply-To: <20230824193712.542167-13-helgaas@kernel.org>

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

On Thu, 24 Aug 2023, Bjorn Helgaas wrote:

> 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>

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

> ---
>  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);
>  
> 

  reply	other threads:[~2023-08-25  8:10 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 ` [PATCH 12/12] PCI: Simplify pcie_capability_clear_and_set_word() control flow Bjorn Helgaas
2023-08-25  8:09   ` Ilpo Järvinen [this message]
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=8f5f10be-333a-9d88-7acf-1cbb2b11680@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --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).