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

From: Manivannan Sadhasivam

Date: Wed Jan 07 2026 - 07:32:05 EST


On Wed, Jan 07, 2026 at 10:51:11AM +0100, Bartosz Golaszewski wrote:
> 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.

Good practice you inherited from writing Rust code :)

> 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.
>

This may not be needed. I can use of_node_get() here, but the APIs are just
fragile such that neither dev_of_node() nor of_node_get() increments the
refcount always.

- Mani

--
மணிவண்ணன் சதாசிவம்