Re: [PATCH v4 5/5] power: sequencing: Add the Power Sequencing driver for the PCIe M.2 connectors

From: Bartosz Golaszewski

Date: Wed Jan 07 2026 - 04:51:26 EST


On Wed, Jan 7, 2026 at 10:39 AM Manivannan Sadhasivam <mani@xxxxxxxxxx> wrote:
>
> > > +
> > > +static int pwrseq_pcie_m2_probe(struct platform_device *pdev)
> > > +{
> > > + struct device *dev = &pdev->dev;
> > > + struct pwrseq_pcie_m2_ctx *ctx;
> > > + struct pwrseq_config config = {};
> > > + int ret;
> > > +
> > > + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> > > + if (!ctx)
> > > + return -ENOMEM;
> > > +
> > > + ctx->of_node = dev_of_node(dev);
> >
> > Since you're storing the node address for later, I'd suggest using
> > of_node_get() to get a real reference.
> >
>
> If CONFIG_OF_DYNAMIC is not enabled, then of_node_get() will just return the
> passed pointer. I always prefer using dev_of_node() since it has the CONFIG_OF
> and NULL check. Though, the checks won't apply here, I used it for consistency.
>

I think it's just more of a good practice to take a reference to any
resource whenever you store keep it for longer than the duration of
the function even if the actual reference counting is disabled in some
instances. If ever we switch to fwnodes, the circumstances may be
different than static devicetree.

You can also do "ctx->of_node = of_node_get(dev_of_node(dev));", all
the NULL-checks are there.

Bart