From patchwork Tue Aug 20 19:02:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13770546 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 D2024C3DA4A for ; Tue, 20 Aug 2024 19:04:09 +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:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RlwKey+PJeZN0A9rh/S0vL1F8rX1MwKvwXZ2q25uwGA=; b=JHbxgevyzgsOnlo/LVBW5Y/7oq NhgXpBeyyxwkxr6J8AHArcpF5WJ9YjvXUdJqw0+iVR8G8IoJuSxmZKb18uxTh1eNJQQSPJ+02yGrC kZHVXScohWhapKOyHTctbsRypsESWj4hywpGj3SdOnsCp29JLLB3Koi+kIo05LXV4cVNYbP8VX6R1 CocmCQBfpwufd1ibHg0PUNN05qlh7sMPgEk8VoP9sF1460fr/Rjtzu6Ter+5mnNxy5k0iVL5nRFFc IZ1stYkdAyqN7ikCFwA5ThAb415aiDuW/itENgg+xln54Z+yumheruBxAMW8/ql8ABY5/5J4g+SeD x2DBwNBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgU9B-00000006PIe-0MoE; Tue, 20 Aug 2024 19:04:01 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgU7o-00000006P1r-0P7l for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 19:02:37 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4280bca3960so51477215e9.3 for ; Tue, 20 Aug 2024 12:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724180554; x=1724785354; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RlwKey+PJeZN0A9rh/S0vL1F8rX1MwKvwXZ2q25uwGA=; b=PHQ7VefZiigFpczxZQkOHtQe4Kfuw0Nk4OECnCEzq3vBnsC0G6lg/qwcGGE2Z0Jhtr E0w81/sBhT1SGJb5nGn3G8WENLLHB035Lpki1lwslSTTM85eGhTKbiqKD9UN7S34/E96 7eb3DVLBomDu5bNQunvImPmjxtVeLpGFnaroErnxhMKV7zu5ZMuKqiJLOPbzzMq4s8rM Ag+Av6v8JQYDGGYFGof4HGzQpbLNTdkjE9h5RmOPW1MSmPUM9dru3dIuUBbI6uJp8RT/ QPDOj/33c4kbJ3bzlGK8B1XAgkVY/ieLaWs24WmGUdxrcGF3y6HYWWMB3zHK+8do/BZX OWeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724180554; x=1724785354; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RlwKey+PJeZN0A9rh/S0vL1F8rX1MwKvwXZ2q25uwGA=; b=SJE4FUnZO2s1FQnuuvkFBe2fBfar1DpaiV9D2hVfezDCkUXeztgD9H3FbKPRNgw981 yz7pbkBPJV5B8aP/umiXj6xOjyJgRnggbK+qDQkSZlKjKtuQYuNWfNeyCuPWtrFqFg20 pD0t0zVRloAiCX5JRlwpEDgvPGKoVW5uenin86Anl1lNQjc5wY3B+WH4CTAevVWb+QWi CMph2iGOsoXgAwcftEFzboLpRZj62XyPKqdzoKbt7Xgvp9djnu+glIy4eM0/n59GurCh eg2esbcfvUzRgBMME/Tru1HtR90/Sr8Joxxf94jBZFXYMSBKl/D7ZXt3n7ELLr9yGzpt vrCg== X-Forwarded-Encrypted: i=1; AJvYcCWrhHT5w1xg6C0Bb8x/Oe7pgKCILcTI0li2bFjwoai5Vo06eYXoSIw57DXCxnkHzV1uLnosdaqOVx7BofdZGiRO@lists.infradead.org X-Gm-Message-State: AOJu0Yx6PVNEv2DlBDElean12dUKD7lUpDFpoXECu1IkWHltHe6LV677 1NN8s4XkjygRG4aRrUMsI75GLmI4T6aXjWwxUsyxkKO/hw4pCt7U X-Google-Smtp-Source: AGHT+IFd/9eXjIimfq6IVjdiKHAYzFfXr+fnsj7PnsuNsfpHif9KAV2JjMtdFT05yi0N5r7XiYy0fQ== X-Received: by 2002:adf:ec4b:0:b0:366:eade:bfbb with SMTP id ffacd0b85a97d-371946a48camr9184041f8f.46.1724180554278; Tue, 20 Aug 2024 12:02:34 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-37.cable.dynamic.surfer.at. [84.115.213.37]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497ffsm13685375f8f.27.2024.08.20.12.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2024 12:02:33 -0700 (PDT) From: Javier Carrasco Date: Tue, 20 Aug 2024 21:02:26 +0200 Subject: [PATCH v3 1/2] iio: adc: xilinx-ams: use device_* to iterate over device child nodes MIME-Version: 1.0 Message-Id: <20240820-device_child_node_access-v3-1-1ee09bdedb9e@gmail.com> References: <20240820-device_child_node_access-v3-0-1ee09bdedb9e@gmail.com> In-Reply-To: <20240820-device_child_node_access-v3-0-1ee09bdedb9e@gmail.com> To: Suzuki K Poulose , 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, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1724180551; l=1584; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=cl0OgwWFGj09y5TwwEPvN3u/Sy1PyJsfo8HSpKT7rW0=; b=PMTWQVUhRErOEF/Tm2rq2wYK9XrGuYNQoynvd7qUkDe28eBhRUo+E8ZtAitFprlj5LYADlvj5 ZbAAIdu/x2vBs3otupjyQRtgQQM9fPgFm18yXZ3cS/DLvYau8sueJLS X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240820_120236_175636_A9DC24EE X-CRM114-Status: GOOD ( 14.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 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 | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c index f051358d6b50..ebc583b07e0c 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,16 +1296,12 @@ static int ams_parse_firmware(struct iio_dev *indio_dev) num_channels += ret; } - fwnode_for_each_child_node(fwnode, child) { - if (fwnode_device_is_available(child)) { - ret = ams_init_module(indio_dev, child, ams_channels + num_channels); - if (ret < 0) { - fwnode_handle_put(child); - return ret; - } + device_for_each_child_node_scoped(dev, child) { + ret = ams_init_module(indio_dev, child, ams_channels + num_channels); + if (ret < 0) + return ret; - num_channels += ret; - } + num_channels += ret; } for (i = 0; i < num_channels; i++) {