From patchwork Fri Aug 16 15:31:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766542 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 44087C3DA4A for ; Fri, 16 Aug 2024 15:37:56 +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=LGaV2RDOc8MAwrZD+PEbChQMiUdw7FasLLrpXnw03mg=; b=lDutNbv0e6B2pTyH4kdj65yE0M Vl9dAV5+xtDaWaEFv8XiRuvBrr0DwuRxBIJbGD+tCJdU/SAMqTwo2wWAXzG/KU8qn4JmVXYOUP2+T +XOUoAunCUmvAdg0YGHQQxkskn+p1q76okW6lImGOjcfqWoMAZ3/Djf5OiVlTKe/tAafvVdLbqvqu xvphiQJFqBAeH/L/w9R151U2mXOeGV+A8IsrRBvoS+tZhasRGyAQl+2AkMTsC8E0guJTh76zlnlLo CP2g9WCnZrFpcoMVFUsiyJO6x0+rTWeX2/hZwLkayp60NBqu1Yo+vVznH/4mvJFCJUk7Xv+5LQyeN 7KyR2XTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez1O-0000000DQHR-3iby; Fri, 16 Aug 2024 15:37:47 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyvx-0000000DOdp-0I2X for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:10 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4281ca54fd3so15392735e9.2 for ; Fri, 16 Aug 2024 08:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822328; x=1724427128; 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=LGaV2RDOc8MAwrZD+PEbChQMiUdw7FasLLrpXnw03mg=; b=kystC/ds0RxHxDVQNmXwL6Qzf+SNNQTc3+u3vGPjm4oVNZ5Jjlfd6kSlkGuATpBCY9 I+f5x4rE3z+UD3ghDBpqlGmsHE7uA+G+6DJ8dqTVhuPR7JUOqFF7fDsS75DCChhwVSoc DaOwwgFx0J7LKhq8eOHQIyAu3FA16vOEm2WqFN0EA8sdZsqzaZKl8tF9KMSp4jxY4NQx mQ5NIGDqSivy0H/Zt+rVow47wCAw7mOwwJie/XTUD2z1af0/YfKijRT2wtY1Fyj0btdP xZt+LM1PPhZD8v80W+Ndd6mlhW/2PTQ1Hqf09Faxmm6P1pHh8bmdKBYEGUZ+fq0+NLQ4 KlFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822328; x=1724427128; 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=LGaV2RDOc8MAwrZD+PEbChQMiUdw7FasLLrpXnw03mg=; b=CW0oZud7HQasEJUIy1LwivQ2ntUFE0ukl2iBSL/Z2yi9L8v/JUEcH+i899r/a7ow9S /W01emaTNRheDKSzbkWbbAXysK5Nqt935Aq6Ss8ZRlNVi1JsPBKOsuuQi94NYaIxOF9j VDb0BCH6P3fCdA8EZWlWE8hRYDerB/4BnUxc4wIb6gZdCZbzczDLgInjZJxoVAyrQLT/ Dq6VeWQdTSS0Tnld8pw2UAunKoY7JgJ9SgbHLylfzCdvdbIeDVRnkGfXEUnbthj78snO AX7PBxMb3DPDKLQ/fpCCBbvEaws/hNK5s+Rlp0S0hF3u7vG2CNtrmfJlbQxV1vQ7YJZd JVgQ== X-Forwarded-Encrypted: i=1; AJvYcCW+sIMebctmot7zfAjQ2gwDupjuCXUebtQ0YBIgPjQWiXXnAVPmbYm8XwWJVuPwIIjXR3OeyXcuzthbBvv2pwrCAmMa+nJBzU9QstG3OAS9Hx0HrMQ= X-Gm-Message-State: AOJu0YxbdwuqRdFHsnCeBwLDBWtZvhIh6jG26xESZrHrAf0BilWC5hPW AQxiiP5iSB0BWQkJAE3+th0I/7+daHTPPY77eCNl4JuRtW4dEk0vwxoIrHAbRxA= X-Google-Smtp-Source: AGHT+IFfmPaV7HvNPh3uTKrf3gPU3+DlTc+If8+6DTZ+FnUuks5SQ2r0R/qNXIMR4vvm/S2Vv5bzyQ== X-Received: by 2002:a5d:4e4e:0:b0:360:7887:31ae with SMTP id ffacd0b85a97d-3719468d263mr2762190f8f.54.1723822327656; Fri, 16 Aug 2024 08:32:07 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:07 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:41 +0200 Subject: [PATCH 09/17] leds: is31fl32xx: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-9-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1925; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=+81/quQFHALMpUB6fQmVb6mYEiHO0lEYq5t7UhRRMzs=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DgYLr3gj7531lmAyEQypWWevzG4gT7CE04J K7wVw1+wd2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w4AAKCRDBN2bmhouD 18xTEACSro+sjGBUtLTGgjVaSxyV60PtwZwyOAK7Fqq5RH1ZZVgzESSlUU4qdgNYZeDkODJl+XV q7Orhu0Ajk5cK5db9fLOIQJkaXRvUU47dRau+PErZEtCvDdRmpFkxBMmw8KR0l/Vnv4RYUZV3Jm P0cQEcKCg9YRbojaWpMU+quoyK5LaLGG+Cx0tPZeSuUJpJTOGFZ1J45hL6greDe5n2VKdBukx6a aZWqSnZrvVfGnwiUx5a2CGDix7osxzq7lmbmutLc6T/AY65rW3hg5oCT1O7jYY3uuXD0Laf42eC BBTlIhd6KtnfY2oto8IDnEA2vKT8PjFD/nN7rSdU41LNMMDMDYz7erZQsvRjYvSqguihznoR5/B Bv+QTFItKK/xXo1rDiigsO8nYwzjLJLRt6HRkQJYq+Vjpoalu2pdQst+Ag3PG0PL2UBBR5jGGgm T8gf3mtGBE39cfCl/Mzx0EtK+q1COmuvOZzQdjByTdCoDc81E41quD4JvGt4IjHKJttzblIkOuw wD1jYqT4VIgAxshxIwIGVhY7xHvx7CIPQjOmj499jKFh4+alZP/cTnAnUfiDZ4m/3sKulB8kiqF 9NGVGnke+Ui9f3fbfrhIjExOqOW7HcXHD7w+LwnJSHkvbiclraXKpDezFEiTmuvKQ2slyYcVW1r zTb+hCEeRcSiRkA== 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-20240816_083209_213687_8091281D X-CRM114-Status: GOOD ( 14.10 ) 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_available_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/leds/leds-is31fl32xx.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c index b0a0be77bb33..8793330dd414 100644 --- a/drivers/leds/leds-is31fl32xx.c +++ b/drivers/leds/leds-is31fl32xx.c @@ -363,10 +363,9 @@ static struct is31fl32xx_led_data *is31fl32xx_find_led_data( static int is31fl32xx_parse_dt(struct device *dev, struct is31fl32xx_priv *priv) { - struct device_node *child; int ret = 0; - for_each_available_child_of_node(dev_of_node(dev), child) { + for_each_available_child_of_node_scoped(dev_of_node(dev), child) { struct led_init_data init_data = {}; struct is31fl32xx_led_data *led_data = &priv->leds[priv->num_leds]; @@ -376,7 +375,7 @@ static int is31fl32xx_parse_dt(struct device *dev, ret = is31fl32xx_parse_child_dt(dev, child, led_data); if (ret) - goto err; + return ret; /* Detect if channel is already in use by another child */ other_led_data = is31fl32xx_find_led_data(priv, @@ -385,8 +384,7 @@ static int is31fl32xx_parse_dt(struct device *dev, dev_err(dev, "Node %pOF 'reg' conflicts with another LED\n", child); - ret = -EINVAL; - goto err; + return -EINVAL; } init_data.fwnode = of_fwnode_handle(child); @@ -396,17 +394,13 @@ static int is31fl32xx_parse_dt(struct device *dev, if (ret) { dev_err(dev, "Failed to register LED for %pOF: %d\n", child, ret); - goto err; + return ret; } priv->num_leds++; } return 0; - -err: - of_node_put(child); - return ret; } static const struct of_device_id of_is31fl32xx_match[] = {