Re: [PATCH] PCI: Check for the existence of 'dev.of_node' before calling of_platform_populate()

From: Bartosz Golaszewski
Date: Tue Jul 16 2024 - 14:49:26 EST


On Tue, Jul 16, 2024 at 8:02 PM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Tue, 16 Jul 2024 at 01:04, Manivannan Sadhasivam
> <manivannan.sadhasivam@xxxxxxxxxx> wrote:
> >
> > - if (IS_ENABLED(CONFIG_OF) && pci_is_bridge(dev)) {
> > + if (IS_ENABLED(CONFIG_OF) && dev_of_node(&dev->dev) && pci_is_bridge(dev)) {
> > retval = of_platform_populate(dev->dev.of_node, NULL, NULL,

While at it: you could replace the dev.of_node here with dev_of_node()
too. I seem to have missed this helper.

Bartosz

> > &dev->dev);
>
> I think you should just drop the IS_ENABLED(CONFIG_OF) check entirely.
>
> afaik, dev_of_node() already returns NULL if CONFIG_OF isn't set.
>
> So the bug was literally that you based the decision on something
> pointless that shouldn't be there at all.
>
> Linus