Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2067323rdb; Sun, 11 Feb 2024 09:43:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUVMV2UvWt2hJTllWC5UlGFX3aSqcKurtgI8Y7x4x0NysxzXcVnDDcBHFrJ8/tHbpctUw98oxFTw4A/dRQs7YyR609xalNeTI23Yc5CNg== X-Google-Smtp-Source: AGHT+IF2CzAvCKOjufIEpLe12XbYWoiXjf8iddyK8hF/aNj94AP1Zs/GbYIC8yTIcDRMsr7ZmPfj X-Received: by 2002:a05:6359:459c:b0:178:a197:15e with SMTP id no28-20020a056359459c00b00178a197015emr5638299rwb.32.1707673404700; Sun, 11 Feb 2024 09:43:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707673404; cv=pass; d=google.com; s=arc-20160816; b=roXsbGvfZSG+7d8NDbAHP4E0jRwjIcZSXRb4UU3ZedvUMURdflvJISXnT5OcrAJIrw H52bR3AjFqGY6PUvOq4JFNmEswNb1Wk70nJ3CtLWUAInXyN62mGOBsPc2zxt9VQfuL/S 58C86aBSr4EBTUUKc5CqM0++TiE90oZYj3c2gzp4J3JNrRg5tigOwF+43g0YRY+zYdci D0XUYDdUnN27sPit9mmYG99ytcVjFsjaAEB+LOPYCnobrh3d6n1GsSfecHxYpcTwaZlj P5SAUZTGY09WEqQEVY76K3liOMjOsbb1bjKnRF239vwMhlT3xWjT01p4TjocC0SDipWd d6Vg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=6epoY1w1ZCdYt6KP00aa67gMeWz/golbw8by5z5cyLo=; fh=OHkmYBQEGCrRSSbfURR8mSL6p9jxuMpZGNuvSdNljpQ=; b=wHgEznDjAoaprcT1JtWrUV0RhsJUCCOa2qHkiCFmojp0KTGcNYFVQFrAahOnJMQ5Xm NJL9xED2F9dYRJvCKjZDMXdC84mWjMLPgEL807ufxRdEdDHMXJNV5WPcG+oezCt/MyQC +4eKcp2xhgqTylNwG7Tq1vuxiDvr3KCUS0Z7wrt5P0Kn2btrzv0qYzwrKfKapwDUnkAL 2gc1PxppWTP6yw6mi+lkkPG4/DV7t1GluJ6H0bmy5+rg0e0oFaU/9gPKemNmDuFHpKRa 353v19edUccuFwh6NwWHAgjlcJ66H23O5hzZ/iYNsRljolkx76MLGUSNGwGVAwxE9RB2 0xaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GXS9pOT4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60885-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUc8OUKtLCrhkxJe55zegdkf+WOVa+skI75ukWRA/kcIaQEi/5VAv1++rByD5F/LD+UukNXq0HsR4/OZUgp9Rx5Fdc693QjeiWc0lydyg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f50-20020a056a000b3200b006e03d20f87fsi3738835pfu.66.2024.02.11.09.43.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 09:43:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GXS9pOT4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60885-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 97FBEB21A0D for ; Sun, 11 Feb 2024 17:43:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 609225D460; Sun, 11 Feb 2024 17:43:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GXS9pOT4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8189B2837D; Sun, 11 Feb 2024 17:43:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707673389; cv=none; b=VpJLCyI0fbLjZOxBWoHq3+WVNtpVGCnXubfWIVV/CXKZpMn1lcO2UXLCnzQ5uTWNn95m3mw1Rqka4LiUOSYjxBDK6O8ZdJf87MlWvjB4hLRBn1Y4RPnrIsXl189v44tuSrgDKIBdX5zAHCK9gFRLN5vuzX/45OOjYPo5tWviCbQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707673389; c=relaxed/simple; bh=ozx5VYs6gCeBet+H6hdug10X/WXACSIPRnOQiwAk13s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZENJaUAmkmchLYJz9h3ap3Lwk1tdqXY0U88DsIzFDA3ZuTjStWjIKJK6z94DErgCC+Edxylat8fiDQMw1SYj5njIjv9voOpR3gZ9QR61qnwo9Im9ffMT7bizLwcmBdYTuQCkvdCEofylx5KJ39XY5tbkUzpaM9c64Td5OkKqBBg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GXS9pOT4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6766DC433F1; Sun, 11 Feb 2024 17:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707673389; bh=ozx5VYs6gCeBet+H6hdug10X/WXACSIPRnOQiwAk13s=; h=From:To:Cc:Subject:Date:From; b=GXS9pOT4FIBWQFj5n7lrHKn4ZV9hmz3hr5SFQlQ4KJSjSeE8mceyYFV+mzW5YyFvs 0sDeVSlzjLNsj44dCl9xmDi/EwVQKFs/zOv70Km08wkGpPe64wwzYJc8brFkmD9kMS +snlEX/AaCR1sFMKcipCHh044Uzy8m0fVawPFZOYiCcBMmxoQ8e/o0P121TXHWYIXT LMxp5ncgNF3O1O2/7yDStM6qHDqkJN6afA8qqxSWoudf12jGsBynuz2tc04EgR71ko jeCyT3ioHtzhBtt77wvOCvs9eljk2ikIueUbye+04K30z5+ddwk4cYZVMdFrAC5Yto 9OfKGjF1uYjjA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org, Julia Lawall Cc: Peter Zijlstra , Nicolas Palix , Sumera Priyadarsini , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Andy Shevchenko , Greg Kroah-Hartman , =?UTF-8?q?Nuno=20S=C3=A1?= , Jonathan Cameron Subject: [PATCH 0/8] of: automate of_node_put() - new approach to loops. Date: Sun, 11 Feb 2024 17:42:28 +0000 Message-ID: <20240211174237.182947-1-jic23@kernel.org> X-Mailer: git-send-email 2.43.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jonathan Cameron Since RFC: - Provide a for_each_available_child_of_node_scoped() variant and use that whenever we aren't specifically trying to include disabled nodes. - Fix the for_each_child_of_node_scoped() to not use a mix of _available_ and other calls. - Include a few more examples. The last one is there to show that not all uses of the __free(device_node) call are due to the loops. Thanks to Julia Lawal who also posted coccinelle for both types (loop and non loop cases) https://lore.kernel.org/all/alpine.DEB.2.22.394.2401312234250.3245@hadrien/ https://lore.kernel.org/all/alpine.DEB.2.22.394.2401291455430.8649@hadrien/ The cover letter of the RFC includes information on the various approaches considered. https://lore.kernel.org/all/20240128160542.178315-1-jic23@kernel.org/ Whilst these macros profduce nice reductions in complexity the loops still have the unfortunate side effect of hiding the local declaration of a struct device_node * which is then used inside the loop. Julia suggested making that a little more visible via #define for_each_child_of_node_scoped(parent, struct device_node *, child) but in discussion we both expressed that this doesn't really make things all that clear either so I haven't adopted this suggestion. If the responses to this series are positive I can put the first few patches on an immutable branch, allowing rapid adoption in other trees if people want to move quickly. If not we can wait for next cycle and just take this infrastructure through the IIO tree ready for the 6.9 merge cycle. I'll be optimistic that we are converging and send out an equivalent series for fwnode_handle / property.h to replace the previous proposal: https://lore.kernel.org/all/20240114172009.179893-1-jic23@kernel.org/ Jonathan Cameron (8): of: Add cleanup.h based auto release via __free(device_node) markings. of: Introduce for_each_*_child_of_node_scoped() to automate of_node_put() handling of: unittest: Use for_each_child_of_node_scoped() iio: adc: fsl-imx25-gcq: Use for_each_available_child_node_scoped() iio: adc: rcar-gyroadc: use for_each_available_child_node_scoped() iio: adc: ad7124: Use for_each_available_child_of_node_scoped() iio: adc: ad7292: Use for_each_available_child_of_node_scoped() iio: adc: adi-axi-adc: Use __free(device_node) and guard(mutex) drivers/iio/adc/ad7124.c | 20 ++++++-------------- drivers/iio/adc/ad7292.c | 7 ++----- drivers/iio/adc/adi-axi-adc.c | 16 ++++------------ drivers/iio/adc/fsl-imx25-gcq.c | 13 +++---------- drivers/iio/adc/rcar-gyroadc.c | 21 ++++++--------------- drivers/of/unittest.c | 11 +++-------- include/linux/of.h | 15 +++++++++++++++ 7 files changed, 39 insertions(+), 64 deletions(-) -- 2.43.1