From patchwork Fri Aug 16 15:31:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766527 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 21C54C531DC for ; Fri, 16 Aug 2024 15:33:32 +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=Bs19CWciVe69z8rsWTOPtucmozrfgqJROhrJ589EkVY=; b=ag8y9aZzQm/86H3wmoitFWMz5z xddqH3Zn/Lsx40ZWSUNvC3+Sz/wykPWPBsWhnZjDWTBbCsmvuGcRDF/IhE73zmVar8VX8vsnvWTsI OPKAlZhqFLzI0YPzKrOq29+YpYFELT1BvwA7Q/M4NuLE1U76apKsmYGLGDlZmXS3HoHBba8FC6lXB Wi/+rHRAHjYYDM0nZvyyRjm1NfzPK/vW3bpIAMj8Yw20pAGo1+tE68O4VETEvqfHO2Dm+XRcr2T5p WQT5lrlrOdqtgn64OFei5nrmGRjTS6qO67+ofFITSzLaqZg3EcPmYi/gSiYE19c8vn2RMsnjJqUjA i88OeWzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyx7-0000000DP6r-3Wbf; Fri, 16 Aug 2024 15:33:21 +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 1seyvl-0000000DOW7-2QYa for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:31:58 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4280bca3960so16663325e9.3 for ; Fri, 16 Aug 2024 08:31:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822316; x=1724427116; 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=Bs19CWciVe69z8rsWTOPtucmozrfgqJROhrJ589EkVY=; b=AkkkoqfeqT1ERqsnPnQR1OtDFgHglGT10JPdyuCz0vnVa5Xlm3d7fCsEjJmict0xYH 6Ww+KuGhY4uuoOeFnoqjsYnM6bNldi86o84yn3dchICD6RYxRGJ+5ixAA76KeTcsdQum N9HSae++2ZiorMSECFUEacUbb9Q1IPuljHL2Z6BxHjqR++orRGAr7jTOpktThL7Lnkl+ YSv/ZUDMWxdclJVRYp4kQNGtdbF6oTdcWn6AM1Ekl3Vgk1ctL0aWFSB/vv1NIvWax9cp pKuVLX5iw6f1FUWGpnAgcwgcbOewXpa/1XyYYteGa89X6ncY4R4MWKLPnDxA75eZMJym S14A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822316; x=1724427116; 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=Bs19CWciVe69z8rsWTOPtucmozrfgqJROhrJ589EkVY=; b=ZuoEknw2Zl2i7nYOwGw2tx9IMs4uPSoK9zRHmQHyar2am9AiSyo2tY6XrLOAjQrflx 5je9/nV2V4y2pYVu+sgQko19bLUOP6zS8btETfc48ZtSxbc+Kr6qAm5BySfQvUXMV+mt h/+dPyzFBz6jBWAoxiYHUBUb6enENo9eFfC5yfqGmpf30Q9KLVcHIdT9lIdMPSYmpIFe Vh2Nyx3iAkT2fGIfC/h6ANZ4vbZp0aaaQe6IaKDPLUm9LJZ1GkT1fKdO9qvl8MztkCyQ oV9jLaT13WVol/KYUehL8hdCPH6W9L3vjhYEryEXwW0N68ZpHlRT57pqt6M9FrGoqJ6n Mblg== X-Forwarded-Encrypted: i=1; AJvYcCVgx0iPHZ79yA6ssn+P62j5JG62HNwiA+d0jSWoYiGxLpVo2jbIdhJ2kcweMCwoshHvmjcf8dreI/Wxer+c25UDqDQxCpSPsPnCgpgKsVNX4nQ0vRc= X-Gm-Message-State: AOJu0YwHHPKGmy+czeKG3YCU2TKl8Lr1/tqiR+3yNxoK7yd/PDPcSeZ7 z9HPfdP3deboC6pyVrALXhOsIXb+dBCpcNVJ6eBtOIy5P8/z8PzQeypy7cm2x9o= X-Google-Smtp-Source: AGHT+IGR3dEEF3paPLhCSZQYsm1dXDhlnka2LZPKsFs9HlMVLbvtSAJs2IkTJafZE9YHaH92MT5WjA== X-Received: by 2002:a05:600c:4fd1:b0:426:6353:4b7c with SMTP id 5b1f17b1804b1-429ed7855f7mr22773225e9.8.1723822315663; Fri, 16 Aug 2024 08:31:55 -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.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:31:55 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:33 +0200 Subject: [PATCH 01/17] leds: aat1290: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-1-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=2066; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=a1YGQS8jzBzLcYjwPx4kf8irSYV8QsT8hVGiKzaSR0k=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DZOpqtaUv4QAkOdHVd+6wkSZBmNTro/fzvY CO/ZnU/HP+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w2QAKCRDBN2bmhouD 18eeD/44UH0sp3C6aYfp1LBephrs+liKt3nfnjZdWSJ0v/TieMbxVM6d4zS9ydJ5ky9FnYwB/bn /67+vER0yxMdbgcdPdnq+7RJo3bpW2eqChHfkD1gR59G6Ochw7Zhoue60ljd9KsBK2RPJ9+7Dd+ Bk0oHl3jNMvbjNIfNBaqvnSCmvazbnZi2n1JrGvRuuhOSF6/oY0hlzCzYJj6U3J5JLoUHo/RvEv xIDgNvQXD1Ul8c2AhudnTWUCCXGpw5bwLleLXZNh6r77KiudcrQ+wHjc+3AyB5100d/IDZV9pLz T5KFT9Qqgr1UnhKUPqvmz/9zaqtUAp1yqWgIyE6dCiKKs5ll1ljE/4lx04RwwH7gIhPAUDp19um 23NJqm8wECy/46SyyMgwAsCkV2PlLcjsTWknCQUnZKJlQawsbb/R6DYLt0NlwpkK5q+B5uh4cl7 kq4UnvALsghb7p84K1nYZ43IKYhaeH0AvYe7Q0nL3rFlNOTwi0+nCoCC8v9EleQ4sNat1X3RRxR Bu8JX6oRfVsvIDPeQ1hzmdLHAmva4nLqWQQ3yEu8cwGljT1m2fYTuEzrn7BQnFKV/xC5rID1TqV vbAdvyBu4MsxqHL8865ARm42fwwkprl2/gxxZdxmhDNYDD0KmvvJ3WQ0qiDzJATfz6/2/NPYVWP V56tjRRvGbYMRoQ== 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_083157_657989_EDDBFDB5 X-CRM114-Status: GOOD ( 13.93 ) 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 Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/leds/flash/leds-aat1290.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/leds/flash/leds-aat1290.c b/drivers/leds/flash/leds-aat1290.c index e8f9dd293592..c7b6a1f01288 100644 --- a/drivers/leds/flash/leds-aat1290.c +++ b/drivers/leds/flash/leds-aat1290.c @@ -7,6 +7,7 @@ * Author: Jacek Anaszewski */ +#include #include #include #include @@ -215,7 +216,6 @@ static int aat1290_led_parse_dt(struct aat1290_led *led, struct device_node **sub_node) { struct device *dev = &led->pdev->dev; - struct device_node *child_node; #if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS) struct pinctrl *pinctrl; #endif @@ -246,7 +246,8 @@ static int aat1290_led_parse_dt(struct aat1290_led *led, } #endif - child_node = of_get_next_available_child(dev_of_node(dev), NULL); + struct device_node *child_node __free(device_node) = + of_get_next_available_child(dev_of_node(dev), NULL); if (!child_node) { dev_err(dev, "No DT child node found for connected LED.\n"); return -EINVAL; @@ -267,7 +268,7 @@ static int aat1290_led_parse_dt(struct aat1290_led *led, if (ret < 0) { dev_err(dev, "flash-max-microamp DT property missing\n"); - goto err_parse_dt; + return ret; } ret = of_property_read_u32(child_node, "flash-max-timeout-us", @@ -275,15 +276,12 @@ static int aat1290_led_parse_dt(struct aat1290_led *led, if (ret < 0) { dev_err(dev, "flash-max-timeout-us DT property missing\n"); - goto err_parse_dt; + return ret; } *sub_node = child_node; -err_parse_dt: - of_node_put(child_node); - - return ret; + return 0; } static void aat1290_led_validate_mm_current(struct aat1290_led *led, From patchwork Fri Aug 16 15:31:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766528 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 5A73EC3DA4A for ; Fri, 16 Aug 2024 15:34:13 +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=4sCEiKf2B9DqzQ8Bb94EFqGzHc8DX0w0QdFuF8Rhqn4=; b=VM0aKh/dtyF9iL/xRgRjyx/XYb hjG9VCQlVEMAP7ku/8M/ZL18cQ8tlYcAaAgdTLWmIy1JS6OdyDicsiccUSoITm4exZrRH03cJq++S yCy+maPogro09I/qaKL2E5ebVRC2MJcnTSPe9G/TDqu6h5cmwmz5vJe4pFbjc5s76ZFyaCnVxH6pC VlMW3yNrF5doJfD5M33TQfJprUYK7D4xkIndRJrUp55oQRH0ZGXlowdIRQqQ2fBrPw+uNvcM6KNmG WOyNWzjaKasKO2/Y/fISXepqWUskAT1MEqIMk06IKZXNgTsWG0Wi5gCcl8Wq64PU4nf03thcHwiBJ 3rHSpeLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyxk-0000000DPKe-414l; Fri, 16 Aug 2024 15:34:00 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyvm-0000000DOWf-3Lu8 for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:00 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4280c55e488so11223065e9.0 for ; Fri, 16 Aug 2024 08:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822317; x=1724427117; 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=4sCEiKf2B9DqzQ8Bb94EFqGzHc8DX0w0QdFuF8Rhqn4=; b=qNKAaI8wq/Mwx8mO5q51juTq5uHMGTqcmBIaKh3KN9C5QYkPvq05JzEi5CiIz+6hAM aNfDGZz4NYDV5T46bYMp1Sum+W/51glu1sk7lzWAyahmhDyrm7bMn5dC4Utbvxk9DbFB AOwx3B5SoEj9GFb3AAuQ7mMVVjtKGMcmPftWR/3wlIlF7WUUcEcYBeo4/fl95uQ1aPn6 txpKR7Pwp75JcCCSuMy3q/rN0xooFK8Apjlxlb6rEeir7GFE/oy2yd2eBif1w5nw6oLF klfMboptuwfrt74xMhnHpqZbVGN634eWFA6/XnV/JDysRA1zMAdanXX3Y0V5m6elRJlS I7rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822317; x=1724427117; 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=4sCEiKf2B9DqzQ8Bb94EFqGzHc8DX0w0QdFuF8Rhqn4=; b=MNk5f7dFUjdmELUzovzJNy2clvXMyKJyYeWugAOCk34LRQ3quG97zfLwVZ4yIoUmID lu47J4UzAEYhWeARtwZtotg8Ne9Vz/Q7l4KtgIXy9IyuVvYipNu32XoL3t4hXrq3KcYt GJyQ7AKifuFJSVfle3k2GAR0GNvI0+lx/1bHaTCnpfHEtFIhC8HZSSaOGu5LJKtx0YQO gWZ3RmlVA9b9ZbH8l+heqcAn2kliX/rGw2aOc+ifzsIrnsKHdQhW2sMpJphwQVdocJia CjcIhbAgsXE/mCerT4RGmsEOYydS+jhKAy9V/kNQn7JUzDqzwHIsgKzjTS5xxlPuGte/ iK3w== X-Forwarded-Encrypted: i=1; AJvYcCWkaXce8tdaKfS0jXu/TeKu0GDpmYo+69386d/J2Xdh3LMjnzM0Af9O45MpcYsv7g0U3WzqmsjrXjKAnNSuklKfvMPu3PA9cZyhCu2VnA1q7BXQs10= X-Gm-Message-State: AOJu0YxZogTKgJiQ5YfZAjircLYu3UWYCD/QQ399rpAmPvqWEUp+s/dP y08O8xpzM0qJ9rJLLEPjoiP1mX5lSOSGjOLcKzVfZmsvTK+INuLfq/9gVtgTeL8= X-Google-Smtp-Source: AGHT+IHyXrDHQQ8xvlWiTDWTVoEhaAwJIa4Z1GZboPifzHF1ML55V2Wee10MVI+0W3m/5b6OJzB4SQ== X-Received: by 2002:a05:600c:1909:b0:427:ee01:ebf0 with SMTP id 5b1f17b1804b1-429e232c0e2mr51862515e9.8.1723822317254; Fri, 16 Aug 2024 08:31:57 -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.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:31:56 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:34 +0200 Subject: [PATCH 02/17] leds: ktd2692: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-2-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=2165; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=9Die7rsR0B6JZR+OB5IykGhnUTGNXFPzBPfH+JonqpE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DaAzLdZslDk0FQE8r1wjsl32N1ooly3he/+ EvtSvhfqEaJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w2gAKCRDBN2bmhouD 17GeEACO5DbF3CFK0Jm/yLGicXuoliag3DYz7K6gsIaFii1FHbBFpZHVfrfgWYFVJ8CYd37v68w soy0nF1zPooHW/VDuHGHdPQM+JHUmVqvUunZEIc6hxiP2ega264eB3t/cyXxpJyTy8EvxTvH2S8 RLZm6GSGQmTFb9b8tFr9kTeC0FPg7i9FJRzkCCEnlXJsRplK/CW/sk/c0+7xsTXgWn1+cHnB/z4 1nWHl/IamnG7It/5//a4DlRR+8XeAL4iQLc5liQIgR8ab1IjKSuVly/W2f3FPjckkMMVIAiP0NY lXZuuMD4Xg/spf/HqwoTG9qlMAo2UDELs19WB5qozuKnq/OLe9OJzUV/t5gEjEOKr7Kf6HnP4NP pPGUQwe9j9k1bsE36op0VjHzY6nDR1vZDxTvmO6sJeGeptqHCWQtkQoXncP0hdgHEy+YiO9j7Sf MyH6enXPvNslJ+WiY6GLycxqvWbCVG/y7jOtjlzW9Nl3UNHbPuh7ZVt+C8GZ5DfJxPZVUHZ4yxU JI6xexzf69WgGGMsrLOmRbNZeopiDlAirPTz/tKiocePbzX73jydUexldAE2IPUgDYT0hjPcWpk yk5iGPgYLagzljdrUiIib+oUnd6ApXqoYlXT8TLGe1VdfmbbssaXp6dH/f3iRB+T0u79f23A33U ex5HyA/XSxDiKpw== 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_083158_848756_4D1274E6 X-CRM114-Status: GOOD ( 13.55 ) 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 Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/leds/flash/leds-ktd2692.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/leds/flash/leds-ktd2692.c b/drivers/leds/flash/leds-ktd2692.c index 7bb0aa2753e3..16a01a200c0b 100644 --- a/drivers/leds/flash/leds-ktd2692.c +++ b/drivers/leds/flash/leds-ktd2692.c @@ -6,6 +6,7 @@ * Ingi Kim */ +#include #include #include #include @@ -208,7 +209,6 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, struct ktd2692_led_config_data *cfg) { struct device_node *np = dev_of_node(dev); - struct device_node *child_node; int ret; if (!np) @@ -239,7 +239,8 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, } } - child_node = of_get_next_available_child(np, NULL); + struct device_node *child_node __free(device_node) = + of_get_next_available_child(np, NULL); if (!child_node) { dev_err(dev, "No DT child node found for connected LED.\n"); return -EINVAL; @@ -252,26 +253,24 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, &cfg->movie_max_microamp); if (ret) { dev_err(dev, "failed to parse led-max-microamp\n"); - goto err_parse_dt; + return ret; } ret = of_property_read_u32(child_node, "flash-max-microamp", &cfg->flash_max_microamp); if (ret) { dev_err(dev, "failed to parse flash-max-microamp\n"); - goto err_parse_dt; + return ret; } ret = of_property_read_u32(child_node, "flash-max-timeout-us", &cfg->flash_max_timeout); if (ret) { dev_err(dev, "failed to parse flash-max-timeout-us\n"); - goto err_parse_dt; + return ret; } -err_parse_dt: - of_node_put(child_node); - return ret; + return 0; } static const struct led_flash_ops flash_ops = { From patchwork Fri Aug 16 15:31:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766529 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 29A2AC531DC for ; Fri, 16 Aug 2024 15:34: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=CMXjCi1nWSGJw2HEGXaKpvGQBWqmSFyvM6Rv3lJzOnk=; b=H4K3TA2NHMYMoREsAudBAUGIyG bog/gUdR44CYSjjX7fQ3O6aEaX/y8HRwmuomKR181HE81gGzw8W5WvhcTSA67moXrxeYYPMc7hZtU mW91pOjsVwr4E51HrznRcriDPHDj6rGA4q+5AaFgPX16NA8Z1SepoIX/ASHprDgqGEsQvxSbaitZE XREGHe9t29PwkwT83cIZ3U68bnoig2F8cAsmI7SdmTI5w4fduTsUq07eDQnjmqgqhHHgqpyr9uE4R 1M2UMSnU/U2O3o+zmStgvPIuxQkPEEdL/wKKvhlnnHrrqYPAfJkX0R18O8xW5Pqq+ZZ8c4IlQZWf0 4W8bCbig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyyO-0000000DPVR-2QUh; Fri, 16 Aug 2024 15:34:40 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyvp-0000000DOXs-1hDx for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:03 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4280bca3960so16663755e9.3 for ; Fri, 16 Aug 2024 08:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822319; x=1724427119; 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=CMXjCi1nWSGJw2HEGXaKpvGQBWqmSFyvM6Rv3lJzOnk=; b=FiCc1Uw08r3i8LRMgAxi4De0foD9OfCmRiW+Fs9mk/j3Psl43RBXZWVRRygxB3koC5 R7mkbP40NBnXDXC4MWqANJxnTGt5tXdGUVI1NFBWE/K6opyKmXO+bzntghsCrRJ8wSUU 5fW11VQr+F02Un4nBh7gEkIWYi1OsXNwrpSJu5wHqd9eeaL8ppHO+uZYiJwgzoAN49iS EAywutjWgh/Yhqu0qUbKreB6MFIK7/PCxJ5ttmqxKH/bobjcnxun7ul9lg+xjpgqgRSN ItI6A0FQjCYpx1W/ukkWRf4/0jdnMKD9mJQQorU5C6seLlf2DnrRnQ2DCmXmjxbTVfjN hFvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822319; x=1724427119; 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=CMXjCi1nWSGJw2HEGXaKpvGQBWqmSFyvM6Rv3lJzOnk=; b=D6BII0bFzLdyhPMiexQupsImGOlE7pgfQ/Srl3v3ioku9bdIHbeocE308Glk64iMsj 7Y3qGqGdQ0lYYvRQqqHdGMTBW5YpaZmylCkaZpUmxxeIRzACy5hD0n0d7d+R3TZ2gQhO 1G8+I7BG8Tjud4qOgfLlp50Iu48+j9L/tOtQxDdeveE9D+tysYDX8o5+x26vHA1TZiQb dFllzyYVmA6XGkl3wwKiARqpupSTFGtomI0J8EDiblXeS0YKE38BBODZmTJ/BUNzq2DM Np2xAe1SWXYub6Wg7mAbnFz1yBxszEGtx6ElXESOJIVxNkx0EbbEqNFJOtQYDqCOozeA lrWw== X-Forwarded-Encrypted: i=1; AJvYcCVy59VBZcUMj6+er7jxe9OcFcXyMuB1cbcJAs3ug2rtfIFLyoLQ737ASKDQYD3n2DiPID1h+OWt0HFf1bn3EJfhWCxrlDHZTUUeZwgmsSqsipyBRYg= X-Gm-Message-State: AOJu0YzXsbQpoxMsGKnGnMUunkslXBN9Yqu7dfXd2ptY2WmroEVAiHPZ X4jEmRvYCJSKv3fIWnp4QLKYH/9TedSD+FmdxALooRCyLkbFt13EChyoG+ZCjAI= X-Google-Smtp-Source: AGHT+IHQVp9RMVKnFXRmolzPy8dcbt7NmXN/jroL6chg+fDJWYg7uMIzfeBfP3NPtNgAOQVI5RxN+w== X-Received: by 2002:a05:600c:1987:b0:428:9ba:39f with SMTP id 5b1f17b1804b1-429ed79e212mr21385555e9.11.1723822318959; Fri, 16 Aug 2024 08:31:58 -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.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:31:58 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:35 +0200 Subject: [PATCH 03/17] leds: max77693: add missing of_node_get for probe duration MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-3-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=1838; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=5KMyb/0ghZiWoNxxGIN0+j8uXXpKKlWx7oozmJ4CEcs=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DbVDkrgpNCWbqNPXUp9YCFjKcR3EI+TV8pk PJEmPek6O2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w2wAKCRDBN2bmhouD 16uRD/9jJHb7kLUKzwpJD2ZWds7O67ALfXb3ZP6DUa7effzfaE+ihgB7WVZpKDFSz4Ynnq+GhzC SD7hYFMiD1dlIU45EiowQ6w17hk6OGGckkc4oS5UDLJHqO38ddcLxZMtxjHDGR8DPAIRHYRRSCV aeJF3qb6rx4DHfiGx+7HuYGQahBxc5wQO7aUmpD+tKb30AdRIIpxWoRL34DC3QyNlAkpBwXC34u S8wYpbf1rQQxBswNLYYVojtvNJmVa+/7G4urNcX3L2t5N9Ocz78wJ2KXKaJ6PmByMd996E0Wi2c zM3+rJPt//QRSatrCP+YBcu9vxG86z9Ssu+7kV3vDNkYop/8zteJ8ZUPHPgVNxvBuFt0JLzL8QR 39T+Se5p7DgKy2U7tH/cp8FZ8cwH87/8uXrGiwhgi5r6tn9THegbdFj1ZwKt6Q4phJpPKJxglY6 bWKZfin1lyWgHMxA++9MV8mY7GtZ+lh8kRrvMJWq+Y9eva4qZJlXBk9O+Fu6OLzi+fHGL65R2LX JTUkAzxdPa/proprkZCnXopEdTizjxhet3j0QeFnBB5lAtMSuUttFIZKMxZg0OE96gq4JtVmGMy 56lHesBi9ptFlDGB2uRlD2OAXJ0+NmuyD0GOY548/WByuED2YjR12ECGeD4jD7KlanlFHSgqIAE FqnXEfx8WMfK5ig== 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_083201_697400_D88406A3 X-CRM114-Status: GOOD ( 14.69 ) 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 At beginning of probe() function, the driver iterates over OF children and assigns found device node for later. The code uses for_each_available_child_of_node() which drops the references on children on each successful pass, thus the probe function operates later on the device node without holding the reference. Fix this by increasing the reference count for found child node and drop it at the end of the probe, because it is not needed further (the V4L init code takes its own references). Signed-off-by: Krzysztof Kozlowski --- drivers/leds/flash/leds-max77693.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/leds/flash/leds-max77693.c b/drivers/leds/flash/leds-max77693.c index 9f016b851193..16b169e658de 100644 --- a/drivers/leds/flash/leds-max77693.c +++ b/drivers/leds/flash/leds-max77693.c @@ -649,7 +649,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, return -EINVAL; } - sub_nodes[fled_id] = child_node; + sub_nodes[fled_id] = of_node_get(child_node); sub_leds[fled_id].fled_id = fled_id; cfg->label[fled_id] = @@ -968,7 +968,7 @@ static int max77693_led_probe(struct platform_device *pdev) ret = max77693_setup(led, &led_cfg); if (ret < 0) - return ret; + goto err_setup; mutex_init(&led->lock); @@ -1000,6 +1000,8 @@ static int max77693_led_probe(struct platform_device *pdev) else goto err_register_led1; } + of_node_put(sub_nodes[i]); + sub_nodes[i] = NULL; } return 0; @@ -1013,6 +1015,9 @@ static int max77693_led_probe(struct platform_device *pdev) err_register_led1: mutex_destroy(&led->lock); +err_setup: + for (i = FLED1; i <= FLED2; i++) + of_node_put(sub_nodes[i]); return ret; } From patchwork Fri Aug 16 15:31:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766657 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 5AAEEC531DC for ; Fri, 16 Aug 2024 16:46:28 +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=JmSp/tI6/cAsvRbhfMHRpQD46ohRd+mOrBdZEg+M/0c=; b=0ZNZTqFuKyg5T3M9Oh5SFpQyHQ Z3yuCbkuqAfO3o01dyYBVRuLIcJBYaMQcqrcwZ4ve4W/vPkvABW2XHO/1OoBk1KGOk/qui+D22BBr QmvRqXg/i535twx2O4HQ8hiCiWUZ0vo8nE/JxEl63krCuM1+/AMmQ46pYib3gfxS1mM1b0HW8IFBT gm8DmG6/aSHBkai0pnjNFidOTn5IW68JBTexjSEJHhQE+xiU4FbQqskd2xy6iQEjqOcRIuGz/AEm9 imLX2Yl8B9cT3X1+aevqkwzKRKJfz3qC0OwG9WN8gcHYMRhgab0fBd9/2BU6daYi1CSwNvRsaBFzd jenH82lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sf05g-0000000Dcbx-2Se7; Fri, 16 Aug 2024 16:46:16 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyvq-0000000DOYK-2tMB for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:04 +0000 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3687ea0521cso1355170f8f.1 for ; Fri, 16 Aug 2024 08:32:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822320; x=1724427120; 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=JmSp/tI6/cAsvRbhfMHRpQD46ohRd+mOrBdZEg+M/0c=; b=Ed22lDrTxO1eZ9POux8kq6GpyGJ+0rAWKqd33KNKwKICv4JVLaPU+FlapRixzkNhmR zqaomoh4UH7KD11YovfFdqWY8FQ+yDqsgAj17yt3wsLpC2KgakgAypqNqLe6nGJOZUeI GnNBrlEo3uuGTwRDkvnr43FyMiHgQG83s6Av3gZWLc8iftdGsOG/ONYNDpz5Hox/Cwnn JAtB6+D5EL+ugXbYEFQ0YQLFyJIPtCJN147ROH3o+n0vj63g8Ubx9ZmXkbGSYckFx3rN aJt1s7srekWCS56lPWdRRy4nUyVR5Kywbh2FXsA3bw2Nh/STVRFCS0tfLamo4mIo5AOs exSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822320; x=1724427120; 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=JmSp/tI6/cAsvRbhfMHRpQD46ohRd+mOrBdZEg+M/0c=; b=bfxKKUBU6Gtmvcwk83fkF9yilZigm42x/csvRuxW3mFPFUD7vAnMBJ8gu8dxbRdCoO Isminbzk2AfD4pBBn6hSR1OLhgAxIQ4yyYMZU7BcVldK7OtQ/XpJBPxBSNqexizFH0L3 59ndO9IydgI4SwDxUrM75jU1YUwONZRKuHLUJAaYtCJEl3Bto0TyTn+tEuK8XJnhqZtH cJU1+qGUZdJ8FH3sAtZO3J8zgYTYlD01GVULi7Pt9MiHWQ6+B5wby5c/6+svt9E4T9vN V9hVPntYfC9h+A/rnb4kR+BY9FUHvEZqWVthAViSPBg5DJcETeulZvrcSQ+VLICEANRn 3zDQ== X-Forwarded-Encrypted: i=1; AJvYcCVWbA3HlXcpO7CKHxIUL8VTjYmpUR+KDvxOh41btFhMeD8SyfixCnvU0xxUE+Vc/XCV14nIy3QECrp+Jsp//31VxXapUZo6n54akuOXYAnDzTJUqns= X-Gm-Message-State: AOJu0YyNscmQPilrVjnnShPolikJecSwKHwbUeeil7WBRlBKi750t3Sk +yxhmR7PFCPmLzdKv57rnlePXJugfey1XBcCFueeBbu8luKarBJszvpG7E3EyRE= X-Google-Smtp-Source: AGHT+IENvgflPrCRLHnfFtaGxKPmZxIFqASabhejGrvVmiQr8wKujrxn8UdnFq1rYdKsHedXwj+CoA== X-Received: by 2002:adf:a443:0:b0:368:7f8f:ca68 with SMTP id ffacd0b85a97d-3719464e70fmr2963005f8f.30.1723822320474; Fri, 16 Aug 2024 08:32:00 -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.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:00 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:36 +0200 Subject: [PATCH 04/17] leds: max77693: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-4-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=2297; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=haphcDVabNY+m5Vrc9+jwTzdz2gW4B9j++QCcBv7uus=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DcFsjEVoUNxcpg4fNpAtVDyd+JTLcgwo8Hw k/LlBeAdrSJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w3AAKCRDBN2bmhouD 17zkD/0b5uHnjnzjPvy7kRfLttY9Q5sWPLsfyEq6CLUzPTCBewXF8K27CAlQIluNVr9MosDCghO U7QGtLk8uSvJj9KQ02Yig2QWAcy/s5wRX+ONqPYRue6VOXglHUB0PaP/hurfyKbriRaOUyg3bm3 Ffad+VfZ46D5xsiEVre/lHkn2amNZE4K2cYDi73IjaGDH4+rdGn/xY4GWlBlA0sDiFaaZbq9mE9 1bHtk3cykDUdm2ykX4X+1ycApN5D9e0drHjadREgiSLjd8NQmMWPwb9yroUwjZSfEPsFZzXEiGH ESatJmodVxi+VpuKSU6tN+pn36jp7Uvo8oJLg2ciIqkhH7l/8f26PToam8oq0III9BmKa7K+WE2 SA2i561NmARvZKIb7ov2/YXtvUFPzgn/7ENHvP3gnz3QrvNmc6UPPaGIWeENQnPPlEqh9VDOciQ GtOI3WZtohFdCug3984yJMuJtGZ2lScEuevzxO0cF2t1KI8+qhrQ4yog1t0e/OS5HQT8Iz4fa8g XzXe3ZIxRQQ4cV9Dazp74uPSEkMMyN8EKzdftcVEuL48b9NbqZBencwcIcjhkt6pPpRXBMgLvu4 weZ7WS3MKriAVqcl2tPp4IjWatK/agobg3xKELYxOlZDdKiHQJc6uUI665Mi9MamHNKIXUMmcyo ejGSHUPPEivrccw== 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_083202_781081_0753E89B X-CRM114-Status: GOOD ( 12.78 ) 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/flash/leds-max77693.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/leds/flash/leds-max77693.c b/drivers/leds/flash/leds-max77693.c index 16b169e658de..90d78b3d22f8 100644 --- a/drivers/leds/flash/leds-max77693.c +++ b/drivers/leds/flash/leds-max77693.c @@ -599,7 +599,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, { struct device *dev = &led->pdev->dev; struct max77693_sub_led *sub_leds = led->sub_leds; - struct device_node *node = dev_of_node(dev), *child_node; + struct device_node *node = dev_of_node(dev); struct property *prop; u32 led_sources[2]; int i, ret, fled_id; @@ -608,7 +608,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, of_property_read_u32(node, "maxim,boost-mvout", &cfg->boost_vout); of_property_read_u32(node, "maxim,mvsys-min", &cfg->low_vsys); - for_each_available_child_of_node(node, child_node) { + for_each_available_child_of_node_scoped(node, child_node) { prop = of_find_property(child_node, "led-sources", NULL); if (prop) { const __be32 *srcs = NULL; @@ -622,7 +622,6 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, } else { dev_err(dev, "led-sources DT property missing\n"); - of_node_put(child_node); return -EINVAL; } @@ -638,14 +637,12 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, } else { dev_err(dev, "Wrong led-sources DT property value.\n"); - of_node_put(child_node); return -EINVAL; } if (sub_nodes[fled_id]) { dev_err(dev, "Conflicting \"led-sources\" DT properties\n"); - of_node_put(child_node); return -EINVAL; } @@ -681,10 +678,8 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, if (++cfg->num_leds == 2 || (max77693_fled_used(led, FLED1) && - max77693_fled_used(led, FLED2))) { - of_node_put(child_node); + max77693_fled_used(led, FLED2))) break; - } } if (cfg->num_leds == 0) { From patchwork Fri Aug 16 15:31:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766565 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 010CDC3DA4A for ; Fri, 16 Aug 2024 15:45:06 +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=LbHR44bLM4FZ52+TjzVnIlbfMCn5qE1DnTHfiWLJ7c8=; b=LkgrUovhqZb+ipuAv89mfcC3Kc qgfMvDrdOWCEpI52KYetyB4qIs1EZWUx7jiNM1jwO6cSEd9WK7akURlPZxJig6e27KjTwyirIiT0q x9whvfMvkb++LePUOLM3i7yrw2+t/FzwsRSbwU3YaP+/Hjb4J9GWDcu6hicnExGAsTL23SmX4qldS Jskc1HW/0DKWz9WeiCvoclvjYIcaEt2LlIeFrJF+UMtexrRXa86eCiL7SqjqFAC3c+8YcDIRFKrEO yYRNJtxoG0Qee+7+fSuPGfYRzkGEI1l62L2rrsawszwfZZ+Ax2qMsHQo59OtG29/RqvAgIil7u/4O P4OtHL3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez8I-0000000DRq3-1gXi; Fri, 16 Aug 2024 15:44:54 +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 1seyvw-0000000DOdl-48dM for linux-arm-kernel@bombadil.infradead.org; Fri, 16 Aug 2024 15:32:09 +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=LbHR44bLM4FZ52+TjzVnIlbfMCn5qE1DnTHfiWLJ7c8=; b=So0h236C5vALhhbeOxO+pJAPe/ Cpwjd+5cr1MXQfzprE1oYwCM2PWoKdv0VjRhoxBgdLtMkhgei0OPL2y+Q0uI59fFKlFIqwxCrEO2d EU7ybcwSqiUuYHn5w1fJoMm3T+yqtX+NlRM7EIz+Mg5nCbkWE29uQzgPMYIrcWjL3m3Zj46ZqXS1m xtswOTq+PwgKVTKj0UCkM9wSdo5/Z/29XJxVDmrgWYZFWnzMAdJtPxlnSHL61Dp5U7XjqbJgBDbks n+3gOXcefaVBqOGgl2T0P6lz3AQS0k7lWaeXe6v3xHej2J4OSi4MRMSctms1e1r33zNg13K6jZbf+ YIvMaMyw==; Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyvt-00000008hVo-2UR4 for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:07 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5320d8155b4so2859449e87.3 for ; Fri, 16 Aug 2024 08:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822322; x=1724427122; 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=LbHR44bLM4FZ52+TjzVnIlbfMCn5qE1DnTHfiWLJ7c8=; b=ofzi6kDHShCKll/hsNHqm+NNc18cgEzl9bjGmBG++flv+GRldSsADrSgtzjU2VNqTo opTPr2U+Ky7v67JgyuawGFO/hbAw6c9C5+ITHmYZ+v2jy5/hijv0gtHQUZ+IwUTWtBjn NrtPO3mWTcfzwiIdZHmgGu6EOuT4DmJH5ACTIkfZQcIhd7OC43hgzTVKfokHwp4PCSyH NNp3ywRsFizbZyjnoSeaB3Nc9zEUa2W6uh5Via3AZmn8/zcJ1nC7qTSdWGzuKqepzs7H gWOzD08Nsc34/cHGGJB/0EAHuWoqn3BTkcIodjqy6LZ10CBwP5OfJM3if6Y0kab57mme la2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822322; x=1724427122; 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=LbHR44bLM4FZ52+TjzVnIlbfMCn5qE1DnTHfiWLJ7c8=; b=P0OoK2yvKFvSB7KcV8kAY5pt4eSH8sO9f0Gl4brlpmIVYg77p112rZQdMek18ztjak iSKDWGm/omqKOtHT2S/QID6JJpQs0VhZjK5rLphu2oq7I+AP/oMbwarlNXoUrJ0VLicI c+FhwqCoCgl0Nl/BeVr2bO3ceJj6E5ZW/IUuDatiu9hL6jRRMg5SgkM8I5/dKJTdgzy4 qg/LpLd1y9OBo82FJZVB9JIsNokNvnpvm0lsAd/W4YwEe7vl9C+Gmwh6veqss542qakb iW8PQbKJpY/Nyp303OimtmffLSVaF0W5p2aorzDBKQIiYRFTKHz16hSFRjoyzHJI+S/s 2ScA== X-Forwarded-Encrypted: i=1; AJvYcCV6BshOfipOHEQo7i6KUOSjf2S4Pw2aBkY2NiKUP7TQdWsoh5MUah4Jn3EsAk+y9Src07JQvRrKc5tuZSatS2ZjWIFM6D0fT2tB1s/OOWUv4hewemY= X-Gm-Message-State: AOJu0YxWWM4EQJCQHttOn8dfGe7NKNho92JXwb7IFfzCSI3MlHnY09Lc yBkO71N325rXM3IXW6fzIvAWuHliBhOsGOuowlJvsnidmOSZQhvJdBZojSh4vYQ= X-Google-Smtp-Source: AGHT+IHxActLiG1YjVcFGYIn8S8tpL7GYn5YjKZvtEnowQwIDKLJw+P78NbSRNVlVr9yhYxdj5YjcA== X-Received: by 2002:a05:6512:3a8d:b0:533:966:72cb with SMTP id 2adb3069b0e04-5331c6e324bmr2378225e87.48.1723822321846; Fri, 16 Aug 2024 08:32:01 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:01 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:37 +0200 Subject: [PATCH 05/17] leds: 88pm860x: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-5-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=1266; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=OVXsaLaHpAF5uH0owWFBXjKO4nS2BM2WznX7TKsIhSw=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DdGtKK9vF/Igsn3otgQXRhwFYgtdI8zMghG N6WWewQV0WJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w3QAKCRDBN2bmhouD 19gEEACXTE/Bt5Piq+7QmHZKIKxE1e5XsrbSqm+4ImFiwaVig9kbXgGQLSXRH5UEENiLqiPpXwb cGBK827MslxTx5lvc0eqR0xGw5V0SUzmr24svS0ymsfjoLQvv0gpM5IIT8/j9xELhWXIvzDq9Eq NxoLtGrjXoWOkh2UU6ivt+4pSlksA3XINGNsi/nJBBe+x05EcF0F/Xhkrp8eaz0B3eYuQ7y/xIM ijNujYDLau798JvaH9MxCHeJykRB6NgKBBae8AzwIQamvrRPgKQM+KwzMVvEGCOohOrgibC49Mh 231FWX5ZK/ciy22x3L13xDzYEAfAtuZLNAPGLovVhPGnAkeTBnJLHrPLa26Ab1+t1O8oYSL5SoB +Cu4/Hegu3x+oE4M/EugmWJlSuSXJCIYcPDXv37kaN6dNfUfCI2r6WR6yyOgpb3yGtIMdNrCZiv kNFB7MweAhEoln+tKaWZtathfLXF2PMhC6ikSGMWp17TLFwxy3nO5PARn/xkUj2OgHgjGy24ZVb OBobeUnbLjcKLj6LZcBbcKRadYhL5H1xYV9W3aGmCX/LIwvQGNrKQ2dNpaVgX+bPie592yDYuJP n2mb05+YBpkWuLztzlqcQAWqhRVggciLTuzTJZXz9fe1mGRy3B5l8npgdzp5ZHx7IvTCqjYKS7t QMf28Mjz4M4dbnA== 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_163206_018541_10F348C4 X-CRM114-Status: GOOD ( 12.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-88pm860x.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c index 033ab5fed38a..81238376484b 100644 --- a/drivers/leds/leds-88pm860x.c +++ b/drivers/leds/leds-88pm860x.c @@ -115,7 +115,7 @@ static int pm860x_led_set(struct led_classdev *cdev, static int pm860x_led_dt_init(struct platform_device *pdev, struct pm860x_led *data) { - struct device_node *nproot, *np; + struct device_node *nproot; int iset = 0; if (!dev_of_node(pdev->dev.parent)) @@ -125,12 +125,11 @@ static int pm860x_led_dt_init(struct platform_device *pdev, dev_err(&pdev->dev, "failed to find leds node\n"); return -ENODEV; } - for_each_available_child_of_node(nproot, np) { + for_each_available_child_of_node_scoped(nproot, np) { if (of_node_name_eq(np, data->name)) { of_property_read_u32(np, "marvell,88pm860x-iset", &iset); data->iset = PM8606_LED_CURRENT(iset); - of_node_put(np); break; } } From patchwork Fri Aug 16 15:31:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766530 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 C5268C3DA4A for ; Fri, 16 Aug 2024 15:36:08 +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=SlPHB4gr+L6a3Oj22+1JrD6FFL140QqYHUkR8oZywNI=; b=V9BakhVIHg04UZq2bueOzh7w87 zcYPBkj2jN2k7whl9ng2EA8wZgU1Q/kX9+f0LHdK1mrLp7JCfpQAX+9ZgghITyVxgePHeLpH6UOtG q7xyNOWwlKWFsk5kTRWZaIwmcx9AAjByRLQbcRGikv3CLw+qf+CgOWCMjoXGCX5CMBEbAbZsutT7W U/mh10iwfNRJpdFEWLO3YeZuYNh4jlfp+5vSvv4TpiY4Nr9LRa06Iv2jNhSM+4e0eCR9JVaRG3N7p IHou86nVohZ16YxceEy4mCbkyBq8FHnDUIkhn1WGKhrZAZ08ORCHy/dZ0U9o7X1wrxQ+OTc7XkDKY U1ME6M1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyze-0000000DPsS-22Vz; Fri, 16 Aug 2024 15:35:58 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyvs-0000000DOaG-2rON for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:06 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4280ca0791bso15645215e9.1 for ; Fri, 16 Aug 2024 08:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822323; x=1724427123; 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=SlPHB4gr+L6a3Oj22+1JrD6FFL140QqYHUkR8oZywNI=; b=rn8RkvDPMJ1BPEq3mb6RREZ0L34p5bOt9dr8AYia0uOR9o9uKA8wjv2T/web08cv0Z TldHDGedN/U0BDSXJqE2rHCj7ppEfNpAGZ+wRNEKFFgYCrqtx4DydmeRji5e6DjHFn9Q eQ5uRGBMnXNpwAyfLBDtjw1ku1jrs8YyI8vo5l9cLey1qac8oIH8viZowG63lMIq1OIF 1rKUYVOs6wQ83yCC/ghLkrSWbiZVxgy/ptm+d4I/AlsjfGXjpqQudUyex5L2+4fOrYI9 9opKWcUttUQnoeMmgKsjc7cfflSyWjYPVcF7EBG1TQ7JEuW8jLt94qLRbN7A3H1u3ZlC 1IHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822323; x=1724427123; 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=SlPHB4gr+L6a3Oj22+1JrD6FFL140QqYHUkR8oZywNI=; b=tAT96pDtusC2s176YgNKm3Kw1g38GamNdGj8sLT150uAB2yxt7LlpZCfNaw+gJSqEP pWjsgLGe0f9mSj6mSfIGjSu11WzBBTyR5NPd//LQrOKr3+1rw0HWVeOUxJaOAAXlOp6J y5rwdJYdWeqXP5PtkPtQ6yGl9jraqPuIAKdwiL/Kfmd2Zut4Uoxj4lBjtuGx5RChqUQu Jr3fv4SoZZZIx02bVCKIDwbGv/anvevu5O4Y2qw6oteoaiISeKblmw85ydwh9uuxzJrQ /mGFkIQE2n66N+kIxiJ8HizQigXkis8b5dnLxSDW5wXqcF3PB29EVkCyEokq0Pj1wHTA w4YQ== X-Forwarded-Encrypted: i=1; AJvYcCUrUe/3E21ynRK6JOkiBtCu6qYbg7Qx4CUzYkuFFtCGuoDGaY3ICggt7ogH+tSgOcIZwlckZ54NVoEbwNjhyMic2RW51GYnM2FIZcKfL5NFw6mI2xo= X-Gm-Message-State: AOJu0Yy0dC3xBdUh4aA/VzLbHhcCr7ENbUW2y8L9AN4wwyIfJClR/Ejq EZjmpBQdFuU1y50J87rvEdsJka/cCsEYHoiNxwMPudWEyVaisZqnOS/G7lmz4SCAyvIkhHcsMjS c X-Google-Smtp-Source: AGHT+IFBqViSqYS/Qn+XxO+w4C7+CaQs7V1F2BGvW2XzllPgvjc7cAPVBUQf03iTq4tSEpEg3x4Iag== X-Received: by 2002:a05:600c:3589:b0:426:6388:d59f with SMTP id 5b1f17b1804b1-429ed7a6224mr21796435e9.1.1723822323342; Fri, 16 Aug 2024 08:32:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:02 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:38 +0200 Subject: [PATCH 06/17] leds: aw2013: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-6-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=1390; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=jPAa7n3fQCOZoqW7oKViIUd50z7rPIx9W0P9wLhVk9w=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DerHRigkFM7NozDs05CzB4VVyXWnkCs7tkx sIk5q1y1CuJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w3gAKCRDBN2bmhouD 18ZrD/97YWODT5Z5+DTebBI3wZE+0JSm6MgT/9fQqSV/jAaNDxPDxtcrU9f1tlmGpI9FQ3ztA1w 5kIZXiEWrzUgc01OD/J1u+jXMzVC1rntgQmcCz3eR3mo7vdPoClcn8T4O64bLR388bwI+a/olF8 ujcI81Zj77ajVSpsdceGMgG+REsRgUhZioX3In0qTtBtjFsadb/4L8RWNBVOt0AO5upLV8A/3gn JF6ZkJUcMAY0Qi0Da3wK33LBIxv2tlml2WyLQR7yfSeNJ+dBKo3cAPBXVC/GV/put6MdXTZbbOG ntf71ez6jrXpLB9FsKzXgKCZzAXfFyaj7c6KDKJZ0qdComtXvSZ9+mSp1BaMRlT4eBSVFgM3cZR aKo+cuCf9Ncg2VJFtXFtMzUFZexM9DjBvAC1DEpVp+NIeqZRM3mp7qsMfRUG9nTl2RVE3i62Yer peM1zsF7ZPtFOxd4B+nLZz4t6+pY9/fwPN8b5qz6rLrUQw6zir30lR/BIxNcgMmuFUK2hhjIedu zkFHEl6XDKHT1SYYpTDgvlWsGjQll18W4iojiDomjGXNaDHA6idfH18a2C2nDQ0S6Grm5I/A4RB 9B5KZAgZi4zpiIw7aIsDRpYPQKDdovhX36Zqllgl60VZ5jN4ls0x1PBS4nHla9fOA5RQvPNMBvL PMAHdiIqEHJcgMA== 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_083204_806144_88FD5528 X-CRM114-Status: GOOD ( 13.24 ) 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-aw2013.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c index 6475eadcb0df..216755d6010f 100644 --- a/drivers/leds/leds-aw2013.c +++ b/drivers/leds/leds-aw2013.c @@ -263,7 +263,7 @@ static int aw2013_blink_set(struct led_classdev *cdev, static int aw2013_probe_dt(struct aw2013 *chip) { - struct device_node *np = dev_of_node(&chip->client->dev), *child; + struct device_node *np = dev_of_node(&chip->client->dev); int count, ret = 0, i = 0; struct aw2013_led *led; @@ -273,7 +273,7 @@ static int aw2013_probe_dt(struct aw2013 *chip) regmap_write(chip->regmap, AW2013_RSTR, AW2013_RSTR_RESET); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { struct led_init_data init_data = {}; u32 source; u32 imax; @@ -304,10 +304,8 @@ static int aw2013_probe_dt(struct aw2013 *chip) ret = devm_led_classdev_register_ext(&chip->client->dev, &led->cdev, &init_data); - if (ret < 0) { - of_node_put(child); + if (ret < 0) return ret; - } i++; } From patchwork Fri Aug 16 15:31:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766564 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 9E834C3DA4A for ; Fri, 16 Aug 2024 15:44:23 +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=IpSzvs+nYkevHrGD0uZRXPPuCA8pLPFmiuPfAoAZn4g=; b=jCMWa+9OV9YbsCbUkRuwjofXfd IExIb2zVnXzrQUGqlJJW3r1Ixibq69UwwLVtZDR+mjoibwycsqeEY96RESH5lCgL3dykGJl17C1Of QTG95gt4dm1HpFtEeigggA3ilWprUze+sAHsv4rHUMTlSTBhefRuFoJeWMSqIxwsbS0D9SyvycKSG uQtCBy+95M60syc/IzeV2Jhcov3dBjV/y5iIRFHGyuSXF9LfFmL7jk8Dq3jbd1li8PXK1ZGvU8QHG JuRVhDIMzG8bgZMRDGvgL2+plF3J72QZY3RCz5GJW0IulGVAvZ/1rvLIO6uxeFDaPLZJb+YScdozo 2SyrpZLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez7e-0000000DRcz-0WFk; Fri, 16 Aug 2024 15:44:14 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyvu-0000000DObd-2F70 for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:08 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-428e1915e18so14753105e9.1 for ; Fri, 16 Aug 2024 08:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822325; x=1724427125; 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=IpSzvs+nYkevHrGD0uZRXPPuCA8pLPFmiuPfAoAZn4g=; b=TQcU6EaD6pk2SY6oC6R7TsdSKhButPVlNMzbvLElpIqzdm1mM9tLGtNrBNjTmmdae0 qYwIgGYAEGq3VlMEyC2LsSKzAD6ut9Pr/OgPXojbFr9A+Mnw/A4912eVhmcJC6KmcRdA Y657zzxU+zxyk7ajeG2IUGjL6bYn7NgC+kOGLPv2IuwBWlKEIW4/10QEgMDjK9+O8Sy8 u11lZjFtxCaVAB6EhCmEAE3I+X6rC9N4UewFSpXSQQelJZs80cxdUycLuBQmmxu8WSUK pTAV/wwakgJ/uCpm2XIy8UgB6yBQI3bzNtOPCYVNa0E6+TuE3IWIOGcbI20I+fflpddT uFRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822325; x=1724427125; 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=IpSzvs+nYkevHrGD0uZRXPPuCA8pLPFmiuPfAoAZn4g=; b=VEzGI4YxpHf5nZ19AGOX3j4kP1uPhMDSXymv488H/QRC2ieyxNgkp690jMZDFanmx0 7d8/zIOyG36PQlSH/oAWwCYF6Ga6kbVmjovpFehJ4S+nBPoSnweeZrzlOo+fp4tDWOLz 9rJ3vr7gTv+zNBg1fc+ZUu+2xcTT2YaQJF4zWdmvAuevrsIKrrVnPe/yyF2HwLtAWon+ GHgYPpwMZ+TOyJXxy2cZDFmNFakbcvxWDnS/RMl4eiPEpbPIf5hUlc16dmVuoRoR4nQX nGHCsOh67uMw//WAlotY9zGQBWEpsY9RqU7XuIk137Fl1O9otqpeFLtcWsa3MtM8Nw7C AB7A== X-Forwarded-Encrypted: i=1; AJvYcCUnmiiBJeK/Q0YkrZN4iwmaWQoWlkMDQcMTT+iCl9zDN9yyQ/5byXyw0d8TukbFULKS2s/Pm3bBd5uD1rsyoTX74GjV10t/472CAysl/66XLikWYS0= X-Gm-Message-State: AOJu0YyKgk5fr24VgMmeJd6pblVYHdskeF0KgoDqcE3czy1Amlzsi+a4 WH1ChNk/o8hLJMSvC3XbvCjf9+wDWF6QEmIihHL36R5b4AXP7/tK2RRdML6IMbw= X-Google-Smtp-Source: AGHT+IFIM8SM/oUAoIoij6/+F29yCUYD7CkGrKL1zCzaVxOUpWq9yef5gSYP4cevO1RzYy6a3+hjag== X-Received: by 2002:a05:600c:3143:b0:426:51ce:bb14 with SMTP id 5b1f17b1804b1-429ed7e43femr20311845e9.30.1723822324872; Fri, 16 Aug 2024 08:32:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:04 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:39 +0200 Subject: [PATCH 07/17] leds: bcm6328: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-7-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=1378; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=m6Hk8gKMX1w5RtMdLACIAQ5rXDRi8vsYTQoqOdYtge4=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Dfttu0MwP3EZEIzlwWVIzETU/wM+a6ZdT+U j6PqUtmWHWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w3wAKCRDBN2bmhouD 147yD/9gLAyT7CaUKu376rhokAa5nBq87hnVOfCdhHEcAQUegVx3PHvtzhd1qXPs+duPUC0yuV7 Do3NvZOVUcUJRIHkBt/UXC6hUR1sJBk6WXUjJOkMj46EOuhLuwpwzLoQt/oVR4u2EO5i1FPOoTG D0Dl3i1+iWU8Fp6BAqYuZhd+e0lDEfaAkO9dSIEli4r45FXW2ljOBOky5fHTOUzPo4GoPRatKCN OrSd7SNZQ+CiOMREI6sEwJ2HVPu3xmcMAXas9HoDQKcVDdf7zHek0y+kxMU3cRX3tg0ApwR6kcL xJqDIBG2fUDG1RyLrMwaSe5nd6+NjEfzjRUQz/BuVkLV7WLafu1R23us2RtQlVzaQfzrnKou4hC 6jGSuH5a2I9OqFbVh2AwwM79Mfl8xHFEqwPrn0OaC2kKNOLrYTatVf199VGOzrcLbB218zt9LwR BRVxtpUk4zm56QgpLS6AW9O0DRGBFsSptO1UFHbsMQK170y6mJaNERN8RnkRLnN14EPw+y/acbL VQ5Ok6Ek8WU/LdX4ct0HkFJfcfaV72fBxQ2HSJpQoV+cXp2AKyaznPx9WMLwOfgT1NkS3j+Oo9M 5CTDWkCmklwcwRPvtNc5/dwJlXbY2Z/WdKS0zlQ6LOniVJx+yMLFFPzOL8+9HuAg+8jbU9MByx/ 5SnE2hJywDwR/8g== 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_083206_635836_A32EF23D X-CRM114-Status: GOOD ( 13.87 ) 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-bcm6328.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c index 246f1296ab09..29f5bad61796 100644 --- a/drivers/leds/leds-bcm6328.c +++ b/drivers/leds/leds-bcm6328.c @@ -392,7 +392,6 @@ static int bcm6328_leds_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev_of_node(&pdev->dev); - struct device_node *child; void __iomem *mem; spinlock_t *lock; /* memory lock */ unsigned long val, *blink_leds, *blink_delay; @@ -435,7 +434,7 @@ static int bcm6328_leds_probe(struct platform_device *pdev) val |= BCM6328_SERIAL_LED_SHIFT_DIR; bcm6328_led_write(mem + BCM6328_REG_INIT, val); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { int rc; u32 reg; @@ -454,10 +453,8 @@ static int bcm6328_leds_probe(struct platform_device *pdev) rc = bcm6328_led(dev, child, reg, mem, lock, blink_leds, blink_delay); - if (rc < 0) { - of_node_put(child); + if (rc < 0) return rc; - } } return 0; From patchwork Fri Aug 16 15:31:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766541 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 712C0C3DA4A for ; Fri, 16 Aug 2024 15:37:22 +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=bO9KX3t0CameG4s7E8ol/+1HoTbso6o0yUSmdA3MC9U=; b=01tzFB2IBVhVhO8GrupxXCSfJ4 AWkVWa7CO1cnt3nedJaqc/p8fNy3UB9qNvzvjN7NgI+tPWWvfGE6E0KscXtyLhOum5CLs7HDIpC8c 94uj2Ort0PvnI0t1oiDP4JkYG34+1HZ3MuSdCqx+CnKlAi1TBq5IzJJIxqCa39ySQ0l3sJiFutFeI PtAydwGWZgYu2nuw9WNAKRfGcdHcG9wt0Dk4VcM94sdas5suYQcmhxtDv0DmMhBWZWkn+uF7etYDv tUACz52Vu2IVAnH7vWBqlkBYnsKG0/jRB8LVnjX9sjM1IVA1j4GhAk05vJ+3crwzSIStwZAM7u0OH U1ZzigBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez0m-0000000DQBj-2dBa; Fri, 16 Aug 2024 15:37:08 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyvv-0000000DOcn-2oev for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:09 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-428fb103724so16744065e9.1 for ; Fri, 16 Aug 2024 08:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822326; x=1724427126; 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=bO9KX3t0CameG4s7E8ol/+1HoTbso6o0yUSmdA3MC9U=; b=S/Oys+vLItLprq//mziMXe4jdTx54jDBWhXusurLlT6TYTEWWActwwSHlbZtRHhU5m vV6M1LsZXALSUnLY6+3BhYfta1YVyoex3NDtgjkeyWM7vp5tV5pCp17rB9kz1rTabXKH elSPxl37qAjlvylzP3Z0GBfp79g4bT1AsHpxVFA4tUuIb+gc1F6DlndkxuPmupQyj5ZC WMn4O/fgq+DyEJlYbHbjJNVzXKvkQQm6XTV/14EGZEXwDoYbA72l4FmbaCTrtPLOSAEP J5F+27XmystbY5D8XeR9VO2Jc9ZxUKBhmWC+A9rcI7LSWrr9yZzH0f9EoOnwcYBgkEtm xf7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822326; x=1724427126; 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=bO9KX3t0CameG4s7E8ol/+1HoTbso6o0yUSmdA3MC9U=; b=WcFMmJwrdTTFBpWs6J/YuTVXo25BKeTzyQRxBakrh63iNgMhLge28yJr7zdFk6wfrD +XzwGUqCMlOyEU/iSSTL7V6B+aA9V4jhkTi9mVGbHlrRBjy9swJkMQ1fcxM9Xxgv/gA+ hxOlZPHw2nJV/CKEhTgB2nsXIoXAih3mAqhpqVErL8GS3F9jd5B+/iYW6dbNgSSLbOZf toEMgG+kTDzTfQ614SH9SWdaclAKqpxsNxAB2TvX2TyNODnJRKu8vKxm0kA5Uo4nxhSI F2VpzKUAx0koSOrz9/VuGO39O3EX8dbcwBmpE3aaOYSGnjnA7/YTqcNFB1LrdDn0oVS0 RB0Q== X-Forwarded-Encrypted: i=1; AJvYcCW6EigcyqzPcm6pxD/6ZDsAnvbJ32yV1UKM2BwCS/lipCTNhb9DSRN+AJ6o+yMkvqFPMg4aHgk28DpbtEdUCgGjACbx9yEAcu7jO++6Qjw+4lx9J+Y= X-Gm-Message-State: AOJu0YwqPgAGYlJZqLoqvC4YuaqBdPjTKk4BpbO4PaVrgu3+FDLzsHLZ RHPlZYm41QxGVrg8ntiChbai+Hf9ES4l7objwentArAjV6C7dxJAPI27fJ6D+64= X-Google-Smtp-Source: AGHT+IFO6DlpkZlrb7PQDXCCkwkdt1PkYJMksByyV9gy/3kYvIXYmOf5Fd1cqFTrDNfriARDeJMtyA== X-Received: by 2002:adf:e6c3:0:b0:365:aec0:e191 with SMTP id ffacd0b85a97d-37186d740a7mr5074245f8f.21.1723822326272; Fri, 16 Aug 2024 08:32:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:05 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:40 +0200 Subject: [PATCH 08/17] leds: bcm6358: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-8-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=1287; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=gN/N7MTnfesRcU0ZUz+5FDMsGWVo2Qy6wwU3HvO2nBU=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DfPgJIiHDC3hZ2bkc5m7qeMomLAN1W2uZDq zxZ4A5tqh6JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w3wAKCRDBN2bmhouD 18UJD/9O2BpM8SXiXEcgj51PM7x8myw6JvKSH40bF5oY9mhYIhkrZpWkbw+Q/7QL7B2EcIXbGwo LrmxiMbQvg87Z7lN78d8yf0GJr2ja+HX25WLRTCfL9lAoXbHMGotJD66V3I3D4I/NRdUbQTDzMa GHxvligWU2jeLN1qjSSE4Z5ZXQcFGaQ22RBOgL5IhzzmHNjVyaQ0I7YMKWJ5UcwIh88EXJikd90 9Mj5JYSJO5GCunLxqgi5x20aMYuVoCPdhfrhykPvY1/WrKKcA/qfmrjY5VrzSJv06q4CRJ0xQqD MMTkyJKgY4S7pwZuJA3SsLEgggw4C2Mcdut6XkUdyiYwmWIk5T9sd2U6qVhDGyzw3GoTtyfvkdh 3bv18L9qH84cqiM2E9uvA5HGw0+tNVVqcfAaA73pn3TugUj2UBQw0ZACpoNU61mgPROTd9zjE8g 2ljGiXGegvDG5Lc3FdUQ8NMq27W6vFFcZ7fqUFh9ifzKYDwuU20YsvxySGmH2DbOdhc/wTDNhdD ErXZc8VIuCFnfQrbciDcVUluC73s8YaaAMVICIhZNMluBx0SGWut77qF8+CCA/yBy86CXrd1Be1 mbGNuNEztzvTIQQeX55KCYhBtgdSnordy28kcn6S2dP5p29AGcaoNW3aG83jOWEDjwSyBfuAJ6b aRt8rutA2xi1+dw== 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_083207_756493_E8513F35 X-CRM114-Status: GOOD ( 13.94 ) 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-bcm6358.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c index 86e51d44a5a7..51fcff2a64fd 100644 --- a/drivers/leds/leds-bcm6358.c +++ b/drivers/leds/leds-bcm6358.c @@ -147,7 +147,6 @@ static int bcm6358_leds_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev_of_node(&pdev->dev); - struct device_node *child; void __iomem *mem; spinlock_t *lock; /* memory lock */ unsigned long val; @@ -184,7 +183,7 @@ static int bcm6358_leds_probe(struct platform_device *pdev) } bcm6358_led_write(mem + BCM6358_REG_CTRL, val); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { int rc; u32 reg; @@ -198,10 +197,8 @@ static int bcm6358_leds_probe(struct platform_device *pdev) } rc = bcm6358_led(dev, child, reg, mem, lock); - if (rc < 0) { - of_node_put(child); + if (rc < 0) return rc; - } } return 0; 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[] = { From patchwork Fri Aug 16 15:31:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766543 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 3D801C531DC for ; Fri, 16 Aug 2024 15:38:37 +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=fUGzP1t9Gta8AcQElPeRx7Ldl4ob+d0gDQH5kp4CXpA=; b=ADK64fJsBBCSyx8TKP9qnagCa8 vagyqzp4iO2uaT3Ot1VwpiWjchXOkO0ZT+ol2GBdA23+kLY2EgxqB3bRo7XticC2Tkf58Kw6Cr3GA Yh5s1SYXnSF1J2tCHUBMGOtrYQler2/qxoiJffkRaY+sb+po2HMVgx5EYLJTK5gGvzc1hmambh+bH dhb7ipsOI0GevYgAgRW2Jcl1vxFPvvAlEH1vTt+q9532oWvtheiiTcQw7uBIo+lfxm07lK+hnlamd lbkJ0ap6T2XmECMbxmidwuhz8LGggQovqAwxY48vHoSTpTj9bq9I5lvpAtgICBqUZPtupkspYZrcn tx4nbCnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez21-0000000DQOX-1Gbk; Fri, 16 Aug 2024 15:38:25 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyvy-0000000DOev-2m16 for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:12 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3717ff2358eso1125739f8f.1 for ; Fri, 16 Aug 2024 08:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822329; x=1724427129; 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=fUGzP1t9Gta8AcQElPeRx7Ldl4ob+d0gDQH5kp4CXpA=; b=ieCdHlPy7KbzDBYYeS+oTF9Js41VVVS+MZcxka4kTWekR9hjhrekGFMJnGAUp35QsV 1VgMSrDGpQSLf5oDcyMrzrFMgprBLioAlW5R0UVauhWxm1jpDINFXe2Agmxdxh8OShAV 5slxLwMuhqRqUkiSrc8i6IRAfdARhX5y7/WATrt3SG3pERrodpXg7pLNwiokyaEU0+xS HxMobDMml99owhblBzgxly135r20kYmcIwTjMhrJkiHJuLZSPka6R3gHgzG06xHlmoiw rTkMigKYSmeLcARdFARz6EVW9r85QSg/1SEiIlvaAbjbpALu64Xc52AeTer9286SyNG1 j++w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822329; x=1724427129; 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=fUGzP1t9Gta8AcQElPeRx7Ldl4ob+d0gDQH5kp4CXpA=; b=JJYdtsSOvx+zmz9roFm1pQMNborbfg65QMcaYAjvAVIHPkHsf98WdhrTv0heOvt1dh xaHocBGP9RPmFbYx9awstwbzCRlAZwU5qffJG/58tohEfDiHrnVr/FHbnLoHVbQhlynk F3qvXEkJzST4fZShws7kHYG3GDiV1hpQjAeCaUxKE9SVASpnPtAg5L3tTDESzytsfKcH UmCou9EzScyLYpBvzfKbDRRz+dDtF71nZCWi4kFoaVIeRBOHsLAKEK1sWzPR/Aal7N1w WZoJ5T8uJPCiI8KePWnzIbpJL08g/HgpMCk6PeTn+atcKXKZcfQYy6DMIDAUqpBwA263 9G3Q== X-Forwarded-Encrypted: i=1; AJvYcCWPKAFtDf2AEkelLtQ4dO9HDEHlUmBW4Y7u9aK45CZaPDxWGQVzC7Rfpi5ZE8hKkjTUaAGpwghOMofFLXMPU979H82OhCZLLnCGUL5uRvFhtlwbbMg= X-Gm-Message-State: AOJu0Yyk+HN34AgSxyMCbrcWuhnK3gBb1M8nh57cmPhvykYsZM4th5Dz 33wpDuvq0fdv83RecGBbCivWkxGxNDmnznofKkLRYt29A3Y45avDHBcQ0d/6X5U= X-Google-Smtp-Source: AGHT+IGhEOtCAhmiEJzyM6rHhtwOV8c0tEKSFIqBbM2oY0Emu/CY0p4z+M30teYyAFMwJF8/lsh8kw== X-Received: by 2002:adf:e907:0:b0:371:8f32:557e with SMTP id ffacd0b85a97d-371946a48bemr1879100f8f.39.1723822329270; Fri, 16 Aug 2024 08:32:09 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:08 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:42 +0200 Subject: [PATCH 10/17] leds: lp55xx: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-10-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=1023; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=pmrGUTEyc4+OdSgnYm2SLaaXl8kY77CCNdxnjrRu1fY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DhRHjXK+VVZ1wGfuTNvr54zgIfsr6GoeBrH 1NeN/M93z2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w4QAKCRDBN2bmhouD 1/ByD/9j6wZL4arhQNjD+UFfZLKCUSB+07X+VLcSzVuP8NTqtzt9JdzpwATyKwe+8mx4uaDZxsb GyCQxZBMeiJ5WyJ0GIhCw2HIc3aA9GoNieEjdRCZvaDvuh22wl5qUf5h9TBXcWlOP8nuX12gTbW VO79LyvYiS6Wcwfr38fhMxmCImw6vRxdBXOPdyJkqaeR7LptXb1w+5/c1xXHnd2D3xDHZhLahod QGtHiwJrNTQSZxwK8V3o4Sp+GG7KRxXMfXxsXxC/0LP6LMxe8NvryP+/ILF99EkLvjFEb7cAI1o 2Yy/dUh36Wnt2bPgvIFZjQDGPLcRSNGjvfe1XaIHeoq3dNte0b+umeva9edjpAGZw3IgKOe6R3D CEzVN2rDv/DbS8biy9Ru226n+ymrguhAn12JQSErEnQ/Suw9+3NnXjhNUtl2KeSXWhMTeKaVcl5 bJ0cDPBAehRG+k+e3ERjKnM5USAn9Jfgv7mRXpjdRCKcFBvNQ/0lnEA0e93da9h/mbXGfCAsJHe rxMoQ3aGihwQ7gGOAce92nHK4uyVHPuOj3UPq1ZoAnPjup8U8p3xLhNBj0Rdhw6TnwiyHdfqluv aivLqNn/0d44N/vgtlMX69I0VOhGgC28XeI05p99ukmU8CUtzwlQUZKApdcBL3wVj3h63Y5NejQ 9gCn501ogVJCjxA== 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_083210_791139_3F704BFA X-CRM114-Status: GOOD ( 11.56 ) 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-lp55xx-common.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 29e7142dca72..d493b31c215a 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -1173,16 +1173,13 @@ static int lp55xx_parse_multi_led(struct device_node *np, struct lp55xx_led_config *cfg, int child_number) { - struct device_node *child; int num_colors = 0, ret; - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { ret = lp55xx_parse_multi_led_child(child, cfg, child_number, num_colors); - if (ret) { - of_node_put(child); + if (ret) return ret; - } num_colors++; } From patchwork Fri Aug 16 15:31:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766544 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 36FD6C531DC for ; Fri, 16 Aug 2024 15:39:15 +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=ExS3Adk0ysbxVxPe6mSqv52zzn6f2EvdipX95Ynjg4g=; b=gODhTwW+GzqJZect9ZAwe1dlvU QGP7sh2onNwl0WJRfvusEyEgxUcL6hkBxpIkedb0NZG+jGBjV4w29csgs+a+g9kqao2FsmRLU/+nm xKiTcGjhf77pUa7HbDbvRYvrzk5HfYY4jW6rLF6oJrJDEu8qFHm07LYHp58NNCYJjsZGtV5MQw1FP +Dh2KfZ2MxVBbcrvLbQOlymIATvc5k3W+yWfttiZlKNml+riSh//stiG72lphJVE9F+cFQHtHD4B3 4StTOkWINEfU5DmNwycIWthDOsGyNXMPQ2eYWV2qKfzd5VP8ktSX2nb9QDgJP9zpZQtvleA6s17fz 4YKVEV3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez2e-0000000DQZ4-3C3i; Fri, 16 Aug 2024 15:39:04 +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 1seyw4-0000000DOiO-1fVI for linux-arm-kernel@bombadil.infradead.org; Fri, 16 Aug 2024 15:32:16 +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=ExS3Adk0ysbxVxPe6mSqv52zzn6f2EvdipX95Ynjg4g=; b=htWOcm5KlMhSDcKPDjg51vr4JY NtSNLvYCe6nIt9gzDx4aIzIVLgQXyb8XNBNMSob67Gx5XWH7f51BEpt6fS4VHKRqQspYxeQMsNl3Z HjtjqbOU5nsjrDNMWEI7c1zl8FfMEzcr4cMZy1dMB6uaMM2prFJd19+5j7HxSjZLPEyhcu4P+Bs9i IAuEEgBQinDIDHz/1EddEfo2rscJMGLlI78ai5np0imd5T0F3H9WIaG5kFqZjdKo9MJU68sE1ozRy WxhYnhRC/+bs1LnlvvLPG5NSYaI+eEdX/APmXGxn8+1P2tQDq76Env11BvZNx0qsFNu8MEgE1eUP2 xoWjaOHg==; Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyw1-00000008hXE-0mOp for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:15 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-428101fa30aso15374735e9.3 for ; Fri, 16 Aug 2024 08:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822331; x=1724427131; 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=ExS3Adk0ysbxVxPe6mSqv52zzn6f2EvdipX95Ynjg4g=; b=xjPo6As4gsZN/yRikJk5YUj/+iAj0NbDgSKzArmNtgWJDaytukx5FNOpZcNpOsFq0h fkCXK5Zi228Cr1MUXDWoOUr3XZ0njMKTR3nSQ2egwns8NTXZMHxj1wbmoP/bXxzDbhdb Wzc6dQP0QkUedkxoDBxpOYEcn+6dk/KZl0ZtBCKeHsckOXlUGiUDuKPKPxohjhasbxfN slo8NQf/x/MEwWk68ArzlJUpIR+kV/ZjCOxYJ5B0YcXwLNyasGKb0ORvhFrcpEYBQUWD UY0H9j5qL0sh12fYzFivOoy8rt0TNz941Qr3XxKgSrFEfwMv0OA7k5Pjw2GoPGTN4Jfj PDxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822331; x=1724427131; 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=ExS3Adk0ysbxVxPe6mSqv52zzn6f2EvdipX95Ynjg4g=; b=qf/xbCc2JWUV2jBY2HshyOTP2SFVgjKHWlaTWbnhIaguYn5KpShxotAf7BMUG3+i+o C+M4QW1eUjnxVfEtd3NijkLi5Oz1EeyuczoieS498C9sxItCoJbvG6uP5TDxhljZ+UX2 4t56DFdmzTe6GlY4dhxoRPw2QtN4J53CMUUt2g3Q4WvqYTVPi/rRSuj2NX3TYwRS1BOL xQ1zYtfDjFb+ZSOAyYBJA/rc8rlsJl+YhXaqWd+qU2A0EdrakkQnoCqRz3Kg+i2QwvCK PH0Gb9Jls4DYSkChD/bJmotbsyQtFvgTHDnyfBNNXbhY3ii0hKG6FxMpUQQzametexzb x7TA== X-Forwarded-Encrypted: i=1; AJvYcCVnxufWsnwjVgMldu/u0aRR5Wi8iXFehTDnwZJIn6BtT093PTgSoLtiyfYXQgy8PSHkI3Q/H/hUgrCUGQ4ViSvXY2c+m9aQp6CpQgpup0+kza9mz4I= X-Gm-Message-State: AOJu0YycsCkdy6OReJquZFbLVv5BL1lJl4Igp35F5kTBC5sQ7tJVMjx7 oZI/F3udkPj2cfxcq/puHOf7a7rFhZd1x6DrTel2dzwtVc+Wv2unPZwpzydO5K0= X-Google-Smtp-Source: AGHT+IGY3LRWMur+RIX2EsOyWFfYB56XC96QTNt2jgmYdeU0Jid4hrYTxjzYfgcQsMTsb6CsL+XrrA== X-Received: by 2002:a05:600c:358b:b0:426:68f2:4d7b with SMTP id 5b1f17b1804b1-429ed78562fmr22527545e9.3.1723822330645; Fri, 16 Aug 2024 08:32:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:10 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:43 +0200 Subject: [PATCH 11/17] leds: mc13783: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-11-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=2357; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=lKaguPS9XCpAsm5c5uDkmtZO7d+eB+Wkab1pNRXTP9U=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Di/6NaLLFot+D5dfegT8i/v6A5joRiEW89N jDAhq5CjM2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w4gAKCRDBN2bmhouD 1+8tEACVczd8uQcgqQnn1chR1D9ZHwx5vpecvoE+zaIxLcF5I+90rwhxxDn8jJIGBDIEB4D9lEY 8VArDs5hWgYidus4DO8QPVMc724Na7iEO7XzHXA0vlYqglosEqKSCnk4YhLj9qeh3+5O3s9AvHO R33hSdaUSKRYUo3TbrUsZEGXIeFOzwtCuHLsZ7q5n1zPLKNnM3zoWIwsYsAhBbyKKJG2C0DiGSQ 2C2cIy6FWj+wnvnOugue2gimQjVJfyuQN9DzLZ8XGwrti2/8VvZRNUjkfCI2rAJxr9kwhYzVzr/ MpKyOM/P4/YzNG8obVj+CwBkV+W8vCB0nXinpOgz7ZP9U7h5exRrnzfkT8OYQkEMN2K1KF5XpST DCGPitYNCxFLKDO3lSHmtS/5Uinxi5W9s9bcES7OcytdUjcqNr4rFP8F6AXsJZZEnBu9LTX2vnJ CyxeqAjuuhSzLaQqA75FgTeeQ1Q7SpHfyvewqraZVxTQRKdeuJJvXZo/aKCdvfZtzuo5bYGaBeC OiRKTvWBCZtlOIob7/WKFTNmtZyltasnmpOPnHBdyojcJynwE1/+XZ/AzSPpVBnvmulZACpMAT0 3YFovAp4Rms2RRR8qDQXBvLFJMeuUkgoSK2KBHBiUy0eo/yRQDOxKD6WC52EALjbTb/BLwiLhox wdc6cj6rorb2j6Q== 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_163213_317649_DAC0CB8E X-CRM114-Status: GOOD ( 15.50 ) 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 Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/leds/leds-mc13783.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c index bbd1d359bba4..da99d114bfb2 100644 --- a/drivers/leds/leds-mc13783.c +++ b/drivers/leds/leds-mc13783.c @@ -12,6 +12,7 @@ * Eric Miao */ +#include #include #include #include @@ -113,7 +114,7 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( { struct mc13xxx_leds *leds = platform_get_drvdata(pdev); struct mc13xxx_leds_platform_data *pdata; - struct device_node *parent, *child; + struct device_node *child; struct device *dev = &pdev->dev; int i = 0, ret = -ENODATA; @@ -121,24 +122,23 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( if (!pdata) return ERR_PTR(-ENOMEM); - parent = of_get_child_by_name(dev_of_node(dev->parent), "leds"); + struct device_node *parent __free(device_node) = + of_get_child_by_name(dev_of_node(dev->parent), "leds"); if (!parent) - goto out_node_put; + return ERR_PTR(-ENODATA); ret = of_property_read_u32_array(parent, "led-control", pdata->led_control, leds->devtype->num_regs); if (ret) - goto out_node_put; + return ERR_PTR(ret); pdata->num_leds = of_get_available_child_count(parent); pdata->led = devm_kcalloc(dev, pdata->num_leds, sizeof(*pdata->led), GFP_KERNEL); - if (!pdata->led) { - ret = -ENOMEM; - goto out_node_put; - } + if (!pdata->led) + return ERR_PTR(-ENOMEM); for_each_available_child_of_node(parent, child) { const char *str; @@ -158,12 +158,10 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( } pdata->num_leds = i; - ret = i > 0 ? 0 : -ENODATA; + if (i <= 0) + return ERR_PTR(-ENODATA); -out_node_put: - of_node_put(parent); - - return ret ? ERR_PTR(ret) : pdata; + return pdata; } #else static inline struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( 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) From patchwork Fri Aug 16 15:31:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766545 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 39546C3DA4A for ; Fri, 16 Aug 2024 15:39:57 +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=0JgxLZXaOT7jTL6qyBA9SLrwZQeJRHeBJE8R6L3hV10=; b=2lYnl2gpbsLJP7noa1ThzKKrE/ brAH6+ATGRvncT+jR4fJEB96KraIjMwzJtlJg7Txcqnu7jDBQoumo3OSjoW12qFb9BGGm4cRdvTAM W0JwL65I+ZSnT9DRRRZ9f1JGyAeUSTCv7Rjq7oHujr0CUyRuINg4fJdbdvE2PJpt1zx+n+gIwlyCr lr3zlwrM1RU1QXaLCTxBxqWx86PYs1NeMUnnmw2GGG0lBqkYg/9Kiv7l0g/SLI8bZ1RUuspKFZySF Nva/kdPy06bfXydqydJq/Wrg4zVN8nykE5/As0VUMMul8+y/Swn4F5YbYjGvOU//SqXK28SoqavTo YpBokMoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez3I-0000000DQjk-39yw; Fri, 16 Aug 2024 15:39:44 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyw3-0000000DOhV-2kiZ for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:17 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-428e0d18666so14812645e9.3 for ; Fri, 16 Aug 2024 08:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822333; x=1724427133; 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=0JgxLZXaOT7jTL6qyBA9SLrwZQeJRHeBJE8R6L3hV10=; b=boGzt4ZY0pZIMLdB93uz0Z9n6UsATCTVFuHA3/bnqf3WVfxb69DtEcTcC9hF8N+L+4 Cpk8etbmENLgP1ImT1nac9FdMVU0Fl4+PZYfrB/NKxOlKH89srHMvA/EvGDwxZf/Vr8z 9Okj1GRhniKh8TbG9na1oP8BjU7J15LRbaq0ismRm0X/P4DAQsvLc/z2fOmsLU6JSyto 6eZVkJpJRrCiWP17i+8oTMTDquCo1BYitoPEuprT/aedV1kKmKldAjMXXPnTgoULArnF K7c+AKFHKLa5X5y14Cr+W5TVYLaqgnVNWijHPyKVu40EcjsgBmrnwl2sbh72O6doEv73 cUJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822333; x=1724427133; 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=0JgxLZXaOT7jTL6qyBA9SLrwZQeJRHeBJE8R6L3hV10=; b=PUQckaeqcSB6GhpOJlrb34gNCk1C5gGc1Y57LLvCNAYLcoubGqmS4Vb+RMr0pEsWwE 0lTCKQunjAOWqXquaaIDrvtjmJKsr2EaH+1+SwWH0UIqjs5z+Drph4kbaeA6v1v/A1MX HYkw+rZUuTIfERA4gTpvGA8m3v/0sTZrddq8WIFqWkWTLazNBfChuBYibrUJLyIGhAeR 0d1qIkHZ3jy6m/3oOON1oRrJZZcApwFw3P//d66viauhi3Up6hfMC8WDCugmkwzd8zrZ Te5r2elF4+krsq8dCT5q4WntDaK+H/6wOam01dUf1CD5NjlGvxjiC13zOOtwNzbWnIZh kh1A== X-Forwarded-Encrypted: i=1; AJvYcCW4L/pCR0/kZbBmeUe08kJYiCa2c2d5GlbNhNiWwn8SyO4T/LXZBKa80vnNLflkbZuS3RGO+lGlv/Fl5oq55Wa5R51nTS1rMhLJ8exgrvsrslA1Mf0= X-Gm-Message-State: AOJu0YwSNlWW3DCYjFrclleMHMo/c/nxinsSJz1bknB6nL+iigr9YY0O X5B7wDOrn5NAaavmLMPRPRV5wk6oi6SO/yWVBE62v5rC3XlthMXLvv5w6hrvp3UB6Nqd+rnz2sZ Q X-Google-Smtp-Source: AGHT+IGEXRtSKYqMHdRXL9A0IVWYnjdiaFA3vVmWXlDDw3F+xS7fwXoLMur4GHVC1AGF3Jdg085/ig== X-Received: by 2002:a05:600c:3b1e:b0:428:1fa1:7b92 with SMTP id 5b1f17b1804b1-429ed7ae3ecmr20377775e9.19.1723822333456; Fri, 16 Aug 2024 08:32:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:12 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:45 +0200 Subject: [PATCH 13/17] leds: netxbig: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-13-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=2775; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=ZbpwvH2ustjiwLvVNFB7gNYO6vZKL2oVpGeN6mWbO44=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DkDqyZck82XNzSXwocQQY4b+BjTR2I/skAe /0iaxSnekWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w5AAKCRDBN2bmhouD 1zT7D/9LA9styAbhhWAgbwLixcjU5nsbijFUo4i2fJCjHsFr6OI5L9kYopu/4IqvUkdsFfIoLoi Am8mhH37EL2J7Wqaa4UyyyDhl828FW+J5WWGorkvyeZub68/URCiLwlvw754aiqAlZvXBcUW/wq DBvZUCDT2I93vgdlaK8T+jaeqXFh/ZiPBGOopvru4O/IHC8Q3T/uKoAKcF/IlmDptsz/l127ml3 Wj1RmTgWTFJ1fnpxd4gFo9bEMZ8NcmHpidcBQY8G8A82hJlKNJ3qqz5RXVPaySGdGSv/9YUF7bw rdOrzSpRB3vBzgAt9HuRDAdzaCZJRYlbW7g4/mDP71dpVRnDebllQX/BJhobp4h+MA+4ZLGFfET /fCp//41B8J4LrjD14f7Z/j3HXXGthuMBpi+WTQRXiS5QSRwzAjIYV13D+dmbCuzGPD8aMwAWLZ Vii9spzKcwv3Y20GxPQuHXVeIIY8Fp3lyhfwCO7HBJbzmUi9sKfcWPvjKzFIpJHodgEt/L34942 8qp2LY/qUq2KqrGKhePZtJW8D5tfXBrpDWpVZPb2zByLex/FttuvcKtjzvwP1q6pf2J/MzD8ba9 QJbWLFhD1zPgxo6X+YG9IePLDsz6HLk1vH8xbfu8ppnwbToivodXMGG9k78U7yqj6vG2S4ZjsC+ neKFv1FiAciy6/Q== 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_083215_745765_F4E20DA2 X-CRM114-Status: GOOD ( 13.93 ) 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-netxbig.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c index 77213b79f84d..af5a908b8d9e 100644 --- a/drivers/leds/leds-netxbig.c +++ b/drivers/leds/leds-netxbig.c @@ -423,7 +423,6 @@ static int netxbig_leds_get_of_pdata(struct device *dev, struct device_node *gpio_ext_np; struct platform_device *gpio_ext_pdev; struct device *gpio_ext_dev; - struct device_node *child; struct netxbig_gpio_ext *gpio_ext; struct netxbig_led_timer *timers; struct netxbig_led *leds, *led; @@ -507,7 +506,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, } led = leds; - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { const char *string; int *mode_val; int num_modes; @@ -515,17 +514,17 @@ static int netxbig_leds_get_of_pdata(struct device *dev, ret = of_property_read_u32(child, "mode-addr", &led->mode_addr); if (ret) - goto err_node_put; + goto put_device; ret = of_property_read_u32(child, "bright-addr", &led->bright_addr); if (ret) - goto err_node_put; + goto put_device; ret = of_property_read_u32(child, "max-brightness", &led->bright_max); if (ret) - goto err_node_put; + goto put_device; mode_val = devm_kcalloc(dev, @@ -533,7 +532,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, GFP_KERNEL); if (!mode_val) { ret = -ENOMEM; - goto err_node_put; + goto put_device; } for (i = 0; i < NETXBIG_LED_MODE_NUM; i++) @@ -542,12 +541,12 @@ static int netxbig_leds_get_of_pdata(struct device *dev, ret = of_property_count_u32_elems(child, "mode-val"); if (ret < 0 || ret % 2) { ret = -EINVAL; - goto err_node_put; + goto put_device; } num_modes = ret / 2; if (num_modes > NETXBIG_LED_MODE_NUM) { ret = -EINVAL; - goto err_node_put; + goto put_device; } for (i = 0; i < num_modes; i++) { @@ -560,7 +559,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, "mode-val", 2 * i + 1, &val); if (mode >= NETXBIG_LED_MODE_NUM) { ret = -EINVAL; - goto err_node_put; + goto put_device; } mode_val[mode] = val; } @@ -583,8 +582,6 @@ static int netxbig_leds_get_of_pdata(struct device *dev, return 0; -err_node_put: - of_node_put(child); put_device: put_device(gpio_ext_dev); return ret; From patchwork Fri Aug 16 15:31:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766546 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 F2FC1C531DC for ; Fri, 16 Aug 2024 15:40:33 +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=LOl1ZqBXdbAJXZzTI3BlQ8z/3fBsZwwoZ15vO5UkJdk=; b=aCgonk2CHoZ10LNZZFSbTRzXdq vSFR+MZksM2eE1XTqurkKPBEQJl6EvtbtelCR0VeQUWPQk05tVEjFYGAsKPjFOts9+GKPXc3BW4ve HzwQLKyEY8eaAVfGipty1/iNURHVxdhBuHu/GAon2WEc7UAeI2RZTiy9gKMgw2N4We13h1+ULvVfo eaFkgTNY01sjALsa2qH5mTwpRq8KCZ31n3eaR0hw0bDik+kTnVpw4pgtR1D1M3c7shfZTI0W1cmNP wgAQ16Rqcz5WyvaqB/6WCUk6Sja9LA44g7t85nxOPDBkMnsa4rzrIqgkr4bZppQf5aQo86af+Rp7v 8W/Cfq9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez3u-0000000DQs6-3DXz; Fri, 16 Aug 2024 15:40:22 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyw4-0000000DOiK-1dzw for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:18 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-429d2d7be1eso11115115e9.1 for ; Fri, 16 Aug 2024 08:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822335; x=1724427135; 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=LOl1ZqBXdbAJXZzTI3BlQ8z/3fBsZwwoZ15vO5UkJdk=; b=pg28X4LiUv7OiCvf60UuaGKL03tawqVuUNNWjqOWKHj6t59PiyFxkGXjdykr7I3P9n +OcQo/xDmffd+Z7d1lZyHAjiejz5xxpq7iFe3gRqc0NVMaJy7LzbFmcdnGAaQ6vIuGw5 FNWthxc7K3NUc/kXgDa4EFTzPTBNAQp4qoC64+v7aaE3sf2vB/FEb8OllKJHp2GpKmsP pCY5uLRGlNh8xiZ2IG4fxDSBW+nFeG43LRzlbsNX1xMNEX0bXnV4B6SMR0CTyfLoMY83 YBOoW2A4ISy5Z7AnnWBouZoxApjJoUmFS5Db0zRXaUEaDEal1TSYaOGh3uMmaGylJ7u3 +5/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822335; x=1724427135; 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=LOl1ZqBXdbAJXZzTI3BlQ8z/3fBsZwwoZ15vO5UkJdk=; b=NVRlM3udTgvD4XLfsFCbU8Va0fWfbGarHinKpGzYtl8dnHzef9l6QAFHLoKaRBVxGb 2Qz4JzPpTwMD47Yqf9eqKO+ySGgxKRMYUlGYsFzLX99caVetLyibiJVSZXv2D7wlhRoI DogPl2dDGazjBO9W+iVuCEFY/tTbcokNeUXaa3SatdSqk1ZxLd2Np4Swsi5PSBqiiIQW rjGFSWJj7tJDv+FcTxB7arEa2Sv/5mNBd+LjuhhYUHgClZtobSGmX3zkaj448Zuxi4jF FF0d76qvF9rfHcsCSD0kWnI/pdaQcTHSpqSHAVLEj3XZDUuufpxR/1dNIt4teqM71oxx r1zQ== X-Forwarded-Encrypted: i=1; AJvYcCXaSMHsmNu/rqMrXPdpuYMdSdK+M+jdcz129KRbFK+Mnb7bS+OBOtnCNsu7otPdeZxn55rYiNmIJ9G+YFhkVg6GUOO5zV+KhgW5oRzjEJGSnAQ9ty0= X-Gm-Message-State: AOJu0YzubV/xGD8SkyOn/uI36Eac28oRKjbedrD2iCFdCol79G22tq7N CfzjDAA/xwBBoJuQlZbnucsNQqYP5f0VD7iXudF9C78l0keNLmS07jq7qr1Srmc= X-Google-Smtp-Source: AGHT+IEFjSH4WqobBhV+up3oZ7ztZRwBuC3HgNzLRXaYpTTRLatXBwsIRxgmIFfySIZM1KogU0AXTQ== X-Received: by 2002:a05:600c:450c:b0:424:8743:86b4 with SMTP id 5b1f17b1804b1-429e232b8a0mr50953985e9.6.1723822334803; Fri, 16 Aug 2024 08:32:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:14 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:46 +0200 Subject: [PATCH 14/17] leds: pca9532: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-14-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=1474; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=3ARnnx7uT2kjUKO/lBdUAxqqDcV1RDRByaeh6p9QzVk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Dl9NwZPB/MApEGkh1nDqgHmMiX/P3/AIqpm RoLHvTk8y6JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w5QAKCRDBN2bmhouD 19g0D/wMAqWjPIbSHETSNRfB9R/1HlUm5xI5ndiN59Zcgwr/clBCSt48gRDMuFGS05K/kNaSvRO 8IbtYru6I5aMaoGCHU1KgbcevPw39TynUzLejaKERSJ2zXJ8UQ+qvh80ce/3XMYlfCBf9b19psi xRyJnm70aht0YnafXUBRfWvp6Im9/I7y1YV+tXBnLIKXrWLznSUDTHXSs7EKODOjnqt4mFNJfew qMZ4Lu9SFU+kG99RWVs4R96XWtdI5gtCmt9yjriDw5/cD9GE4Ad7Wjk+juXE5HvEjl/hZ0OnokN 3HsBKw9y+68dZIwQVVDmPPZJb50/DGJstWUwxOti9yfDxKYMCkW/+dZf1/LxZYvuxb/0WOvODM5 PNeM2bx/y0m/cOQY6GAYpu8UgoAbMWzQxufvxjUN52w+IQjQ7w3epmoZLycDyPEFvVQ9+Nz7kOQ I3QvW+PFDLC+htKn3wV0X1Adnhj3CWolfRDdVQ5m/UMB2EwDZy+VOthEx7pNzC5wcmFzTXoL6Sx 4D/8ee8LHgG/8I5MiNA6wVgqUJCu/NJE1DY6XJ1JuVTbs8qyCiLVW8bJ/yo4ecJgPpBBhPTGdfE Ld2si21avus1XNVlYHHao2BVVh3XLSmqiMvmaWBGvQw3Y2J0/nbyOBAcRN0BUWe6W+N0RGJ2O2a fZZYbzRJlMQmwbQ== 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_083216_472656_6B951889 X-CRM114-Status: GOOD ( 12.57 ) 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-pca9532.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c index 9f3fac66a11c..338ddada3de9 100644 --- a/drivers/leds/leds-pca9532.c +++ b/drivers/leds/leds-pca9532.c @@ -506,7 +506,6 @@ static struct pca9532_platform_data * pca9532_of_populate_pdata(struct device *dev, struct device_node *np) { struct pca9532_platform_data *pdata; - struct device_node *child; int devid, maxleds; int i = 0; const char *state; @@ -525,7 +524,7 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np) of_property_read_u8_array(np, "nxp,psc", &pdata->psc[PCA9532_PWM_ID_0], ARRAY_SIZE(pdata->psc)); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { if (of_property_read_string(child, "label", &pdata->leds[i].name)) pdata->leds[i].name = child->name; @@ -538,10 +537,8 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np) else if (!strcmp(state, "keep")) pdata->leds[i].state = PCA9532_KEEP; } - if (++i >= maxleds) { - of_node_put(child); + if (++i >= maxleds) break; - } } return pdata; 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; From patchwork Fri Aug 16 15:31:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766562 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 627D2C3DA4A for ; Fri, 16 Aug 2024 15:42:30 +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=d4o6NVK+5RxP9AE82dc0tQeAqHho4Q+RR5k5EOL8qCE=; b=R5NmmiY+YjRtuPju0cejPMmeE1 WIygSFegxOohOFodkg8ATfG1pKpNwhOMmzcwkM/vihjNJuDrchwaL4P6wX/gJRMJzjQf9AN8yk8KP IiwQAmw0u/AlEvy3lfqP3hy8Rt9+Cv7fz1oKkhoVDszyKaiGr7CTp86jowS+5n17AIKCqj8UtIhZE 4Go9FlTbQAbz89Ve3Dv48P2qgCe5bYLG428zb9Fz8oss+XzLCJAu6DH6VvP6jTFzAF0xoc3sPVgGG bCGvhrGbXKcUgjPdytjhTejZ8i9UTsfukmoqyoepKpvlwXGVpE1XG1vgMHjbsHmNqXWfcs3suLiXo /XiaPLqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez5m-0000000DREW-0ERF; Fri, 16 Aug 2024 15:42:18 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyw8-0000000DOkC-0H0d for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:21 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52efd530a4eso3409264e87.0 for ; Fri, 16 Aug 2024 08:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822338; x=1724427138; 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=d4o6NVK+5RxP9AE82dc0tQeAqHho4Q+RR5k5EOL8qCE=; b=zdNSQZPq+sg7oSjKetLbyXH+I98NHd0t2llUatFbrQvlwq9B/XN/IOdzrudTIHLXTs P+3ghVK357MIdImRhnFk/FHSJqxbw7s/Tk8HDZQzYm85vYB1SvRWcshpUldMO4SONS2e ALk/bLoERBb7Et0dBBVCrUbtVCkGc9TymEU30pyKLjb3MylyANoXQVgERFomSrO1gCfK v1oiB0hgbuqBIV9CAB8SgMfgrcqfRP2kSK7bIgPHcKcsEUzu1bYXG0j+4Lru/WMlGsgt s3Rk698cpvZGHOikMHFk74shbhYGwbEchXSuZVW4+0YW17tznQmincoeQ+N0sh6D26gU xPfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822338; x=1724427138; 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=d4o6NVK+5RxP9AE82dc0tQeAqHho4Q+RR5k5EOL8qCE=; b=fNNGcu+bYGGFtIJGxqN/G95IU2kyVPo0HtuhruJNn+3hh8VdDvLA0dbGPwOhA3WT2K GceMipF3GWl5Lermu2rEQqw9hjznd9HrIevJJwZPLPdqjqk2i6sVOFPbE0iqqSXZ5Yej OTfRlhCCdU4c9i3+MxajOH48cafam1x5IGts0EZUJCcCCbrxFHrpf7l1w3EJ4FUbsmjd kbNzAz6hy2LeTwNoGZzoj2Y+5uGnhBrEE7XIW2LJD7tiQC8g5Co7d4gQQw3CbhiIOaJa 2yRgnRkPHnf1HLUg6mHRWuZF/WfBQLQBOExTtBRvc5GGn3V8/ErHxrdmZwuSiWQDyvvT e33w== X-Forwarded-Encrypted: i=1; AJvYcCXBLM89DPO5DTUg/0z1uCgMoDhmslhPVXjjFhqPfF5irpIeIOltucV9yV4OaVkac//nReamnF62deGl2FlSaj12uwVnBP06xooewH+TWIoB9xlEQZc= X-Gm-Message-State: AOJu0YxuY6Oa42ueHJN1no6l7+qBZzn3FutyGTpoI6QdzRrSRuMmeDFu 26LguTYWEgGieBCGaJ2sLObeq0hs2fzr4D3DNm0YcbHlYFfAsVGknBpZ2Iu1L+CwrEDlRIbphRV m X-Google-Smtp-Source: AGHT+IET/CjplVHoqhJT1dgGbpnM7bOR/IOJJFLcUpaq7hdaaWtUXfMeQ9ArJ1WuxrwkKCsQRRpLyg== X-Received: by 2002:a05:6512:3d1e:b0:533:d7d:a34e with SMTP id 2adb3069b0e04-5331c695987mr2342012e87.7.1723822337538; Fri, 16 Aug 2024 08:32:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:17 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:48 +0200 Subject: [PATCH 16/17] leds: turris-omnia: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-16-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=1244; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=HqurU8v6FoUuPIeHjxpMhqt9yfUTtSWFQuHadg1beqc=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Dn/4FodrZqZy9l8ymKC3RzvyZz5qUjuY2CL I8dXCHswfSJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w5wAKCRDBN2bmhouD 1/k9D/9UMNk7RM3WQGHAruhcdLJVhguE7sJuyHNKcv0JiIT7rLqrxgI0kl0TXtijoBLQifUtmXZ n35/z2TOA0jMGVqDPqGfeNVLVubMwH2nrI2Ni5HcdxRIcVmOI5Qx8hGIAXD8y0+OJYkM+e9+MMW 09hTenPhrVmvb8M7YhycHH1JSDV9cQj5pWdYrcf9X259N9O2dQzVfpdI4UA9GtQqSNLEkbuW9Hp y74zqYk3zBvM3xAlvg43roVpp4MqjH45PtJ11CNOOpMNAVh4KO+73Sx7Y/Zxhc/iHv18ky49WfS lGjmWX7aYivBbwfKDQrc1uuJsio9CXHKui9IFVREXod3XAW8dFzQmBJhlmrhp2ppVcf3wqOCd/g v2zH8BG+SM+ulHja62+nlUfuD6B6vDBpNLRKLkHC0jKuhUb2yXe4OFT17v8Vwkzs6/t0vCbKIoW idbzDQf82L1WtL+yWv/brsico0O/8/FBiODTt15BMAZ4wYOG5YrOem6kGbv8kSxea9vP+S7vpdO 9JpanPlCJQ8Z4xlCm3uumDcswywrJ9FhFvqonNLpVQfBwk6gcMt7q1GkAsIB0P6LjEgEHgdm3qD ZGlGjHkSWXHGIFYWFg5IYbAYfEzX3nOZJAkkSKxMA+DQOjYqzxql8WnOoHOeUfh0p5rdk1Os5pI C3oB8c3EPtY7V/g== 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_083220_135172_18D16987 X-CRM114-Status: GOOD ( 13.63 ) 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 Reviewed-by: Marek BehĂșn --- drivers/leds/leds-turris-omnia.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index 39f740be058f..1ef942b5cefa 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -452,7 +452,7 @@ static int omnia_mcu_get_features(const struct i2c_client *client) static int omnia_leds_probe(struct i2c_client *client) { struct device *dev = &client->dev; - struct device_node *np = dev_of_node(dev), *child; + struct device_node *np = dev_of_node(dev); struct omnia_leds *leds; struct omnia_led *led; int ret, count; @@ -497,12 +497,10 @@ static int omnia_leds_probe(struct i2c_client *client) } led = &leds->leds[0]; - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { ret = omnia_led_register(client, led, child); - if (ret < 0) { - of_node_put(child); + if (ret < 0) return ret; - } led += ret; } From patchwork Fri Aug 16 15:31:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766563 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 83E8EC531DC for ; Fri, 16 Aug 2024 15:43:05 +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=i72cl2LG6rsfBE9NuFNe0vCjzQLf8lqqkLVcJWffpKE=; b=Lcn5Mm8+XLrMFy6mI6vR2TOruF XiLCbpGyh7f+Iq7wqsfJot1NtVrjHn9ss0sQ414mMNPIF0FHnbf1o1PgORvAVgI9P5FpjnphR+Ecx Kr77YQAGNbIcroscO7RYSUFNGU3JQhJ9vdDwma/EALqs6ZmHR6HEpbCdRgEDlcWNyreoD6Jwd/8Of /Ujju53tX+Htqq9/YVg5qVmtNLHSFrxPGDMalrf0ZBDeQEP0DbNomh2D9dGm2g4SEOyEVC9o68whv 8nH+3gv4BDAQOQowplfZ5uUZeVdWEXAfhzuX011Bf7RBai3ALblBu9uPQYHxSpKYD/HRkjc6VfUXq Ikk8SWKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sez6P-0000000DRLK-0dZs; Fri, 16 Aug 2024 15:42:57 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyw8-0000000DOkz-1a1x for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:22 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3719398eafcso645547f8f.1 for ; Fri, 16 Aug 2024 08:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822339; x=1724427139; 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=i72cl2LG6rsfBE9NuFNe0vCjzQLf8lqqkLVcJWffpKE=; b=WD8adzXUIk/khadRaCUzhmKiEK8Ge8gzlE3758odUdMK+4yBubiCfpxxtLE07G/2T4 IAbZQmzwTulptu7/w4JyHEV7SEK7B14x1yh/ESjmRC+Yax1DFkPEcOmWUi4QldCg7Pky avJf0rftgIKfqRj7qajjSDyoRN/STsbAqXGuRIb1dsaCKPz7M/qNw/RnLKulRHVwzcAZ mmT6e8OyNDkcBNsSxyELtPSx/X/3l9MtFjRnRiJz0Sn3lm1vRGMloP3wQdIfmY0Y+pJT +ZTa9s1Y6/Tdy6Gd5MeaYprkUfBANGcsyp1Jmkacz9p6G6jLBA0kSYpqCcLqbgIGoyep nkmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822339; x=1724427139; 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=i72cl2LG6rsfBE9NuFNe0vCjzQLf8lqqkLVcJWffpKE=; b=BLcGMx2V9in1hmVOHyXGJPPveElrZGMBDB+zNaQj7+VdoCYhUESWxpgEltSLW1PMGx cr8LrxWn582oVd2FHVH0Vk+7ySldhyPkyp2EIguAe9fBVMrIByx3AxH/GvCXFJWOrtc7 iKkaVqurd2kCZOum6R32H28jdwxuyiTWDaKR2op7i5wXEMqNbTzgO7NgLfFYRwDbnvSd s4nI2byFr5uawZIB2szUbCzYmUTgptVYN+XrSdWKOpxtnBAAV5VuOpk3ok8xMAqhjETt IZlcN7jJxlYrRlqgu7XSb+FLwUZgjTWugAo2kNp8DYfNopsKo19Yo12ayOHk4M0fJpqV S8+w== X-Forwarded-Encrypted: i=1; AJvYcCXfgDL/6R5+Rgu6nRqv/XGNQToya9LZlPI0QC82god8XgFTOEWPgxUw3rOdUbqqKPYXUCpDs+toC0waU8teqbhdSsCJzC2MMUdRhdAX6ODpb3K5svA= X-Gm-Message-State: AOJu0YzAK5L8uSmJcO3qltjkrix7eJaMq5oJsG2BRvPhDP8NnTVu5Skx kzhabX7HffNYl4mf05xXOC+3tUaCqk1uf2dsMMz064Ir2zm5cM4PT+HHvxfGQtI= X-Google-Smtp-Source: AGHT+IED0WYx0TreQX2OrKap07J96mSpWj6wWPju1D8qe2yhsCsW41zGu895F7DsFQ1Mn543/zW+Kg== X-Received: by 2002:a5d:4b02:0:b0:371:82ec:206f with SMTP id ffacd0b85a97d-371943293cdmr1861574f8f.16.1723822338955; Fri, 16 Aug 2024 08:32:18 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:18 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:49 +0200 Subject: [PATCH 17/17] leds: qcom-lpg: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-17-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=1848; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=evm4/Qf1Gix0CG1zjk2y90RZHb2Oo+FXRI+CwqZngfA=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DojUfs6j9ghjY8rYQZeR83/DBn5C5vGVai7 SH1nEKJD1aJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w6AAKCRDBN2bmhouD 12UID/4yUfw9u/p7xohuwxORPZDDT+wUHcCCjyoUV2diG+Nd0Oqzcv35eu6NeZNl7BNB3X0EQoQ VQn8BrW9aEHJFgdQC2UPhVqwKnqyy2th/AJfD9MDAa63IdWIdTPI4ZAUqhAMFTHyj4QCIM+Cewp 6LSA+M0GHdFwqqZXKWRyINxmfNb+nD1yOcUJSn1p4mQVAlwWCr5tXZEmhFh/pvurGumxCqeHGt4 EEPK8uuEV/ZrxuMoKFKYaZxEmbrQkvfISkoql4+54GXtQ4u7qmSdTqCSESVW8wrX19GteWzW34w /3rW7iV14tptFvALyHd80HwsDP/FpK1oa9PDUI4ukf8VXk4DMcTg0/DlK553j0gew5RgjMZszdh D6o0hFLVuvoe4M/wRvnYDb2c/HvPKNwKG2yLIkft3ezelGstcfsyprKU6Wvg9ui2s4MSiYcfIpb RkiasvWRnhtsxaMbCeE0GbtB8xTkCUJufOlMHca6MY6/0upIL7buM+iZ2gQD03zfpWZChYZ9xRT noGcSiHIFcHWGBT7QU3Aac96iJHkrY4pfr8vq2oE3o8DZhpegNlm58HqHDk0kl89GIR+JuccPSF ZN/CyNtXDJP5V8DPnd4ZHC6QzRAeZYyQ3PrXV/BluuDVR+gcWQ4G60i6McsRcpRxELK+EFjjgst yLwTWCItNdg6GjA== 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_083220_482332_8E07074C X-CRM114-Status: GOOD ( 14.47 ) 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/rgb/leds-qcom-lpg.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c index e74b2ceed1c2..f3c9ef2bfa57 100644 --- a/drivers/leds/rgb/leds-qcom-lpg.c +++ b/drivers/leds/rgb/leds-qcom-lpg.c @@ -1368,7 +1368,6 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np) { struct led_init_data init_data = {}; struct led_classdev *cdev; - struct device_node *child; struct mc_subled *info; struct lpg_led *led; const char *state; @@ -1399,12 +1398,10 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np) if (!info) return -ENOMEM; i = 0; - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { ret = lpg_parse_channel(lpg, child, &led->channels[i]); - if (ret < 0) { - of_node_put(child); + if (ret < 0) return ret; - } info[i].color_index = led->channels[i]->color; info[i].intensity = 0; @@ -1600,7 +1597,6 @@ static int lpg_init_sdam(struct lpg *lpg) static int lpg_probe(struct platform_device *pdev) { - struct device_node *np; struct lpg *lpg; int ret; int i; @@ -1640,12 +1636,10 @@ static int lpg_probe(struct platform_device *pdev) if (ret < 0) return ret; - for_each_available_child_of_node(pdev->dev.of_node, np) { + for_each_available_child_of_node_scoped(pdev->dev.of_node, np) { ret = lpg_add_led(lpg, np); - if (ret) { - of_node_put(np); + if (ret) return ret; - } } for (i = 0; i < lpg->num_channels; i++)