From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: driver core: platform: provide platform_device_set_of_node_from_dev() Date: Mon, 25 May 2026 20:33:08 +1000 Message-ID: In-Reply-To: <20260521-pdev-fwnode-ref-v1-8-88c324a1b8d2@oss.qualcomm.com> References: <20260521-pdev-fwnode-ref-v1-0-88c324a1b8d2@oss.qualcomm.com> <20260521-pdev-fwnode-ref-v1-8-88c324a1b8d2@oss.qualcomm.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review ```c void platform_device_set_of_node_from_dev(struct platform_device *pdev, const struct device *dev2) { device_set_of_node_from_dev(&pdev->dev, dev2); pdev->dev.fwnode =3D of_fwnode_handle(pdev->dev.of_node); } ``` This wraps `device_set_of_node_from_dev()` (which does `of_node_get`/`of_no= de_put` and sets `of_node_reused =3D true`) and then syncs the fwnode point= er. **Minor concern for post-patch-23**: After patch 23 changes release to `fwn= ode_handle_put()`, this function sets `pdev->dev.fwnode` without calling `f= wnode_handle_put()` on the old value first. If the old fwnode was a non-OF = fwnode that was set via `platform_device_set_fwnode()` (which after patch 2= 3 takes a ref via `fwnode_handle_get()`), this would leak. In practice this= is extremely unlikely since these are called once on freshly allocated pde= vs, but for symmetry with how `platform_device_set_fwnode()` works post-pat= ch-23, consider implementing this as: ```c platform_device_set_of_node(pdev, dev2->of_node); pdev->dev.of_node_reused =3D true; ``` This would route through the helper chain and handle put/get correctly. ### PATCHES 9-22: Driver conversions These are all mechanical conversions from direct `pdev->dev.of_node =3D ...= ` or `pdev->dev.fwnode =3D ...` assignments to using the new helpers. Each = one is straightforward: - **Patch 9** (of/platform): Replaces `device_set_node(&dev->dev, of_fwnode= _handle(of_node_get(np)))` with `platform_device_set_of_node(dev, np)`. Cle= an simplification. - **Patch 10** (powerpc/powermac): Converts the fix from patch 5 to use the= helper. Removes the explicit `of_node_get()` since the helper does it inte= rnally. - **Patch 11** (i2c/pxa-pci): Straightforward conversion. - **Patch 12** (iommu/fsl): This one is interesting =E2=80=94 in addition t= o the conversion, it restructures the error handling: ```c - pdev->dev.of_node =3D of_node_get(np); + platform_device_set_of_node(pdev, np); ... + of_node_put(np); return 0; =20 error_device_add: - of_node_put(pdev->dev.of_node); - pdev->dev.of_node =3D NULL; - platform_device_put(pdev); ``` The error path simplification is correct: `platform_device_put()` =E2=86=92= `platform_device_release()` =E2=86=92 `of_node_put()` handles the pdev's r= eference. The new `of_node_put(np)` on the success path drops the original = search reference. The old error path code (`of_node_put` + NULL assignment)= was being done manually because the caller wanted to avoid the double-put = in `platform_device_release()`, but with the helper taking its own ref, `pl= atform_device_put()` cleanly handles it. **However**, this patch is doing a= subtle bug fix (adding the missing `of_node_put(np)` on the success path) = mixed in with the conversion. It might be worth splitting or at least notin= g in the commit message. - **Patch 13** (net/bcmgenet): Nice use of `__free(device_node)` cleanup at= tribute: ```c + struct device_node *np __free(device_node) =3D bcmgenet_mii_of_find_mdio= (priv); + platform_device_set_of_node(ppdev, np); ``` The `__free(device_node)` ensures the search reference is dropped when `np`= goes out of scope, while the helper takes its own ref. Clean. - **Patches 14-17**: Straightforward conversions of the fixup patches (1-5 = sites) to use helpers. - **Patch 18** (drm/xe/i2c): The DRM-relevant patch. Trivial conversion: ```c - pdev->dev.fwnode =3D fwnode; + platform_device_set_fwnode(pdev, fwnode); ``` Since `fwnode` here is a software node (not an OF node), in the pre-patch-2= 3 world this is a no-op behavioral change (the `else` branch of `platform_d= evice_set_fwnode` just does `pdev->dev.fwnode =3D fwnode`). After patch 23,= it will correctly take a fwnode reference. **No issues for the DRM subsyst= em**. - **Patch 19** (platform/surface): Same pattern as patch 18 with non-OF fwn= ode. - **Patches 20-22**: Convert `device_set_of_node_from_dev()` calls to `plat= form_device_set_of_node_from_dev()`. The key addition is that fwnode is now= synced alongside of_node. --- Generated by Claude Code Patch Reviewer