From patchwork Fri Aug 16 15:31:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766547 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 88F80C3DA4A for ; Fri, 16 Aug 2024 15:41:14 +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=BqtNBWOnQ3Xg+u5frXQomaMjbI/CKyIXNSmcFe+MZzY=; b=eE8/SYgS62Qqjxzt+xaOL39rm8 Lc1MMtIMHTwv008AUFgQztMbykbiHqHlaOtPBmV4Sa0CMA2A6cPajLIoL9XDqwWLc9kKHEkqznFgZ 1Bk8ptpSj+x28/mWzmS6YVry3rvoFLmUItJbpMyhQyJt+Mp+C1p1jiCZwFJyW5Q1GSRi/nSprQYqa ZCKvL7qW6i6s2xJPNJKJ06XSGpuAFch0eRiHXjKI9UgopSidC3u3zMrqIjTM7F4mud+2tmow4WK4q bL077TIeDNjGVhzKoVkMXCrNXOP8wqewBhRi9aYM2I9FfWMFjJc7+LA1QndEozxKDCEMK5QjKMvoB vlgCzNHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez4X-0000000DR2N-2LZJ; Fri, 16 Aug 2024 15:41:01 +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 1seyw6-0000000DOjy-1kjH for linux-arm-kernel@bombadil.infradead.org; Fri, 16 Aug 2024 15:32:18 +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=BqtNBWOnQ3Xg+u5frXQomaMjbI/CKyIXNSmcFe+MZzY=; b=B2BCHxpREj65cEMD228JiBsDz8 344LEm1hQbzriA3RMpqTVqw7X/lnB2TT3rdK4aNSjTHQXtvkYtzGvZels8A7tzMhfAJlmAV8PX3vF /yIq/+I7cPwg40Dxb+LaFVLaHzQ4dtYW1+j6EFl/KlWAlW2Ftd/Td07TLjS+kB8ZpUBQRuHkXIjDi T+ID0iwHu/JqhcCwK0S8AVjkuOndwRoatyU162MBueXm+89OsW1MvcWkoj1q0Q6R8xT1yat8MCxX7 rGc9495cs4u2Z3G/JSjs2wcyi+cGbqjpepr9RqDFA/nHmxm94C4jit6M6KqieX6KRIHhUWJvF4t9H 1DnwW2bg==; Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyw2-00000008hXl-41yO for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:17 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4281d812d3eso21450895e9.3 for ; Fri, 16 Aug 2024 08:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822332; x=1724427132; 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=BqtNBWOnQ3Xg+u5frXQomaMjbI/CKyIXNSmcFe+MZzY=; b=naGy/6Ffv4cLPUd91ZEpHTXDHXmomVDH4NyXbackPvXfU5X5o+zs6/HmYCStQ2kRmx M9PoimAs23vRf1IdEfScUoBE/dZSmhRrHne0iuaidvI3AUXwMa2MUDZKmKTDp/+WUcN1 ao71aNdSxj0BPpzEg+VS5wtF/kRa90NmsaHAQHo5wAmyWryJJmgyKGAmeDi18hMnGwMW 7j1CUjODZDw7T2iCdyKLU5CHBYQ2kqQTzFBtUSEnt8CiXkSkcUuT5vinldFy1ttlW5Es jB/OgotYfXbddJYcVP/wRcPX8D0MPfhALsdXqtFkN8rkFk0o0O76lTv2Cq7WgP06GvQF 6LKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822332; x=1724427132; 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=BqtNBWOnQ3Xg+u5frXQomaMjbI/CKyIXNSmcFe+MZzY=; b=KxU2uu6v64M9rCP02jw4DGbiVXOIZY16CY1Xli22oNCOi2Tu++CQPAmjP+75aEHBkI /eo9rGX+XulPfxzGqngV3bJna1c5SCkaNRTCKKLBxORmRgktOxb3As7CyLOIO5Yjm/+4 3MfIowEQDYNomiFG4OpObL0+JIwCWdor1ZoTZy/vN5EEARzxRdhPl+VfEGvxRs5OM+Hh H2+RhaK2CHcNNhdpJO8DzXPN4aoS7bsvlJLKK7Vja5NVQzrqID222c4SPW5+jj73DP3f Jt/V9cYHcCdyNUz9TjywxYV1Nj8WTSbwgm39r32GlzhG1fe51t7vyBsKJMDijiGlpWgC GDvw== X-Forwarded-Encrypted: i=1; AJvYcCUVnIjEa9+oKwzB2SlCC8ReZ1Pw4+ITIwsUFbdzU3qRR+4uPrhHrVnx+Pn3tafmDCykDAOo4SZwJ2L5Rqw2hB5dS0B/iTP76fOBIArr5TpJPX1qpEU= X-Gm-Message-State: AOJu0YwFzZ3zKQACFri/ir055R8kMEdqV8bUjoZ2ZpLefVX/SFFibIv0 QOjIhUYrL/xrdwVeeMv5HtTsz0w+vkCVcqAO7SBW7VASz775TNUTAYIwYdwEHic= X-Google-Smtp-Source: AGHT+IGnK3961YuWU4oZFJTYCKl0K2mdOewbI1FmFnvK2B2BUfG+eWPO7zTzTcEARCDrYvRBocT5SA== X-Received: by 2002:adf:fe03:0:b0:368:4def:921a with SMTP id ffacd0b85a97d-3719469f891mr2605779f8f.48.1723822332005; Fri, 16 Aug 2024 08:32:12 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:11 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:44 +0200 Subject: [PATCH 12/17] leds: mt6323: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-12-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=2340; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=dbGzjAZfh7gVxRz/TIXrMdBv0rDvyB2K7+HnKJ4gJaE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Djss2TXuF8dbygBzG44V3L56XAVS0ojN1I5 q5iB2VHMQSJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w4wAKCRDBN2bmhouD 1yUUD/92B+FeoNj59qOoLdJpY0L0jdj1oyZClGW92U7HP3VT2O9z9IFmIMEsFaaI70ggtfNrrGo n3LOrAyB3l1wKms4gb+ZQSmDRYF5Aa0oupBSWPo4/aDejYD6KmRMAG6N1jQlZSmmmbDOYITeoJd pHY3KY4kK5eIJy1/HBfZ4YmW0yQp1zlOJYB+JlaPWYtOU4whCpzmVuXybd33sRRgAKutoEzPJSK QfRT7WC9b+BMO5Z5XYutvBjQszr0jXXfkJuznDkY2yYLDhZJ1aBxdW+aY/BX1re1l0S3/dD48xH xkhARVtXmtZHfioc97M9oW1CJJmzNdsK5JaE/6/hFEghYexU2cN5K8VdAx7ydXoRFJTZGwguwZq SEcdGBMuI272hkbmFHQQsXr3mScckzIePahhWqnSh+hG49AcsO6DZ4J44sD230+IsaXQYmqlmxF RJrtUXpKSFLuN9+xRUPtEkKwnxLGIzOZC2Fa571U5F71wPuGmfVZ8FMNuw430ewjLkDcmyh4Tpl knNeNMNGypnIQTo3/FXuuXkjkgg6zZdomcMYrOTE9PfDpVsGWt8O/bJeetz5k6c5H6Qc/3zFYgD MpW3r9d2aTq7KnrbfguCP3P+CA84Qd+xusPgfqTB2WQ13DGwInvp81b0AQbKe/WXO67p8qpCloV XifrHJi3R9eQxcg== 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_163215_261866_A5D38EA2 X-CRM114-Status: GOOD ( 14.28 ) 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-mt6323.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c index 40d508510823..a19e8e0b6d1b 100644 --- a/drivers/leds/leds-mt6323.c +++ b/drivers/leds/leds-mt6323.c @@ -527,7 +527,6 @@ static int mt6323_led_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev_of_node(dev); - struct device_node *child; struct mt6397_chip *hw = dev_get_drvdata(dev->parent); struct mt6323_leds *leds; struct mt6323_led *led; @@ -565,28 +564,25 @@ static int mt6323_led_probe(struct platform_device *pdev) return ret; } - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { struct led_init_data init_data = {}; bool is_wled; ret = of_property_read_u32(child, "reg", ®); if (ret) { dev_err(dev, "Failed to read led 'reg' property\n"); - goto put_child_node; + return ret; } if (reg >= max_leds || reg >= MAX_SUPPORTED_LEDS || leds->led[reg]) { dev_err(dev, "Invalid led reg %u\n", reg); - ret = -EINVAL; - goto put_child_node; + return -EINVAL; } led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); - if (!led) { - ret = -ENOMEM; - goto put_child_node; - } + if (!led) + return -ENOMEM; is_wled = of_property_read_bool(child, "mediatek,is-wled"); @@ -612,7 +608,7 @@ static int mt6323_led_probe(struct platform_device *pdev) if (ret < 0) { dev_err(leds->dev, "Failed to LED set default from devicetree\n"); - goto put_child_node; + return ret; } init_data.fwnode = of_fwnode_handle(child); @@ -621,15 +617,11 @@ static int mt6323_led_probe(struct platform_device *pdev) &init_data); if (ret) { dev_err(dev, "Failed to register LED: %d\n", ret); - goto put_child_node; + return ret; } } return 0; - -put_child_node: - of_node_put(child); - return ret; } static void mt6323_led_remove(struct platform_device *pdev)