From patchwork Thu May 2 10:55:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 794648 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2092.outbound.protection.outlook.com [40.107.22.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA30056B7B; Thu, 2 May 2024 10:55:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.92 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714647354; cv=fail; b=rxyvZUgDYXqvSZ2Ke6GABVl3GrXr6keUT8axD9N20mZ8/HCyVoFfzrnWsNzgTr+iJVstcwHmk0BVKZ7k/b81M6Ek/n3oKYGMCfceJyO4HXoJBTM3usAfJOqxSNHy/3HFzGhdXKn3HmqenQAHWN9cr8z/vDhSYJRvF/2w4ktkEM0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714647354; c=relaxed/simple; bh=K8QQ0vE6kJS0U2RCCfOS9ovSSAbfliVsZQGnX+PMNVo=; h=From:Date:Subject:Content-Type:Message-Id:To:Cc:MIME-Version; b=L1Q56LXiy5X85NV1wjZvywryd/AcxNisETpL1tZf7FpUhmCZsMVkR+5keQ982RKJAZ9zxBILr4/Q94RTFAsT3cQFRnz9BGBem0cb4Sl316qUss34kxf7OnSO5ILoJXpauHNaQOOH5nRO1uZg5akgYQrBAM9aAHX4EiqWd4Af5QA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net; spf=pass smtp.mailfrom=wolfvision.net; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b=S3x4KkTo; arc=fail smtp.client-ip=40.107.22.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="S3x4KkTo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=buplrOYkfOPPPswGQ5ucMxdcDMGeoF/yWijgRbdQuVquMZKCJp39Jgp2DPvKNut/adYP0oqx37Gkxa2VWVHxfEOMfTNhVcb3w9gbwdHPkeG/80lMRWbS6nrpPn/82LvZQrnOsjstu2+CRP3xfciQPkwE/FBN5sidkq4gqCGVxoQ27m6Ic1LVZiGLEEAsDYmAtZnYSzL+VeQRdTEsgLM4VruVYF+uAX+k57JeKkvtMY6HxtX5wl8utohqw0hG7WXXXAFDc8x2yhw0xAYH++d+eGaluKKbDGwSNJLkY0jhvZYqe1myVu9E798vIYypJq6OT4ji3mKaVubeyuND+hXRxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=JfGtqk+Uq9rLc4eJZoXD5HSehiPmhe4GyU+bw+vXA5E=; b=YYUDg2g5GBxtjC0u0agV+OgIdiMjvl8u+3ix3PjBHruc5Ek1c7qGuPAdS3E52lhTbgR273DwKbteMTSylUWOJAmJ4kN9Tn0AUmbRDPyS5+9PxPnUrw3kZAkzTazYbv3rioPT9f1csl3YjD5GPHMEi6eGfI7+1/0So/zzlRVmNZ5l5IYamgOGJMvgfzcvMXfYdgQnUdWOrse1ahnWTdOendS+4fcXYCBTGd+Y3FxixqTpMwF++mxDoO5quSQmaWiHf0y36uAliv8tZptfrPWkHK3iNaivwTxBLaCklmcxEEpFvmwrdjTRvTs0uw/poE4kPJDuLkY+E2oVkBT7Aj6Dpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JfGtqk+Uq9rLc4eJZoXD5HSehiPmhe4GyU+bw+vXA5E=; b=S3x4KkToK31VsXzLU7uGAqGGl8ePZRkwZjPDru85U8A18cdGwsULIz4dMVt4/HR2+w2+3QRNWTAE+i6jJrBH17TeI5i0TC5WfllDN6nIuTzgGuWmKWJjZ82oTagXHtQzoEhkMlxKrOOI1P9iNFXtCwhOshj2Ai7QoU7Wbrp5XzI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by AS2PR08MB10324.eurprd08.prod.outlook.com (2603:10a6:20b:5e7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.29; Thu, 2 May 2024 10:55:49 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040%6]) with mapi id 15.20.7519.021; Thu, 2 May 2024 10:55:49 +0000 From: Javier Carrasco Date: Thu, 02 May 2024 12:55:40 +0200 Subject: [PATCH] device property: introduce fwnode_for_each_child_node_scoped() Message-Id: <20240502-fwnode_for_each_child_node_scoped-v1-1-868a2b168fa8@wolfvision.net> X-B4-Tracking: v=1; b=H4sIACtxM2YC/x2NQQrDIBQFrxL+uoKaBtpeJRSR77N+KBoUkkDI3 SNZzixmDmqogkaf4aCKVZqU3ME8BuLk8w9KQmey2j71pK2KWy4BLpbq4Dk5TvIP7naNy4KgGGb yb/8aDY/UO0tFlP1+zN/zvAD9iIorcwAAAA== To: Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1714647348; l=1853; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=K8QQ0vE6kJS0U2RCCfOS9ovSSAbfliVsZQGnX+PMNVo=; b=HDQAo6cx3iMEoqs7Ws99rtKNhDYaaWL2t180CkMEQ0D8Uh609Qlk30neM+yz0E2uRueZ5Hfsh vXlcqJ1d9zOAarF9FC0Fe16vK2mIOp8Bi/dIjBvW33gah2EYmc9/Gnf X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VI1PR07CA0262.eurprd07.prod.outlook.com (2603:10a6:803:b4::29) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|AS2PR08MB10324:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e6831ed-746a-46b9-5844-08dc6a966d46 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|366007|52116005|1800799015|376005|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?6PNkWT+V7foi+PzwnZeIB3plOymuYHo?= =?utf-8?q?Ky0aapgDMicFEoW+6Ha6NQ4wmaD6rv7lhLi8iNftBB8WWjB8xtDKEfXOJB/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f-8?q?BmRNF5zKfhzKB7uKp9Kt3XYVIwO7Z1zibt3jv1mZsKt6Wi05xKuzy7fWz0rLjJW04?= =?utf-8?q?ouCc1BHLFLIc7Qg5SPy+uJtZXjX/HcL93KMcCUzc/fnjTSfTiKn+PjKoYo8HWE3pF?= =?utf-8?q?DTwHTUR4cf9l41eR8UjJUKjf6LJlPOo+B0CBrqWTK4qcMtlEEeL6zdCz3M4HdJLvz?= =?utf-8?q?2u62fZ7ttS//HfU3doqwrCgbkAWhZdlI8D1tdGcCA714bOB1v+eWe7U9NEYMihN1S?= =?utf-8?q?oMdFOknN4lmn++x9olwc2kAWoTUx1hB33YBg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR08MB4974.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(52116005)(1800799015)(376005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/uO7r+cdeUr35g4RpHETjwuReayZ?= =?utf-8?q?0AWGz/CE+Yi6HR8CXcHVWsMnzdQJtHRgajA8lNW6dU1GSE2MD9UpJRQN3q9UO7A3S?= =?utf-8?q?bg6P9Hcb6+BeIWxwlxsAWISZfVkgCICtt2Bd1j/QGNDQ20Fkq6Y5I/b98xL1CxUAp?= =?utf-8?q?/fXkmw/WcKXqXvRQynX2zJq7vhQ9oT1wkVqbuKy94ALZ9w+fqiZhkHxgIsVdIVqVG?= =?utf-8?q?Si3753t36RydEW4viYpzwmqukbQzBJvT08nOPfK39oQrKKtGinFr86b2jynu0Rs/6?= =?utf-8?q?O2rS5N30OViej8Y4QB/IvGPPVXqqrcgv7zibOmYG8gah+hDQFZsPKbwYfA2OSnZfG?= =?utf-8?q?rs3nxqED6EHn/w2SDvlhpB/n9rbVf6+N4Z6jRf3r/czqpRmjE3ciIbQk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4lANl+epsm9FTzzRA//Fe4gfdVgdJ?= =?utf-8?q?J2w3IgVQ2PYhSwL1MhnrMAI3b9ab0ijb8+vFyeuMVLd0dTt8WhjTC4RVb2kgZzl/l?= =?utf-8?q?qSYEgSytEsiEDZoH4beYbc9qwgdZnO22FS5gtX7/v4y2wE0M1SbPnfbZO2OMvep69?= =?utf-8?q?gJf6o2Uzav22rr5pwB6Nj+EtA1qvF45qaXJBgfOsHNxoqIvuunbE4XP0lhAhTKzxy?= =?utf-8?q?CwwzXOrg8IJTpEwfKlxfS5oAJxsp6RtHwd/+F7HaEySs6yOZulcf1w6D+joG3jiGW?= =?utf-8?q?OFxbGDOmpv2Y2F7ZOnlnCu/i0uCma0U71bnik1rUh72vr/WgWaSLFPE=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 4e6831ed-746a-46b9-5844-08dc6a966d46 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2024 10:55:49.1578 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QQmqXIfJnVYCzOEPmidLqeY5latoi6V8xX0uUnEA1SDBcm6up/qXRxCOhFIo2wCcAoTYA5LlG5MQn9wDjxXrDBu4hSPB0ZKFndFo3wH4JCQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB10324 Add a scoped version of fwnode_for_each_child_node() following the approach recently taken for other loops that handle child nodes like for_each_child_of_node_scoped() or device_for_each_child_node_scoped(), which are based on the __free() auto cleanup handler to remove the need for fwnode_handle_put() on early loop exits. Signed-off-by: Javier Carrasco --- This macro has been tested with a patch series that has not been applied yet and is under discussion in input [1], which makes use of the non-scoped version of the loop. Based on linux-next (next-20240502). Link: https://lore.kernel.org/linux-input/20240422-feature-ts_virtobj_patch-v9-0-acf118d12a8a@wolfvision.net/ [1] --- include/linux/property.h | 5 +++++ 1 file changed, 5 insertions(+) --- base-commit: 9c6ecb3cb6e20c4fd7997047213ba0efcf9ada1a change-id: 20240502-fwnode_for_each_child_node_scoped-ce15a9a831c3 Best regards, diff --git a/include/linux/property.h b/include/linux/property.h index 61fc20e5f81f..88f930165071 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -164,6 +164,11 @@ struct fwnode_handle *fwnode_get_next_available_child_node( for (child = fwnode_get_next_child_node(fwnode, NULL); child; \ child = fwnode_get_next_child_node(fwnode, child)) +#define fwnode_for_each_child_node_scoped(fwnode, child) \ + for (struct fwnode_handle *child __free(fwnode_handle) = \ + fwnode_get_next_child_node(fwnode, NULL); \ + child; child = fwnode_get_next_child_node(fwnode, child)) + #define fwnode_for_each_available_child_node(fwnode, child) \ for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\ child = fwnode_get_next_available_child_node(fwnode, child))