From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EED22C3DA4A for ; Fri, 2 Aug 2024 07:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3i7xOJQtQKmAS76IUBJI3tZhJEgV6jaRzedwmx9IWZA=; b=zn1tUVN9E+rirOaAjkmqazyBf+ 7E687q4wKvPnNQoA1ESR+igZ6AyKufQMFbHlHm1lD8jNy1y1NWvUW8XLWreb1jddPcEPa+FEzee5I NmUKF0mnaIa1ZnuSrg2tFpogcfnsPHnC/qyvFIV/AVXNDbJFpREwbtoNt2AxSGfsluKVLYMVofn5W Qz73Whz+Df2DBeoOMH5TpOuEzz12d/qiR8EvsTRnD5rDM7J1wdMObF8XMEAyTiEM9O3e+mPTmNDzr 9QIZ4jdhsTmIW4Hr9z9VQ1fxeAShg/M45Udb7njdzpJf9AwudFyOJXU1IOelhbEpM8aIbLrxFqnbY zKcn5Ffg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZn3w-000000080bH-00Gf; Fri, 02 Aug 2024 07:50:56 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZn3R-000000080Ri-1tpI for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2024 07:50:27 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 728C01007; Fri, 2 Aug 2024 00:50:46 -0700 (PDT) Received: from [10.57.95.187] (unknown [10.57.95.187]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9BF7E3F766; Fri, 2 Aug 2024 00:50:18 -0700 (PDT) Message-ID: Date: Fri, 2 Aug 2024 08:50:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/4] coresight: cti: use device_* to iterate over device child nodes Content-Language: en-GB To: Javier Carrasco , Mike Leach , James Clark , Alexander Shishkin , Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , Anand Ashok Dumbre , Michal Simek , Sakari Ailus , Pavel Machek , Lee Jones Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-leds@vger.kernel.org References: <20240801-device_child_node_access-v1-0-ddfa21bef6f2@gmail.com> <20240801-device_child_node_access-v1-1-ddfa21bef6f2@gmail.com> <381fd199-640a-4ca0-8d7e-1c4dae11ef7f@arm.com> From: Suzuki K Poulose In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240802_005025_598271_F83F78A7 X-CRM114-Status: GOOD ( 14.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 01/08/2024 11:37, Javier Carrasco wrote: > On 01/08/2024 11:20, Suzuki K Poulose wrote: >> On 01/08/2024 07:13, Javier Carrasco wrote: >>> Drop the manual access to the fwnode of the device to iterate over its >>> child nodes. `device_for_each_child_node` macro provides direct access >>> to the child nodes, and given that they are only required within the >>> loop, the scoped variant of the macro can be used. >>> >>> Use the `device_for_each_child_node_scoped` macro to iterate over the >>> direct child nodes of the device. >>> >>> Signed-off-by: Javier Carrasco >>> --- >>>   drivers/hwtracing/coresight/coresight-cti-platform.c | 10 +++------- >>>   1 file changed, 3 insertions(+), 7 deletions(-) >>> >>> diff --git a/drivers/hwtracing/coresight/coresight-cti-platform.c b/ >>> drivers/hwtracing/coresight/coresight-cti-platform.c >>> index ccef04f27f12..d0ae10bf6128 100644 >>> --- a/drivers/hwtracing/coresight/coresight-cti-platform.c >>> +++ b/drivers/hwtracing/coresight/coresight-cti-platform.c >>> @@ -416,20 +416,16 @@ static int >>> cti_plat_create_impdef_connections(struct device *dev, >>>                             struct cti_drvdata *drvdata) >>>   { >>>       int rc = 0; >>> -    struct fwnode_handle *fwnode = dev_fwnode(dev); >>> -    struct fwnode_handle *child = NULL; >>>   -    if (IS_ERR_OR_NULL(fwnode)) >>> +    if (IS_ERR_OR_NULL(dev_fwnode(dev))) >>>           return -EINVAL; >>>   -    fwnode_for_each_child_node(fwnode, child) { >>> +    device_for_each_child_node_scoped(dev, child) { >>>           if (cti_plat_node_name_eq(child, CTI_DT_CONNS)) >>> -            rc = cti_plat_create_connection(dev, drvdata, >>> -                            child); >>> +            rc = cti_plat_create_connection(dev, drvdata, child); >>>           if (rc != 0) >>>               break; >> >> Don't we need to fwnode_handle_put(child) here, since we removed the >> outer one ? >> >> Suzuki >> > > Hi Suzuki, > > No, we don't need fwnode_handle_put(child) anymore because the scoped > variant of the macro is used. Ah, apologies, was looking at the non-scoped version. I will queue this. Suzuki > > Best regards, > Javier Carrasco