From patchwork Mon Aug 12 13:33:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13760600 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 E1969C52D7C for ; Mon, 12 Aug 2024 13:37:03 +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=iYu90t8uzYSzwZwxstiM099mVmkqpDjtdWc2Qi9XDBQ=; b=AhrlB/lJUaAmsm9jhEYnDSvs9B GAa/loqoHf9uk2ISaNrBPm/bJWt4cOCYhryzX+g1CvTEVXCgmlqRT0X6c6/H5zrycVORCQkqzPT1X KJG+R7VGyAmp84G/XLRTBfLf3Q3nNbUpKrhK2B2naUAdwAFDkWS6Cwu7rxR/RDa+59iPSSTRPPkVw FqOVpzYMyMfN337ABpa3CoLiN82nENWetjElO/8tZIsl98hoZeMUpj+47FLT2tCZ5li4VgoAAaVqa emFHy+BNthJqXMx+oA81a13j9oNYIhLY5WzSVE/JtnIX7odIXDjDeAdMadYkBHin2lgsvUXB6Mlt1 ayCxtndQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdVEB-00000000Rc2-0e0x; Mon, 12 Aug 2024 13:36:51 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdVBx-00000000R8W-2M1Q for linux-arm-kernel@bombadil.infradead.org; Mon, 12 Aug 2024 13:34:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=iYu90t8uzYSzwZwxstiM099mVmkqpDjtdWc2Qi9XDBQ=; b=meYBDayWm4PgyZWqz6fio9rUsH VghdT47iF/tWAtaEH2lb8YOr9mJX/9yB4Ddj2eWt2UGqgVeZINHr8QL0dRrEccwa93JzzIgP5bwj5 G9ddUGFcMKUXEaQOKuRpElpfOlpqV0Y6rzUFhn1/UemavLrNZCSZFtzn+HW2Xens4MzPxCNlyBG9o T9fRqLlHOOMXDY9MjYiRgCYmqPFv0k55R8oWU74UCfocy9n8RrAfcQvaOcfZu9WVuYuziEFPBceCQ qsAVJqEFBs17+ZjrYoqGmJpk4dqRS8R8np2/2qUyFOm3Gl2oTz9mzeCjcZqVNVvH/kefMItw5f7Rp HGrSu83A==; Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdVBt-00000007ZZO-47CE for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 13:34:32 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-428163f7635so34158855e9.2 for ; Mon, 12 Aug 2024 06:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723469667; x=1724074467; 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=iYu90t8uzYSzwZwxstiM099mVmkqpDjtdWc2Qi9XDBQ=; b=g3FeLjI24ZGdYWOUkH/RPBx9RTjoafXlxHkrwLCwfTPF8Wu3YuWkZjYMgLgia3SmRh nTCyh5D8d48+iMUtWtPKbSpuJfKspYapmQPQJVTw/L/1SZS1shcRmQb8EOxQFBRhNLBI ZmTanCPcacXd/ddOgTCAOUZ3VrruR4RKmVWwqs9+YbicAqTHI3xiYdrcDa5mjdY+8DBo phO7PbUY26lHM8NYvS18WN04sSxQM0s6Bfau80MTwZEzA37PHvcgwCIACl6zxCx3jC/u fp46XdUe18dPsnI1FvWGnTa06bUO0buYqB2M06h0/ab+D1V3+La1f6zlK0tmdFvQBhNg vKTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723469667; x=1724074467; 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=iYu90t8uzYSzwZwxstiM099mVmkqpDjtdWc2Qi9XDBQ=; b=PeJ4b4KWQQyZXE/RJ7wwqnncBgTN8ZZDcW8cZculUf8hmJbOmfAk4QIt4itS8RyE9I NDCc9PoBJKPBuMAVgBkwa/DoUn1o+zjptRnzNZ8BkAHzaXwWTS1uaHZu8mGS0DFZP0jA lFPCZFkoQ23YOygT2r0AxZKB5/VtikheE1yCsJ/PmvJJtCBLQJHcEchRYftly8f//u/G /qDVJaECwkvwAzQyshRGd4pbnuNOwN7Y/Fg/ITwo9L8xakRTGwRS9i/H5t844zOz4Sje 33Ez9syyCQsvIjuF/HnnAHV/t1EU032OkO056wJD3yebj7fFdUIN5IcRbFLQP+UajbVj 1j9A== X-Forwarded-Encrypted: i=1; AJvYcCWM94fInZpZYf/l3kTXkhUFJGW+dNN8PfwulYA02iCCM3egx5+dir+DyWwLujji/YVZVqQ3pddQPnwNTozT/FIcENx8aYrp6h+HgEhVGBG5+eQzU/4= X-Gm-Message-State: AOJu0Yyqwe/14XymHvjurJo54t2P7tq6LLR00hpA1Oa+ZCrkMwXXI4Bd Q6SMODx/FMDggR61pJb6rI4QNl/+dHCkB89iDaJkbdprEn2i1QJkzYByR9ewDuM= X-Google-Smtp-Source: AGHT+IGo+bwIOsZ7HKzwRQ/L9wxhGpzJ+9d90EvUl3/LSZZSk74iCon02t3qgWPnZGmK+APviAH8lQ== X-Received: by 2002:a05:600c:35cb:b0:429:cc03:6450 with SMTP id 5b1f17b1804b1-429d47f3d65mr3847725e9.7.1723469667400; Mon, 12 Aug 2024 06:34:27 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429c7737c64sm102733975e9.31.2024.08.12.06.34.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 06:34:26 -0700 (PDT) From: Krzysztof Kozlowski Date: Mon, 12 Aug 2024 15:33:59 +0200 Subject: [PATCH 5/9] memory: tegra-mc: simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240812-cleanup-h-of-node-put-memory-v1-5-5065a8f361d2@linaro.org> References: <20240812-cleanup-h-of-node-put-memory-v1-0-5065a8f361d2@linaro.org> In-Reply-To: <20240812-cleanup-h-of-node-put-memory-v1-0-5065a8f361d2@linaro.org> To: Krzysztof Kozlowski , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Lukasz Luba , Alim Akhtar , Maxime Coquelin , Alexandre Torgue , Thierry Reding , Jonathan Hunter , Santosh Shilimkar Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1844; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=VUl2omx8TySNDGhRBBGJcq4Ai4teD6LWmoYd+wA7nBQ=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmug9VH3wPyjxN/t/zzCvyjeYSsYVX7Jz1ga252 UjCTUHqiJ2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZroPVQAKCRDBN2bmhouD 18dmD/0ewHA0UK0In5nae64KOCy+CAeX+7EsnZCjszXwHpXtbtbje2b7d8Br0Rj7OsxqkLkswiK 0TtfIJ7JhGZMAjZ++tIyxg3wlqEt35RQt4H+PQvHeDLM2XZ+z9CKTc05uuZqynh/PpvkoXHheOr lO8TR4iguvJTFmKmbSieHEgcEQvDqZL+SnWoADGWfaRqTpuCvzgMMuf+2qPqqnDNfcregG9QgKO +w60nKgkB4CLB6FMMlzAscW23AprITn6TCuZEBd9s9Ml4+hp/NX2QJa/E79ozdZpjz/6nT+JZi2 7QUvHO4EcccyTIqhqcC1Ggezg1vmaglKJdKUI980UDR6GarxWnvJwrNaTIjoOvUnidQNMAbw1E8 Brc88ThoerIMUAaRW36EdH2jze/ynNoiK+qJUZnNdlK9k2d+ApRPCR0llnQTKj7OKVxe92jKUT3 GEYOBQ1Vf6C2aD2syu/gERy554GaWVbVPHBmvlGYFw8VyyirnITcYyw2ElKoHJGTTySSedZp2Uh TUCYUuos2eEzx/EOV9E7LDPfrFWARV8lZefX+nMIUZnYSj1WdfPfKnxWM7S48WuUkXVDaHSNIyz hYY0EVe5bcenb3qyxNONkHg0IKjxWPKwtIzWFh31VxXLQoZ9VXrteRJhyEqthWTt9f6GZALFo9O hWEevbAzA1E3pYQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_143430_390561_485CCA65 X-CRM114-Status: GOOD ( 12.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 Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Jonathan Cameron --- drivers/memory/tegra/mc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c index 224b488794e5..bd5b58f1fd42 100644 --- a/drivers/memory/tegra/mc.c +++ b/drivers/memory/tegra/mc.c @@ -450,7 +450,6 @@ static int load_one_timing(struct tegra_mc *mc, static int load_timings(struct tegra_mc *mc, struct device_node *node) { - struct device_node *child; struct tegra_mc_timing *timing; int child_count = of_get_child_count(node); int i = 0, err; @@ -462,14 +461,12 @@ static int load_timings(struct tegra_mc *mc, struct device_node *node) mc->num_timings = child_count; - for_each_child_of_node(node, child) { + for_each_child_of_node_scoped(node, child) { timing = &mc->timings[i++]; err = load_one_timing(mc, timing, child); - if (err) { - of_node_put(child); + if (err) return err; - } } return 0; @@ -477,7 +474,6 @@ static int load_timings(struct tegra_mc *mc, struct device_node *node) static int tegra_mc_setup_timings(struct tegra_mc *mc) { - struct device_node *node; u32 ram_code, node_ram_code; int err; @@ -485,14 +481,13 @@ static int tegra_mc_setup_timings(struct tegra_mc *mc) mc->num_timings = 0; - for_each_child_of_node(mc->dev->of_node, node) { + for_each_child_of_node_scoped(mc->dev->of_node, node) { err = of_property_read_u32(node, "nvidia,ram-code", &node_ram_code); if (err || (node_ram_code != ram_code)) continue; err = load_timings(mc, node); - of_node_put(node); if (err) return err; break;