From patchwork Sun Feb 11 17:42:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 20223 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2032417dyd; Sun, 11 Feb 2024 09:43:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXMylPXCPFcwmY+u47zrRY7lBcom5AmUU1RGSx1Oxz5iLQIxCMpLr/S4Zge3jr5jA+yZaPXT1+8X/wQTQhtAs6IgEvm2A== X-Google-Smtp-Source: AGHT+IFgOwOU40x534zXKB9Dbtl9IkYQH76dVnssEotJ7YKdhFWq2umAkuj0Nsgq2KbltMPEWwiD X-Received: by 2002:a05:620a:24d6:b0:785:3887:de32 with SMTP id m22-20020a05620a24d600b007853887de32mr7299725qkn.20.1707673408051; Sun, 11 Feb 2024 09:43:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707673408; cv=pass; d=google.com; s=arc-20160816; b=adqL+7IJM2m91zKV90vzphjkfTFPwJmvLzUSoI9obun/hHI8wkV2EZbBt2GcyA4p72 Kx8yL5rNVlz6vXpQWdfDmfAbKGtAB8cd8qxAosoe864U1LyurmGQoH+zWzwMaOJDtE5O i8Rh6pzHSDSrFFq54T1vF/9B0R+cX0BDJBhlFaXnccBDUGd7oT7PQVrMbv/ztfxXDfft pjRa6KW1gElVisjqhQadNvY+VlfvQKn8N3Y3y3kogp74rb80fUSV1Bn586tc8Lv6aIwK XwZ+5siGfGoPE9hcgUzpGgJAfO2JmmjhAc5IEQkS0ks9Y9YAdwZu5xVi6/aubA0Ojy6z aVhA== 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=kXW81nevLRj7zYtpHNVTualEdIiQwDo6qRxan9oaEIc=; b=lEN45eX91RvtW3LJdFmH498ItaDTy+FpKsnD1BmKoItfRnBjkDciBHpnKpOVSK0UZE Edv24z0ZgJVEjNM8C5WSfcjzt4pq7NVndzXRlwAA61T3fDtM7jG5juEJd1sK759ArYri CXKFFwub5g2h9tZ6xKYwNAiBab0IcfYQ25qyyQTuenT+tkYXlUnq/KPqk2vBF9hmZpRn E7uVCQoaRizDSjRSTOtebsKI6j8Xyy/GEGzzCGfwuH8+fsYmpIzIzwzCrjdRaDdzom5+ U/K33rKlOQ8k86e3wRUXkjSxjvfLbu4NcsSalPp7X9Jhkh13sKLYtPszJVUcdluscwkx 2EFA==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60885-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUI3+PfxYtxxs0ahthWjHGfldprMyS73HLK3Dgl5716KR2k8YcP/H2v0luQF6bDiTJVTzxmufuNYOimbR9wuFUcG/1foA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l19-20020a05620a211300b00785d71f6107si387186qkl.516.2024.02.11.09.43.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 09:43:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60885-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60885-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D10A81C20F18 for ; Sun, 11 Feb 2024 17:43:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 345C95D478; Sun, 11 Feb 2024 17:43:12 +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_S=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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790625351655121041 X-GMAIL-MSGID: 1790625351655121041 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(-)