rt-thread/components/drivers/core
lhxj 7641ef6885 [drivers] Fix OFW bus conflict and prevent duplicate device creation
Problem:
When enumerating device tree nodes, platform bus and native buses (I2C/SPI)
may create duplicate devices for the same OFW node, causing cross-bus conflicts.
This triggers assertion failure '(dev->bus != new_bus)' in
rt_bus_reload_driver_device() during boot on minimal DM-enabled systems.

Root Cause:
1. Platform bus tries to reload devices that already belong to other buses
   by calling rt_bus_reload_driver_device(dev->bus, dev), which violates
   the API contract (requires dev->bus != new_bus).
2. Native buses (I2C/SPI) do not mark OFW nodes as occupied, so platform
   bus creates duplicate platform devices for I2C/SPI client nodes.

Solution:
1. components/drivers/core/platform_ofw.c: Return RT_EOK when np->dev exists,
   letting the native bus handle device lifecycle instead of cross-bus reload.
2. components/drivers/i2c/dev_i2c_bus.c: Mark i2c_client_np->dev during scan
   to prevent platform bus from duplicating I2C client devices.
3. components/drivers/spi/dev_spi_bus.c: Mark spi_dev_np->dev during scan
   to prevent platform bus from duplicating SPI devices.

Tested on Spacemit K1 RISC-V platform with minimal DM configuration.

Signed-off-by: lhxj <2743257167@qq.com>
2026-01-20 22:05:28 +08:00
..
utest docs(utest):Add standardized documentation for Drivers Core Test 2025-11-16 10:28:46 +08:00
Kconfig [components] [drivers ] [Kconfig] 整理 components/drivers 的 Kconfig (#9054) 2024-06-16 15:43:27 +08:00
SConscript [dm][core] add common machine power interface 2025-12-16 11:35:35 +08:00
bus.c [DM] Replace spinlock static init by RT_DEFINE_SPINLOCK 2025-02-11 14:58:18 +08:00
device.c 修复编译过程中的 DFS_V2报错、FAL警告 2025-01-01 19:02:50 -05:00
dm.c [dm][core] add new API for DM 2025-12-09 21:04:16 +08:00
driver.c fix Compilation error in "driver.c", "completion_up.c", "syslog.c" and "dlmodule.c". (#9093) 2024-06-26 23:25:23 +08:00
mnt.c [dfs] enable procfs and tempfs in default when using smart; fix LWIP_ROUTE warning issue. 2025-05-20 17:27:55 +08:00
numa.c
platform.c [dm][pinctrl] Set pinctrl default auto in platform bus. (#11052) 2025-12-13 16:33:05 +08:00
platform_ofw.c [drivers] Fix OFW bus conflict and prevent duplicate device creation 2026-01-20 22:05:28 +08:00
power.c [dm][core] add common machine power interface 2025-12-16 11:35:35 +08:00
power_domain.c [Feature] Support simple power domain API (#9005) 2024-05-30 15:30:40 +08:00