Re: [PATCH v2] PCI/pwrctrl: Skip creating pwrctrl device unless CONFIG_PCI_PWRCTRL is enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux