RE: [PATCH v2 2/4] remoteproc: imx_rproc: Populate devices under "rpmsg" subnode

From: Shenwei Wang

Date: Wed Oct 01 2025 - 16:10:02 EST


Hi Peng,

> -----Original Message-----
> From: Peng Fan (OSS) <peng.fan@xxxxxxxxxxx>
> Sent: Sunday, September 28, 2025 3:48 AM
> To: Shenwei Wang <shenwei.wang@xxxxxxx>
> Cc: Bjorn Andersson <andersson@xxxxxxxxxx>; Mathieu Poirier
> <mathieu.poirier@xxxxxxxxxx>; Rob Herring <robh@xxxxxxxxxx>; Krzysztof
> Kozlowski <krzk+dt@xxxxxxxxxx>; Conor Dooley <conor+dt@xxxxxxxxxx>; Shawn
> Guo <shawnguo@xxxxxxxxxx>; Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>; Linus
> Walleij <linus.walleij@xxxxxxxxxx>; Bartosz Golaszewski <brgl@xxxxxxxx>;
> Pengutronix Kernel Team <kernel@xxxxxxxxxxxxxx>; Fabio Estevam
> <festevam@xxxxxxxxx>; Peng Fan <peng.fan@xxxxxxx>; linux-
> remoteproc@xxxxxxxxxxxxxxx; devicetree@xxxxxxxxxxxxxxx; imx@xxxxxxxxxxxxxxx;
> >+
> >+ drvdata->rpdev = rpdev;
> >+ auxdata[0].compatible = channel_device_map[i][1];
> >+ auxdata[0].platform_data = drvdata;
> >+ dev_set_drvdata(dev, drvdata);
> >+
> >+ of_platform_populate(drvdata->channel_node, NULL, auxdata, dev);
> >+ of_node_put(drvdata->channel_node);
>
> of_platform_populate will decrement the reference to drvdata->channel_node
> before it return. I not see other places increment the reference to channel_node,
> of_node_put here could be removed.
>

The of_node_put is to balance the reference counter which is increased by of_get_child_by_name in imx_of_rpmsg_node_init function.

+static int imx_of_rpmsg_node_init(struct platform_device *pdev)
+{
...
+ for (i = 0; i < count; i++) {
+ ret = -ENOMEM;
+ channel = of_get_child_by_name(np, channel_device_map[i][0]);


Thanks,
Shenwei

> >+
> >+ return 0;
> >+}
> >+
> >+static int imx_of_rpmsg_node_init(struct platform_device *pdev) {
> >+ struct device_node *np __free(device_node), *channel;
> >+ struct imx_rpmsg_driver_data *driver_data;
> >+ struct imx_rpmsg_driver *rp_driver;
> >+ struct rpmsg_device_id *rpdev_id;
> >+ int i, ret;
> >+
> >+ int count = ARRAY_SIZE(channel_device_map);
> >+ struct device *dev = &pdev->dev;
> >+