From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.83.4 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796240846; b=xfeQbrjDIqgMF271Ti0Q2vu/S/bqyPMsPnv/KjvpGrxeEwKICOmuybf4XMqfPjAb8c2V nVIBIE+LlLKCV5PVZIsVj1yay2UV/t1CcfeQNzIkwu3grBs1sJ0/YX8sFodCc9epKHpKA VdbXXOw5CMDsSnbl+Lcxz+AATkY9Ov6CWGG22KVAZGj2BrAgo3kqQUkBSciGZ5pP49FMp 9BmoAMhlyo+O02rpHbCSsnlhoe6lAxnK8RGafEGj4UsInDgCq+BiSK+m4Z8r6qH+sSzDP uzM6DKKlomfNi6hI5XbpiJdZZQQbt9D8mupiNOOgArSQL5ug0fn9478pPw22oyIqrXg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796240846; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:Content-Type:Content-Disposition: In-Reply-To:X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=desXjGkZPa2KNjX8hZyKccd/BXmHci+YK+Eu0uo7S4c=; b=GA2TmEk/SUWpgFSAv5W4WEKPbW28tA3LNSjH6I61m1QytcKxcs/toKd2K/HR+ZXbpL43 D8di88ZT5IaAvCPBMWGLJ+lqMkltSySXOg+BWXgqsIdPv116ICVsvHpdqkRoxJ7YOz3ng PQ9k/Te969lOjHPCvCixSbyTn3fMNHlZJqyWqKyQQ85edTNeuFdjLeN3ILZVUmw7tYoMT nUF4xYVMSPi2h01QvZBop0ttMIHax468q9Q1CI2IneROA2NqK3BTrAS+6e8U2c6T/iQPE ZoaghRHmlwR5sH7hv7Y5OqKgcQSiHEdf2lNTjNmVQ43yOp+xxMayCoOpFTe6l17rjug== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-NXP1-onmicrosoft-com header.b=jixHviMU; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.83.4 Received: from GVXPR05CU001.outbound.protection.outlook.com (mail-swedencentralazon11013004.outbound.protection.outlook.com [52.101.83.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3518A606A32C; Wed, 2 Dec 2026 19:47:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3518A606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-NXP1-onmicrosoft-com header.b=jixHviMU ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XAwYnVWdFIHDJeg+CVjjGqVWCktt94iDLbcfJYzsl8WfTi8FEqPFuRGXcLnemRrh7ZZ0b9sgkYMHJAAu8qfDLXRDDXNljoH0eSyYWOGaX7PK5fuiOVdp5gUgpILjJZivggksS+Qi1f93W7VA5dQiK0PffozqopHwIe0H3/OhoGbtPBfVnJsWX5uBcAov11KQmZrCSuHld2WmCgGnK5tpyNVMCd1wc6RJLHZIgu0euTLQNtnxqdn+JsFXa8zC3Nnrgw7VOovRR/rib9Q5L1mbkQfuynLT6gGxtcmW8Ut48NXL2EVuR4FV41zL/RlGrGKk03SMn1W4/+VU8UQrWzZ3HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=desXjGkZPa2KNjX8hZyKccd/BXmHci+YK+Eu0uo7S4c=; b=IDfzfzn/slWuybZJeiqHrtPS1CQvjBhMd0RiDV7BXfNxoDhIfpd93U1iHS9OsdjDImqqQ/EsWOgA0eid+i85fkUav7T4L6+qpt5a1/jINr8FYn/YURhmjHgNvtxatPy4BI9q5DcktoyRzRuwQbExFZuZehwx4X/aZd12xLEQT/RlRLQzvDbbP6V9+e4cz8vJyOyqrGJLElB+SQ7q9Nv39P8QQxVAEMUmFNDWwYRK+xPsjlYgcO5VGSW/92CySUnKJ36MF1eIrZGF526PyXmjxH+dGZFiPq/v9AxGatuTqvLaleaHTBAPjhK7BbzT9UZiqH65Cc49EEidgmKoe7Z90Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=desXjGkZPa2KNjX8hZyKccd/BXmHci+YK+Eu0uo7S4c=; b=jixHviMUFSIjvYfnZrMD8Z5oqy0wUMvN60StMoCEguzUcpxmZgVAAu/geZroeNJRGl+AFgPKhoa1gB8jC2imbm1Gsn4J+Cay1P2pMaiWykq0TAcwJIuGP8F7L8duxNmcY5jermwHjdeR2xYZNDOk1vSrzMyPMeHybPUuS/rSDxR/CPr86PHPrLSTC0n4GXOx3MPPEwL6pW0376hJKMF21MCEX/YXifSfVkpaVskDoqlsMyR4CXNNu1RF8tL9tMwRJBQ8P0rQmJxshMtR4l2vY9yBxVk1Aq9drACLKC6w4fKJkl/onzejjsRjGqesxUSR3SMBBEkasVQj7r4/5TkRnQ== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from MI3PR04MB12438.eurprd04.prod.outlook.com (2603:10a6:290:76::14) by AM7PR04MB6824.eurprd04.prod.outlook.com (2603:10a6:20b:10e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 19:47:19 +0000 Received: from MI3PR04MB12438.eurprd04.prod.outlook.com ([fe80::c715:c32:8bb1:b70b]) by MI3PR04MB12438.eurprd04.prod.outlook.com ([fe80::c715:c32:8bb1:b70b%4]) with mapi id 15.21.0688.009; Wed, 2 Dec 2026 19:47:19 +0000 Date: Wed, 2 Dec 2026 14:47:14 -0500 From: Frank Li To: Billy Tsai Cc: Alexandre Belloni , Frank Li , Peter Yin , linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v3] i3c: master: mark OF bus child nodes OF_POPULATED to avoid legacy I2C rescan Message-ID: References: <20261202-i3c-master-of-populated-v3-1-68d504643bdf@aspeedtech.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202-i3c-master-of-populated-v3-1-68d504643bdf@aspeedtech.com> X-ClientProxiedBy: CPAP307CA0007.DNKP307.PROD.OUTLOOK.COM (2603:10a6:380:3::12) To MI3PR04MB12438.eurprd04.prod.outlook.com (2603:10a6:290:76::14) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MI3PR04MB12438:EE_|AM7PR04MB6824:EE_ X-MS-Office365-Filtering-Correlation-Id: 842c5399-91f3-4993-8991-08df50ad136c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|23010399003|19092799006|261028144727099003|261022105027099003|10067099003|11063799006|56012099006|261021123027099003|261021121427099003|261009223027099003|261009221227099003|261022113327099003|261102123227099003|261026140227099003|261026121527099003|261022075727099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: +eWOWIsGD2jvkpDf4wPFxUollENP3IwcwTEyexMEcuIx0cDe4rrGUKGvqQ4q6hWaZpCPSAkr56hf12qQ3Nu/Fn+SrdKQd9I2tDflQCeSPUTPAJD6vCOYXa35pfj4C4HnTbDpw26eQ+rqRVBeWabcjxtJja4b0O5+d6z0MmGLKCOIjWf2BtkhdSPgSYIFC3uEjBPYX9l8IETMx0kPeOKZtQZ5xcUakXlRlMKQU9ZwbMNnU1i2PmFLSAgq5ptjXgsIP4pcjRVIQtzjsjP4Zb28XBEjJPUHCgMgVi8fO88owcbXDAJOZuwwGCNJqEiAXbF3hTCab4hky6DF27/xGnwagbhqI8EG8pX5oru6SD/YNECd2U5dLehDVV0B39PV6l+WZ6jSc+OTokrPY6hVp0xR25NAr3F9q3GlGJH27M5ROHqwJrfMUxiBB3mpX/kG+E85gwz/mAols5hMTQjFWv8+apjo0ZN8hXHSdUNJt3Qvdz/MIFPN/Nk1qkWfwHObeL6am+JLNWqaE9PPxbYhdygQ/LAjEzgKbvoI/aZ9NwgobiHAGIncT5f91UB7zkEzVVplZIZF8s4LZc+KYgQ2BybwFCpgHlft/0pOvv8qFpxmJnKqeiaAqKFSaueuxoTzvPC8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MI3PR04MB12438.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(23010399003)(19092799006)(261028144727099003)(261022105027099003)(10067099003)(11063799006)(56012099006)(261021123027099003)(261021121427099003)(261009223027099003)(261009221227099003)(261022113327099003)(261102123227099003)(261026140227099003)(261026121527099003)(261022075727099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?YDjO4T+B89KDX7fX+pmQ6xcILUGKulIfGl52KzKPLaN3TObkf1S9GNrb26pK?= =?us-ascii?Q?3dmSlTUYvHBZwsspaJEuofmR6NRqF2Q9tlnkTh9AwFSoI8KYa/LRyvlW7ULO?= =?us-ascii?Q?OdHB8UdYz5lnR8PZ9ndFOh6YSk71T6yyuVN4xAmSGxFMX7ntFQIdvB6Wt1wj?= =?us-ascii?Q?jY1X7R39LEOTpH+Vuovst2AfELjrW+9g4BOreLoGL/N75B3RXRFE0hFv18kU?= =?us-ascii?Q?XrhCEwTjBJig6H2sbMK7Rppgo4fYAP9rziSzVeT2HJergXegLIlkD+hISoHb?= =?us-ascii?Q?5hUwqGl3b7VsNdovcLdL8tOOW2Fw84nMXruAYWccfhhxwKRuSIAsHltw4nq9?= =?us-ascii?Q?LeqZtrxqasskvXXZWgI6VkUJl5FWD+dIcjtcs4XK5XxY3kuDA8MBeaxGiA+S?= =?us-ascii?Q?NrE1CpvbtFJgVMmxsp8YnHusGn/bP2nCc45wkN5tX6/jyLAItX35nfTtJfra?= =?us-ascii?Q?1Uy9rKJVS4c64cMOnKw3tDfK0VeHkSmZBeVIk0Qk2KgCZ3EgkTF4AZEvojN1?= =?us-ascii?Q?eA6EY3UjnDOsUrFkMd+4QxBU8i8MUrn053WI+1ZGFNei1uHRpXVb+A5JI3F3?= =?us-ascii?Q?5b9Ot/ajh6/+/w21PWIUPtAjrB1KL0U1a1F2Wp8pvtP/AfDlydm7emWB3G/f?= =?us-ascii?Q?+c7gFx6PyHjhKPxIo7VQ27xwyc+yJV+s+j/JRKfMCeTl4AN24uQlCn7ql/3f?= =?us-ascii?Q?VsxQxSp516ah4qLmZ/5Uux4aIgO77vtVJGK2Yv3UzCXBXmPKxXq9l7u4/evZ?= =?us-ascii?Q?KTlvPYm52ClWqxCGyT+yFbTyEhvCrfEijNrz2IYP8B9MiTv4PTsM4xQNKGgC?= =?us-ascii?Q?bzqkaeGCvqISUJ2wiHPOaLnn1z47lCm8O/N33rk6YoFQAkSHzbQFjwnfCa1x?= =?us-ascii?Q?v/7xgBpoC/mBkE0as6Eye0Wcoixy5xyOYZNp5JIfuEjUit6diKHMIbDQI0kt?= =?us-ascii?Q?sgejqlPfaqZV2lmc0UF9dGk70GeVsNY4Bbh8fXnvZaKHh+brmkBjrah/f+GM?= =?us-ascii?Q?/tSMGnX/2azrPg88XTwmtCvPs+78wwm9crk3MpEN1u4M5I0RazuS2EBxS+Ns?= =?us-ascii?Q?9/Es5F3Mz3cfbFyQjLfetfFs3HqM4QysKSJSXnfGiHB9cAs4jFOIizMGtXCS?= =?us-ascii?Q?LSS9gypz15wVxX+SzXyfNid8h/KTSXWepCa5xhZbKTZbyy/ORB3h9WZOZuyu?= =?us-ascii?Q?13sQ/b1+Ta8rRs65NVnbMUN5HPp6eS0ssEhHOyimrAe577Ml+RW6v5iM5KbG?= =?us-ascii?Q?yWx7lPbmAu5c1IDLgZzWkFRBh3qzk8HoovTw1uYOdNByxnUoPLf7akP4AEhC?= =?us-ascii?Q?PiRgjRC0gVXclln403Mh8jm1h+YbryhhUjx+8eFHTo70VeBHWqfdAxBgs/WK?= =?us-ascii?Q?5U8BY/eVnypGAyicYjQeUO43JTUxfQwNGUkEpIoVfD63ljq4rjYazfLewcgH?= =?us-ascii?Q?TflDdXzyjQBrpUiTB1+EryKG6w9KSqdbiNnXiWGGlKR8WdJGkW58pWb6FZS5?= =?us-ascii?Q?e3dC4DvuO9k2TQ2zuYB3wE4jGTwUK7Vhe7X5KoNSgkDXzoJoC/FP0ZZITuEW?= =?us-ascii?Q?GhjOceZdINfhXsGvJNxCDt6rEDu8OQ91JHwya8TM/f52jUeoJu4sWvf88Rte?= =?us-ascii?Q?U+vL7tiAEZSyTuGwZicFRwYBWKIT2ZT3jQ/mwvwVZhqkJWQnYg3Ab8Ted6Hx?= =?us-ascii?Q?ogKHqKeijq+KjCRZadEF3YQUFu3lpiyk8vceTGFI54fU5o2+RWHy0Lo7mkMD?= =?us-ascii?Q?wv6Jm75wEYK+apbgL29z/ZM9peF+McMUM7NEdneMxfPIOmCyG+zu?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 842c5399-91f3-4993-8991-08df50ad136c X-MS-Exchange-CrossTenant-AuthSource: MI3PR04MB12438.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 19:47:19.6491 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +E4d0sP50+HUW2tHVoBxZCsficC7ixHbFJsgXCdqUrAz3Z4nIYTo7cUud7rOM/3pCFk1vjCYLjg781Sd8Rn9lKKYB5KyoELtndqLpZo66qjq4bst89Vy1A4SXXNHPD/8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6824 On Wed, Dec 02, 2026 at 04:23:53PM +0800, Billy Tsai wrote: > Commit f26ecaa0f0ab ("i3c: master: dw-i3c: Fix missing of_node for > virtual I2C adapter") made the DesignWare I3C master's virtual legacy > I2C adapter reuse the I3C bus platform device's of_node, so consumers > can resolve the adapter by phandle. i2c_register_adapter() reacts to > any adapter with a non-NULL of_node by unconditionally calling > of_i2c_register_devices(), which walks every child of that node and > requires a "compatible" property to build a modalias. > > The I3C core already owns and fully parses every child of the bus node > via fwnode_populate_i3c_bus()/i3c_master_add_of_dev(), for both native > I3C devices (no "compatible" needed per the i3c.yaml binding) and > legacy-I2C-under-I3C devices (registered explicitly through > master->boardinfo.i2c in i3c_master_i2c_adapter_init()). Since neither > path marks the node OF_POPULATED, the generic of_i2c_register_devices() > walk that now runs afterwards treats every child as unclaimed: > > - native I3C-only nodes have no "compatible", so of_i2c_get_board_info() > fails the modalias lookup and logs "of_i2c: modalias failure" / > "Failed to create I2C device" noise for a device that is already > correctly registered on the I3C bus. > > - legacy-I2C nodes do have "compatible", so of_i2c_register_devices() > silently creates a duplicate i2c_client for the same address that > i3c_master_i2c_adapter_init() also registers from boardinfo.i2c. > > Mark each OF bus child OF_POPULATED once i3c_master_add_of_dev() has > accounted for it. ACPI-described children are left untouched, since > OF_POPULATED and of_i2c_register_devices() only apply to the > devicetree case. fwnode_populate_i3c_bus() always runs before the I2C > adapter is registered, so of_i2c_register_devices() sees the flag > already set and skips these nodes entirely, without disturbing the > of_node propagation from f26ecaa0f0ab. > > OF_POPULATED is a property of the device_node itself, which outlives > this master's registration. fwnode_depopulate_i3c_bus() is the > counterpart that clears the flag again, called from > i3c_master_bus_cleanup() (shared by the registration error path and > i3c_master_unregister()) and from fwnode_populate_i3c_bus()'s own > error path. Without it, the nodes stay claimed after this master is > unbound or fails to register, and a later re-probe or rebind finds > them already marked and silently skips creating their devices. > > Fixes: f26ecaa0f0ab ("i3c: master: dw-i3c: Fix missing of_node for virtual I2C adapter") > Cc: stable@vger.kernel.org > Signed-off-by: Billy Tsai > --- Reviewed-by: Frank Li > Changes in v3: > - Move fwnode_depopulate_i3c_bus() to where its forward declaration was, > so i3c_master_bus_cleanup() calls the real definition directly > (Frank Li). > - Also clear OF_POPULATED on the fwnode_populate_i3c_bus() success but > i3c_master_bus_init() (or an earlier step in the same window) failure > path in i3c_master_register_fwnode(), which previously went straight > to err_put_dev and skipped i3c_master_bus_cleanup() entirely, leaving > the flag set after registration aborts (Sashiko AI review). > - Link to v2: https://lore.kernel.org/r/20261127-i3c-master-of-populated-v2-1-c52095d00218@aspeedtech.com > > Changes in v2: > - Also clear OF_POPULATED again on teardown and on a mid-loop probe > failure (fwnode_depopulate_i3c_bus(), called from > i3c_master_bus_cleanup() and from fwnode_populate_i3c_bus()'s own > error path), so unregister/rebind and a failed probe do not leave OF > bus children permanently marked. > - Link to v1: https://lore.kernel.org/r/20261127-i3c-master-of-populated-v1-1-29d2a6a5509c@aspeedtech.com > --- > drivers/i3c/master.c | 61 ++++++++++++++++++++++++++++++++++++++++++---------- > 1 file changed, 50 insertions(+), 11 deletions(-) > > diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c > index 01e05bad8661..d0b0248ad6b3 100644 > --- a/drivers/i3c/master.c > +++ b/drivers/i3c/master.c > @@ -2667,6 +2667,26 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) > return ret; > } > > +/* > + * Counterpart to fwnode_populate_i3c_bus(): drop the OF_POPULATED claim on > + * every OF bus child so a later re-probe of this master, or the legacy I2C > + * adapter's of_i2c_register_devices() walk on a different master sharing > + * the same of_node, does not find these nodes permanently locked out. > + * ACPI-described children were never marked, so they are skipped here too. > + */ > +static void fwnode_depopulate_i3c_bus(struct i3c_master_controller *master) > +{ > + struct fwnode_handle *fwnode = dev_fwnode(&master->dev); > + > + if (!fwnode) > + return; > + > + fwnode_for_each_available_child_node_scoped(fwnode, child) { > + if (is_of_node(child)) > + of_node_clear_flag(to_of_node(child), OF_POPULATED); > + } > +} > + > static void i3c_master_bus_cleanup(struct i3c_master_controller *master) > { > if (master->ops->bus_cleanup) { > @@ -2681,6 +2701,7 @@ static void i3c_master_bus_cleanup(struct i3c_master_controller *master) > } > } > > + fwnode_depopulate_i3c_bus(master); > i3c_master_detach_free_devs(master); > } > > @@ -3353,15 +3374,29 @@ static int fwnode_populate_i3c_bus(struct i3c_master_controller *master) > return 0; > > fwnode_for_each_available_child_node_scoped(fwnode, child) { > - if (is_of_node(child)) > + if (is_of_node(child)) { > ret = i3c_master_add_of_dev(master, child); > - else if (is_acpi_device_node(child)) > - ret = i3c_master_add_acpi_dev(master, child); > - else > - continue; > + if (ret) { > + fwnode_depopulate_i3c_bus(master); > + return ret; > + } > > - if (ret) > - return ret; > + /* > + * Claim the node so that i2c_register_adapter(), > + * called later for the legacy I2C adapter sharing > + * this same of_node, does not also run > + * of_i2c_register_devices() on it: every child here > + * is already fully accounted for, whether it ends up > + * I3C or legacy-I2C boardinfo. > + */ > + of_node_set_flag(to_of_node(child), OF_POPULATED); > + } else if (is_acpi_device_node(child)) { > + ret = i3c_master_add_acpi_dev(master, child); > + if (ret) { > + fwnode_depopulate_i3c_bus(master); > + return ret; > + } > + } > } > > /* > @@ -3932,7 +3967,7 @@ int i3c_master_register_fwnode(struct i3c_master_controller *master, > break; > default: > ret = -EINVAL; > - goto err_put_dev; > + goto err_depopulate_bus; > } > > if (i2cbi->lvr & I3C_LVR_I2C_FM_MODE) > @@ -3941,19 +3976,19 @@ int i3c_master_register_fwnode(struct i3c_master_controller *master, > > ret = i3c_bus_set_mode(i3cbus, mode, i2c_scl_rate); > if (ret) > - goto err_put_dev; > + goto err_depopulate_bus; > > master->wq = alloc_workqueue("%s", WQ_PERCPU | WQ_FREEZABLE, 0, dev_name(parent)); > if (!master->wq) { > ret = -ENOMEM; > - goto err_put_dev; > + goto err_depopulate_bus; > } > INIT_WORK(&master->hj_work, i3c_master_hj_work_fn); > INIT_WORK(&master->reg_work, i3c_master_reg_work_fn); > > ret = i3c_master_bus_init(master); > if (ret) > - goto err_put_dev; > + goto err_depopulate_bus; > > ret = device_add(&master->dev); > if (ret) > @@ -3997,6 +4032,10 @@ int i3c_master_register_fwnode(struct i3c_master_controller *master, > > err_cleanup_bus: > i3c_master_bus_cleanup(master); > + goto err_put_dev; > + > +err_depopulate_bus: > + fwnode_depopulate_i3c_bus(master); > > err_put_dev: > i3c_master_rpm_put(master); > > --- > base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 > change-id: 20261127-i3c-master-of-populated-2ef07c2bb743 > > Best regards, > -- > Billy Tsai >