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 BA28AC3DA4A for ; Sat, 3 Aug 2024 11:18:35 +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:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Wx1T92utWNVeDZV1B+GTSoTzy2KBmWX1QG++V9LKO9w=; b=wteW/Jc4D0DAizZ1NSfB7OHbjr q0T1S+3dYNLxIvunHnt+BaNuxaiKNLRtgiP0ixhywwctFcyGvUOEpYC7f6KvHOAz1TTmXrfCo+nnZ o7q1ugvd2vEGCaqE6a2BPtWBp1aZEq8Y0XHsSwKjOPHhAqP0QJHvTJJoEaTeP/A3AkPndYlTpzUhm 4ckgHVgYuyuu5Du2HoFbl0aZsZ59llsRcjGFPP7hAI/9LuDhY0UyXX0iKlYVheoZfs4fAL8ZonoYo Doflihmy8UhujdUugeCeBJvbH04WOUTR1q6ZaJ67NQsKmcTKiaJH+AbJNNDDRXL9kBaUukQU7IdIM 16VMG7nw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1saCmD-0000000BIUd-0A6d; Sat, 03 Aug 2024 11:18:21 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1saCle-0000000BIKf-3Xvv for linux-arm-kernel@lists.infradead.org; Sat, 03 Aug 2024 11:17:48 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EE70A6230F; Sat, 3 Aug 2024 11:17:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AA12C116B1; Sat, 3 Aug 2024 11:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722683865; bh=5/DsQtu3T1y/O8PIz5TS2XxabxQtX1xtMM7KNbFl4Jk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OkEMJqwtIC8x7UokMCIy/6YiKHgjZxnz1CQJ2dtAposfloCklhkz3D1j9o1U2h2Hy B5PFCi4ydtkqaZYp8N4ibe64K+lp8zQuTIkO+Vy46E4tQKud8Q1RvZL/9GEdR7zhIK ae9k/rSz8qZEZsd795UyDF+Ra3La8jDadLKnjflYun925r1PllzEboU4twrOZbTdiR mKOORmkiDjrny7i7R6eFje1rJDrONRuCy5cATBMyyc9oDFjO+0uYQz7Tyw9SuL2/6a muvxIjbEMkVwnRowzZe6rke+/bQsY4NgJx57mDCOlsNcN+zEpWtVtxFUZflAJUC3U7 axp7uT7Qrr7ug== Date: Sat, 3 Aug 2024 12:17:34 +0100 From: Jonathan Cameron To: Javier Carrasco Cc: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Michael Hennerich , Lars-Peter Clausen , Anand Ashok Dumbre , Michal Simek , Sakari Ailus , Pavel Machek , Lee Jones , 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 Subject: Re: [PATCH 3/4] iio: adc: xilinx-ams: use device_* to iterate over device child nodes Message-ID: <20240803121734.25f0863b@jic23-huawei> In-Reply-To: <20240801-device_child_node_access-v1-3-ddfa21bef6f2@gmail.com> References: <20240801-device_child_node_access-v1-0-ddfa21bef6f2@gmail.com> <20240801-device_child_node_access-v1-3-ddfa21bef6f2@gmail.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240803_041747_100832_4FF50B5D X-CRM114-Status: GOOD ( 20.84 ) 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 Thu, 01 Aug 2024 08:13:52 +0200 Javier Carrasco wrote: > Use `device_for_each_child_node_scoped()` in `ams_parse_firmware()` > to explicitly state device child node access, and simplify the child > node handling as it is not required outside the loop. > > Signed-off-by: Javier Carrasco > --- > drivers/iio/adc/xilinx-ams.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c > index f051358d6b50..27d5e4a6f9d6 100644 > --- a/drivers/iio/adc/xilinx-ams.c > +++ b/drivers/iio/adc/xilinx-ams.c > @@ -1275,7 +1275,6 @@ static int ams_parse_firmware(struct iio_dev *indio_dev) > struct ams *ams = iio_priv(indio_dev); > struct iio_chan_spec *ams_channels, *dev_channels; > struct device *dev = indio_dev->dev.parent; > - struct fwnode_handle *child = NULL; > struct fwnode_handle *fwnode = dev_fwnode(dev); > size_t ams_size; > int ret, ch_cnt = 0, i, rising_off, falling_off; > @@ -1297,13 +1296,11 @@ static int ams_parse_firmware(struct iio_dev *indio_dev) > num_channels += ret; > } > > - fwnode_for_each_child_node(fwnode, child) { > + device_for_each_child_node_scoped(dev, child) { > if (fwnode_device_is_available(child)) { This is fun. should have been fwnode_for_each_available_child_node() in the first place rather than iterating over all nodes, and only doing stuff for the available ones. Can use the device_for_each_child_node_scoped() but that only includes available nodes anyway, so my understanding is that we can also drop this if statement as it will always be true. > ret = ams_init_module(indio_dev, child, ams_channels + num_channels); > - if (ret < 0) { > - fwnode_handle_put(child); > + if (ret < 0) > return ret; > - } > > num_channels += ret; > } >