[PATCH v2 0/3] driver core: remove software node from platform devices on device release

Bartosz Golaszewski
2026-04-23T12:12:20Z

This fixes an issue in platform device code where, if we specify a
software node for a platform device using struct platform_device_info,
it will not be removed on device .release().

The second patch adds a new kunit helper which is used in patch 3/3 that
adds a test-case that can be used to reproduce the problem and prove that
the fix works as well as another making sure a corner case of using a
software node as the primary firmware node works too.

First patch should go into v7.1 while patches 2/3 and 3/3 can be queued
for v7.2.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Change the order between removing the software node and dropping the
reference to the device's OF node
- Address a situation where a software node is used as the primary
firmware node
- Add a patch adding a new kunit helper
- Add another test case
- Link to v1: https://patch.msgid.link/20260410-swnode-remove-on-dev-unreg-v1-0-cd7d305f3db2@oss.qualcomm.com

---
Bartosz Golaszewski (3):
driver core: platform: remove software node on release()
kunit: provide kunit_software_node_register()
driver core: platform: tests: add test cases for correct swnode removal

drivers/base/platform.c | 11 ++++
drivers/base/test/platform-device-test.c | 106 +++++++++++++++++++++++++++++++
include/kunit/fwnode.h | 19 ++++++
lib/kunit/Makefile | 3 +-
lib/kunit/fwnode.c | 52 +++++++++++++++
5 files changed, 190 insertions(+), 1 deletion(-)
---
base-commit: 70c8a7ec6715b5fb14e501731b5b9210a16684f7
change-id: 20260410-swnode-remove-on-dev-unreg-42bfc4b23ba8

Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>