From patchwork Fri Aug 16 15:31:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766561 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 A27E9C531DC for ; Fri, 16 Aug 2024 15:41:50 +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=82u0aLxCOMmAENgy1g3HMnv8Q8OUR/q6nxVGVYKir68=; b=vLHJL33SCTyb9PP5SpEwD0QjBD 54BUJLu9xdrX0bCJYiAnh+31w1jkZtPYQlIWEag4ZJwSj59qEh3b8Am7mlkbKSYIxGaqL2N9CjU89 NFIVIhfVAaPdJ4riEZUJSOficqUJH3l1di2q2l1Us+tpbmuMS/4JC2/P2nzvAQiVGUNTHuUhCV1dL cVnNWzWqiA13o1R/O7aZMpz5HFjFfvMySEaY8F7U3ry4il7NWo10Ar00jpjbOhgiqwfj/UfKD2s3X tsj9HjbnTkv5Ja+/IS1e7PoR8JtLfCu9dNAxiMzdNua8+MJFfxpfNHeZAO0v/VmYBZXRL0PT6sBKP Uuc7CssQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez5A-0000000DR7S-2AZl; Fri, 16 Aug 2024 15:41:40 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyw5-0000000DOjO-25jZ for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:18 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-429ec9f2155so9466265e9.2 for ; Fri, 16 Aug 2024 08:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822336; x=1724427136; 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=82u0aLxCOMmAENgy1g3HMnv8Q8OUR/q6nxVGVYKir68=; b=wfta9OA8qfKM5UXu0Oq3k7QH/UcoOyJV5sdHBNasy37cAyfVOQ3foMPV5ReaOmFFWz mLA3hMHkRoeBvzuJ+kFBbINAY7WbdJMI6GiS84MU/ZSfLQkxwxCIBj1ZjHdbk8CyHRhs 6mSm7TR+Pde9nKuImuDHm6cQ8FAKptghLde/uEusnTe7zmNCR0TYWHhRnK1qFQKNsrbF wRjZXS0O0Dcav+nHbKCwhVur3pPOaO7Rin6g8V5EoDhHJJ6oGB1ljfB6Xah1Kws9xHNy LXXVScZCQYAqAizL8PmNLoSpTDCT1jS1nIq/JbLA8SUSG1riHTa4eZTirM3s7s8P5DyG rLmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822336; x=1724427136; 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=82u0aLxCOMmAENgy1g3HMnv8Q8OUR/q6nxVGVYKir68=; b=SdU8y834aZZblo3os54GJns3JZRQcHiFZ0+CnPuTV3VEV7G2fYWhxCUaA/vBYmCbF1 pamiLl+THn+7GZyflfXAIeFceNN1rf4g6cI9gcIxYjVFZL4P8zsK1mfxpK3fk8eoHO4T SM6DS2X8QaDMBRHhaK3nP5YGRHY9E1bG1I1bXjCfDfSc1L7qc6wYyZ6S0iElK76a6mUm AiMh1Enaoi5GhlgWU7LstUjrxm4UcvFcVZwQI8rP+FutI94lYuQNh8hVaBS5UvgeMgbN wwvAF1zpb3qvm/5PiR9lwDwCkBwDcUf6QiRYMy9SXc4GztI7ElvQf6cecYwPuMYEii7J EnHg== X-Forwarded-Encrypted: i=1; AJvYcCXRoiFgGQI0t05uyf9Zf81klnZjiVzsDHcfFlX4tsweQrhR7CEUjeLvRqSIxCCGPzBOtUIcNtqkgqSSe2gHjn+M@lists.infradead.org X-Gm-Message-State: AOJu0Yw8Xfl17jjO7RxNpjanmaZu7KZ/Xdp/VryJAKqXJXZdq2coccd7 irEkjsRT5HPBpw8xMOoSK9jVsdP/sPisw4hppYiIQQ6LpYLAh6BMSyH4CH2sgDc= X-Google-Smtp-Source: AGHT+IFoty7tTAPOCyav/M+yMTn7h/aGTkjK2dWYaVz5fLcCWS//Y230cKvMHPE242A86aP9/IgluA== X-Received: by 2002:a05:600c:46cf:b0:426:64f4:7793 with SMTP id 5b1f17b1804b1-429ed7af3d8mr25468635e9.22.1723822336156; Fri, 16 Aug 2024 08:32:16 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:15 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:47 +0200 Subject: [PATCH 15/17] leds: sc27xx: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-15-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=1485; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=P/bMkN6MpG1hpAYn2CS2V4doNmtsHBv2dg+qwQSz6uY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Dm8noI8EzoG5LCskKgbLFVnnrv1PYZVipeX tFmNsyKbeGJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w5gAKCRDBN2bmhouD 180EEACar4IcrZlsd3xk9bIpi0NxSlkXiLAuI8nxmW6mz+cNcfhPQWr4juEKIKU8SWq8Bcjuz0A RA0/Qwpgh/ThAWVSamp8X55go6COy9pVnFY/WIozfcjxLDmnjQc2rNa03f5aknsPajDOz2WoySW vV/UYxxrb2GFPccA/TJERMXE5GeOfqMzjLmOmv2GvpLO6MLT77aVmgva9B55Rg8FG2SyQx0J7pE Lo3Sb5LhsPgASPhBfGo1CNKh/s7c0mO4IhaZIY9gT/M+cJ3k5+2F+tBX95He9It9KNZkpBRh8mF qMOxPToh9G+2XWQbtx7/6RT1NWgXf0xEbwhed0/huc3VhD3QRluxkKuxaUuWrVlS+mRbjiCqm4z pKWcD56pWCpwCxStIm4WVykqOfcDFy7YZTDuSt3s5rxPTEkWutlE/sag3C3XQ8DXw76QWs8k3YE Aj5VT+19zWwY9Gsa7lvRt/KKMZpWgL2FZA+YPZHGspCt0j2sSimeiy3R0rUMnY7U+yVbXXAy1R7 ely/fkQQKsGD6yfysPNqnHAvqiH4vxarsInC0k7iVnm8T8hj1Kd+axD2KUF+Ap1hUF8wvNRJY9O +8lEqFLj2LocXZuxPu+xEX1QvniXbD8I0kYayTZoa+jVonEkM36vST9pM1G2uzlrWhIDTSKn7S7 mTyIm3ENeFrPMCA== 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_083217_573860_E01353D9 X-CRM114-Status: GOOD ( 13.43 ) 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-sc27xx-bltc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/leds/leds-sc27xx-bltc.c b/drivers/leds/leds-sc27xx-bltc.c index f04db793e8d6..cca98c644aa6 100644 --- a/drivers/leds/leds-sc27xx-bltc.c +++ b/drivers/leds/leds-sc27xx-bltc.c @@ -276,7 +276,7 @@ static int sc27xx_led_register(struct device *dev, struct sc27xx_led_priv *priv) static int sc27xx_led_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *np = dev_of_node(dev), *child; + struct device_node *np = dev_of_node(dev); struct sc27xx_led_priv *priv; u32 base, count, reg; int err; @@ -304,17 +304,13 @@ static int sc27xx_led_probe(struct platform_device *pdev) return err; } - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { err = of_property_read_u32(child, "reg", ®); - if (err) { - of_node_put(child); + if (err) return err; - } - if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) { - of_node_put(child); + if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) return -EINVAL; - } priv->leds[reg].fwnode = of_fwnode_handle(child); priv->leds[reg].active = true;