linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Jim Quinlan <james.quinlan@broadcom.com>
Subject: Re: [PATCH v2] PCI/pwrctrl: Skip creating pwrctrl device unless CONFIG_PCI_PWRCTRL is enabled
Date: Tue, 1 Jul 2025 09:00:34 +0200	[thread overview]
Message-ID: <aGOHkmG1jnDistgh@wunner.de> (raw)
In-Reply-To: <20250701064731.52901-1-manivannan.sadhasivam@linaro.org>

On Tue, Jul 01, 2025 at 12:17:31PM +0530, Manivannan Sadhasivam wrote:
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2508,6 +2508,7 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
>  }
>  EXPORT_SYMBOL(pci_bus_read_dev_vendor_id);
>  
> +#if IS_ENABLED(CONFIG_PCI_PWRCTRL)
>  static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn)
>  {

Hm, why does pci_pwrctrl_create_device() return a pointer, even though the
sole caller doesn't make any use of it?  Why not return a negative errno?

Then you could just do this:

	if (!IS_ENABLED(CONFIG_PCI_PWRCTRL))
		return 0;

... at the top of the function and you don't need the extra LoC for the
empty inline stub.

Another option is to set "struct pci_dev *pdev = NULL;" and #ifdef the body
of the function, save for the "return pdev;" at the bottom.

Of course you could also do:

	if (!IS_ENABLED(CONFIG_PCI_PWRCTRL))
		return NULL;

... at the top of the function, but again, the caller doesn't make any
use of the returned pointer.

Thanks,

Lukas

  reply	other threads:[~2025-07-01  7:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-01  6:47 [PATCH v2] PCI/pwrctrl: Skip creating pwrctrl device unless CONFIG_PCI_PWRCTRL is enabled Manivannan Sadhasivam
2025-07-01  7:00 ` Lukas Wunner [this message]
2025-07-01 11:57   ` Manivannan Sadhasivam
2025-07-01 12:49     ` Lukas Wunner
2025-07-01 20:35 ` Bjorn Helgaas
2025-07-02  6:47   ` Manivannan Sadhasivam
2025-07-02 17:53     ` Bjorn Helgaas
2025-07-02 18:30       ` Manivannan Sadhasivam
2025-07-02 20:04         ` Bjorn Helgaas
2025-07-01 21:01 ` Bjorn Helgaas
2025-07-02  7:20   ` Manivannan Sadhasivam
2025-07-22 18:58 ` Bjorn Helgaas
2025-07-22 19:15   ` Bjorn Helgaas

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=aGOHkmG1jnDistgh@wunner.de \
    --to=lukas@wunner.de \
    --cc=bhelgaas@google.com \
    --cc=james.quinlan@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=stable@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).