[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aGOHkmG1jnDistgh@wunner.de>
Date: Tue, 1 Jul 2025 09:00:34 +0200
From: Lukas Wunner <lukas@...ner.de>
To: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>
Cc: bhelgaas@...gle.com, linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Jim Quinlan <james.quinlan@...adcom.com>
Subject: Re: [PATCH v2] PCI/pwrctrl: Skip creating pwrctrl device unless
CONFIG_PCI_PWRCTRL is enabled
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
Powered by blists - more mailing lists