All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] PCI: Cleanup accessor macros formatting
Date: Mon, 29 Apr 2024 10:49:01 -0500	[thread overview]
Message-ID: <20240429154901.GA682729@bhelgaas> (raw)
In-Reply-To: <20240429094707.2529-2-ilpo.jarvinen@linux.intel.com>

On Mon, Apr 29, 2024 at 12:47:07PM +0300, Ilpo Järvinen wrote:
> Cleanup formatting of PCI accessor macros:
> 
> - Put return statements on own line
> - Add a few empty lines for better readability
> - Align macro continuation backslashes
> - Correct function call argument indentation level
> - Reorder variable declarations to reverse xmas tree
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Both applied to pci/misc for v6.10, thanks!

I tweaked the PCI_USER_READ_CONFIG variable declaration from the
existing reverse xmas tree to order of use because xmas tree orders
look nice but carry no useful information.  In the cases you updated,
reverse xmas tree and order of use happen to be the same.

Also dropped "ret" initialization in PCI_USER_READ_CONFIG and
PCI_USER_WRITE_CONFIG since it's always set before being used anyway.

> ---
>  drivers/pci/access.c | 36 +++++++++++++++++++++++++-----------
>  1 file changed, 25 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/pci/access.c b/drivers/pci/access.c
> index 6449056b57dd..4962a841fa35 100644
> --- a/drivers/pci/access.c
> +++ b/drivers/pci/access.c
> @@ -36,10 +36,13 @@ DEFINE_RAW_SPINLOCK(pci_lock);
>  int noinline pci_bus_read_config_##size \
>  	(struct pci_bus *bus, unsigned int devfn, int pos, type *value)	\
>  {									\
> -	int res;							\
>  	unsigned long flags;						\
>  	u32 data = 0;							\
> -	if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER;	\
> +	int res;							\
> +									\
> +	if (PCI_##size##_BAD)						\
> +		return PCIBIOS_BAD_REGISTER_NUMBER;			\
> +									\
>  	pci_lock_config(flags);						\
>  	res = bus->ops->read(bus, devfn, pos, len, &data);		\
>  	if (res)							\
> @@ -47,6 +50,7 @@ int noinline pci_bus_read_config_##size \
>  	else								\
>  		*value = (type)data;					\
>  	pci_unlock_config(flags);					\
> +									\
>  	return res;							\
>  }
>  
> @@ -54,12 +58,16 @@ int noinline pci_bus_read_config_##size \
>  int noinline pci_bus_write_config_##size \
>  	(struct pci_bus *bus, unsigned int devfn, int pos, type value)	\
>  {									\
> -	int res;							\
>  	unsigned long flags;						\
> -	if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER;	\
> +	int res;							\
> +									\
> +	if (PCI_##size##_BAD)						\
> +		return PCIBIOS_BAD_REGISTER_NUMBER;			\
> +									\
>  	pci_lock_config(flags);						\
>  	res = bus->ops->write(bus, devfn, pos, len, value);		\
>  	pci_unlock_config(flags);					\
> +									\
>  	return res;							\
>  }
>  
> @@ -216,24 +224,27 @@ static noinline void pci_wait_cfg(struct pci_dev *dev)
>  }
>  
>  /* Returns 0 on success, negative values indicate error. */
> -#define PCI_USER_READ_CONFIG(size, type)					\
> +#define PCI_USER_READ_CONFIG(size, type)				\
>  int pci_user_read_config_##size						\
>  	(struct pci_dev *dev, int pos, type *val)			\
>  {									\
>  	int ret = PCIBIOS_SUCCESSFUL;					\
>  	u32 data = -1;							\
> +									\
>  	if (PCI_##size##_BAD)						\
>  		return -EINVAL;						\
> -	raw_spin_lock_irq(&pci_lock);				\
> +									\
> +	raw_spin_lock_irq(&pci_lock);					\
>  	if (unlikely(dev->block_cfg_access))				\
>  		pci_wait_cfg(dev);					\
>  	ret = dev->bus->ops->read(dev->bus, dev->devfn,			\
> -					pos, sizeof(type), &data);	\
> -	raw_spin_unlock_irq(&pci_lock);				\
> +				  pos, sizeof(type), &data);		\
> +	raw_spin_unlock_irq(&pci_lock);					\
>  	if (ret)							\
>  		PCI_SET_ERROR_RESPONSE(val);				\
>  	else								\
>  		*val = (type)data;					\
> +									\
>  	return pcibios_err_to_errno(ret);				\
>  }									\
>  EXPORT_SYMBOL_GPL(pci_user_read_config_##size);
> @@ -244,14 +255,17 @@ int pci_user_write_config_##size					\
>  	(struct pci_dev *dev, int pos, type val)			\
>  {									\
>  	int ret = PCIBIOS_SUCCESSFUL;					\
> +									\
>  	if (PCI_##size##_BAD)						\
>  		return -EINVAL;						\
> -	raw_spin_lock_irq(&pci_lock);				\
> +									\
> +	raw_spin_lock_irq(&pci_lock);					\
>  	if (unlikely(dev->block_cfg_access))				\
>  		pci_wait_cfg(dev);					\
>  	ret = dev->bus->ops->write(dev->bus, dev->devfn,		\
> -					pos, sizeof(type), val);	\
> -	raw_spin_unlock_irq(&pci_lock);				\
> +				   pos, sizeof(type), val);		\
> +	raw_spin_unlock_irq(&pci_lock);					\
> +									\
>  	return pcibios_err_to_errno(ret);				\
>  }									\
>  EXPORT_SYMBOL_GPL(pci_user_write_config_##size);
> -- 
> 2.39.2
> 

      reply	other threads:[~2024-04-29 15:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29  9:47 [PATCH 1/2] PCI/ERR: Cleanup misleading indentation inside if conditions Ilpo Järvinen
2024-04-29  9:47 ` [PATCH 2/2] PCI: Cleanup accessor macros formatting Ilpo Järvinen
2024-04-29 15:49   ` Bjorn Helgaas [this message]

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=20240429154901.GA682729@bhelgaas \
    --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 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.