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,