From patchwork Wed Aug 14 15:04:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763619 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 8A642C3DA4A for ; Wed, 14 Aug 2024 15:05: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=3la53aoQx5CXNdnscGkAvwRAocgNTDTT4f12xEvMb4M=; b=WYVBH0YnRtF447bTh+A8kb7D4n O/oGXUkcNXTPOykv/7yvZMfT0CqIVO5+2onAF4cYmgh0cX3uFjcRdt36zJPSluv0rBy+KcEPTKysA tBnYO+bGl2horSB+GgGYWDNDVvLYVl9KrUU8YJAQYLNH1MTOzZ57HnJ5NGTIQtwatTn337a3KM6Fp AX+awUtzYDrBqVA3mJdQjqiQORnJQC+T8JGyfkCmBcL5CNVgcH+ixcfyJBariL7KNLSc+AlQFDlvl Yybyn12mpP4K9URgEwbYdgoqglcghPH84Km6e1vBsce8gG51nXu1O0MOqw6YFxKUfvINDSAjAVbfb hKOgSjeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFYu-00000007Ptu-2TBn; Wed, 14 Aug 2024 15:05:20 +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 1seFXw-00000007PhP-0JP8 for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 15:04:21 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42809d6e719so51645725e9.3 for ; Wed, 14 Aug 2024 08:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647858; x=1724252658; 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=3la53aoQx5CXNdnscGkAvwRAocgNTDTT4f12xEvMb4M=; b=EdTqk1Fek2JRr5gfNNraX0fUNdOy/sMw4G8MOoz6QF9dmSdsVssfDoab11/D6/UmUU o60RdlIuvMplCn1j8U+53LV3+t87IZONCzg330peoUHMpnREKFOCwPKvgEZ23vrxwjEn tAn5twPJMnOi1FOVlPFVB1vS+1ITxmOmAM/lhgAFfV+oRH93PjbPwZSq4qs8IgtHc2zM zfvvAJDz3bfkccxoBEvOj3c1fYKawpIvesZRaNaeBs4b2qHBjDN4I9oGcl2C5c+EDfb2 B8SehaLhbDugO6Dt/QsMfOUxdJd2XInMS1julZWEvqPW/AwVvU41DDC6LThCh4yKdm41 dWJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647858; x=1724252658; 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=3la53aoQx5CXNdnscGkAvwRAocgNTDTT4f12xEvMb4M=; b=YlUocJyeTebat59HRS50f6YlM5tbN/ANueiuWFGV8Krwj7UeLmmS3sxWAGMzENwGT6 u7tQrJXnGVm178kjCwRBYZnu2ZAO3Y2ZV1bctg/05FI1dJ7zKuhP47KD9W5sahanhLRX 7IrXU2Ej5YgQrCXn/1YCCpYJdDQK4U1Jtdypt/q9qkrkSTkLaXBA+4p09CThKz6TPEfb ZgdtNgs9MSlP1pMcEYI6xPxka9XlC+hQcVbkF9+5QuhxoY3RgNljC3qyw+Eyk7GPvEol gyWblUqb7QwZuN+WWVhWClS5pht61HmophmVEk6Ckcw/R7+3vHbCijJFNQkgU8DDV9Ua p1Rw== X-Forwarded-Encrypted: i=1; AJvYcCVZVRJVemQZYAQfPQsZcdLfBRZYkDGUAg0SV0O9y0Yu+ZEeLobOKv97sYpa1uw7CBl6xaZdnE91eiVqYAT2ugfb@lists.infradead.org X-Gm-Message-State: AOJu0Yybt9QbrIG9+7+iM+w4IFnX/Sz2m5xmQW0SIqBD5aNNf+P1iGj9 y+uN7RWgndUqWKAYCCC/Wg4GSSKx6/sNqKUZLbH/OT/x9mrXmoDbRmZrilz61+w= X-Google-Smtp-Source: AGHT+IEEcMUngaR/huI9xnvuAYfbKL2PYJIZ2I2Vju7agb/lAgnPLeyDFgJH4wZoy7E1fNPizlP13g== X-Received: by 2002:a7b:c385:0:b0:429:d43e:db9e with SMTP id 5b1f17b1804b1-429dd26701dmr17332745e9.36.1723647858216; Wed, 14 Aug 2024 08:04:18 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:17 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:05 +0200 Subject: [PATCH 1/7] regulator: bd718x7: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240814-cleanup-h-of-node-put-regulator-v1-1-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2068; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=rPSu/s1mk/65EmKeel3ZSXNy2qhadMl26zNDJ4MnfSg=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdnvE3Tn9NSxneESR03vM+B9CHmU3fn1L1iH fTFW0d70F2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHZwAKCRDBN2bmhouD 19SiD/9H7/t31qMp/9HOygrF7TQy7/pnv8R03i/MYIwYR69rIis3AfXj8hHucOo68d8YkO+17HV lzkY17jjrFSogIb6rrYQiJEbm2DGsPSc7nEbwFLsxWSqESCQOYapjwnWRF+VcjVnOYKG6tP4v85 PZ0W1q6Nj0eP09oMecGZkHAVwtni5yfEeu7gZT+rQoK5zB3TU/0gRq59NBPQxmQmrfcNalqPO0Y oSLOLXD9JAwPzOb5pxlUGOkuqWchnkoC1dbA9ntblSVJY1wm6EVmZ3plr3zJ1ezTE4jmBFQSphe YczAeSTvS2pYbEL+MPMx4cjMIghjAXsvafZxZ1xAdQH0vnJu7etHKfHwSDPdsm4rNokdQBeCOUn SupZ8PkQvlWpqMQgjYCY96Vbr5eo6MIj+ZzinZ7BxHA1EouaFtSGZhWFMG8f1gSPPlmyeu1h96L 3dkF/K/Nuvw1W8hXOIGD3eyF4erBxHoB+Ox6ivagmni51cAFEifICvmOfjOtXUthc18OM8cAhTE 7GjTNHLAnVqdS4mCrkGpvrqk8JGba3XyADO7uspHBoyzD944CtmUuj/OTTXiK6aXF3t46onz7KB 1mV/+d6V9G+JxlBLfcmuCJ7D1Wd2+SMmcY/eC4jCfZ9WPH0iG24VBedhx1uSdVbmsoNapiDafhZ k7GXMyCKl5IZr9g== 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-20240814_080420_150817_50DFB75C 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 Obtain the device node reference with scoped/cleanup.h and use scoped for_each_child_of_node_scoped() to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski Acked-by: Matti Vaittinen --- drivers/regulator/bd718x7-regulator.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c index c3fb05dce40c..1bb048de3ecd 100644 --- a/drivers/regulator/bd718x7-regulator.c +++ b/drivers/regulator/bd718x7-regulator.c @@ -2,6 +2,7 @@ // Copyright (C) 2018 ROHM Semiconductors // bd71837-regulator.c ROHM BD71837MWV/BD71847MWV regulator driver +#include #include #include #include @@ -1635,18 +1636,17 @@ static int get_special_regulators(struct device *dev, unsigned int num_reg_data, int *info) { int ret; - struct device_node *np; - struct device_node *nproot = dev->of_node; int uv; *info = 0; - nproot = of_get_child_by_name(nproot, "regulators"); + struct device_node *nproot __free(device_node) = of_get_child_by_name(dev->of_node, + "regulators"); if (!nproot) { dev_err(dev, "failed to find regulators node\n"); return -ENODEV; } - for_each_child_of_node(nproot, np) { + for_each_child_of_node_scoped(nproot, np) { if (of_property_read_bool(np, "rohm,no-regulator-enable-control")) mark_hw_controlled(dev, np, reg_data, num_reg_data, info); @@ -1656,22 +1656,15 @@ static int get_special_regulators(struct device *dev, if (ret == -EINVAL) continue; else - goto err_out; + return ret; } ret = setup_feedback_loop(dev, np, reg_data, num_reg_data, uv); if (ret) - goto err_out; + return ret; } - of_node_put(nproot); return 0; - -err_out: - of_node_put(np); - of_node_put(nproot); - - return ret; } static int bd718xx_probe(struct platform_device *pdev) From patchwork Wed Aug 14 15:04:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763631 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 F2C94C52D7B for ; Wed, 14 Aug 2024 15:08: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=dEeIEqLVY1ZOACq24mYbeXb9wBOy2fSNM9DcJntAJ74=; b=x71L6xI6bB4Ifpgw/kjHol7vGH cSwmApzdNl/tJ4g+ha/c1hxc1F58ZHmob3ZQHnPVmqrCzVZW+Q3NsBrpaCM/vdgQec8y19haya5FJ xa634rixTYplLKUi+rB5OrJuOOShLJDD3a0prbPYymydz+lLK9IfSX/8l8OnxLef77owZ4d28Y/1z YeNvSSO5ccJTbdxWlZkaM7P0yRGZWm74cNHg9s3wwiDVjpbV6gEduEw/L6v+1bw4Suw2G2JT4/Vzp Wua/HinAHgq4NMkDcPnCRSDtwBw+jiNwCF6CQ9zH/dem1chAzEindibEL1DsoOBumLJ+b6K+K5AuN HmJDQ+Qg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFbL-00000007QWa-3np4; Wed, 14 Aug 2024 15:07:51 +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 1seFY6-00000007Pj9-1hdc for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Aug 2024 15:04:30 +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=dEeIEqLVY1ZOACq24mYbeXb9wBOy2fSNM9DcJntAJ74=; b=m+T6oBnB0ysL1hSeqKGpfnN+XU 6WKrLmDX5jSpWln7HQcybQjyME1tBc020zSsTsejrs6khxRsvD3soGqSFWvr4jP8AcqbYEUrysFNb bnImStwblZczwGAPii084fIsF8PI1eVvCZbvdCwJwazSHpOJWYVx65BYaCjWyIUEi5bWEssNBsvbi L8ool1ZxM4XTrnEzhE79vYEvt/7CLuN5QWuqBFp0GehCJNoHfSjP4rBALRXlJMK3kzHB1OEh6tKH7 jRC96yQUHNtNCmlVNiLbnaZtvjYBJ/OC4ORbTpaiq//ghUi+cy7ck6lrkXGwYsDTjASMLHuqFKpvU IqFe/sRg==; Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFXz-000000085IA-0KCK for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 15:04:26 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-428119da952so47157215e9.0 for ; Wed, 14 Aug 2024 08:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647860; x=1724252660; 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=dEeIEqLVY1ZOACq24mYbeXb9wBOy2fSNM9DcJntAJ74=; b=ziZ66JpybZc8ivQr0yoYMuRqgGuHrFiDmkNvezF7t3OB2b50FASqG5Eg/BHpQ/uItt mODmIIAtPCW6/1meduRSOf/EaP8e9MXeErIyYVPvSYWfmtg8gCjHogWK6lMnEuso1LiI 2mdGVasAmlTtd9bNNHn1lYzKn5K6maNjgk/3PCJYdIairaemBc8qkp7kcl3A6go3Xy+M QozIqpb6fffRGmPMEzO4Y7wImMZFovdF1O6/TVZyjGRph/5Hos8CBFid7jsWFF8t+vDQ ziw15ox46srHJrNO8vV/lzpCbOGQn1IdAodu0AQOwB3UvQrOZ8kAGVb98xwEoC+iYOS7 Or6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647860; x=1724252660; 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=dEeIEqLVY1ZOACq24mYbeXb9wBOy2fSNM9DcJntAJ74=; b=lnVlMPAyhQDNXMblvsYYf1vpmxf7CSvaS6cnAwq+7UdV5Nhk+2ElAAqEdEcZ+K50Wi 8Wvgvy38Lf3BZ9NtD5Vzok9lGLWEAVpLieBXAxvV52GwPB2ePp+YcPT91n+RtlSrKwZ2 UUQb+M0uu/zbxX73hRR9TEK+L63mZ58pZCDNb0ylJdE9Epuh/2LHjnyOMIivYJFJLSyA taMEmiYw3PoPjqrn9McB56RvA61PHqNVeK+KSojBtQWyvFIj/pUIM6zkqRtJTuTGgTIY Uwr6OTfp8NzyezcIBy9c/LX7Q5zG8y+hI/cwdaiPRWTduGkjGknNgoX8oGHCs+RWGZsp YBWg== X-Forwarded-Encrypted: i=1; AJvYcCXmwJfFAhFJuiZWY81HqC+VH+LDz2uYgxBQTdfaY4pjwYFs5cypayh/XxKD5SWPUFyOZWkaphyyOBA6fW5IZjVnUAeEDASm0DeD0waGcy/yZDPnfpY= X-Gm-Message-State: AOJu0YxNI2Qdnoh2xrehQHpAFZTI/rS4B2NFkb9u1Q+ri0kOhLLjIUt5 KujJ8yade0se3U5Wq/ohOizkS1bYFPgoHzey5uMeJ9AO9IfwFbnyQL6D7XdENaI= X-Google-Smtp-Source: AGHT+IFT+r/UF1JH6FSsBdVJjL7VZm2U3O/9DdLtdnvhN4tdlKULjzOhZLrhWci1h9xgCzKbbXSdTQ== X-Received: by 2002:a05:600c:45d4:b0:426:641f:25e2 with SMTP id 5b1f17b1804b1-429dd25fa5emr22233205e9.25.1723647860210; Wed, 14 Aug 2024 08:04:20 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:19 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:06 +0200 Subject: [PATCH 2/7] regulator: bd96801: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240814-cleanup-h-of-node-put-regulator-v1-2-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2266; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=MNChZLpbj/MWNGgnwsRcQZFxOn02r/u5ky3hmD/OW5o=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdoruzUKLXQwbjGAbagYQRMvAI3PsR0rLQ3V 3/d6GTLP6uJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHaAAKCRDBN2bmhouD 15VjD/915tQj7Qr/6BMFohsF8gAVyxOqUm4K+gtazmjt00iFyD/Orfef6dj8ZvNjvrJrWRq0W6+ pXjE8qpNUNa3Wtgo1JPy609NgdDYqcR6/3EBi4BBlVji++M7tWPG8JemQgwc15rdWMtB6Ej5oRR DoRO21/y2QoVbOuEVt5K4oYn8lg2O5nPVWJzm0s7WsrbIw79DqJtci8BU2nhPlcV2rhlm+YLWb9 Xxbr8HfPE9lqPCO8iz0Smvz1f9I8gr7DBJjOJ6a6Dfc7TVqyXLBKi2bZBtYq7b25f4OtgR/6KNP 7lHQ+3ZT1uKR5aZ80FYXj43Ll2njZERAWhYqVgkdqjE2Rcxnf9mKckvPYGWAe+e+J2kKY8SwUyt L/oPBj6Dyh5PB+bwMVtnLjPYdFKFRjQyW+KUHTcrznWlxtndQX9DO/Cdrbyou4pskzambf/W3fw 9oE4f8Y3tT6tN/IEraEh6FcVLI4fGays5v52k8T9k+cN5Wn8jTY7OHGeXZnJCWTsM7+z5RhkG90 gWRIcBmRA3lPQ8WxbBbf/UFT9szAjyaOqDffANjGHs9xlq/l5pV7iLsusIm0ngvcEe8tzJMpat/ npiHx9Q1S1L9u4zZTdkec/mDGVOYm2xjr63eWgQZ/39CNwG5b+dpRTgbmh8W6mrxj23NAbZtGuX wtbSUQR6cYuCv7A== 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-20240814_160423_264765_508D2A48 X-CRM114-Status: GOOD ( 14.48 ) 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 and use scoped for_each_child_of_node_scoped() to reduce error handling and make the code a bit simpler. Add also brackets {} over outer for loop for code readability. Signed-off-by: Krzysztof Kozlowski Acked-by: Matti Vaittinen --- drivers/regulator/bd96801-regulator.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/bd96801-regulator.c b/drivers/regulator/bd96801-regulator.c index ec5b1a6b19e8..9876cc05867e 100644 --- a/drivers/regulator/bd96801-regulator.c +++ b/drivers/regulator/bd96801-regulator.c @@ -34,6 +34,7 @@ * conflict in your downstream driver ;) */ +#include #include #include #include @@ -453,15 +454,14 @@ static int bd96801_walk_regulator_dt(struct device *dev, struct regmap *regmap, int num) { int i, ret; - struct device_node *np; - struct device_node *nproot = dev->parent->of_node; - nproot = of_get_child_by_name(nproot, "regulators"); + struct device_node *nproot __free(device_node) = + of_get_child_by_name(dev->parent->of_node, "regulators"); if (!nproot) { dev_err(dev, "failed to find regulators node\n"); return -ENODEV; } - for_each_child_of_node(nproot, np) + for_each_child_of_node_scoped(nproot, np) { for (i = 0; i < num; i++) { if (!of_node_name_eq(np, data[i].desc.of_match)) continue; @@ -476,11 +476,9 @@ static int bd96801_walk_regulator_dt(struct device *dev, struct regmap *regmap, dev_err(dev, "Initializing voltages for %s failed\n", data[i].desc.name); - of_node_put(np); - of_node_put(nproot); - return ret; } + if (of_property_read_bool(np, "rohm,keep-on-stby")) { ret = regmap_set_bits(regmap, BD96801_ALWAYS_ON_REG, @@ -489,14 +487,11 @@ static int bd96801_walk_regulator_dt(struct device *dev, struct regmap *regmap, dev_err(dev, "failed to set %s on-at-stby\n", data[i].desc.name); - of_node_put(np); - of_node_put(nproot); - return ret; } } } - of_node_put(nproot); + } return 0; } From patchwork Wed Aug 14 15:04:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763629 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 CE4BCC3DA4A for ; Wed, 14 Aug 2024 15:06:49 +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=ql92g3IlSel/JMsJTBmGL12yP4qS4j4UtrmTRytGT1s=; b=Dl2BrzG8zKd286nFwPM5CZZZ5A MJXvYhc4Z8w3y9+whweIZcZlb2GbQR0AjOHEU38OGk7DkCtUkBkxJaysYawcIZKj0CYaaEO5yXx7C LB1U41696a7bczwcIhtklOMvkr1Z0wZQEjxcU2PwVstZXiB1y6lWPEXujROf8MoJ3jsoi17OOUJaH AEwyD5SLzq/iebYzmcZXikxa/3PvjnAwBJx9zsnRzT0OV+oir75ImykMrYKndSrYzDdSEwjhrnjg4 o6UrIksrSV1SzJA+z7Ym9p6hEBcIvBN6DU/H25S/V/lNVHq2Zekl1kVIYxlprCN+FW6DDG6ih/aLS IpoX0HnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFa8-00000007QG9-1lfu; Wed, 14 Aug 2024 15:06:36 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFY1-00000007Phr-0x4O for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 15:04:26 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52f04b4abdcso9198135e87.2 for ; Wed, 14 Aug 2024 08:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647863; x=1724252663; 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=ql92g3IlSel/JMsJTBmGL12yP4qS4j4UtrmTRytGT1s=; b=NJN66nQSIrUtYvy6F+GvF2RKV8YC7bj1OqwJP84Z/LP9HTKUSCfJTgLlnoIXFz95oV 1pyIWA52ndZQTS+qXbs7lhwgi0fC968ZYHrP2dssguEFPo3jjMKb+3EPzJ4LKjbWKAK7 5xnfMW7wmKK+r5cImAIu4SiyZ8rINtSx1k98SAna0PbqlLAneOQoabPY0Z3cgumViszK WPnDo4y1OfPN2rYQ689Vn2olCklC7MCODlnR6/lHR42V0dfpFSAC/mtBi6lHAxwKKnVt 0kv8cwGjIpgO0UUMheA7y7r6K6gKZ6YXQauxwgKTlaICHbHevz1VoEUnpNgqVkhbgzqO OIVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647863; x=1724252663; 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=ql92g3IlSel/JMsJTBmGL12yP4qS4j4UtrmTRytGT1s=; b=Sux39r7DmCI7QM/gl1utJdIlXMcyEJhHE+pOc6bzCdcsIX1ql0yFMkEChq8PJx9lxk 4RtpIwUjJnj+Uwl0hI1qYwbBtFd6Q1z4SkeHXLuDVOkUSU7Aq5nXvulXb6ikaVI03ue0 QOnIuYmKaarJdwOK/Qkl43HRUG2Yfg25wT9AMpd3hYSffyi8D7G0s4r/7kiUI6lAa+fd nZXtiF48UzfVAwJnW2EMlpAQjW1YM329ebKZkU1kjvUY5hxWaFcKVu/qVaErl6iZ6eVl Q6YAg9Cz9zi5utGZv2BdqsPd6T3Q/kXyOo6br/ILhSuio4vZFH0YCKK4s4zSMfjMVjEF bn1g== X-Forwarded-Encrypted: i=1; AJvYcCWsGd4y1AtDf0BXST3K0FN35WLHSTDrbSMj51EM91TkH9zhxhWnF+aauzpHCaAZt5YT+BTdGVAJrEZpt2CfG07rt4iZbyUNNtFiELthD7yrsUxBVA4= X-Gm-Message-State: AOJu0Yx+y5vAsAibzAmbS6hRr9E+CLMvTV8nKuI7jPNDKpfkclQTRDj0 AiR5nNlbWGtXKY/HF8r/k86zIkj1YXS6gRdIyfRYkZA+zBshG/Gg9GVdm62lvlk= X-Google-Smtp-Source: AGHT+IGu3DwjbZr/7noh9P2H71pz2ZOViSHbSyH2U0t4pwvKJvHyX+AJnV0p3bUqSkfSvtJejl7obw== X-Received: by 2002:a05:6512:239b:b0:52e:fa5f:b6b1 with SMTP id 2adb3069b0e04-532edbd598fmr1593960e87.60.1723647862671; Wed, 14 Aug 2024 08:04:22 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:22 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:07 +0200 Subject: [PATCH 3/7] regulator: max8997: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240814-cleanup-h-of-node-put-regulator-v1-3-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2267; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=HKFKyZib5VKnJdUuDJakQAsIhOr5X3HZ7uhakSIt1BE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdp9nwqP+7IBK1IA/FESYOQpVx8C/ZOu7nHN dyB7jnGN/iJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHaQAKCRDBN2bmhouD 19D8D/9qJRD6vc6koDrB7DKkh+SqxKz5mPXuv81NfvAKp+tFZIxwGsSE38f242goqHEvg0UqrX9 dawZdUvXXPprvW8yQUvzaosVLYsXRc6VmfshmGrpqBOk1m7yHeJLDFbwYAvAxMbQSTjub+eHBnN R8a14Pkkize/+HCavGbDnRoeJskMzDuMt3Vpdic7fxO7D55FQ1aAT2NLQpMt3rOpCxnc+QNF84g PFN22YiJ/B2BWzAydXgdiNxzseufjng+ISc0XK5QCxtC9L9F0gNZnFZ7+iRLRu3rZgRGSJmFYfw QlC5J0Iwpm+sxUTvElWmuSTx/LXZhWZ0xVCPWhD92bnWtjRTKG+cPiVf1aKNTycw88Wq1a8dSv9 PuPlf2Y3RIPsJgfNmgYoy/SarvcQ6DD5hm9lzdz9qRxq4ymiYnDQRj6sF7N0TFXHCnU3UDMyAs3 t6UaPf5u1/NlLJCcIGwl1GFQnZVvVBESEkXWMWKTDNExWPgxXaM+/1kA56qZF+XzWvG6EEewhVL rT1bbgSgbq9UYwRaK3nj1lbQSF64DQqb5o0l5trm4M8Zvwj8zqtICo1+qGYnC1qWdB9aKaiH26S LGa+pzCVV7KA/5n8YKfdMYFDfROyoBI8vLci1zwaovbUlNk67VJYY41rGvFg5znsw5ne6eSX6/b 4rvA8VGg995OeZg== 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-20240814_080425_306610_93E25681 X-CRM114-Status: GOOD ( 14.16 ) 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/regulator/max8997-regulator.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/max8997-regulator.c b/drivers/regulator/max8997-regulator.c index cdbfb4561dd8..e77621b6466c 100644 --- a/drivers/regulator/max8997-regulator.c +++ b/drivers/regulator/max8997-regulator.c @@ -8,6 +8,7 @@ // This driver is based on max8998.c #include +#include #include #include #include @@ -876,7 +877,7 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, struct max8997_platform_data *pdata) { struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct device_node *pmic_np, *regulators_np, *reg_np; + struct device_node *pmic_np, *reg_np; struct max8997_regulator_data *rdata; unsigned int i, dvs_voltage_nr = 1; @@ -886,7 +887,8 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, return -ENODEV; } - regulators_np = of_get_child_by_name(pmic_np, "regulators"); + struct device_node *regulators_np __free(device_node) = of_get_child_by_name(pmic_np, + "regulators"); if (!regulators_np) { dev_err(&pdev->dev, "could not find regulators sub-node\n"); return -EINVAL; @@ -898,10 +900,8 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, rdata = devm_kcalloc(&pdev->dev, pdata->num_regulators, sizeof(*rdata), GFP_KERNEL); - if (!rdata) { - of_node_put(regulators_np); + if (!rdata) return -ENOMEM; - } pdata->regulators = rdata; for_each_child_of_node(regulators_np, reg_np) { @@ -922,7 +922,6 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, rdata->reg_node = reg_np; rdata++; } - of_node_put(regulators_np); pdata->buck1_gpiodvs = of_property_read_bool(pmic_np, "max8997,pmic-buck1-uses-gpio-dvs"); pdata->buck2_gpiodvs = of_property_read_bool(pmic_np, "max8997,pmic-buck2-uses-gpio-dvs"); From patchwork Wed Aug 14 15:04:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763632 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 EA881C3DA4A for ; Wed, 14 Aug 2024 15:08:41 +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=5O3B7PyV7G/t+42xNPn3Ro9dRzqDxhODbgBFGwCT/6c=; b=0PNH56s0O4GEhp/XJS3phOjhzq FRe67zu7jgS9Q9AHWsUFO5I05wlIRE4gpcoVaVD91GYYB1VgKrOSBj+laTtHQpBNHtKBy8wNw0BnJ J748HuO3Q8saC8uOYLDsU4dBI6bQvn34dKjEPpEBbySExPbPkIdGI9pfWVanCsEARIc2aJBe6VuxT uUTBOfgOa0s6w1NnIY8/fCdX/NoH7ivniB85n8K8HHx+tBKU8kfllYly6t2Yvb9pfOD/oVkxvlaTJ zOJ9/nSsd1uUd1HMqjrA3u3ZPzXu68OlszeteCNVSL+1ny2FOah9+b9SXwR8xCplFd33E6Pxbqv56 ktqwDc7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFbx-00000007QeZ-1nE8; Wed, 14 Aug 2024 15:08:29 +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 1seFY7-00000007PjW-2l3L for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Aug 2024 15:04:31 +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=5O3B7PyV7G/t+42xNPn3Ro9dRzqDxhODbgBFGwCT/6c=; b=j5xeh+WB3i5ZpDzr4AQbCLMwRU bfIV0yWea7l4TP84XFFsycghR/IDR/i/ZuLd9bB8wXLDlNjlJHTFejhEVrlYcu2wVK4HMynDDhyKj Xqq2wzFMO321ET5Zn0K0sXRDgvsHNDhcBXUqXgXbo3VKfLcqGBApc4Nfr6au+9lSGf1W7kkX2hi0K o0o3MBy6z7JuklZt8sUrmG/VL6cSfhhMOVbIKGs3/WGzG55fCDzB88WYajaVb/ofHQKw3HXlMNCkz XRG8gUC0v7iFMflxltegp3xojF5cxh4BMhBdnguV9xb+23HadrgsMoalY4XtywoIoJcnS4A+Xa09s WEjt1mHA==; Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFY3-000000085J6-0aAd for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 15:04:30 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-428fb103724so5726365e9.1 for ; Wed, 14 Aug 2024 08:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647864; x=1724252664; 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=5O3B7PyV7G/t+42xNPn3Ro9dRzqDxhODbgBFGwCT/6c=; b=aGuZXU54anwV5dy7R3JnjEKwDzdgnGHTYJi0xr1D41QbDKg80mFuRra5mQ2yFQWPoi 8HRAYtYYvi2d3FHSpAgmpBFd5mRe593A8gEEgwPklSh76G1zgF2S2LLobL0qoAZspUDN 4rPQ+0FVmzc33G/G9YNlzkM5R0I3dpu8BB1ltc9XYw4Mrkza/xLD8wwkFnzKpKspuHQU IsYenv3QHoQWIcN0NBdWDwgVyEezo9bOPI6f9fxIVmefcJP+of8zzDYNTiJrAfU8eOsC SAy6Hi++Zr9lpO4OU1/PpzTJv38kbkaNzBXwvTLBqq+L6khRkHH4F1muwX/+AeBCc7VB /sMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647864; x=1724252664; 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=5O3B7PyV7G/t+42xNPn3Ro9dRzqDxhODbgBFGwCT/6c=; b=VJrmBQU8/bekJxL6teL/tw20E8k8H/Juv1453OvcXFu0zK/Y64bPtGi/dU4I7YlJQy kd+Y614uySDTwjCqkFjVePdmw5w7pwDwi98UhLEGQwbLlGjhuuUxUdivPBUHuLUppYus CEP3wTl6cjuaR1ItWdgEOWej/qSE2TECqe2f8Mtc/kgoqkk1XbY7ayTTbJRQmc0Iao76 BE6BzhwnsnEHOUvePn63FtUxzinmvuFHHOOZCX+oU/0mNC6M2KpKb8+utKdKugLhLdzI 0Ss9AEq2yA8vq+GzKOfbGpxd6wfN7HjJ/lIwt6AG98QCsulpixkUH32CHQq1bCgYJ3Jy 82Qg== X-Forwarded-Encrypted: i=1; AJvYcCWYOXH17b2dHzQFSitx/UH1IOUw6TWuneHVcFh8idcXCtbY0uB+aUZzYqHMVovCCQxYNgqskm8rKdDCq49R+fEw5bZ7UAfMpXRwJERSGWlUv30ipyU= X-Gm-Message-State: AOJu0YxptHivbHaavIXKVGBoPby87nrLXuECp0Qlj+cBLs3szHMNBsYQ AUBNr9YMorJJ7stnKVkNB2tfKnFNH6OjTDUWIw0IutbmHOkATKRUIDzk+3Gv87Q= X-Google-Smtp-Source: AGHT+IE6GnWj7iNSWQ5cVSoFgUQG2+GjrEsQBNVpM5I8gWXB0aUTdw2SAlkBE6MigloaWs//cNK/xw== X-Received: by 2002:a05:600c:3512:b0:428:e820:37dc with SMTP id 5b1f17b1804b1-429deeb550cmr19752005e9.7.1723647864513; Wed, 14 Aug 2024 08:04:24 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:24 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:08 +0200 Subject: [PATCH 4/7] regulator: s5m8767: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240814-cleanup-h-of-node-put-regulator-v1-4-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2654; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=krE+SHok9HZd63yAd9AD4NQ/RWe30H45bGKZExWRrHY=; b=kA0DAAoBwTdm5oaLg9cByyZiAGa8x2qgzdRJ7uWuEFgWetBG5o2CYJimnjQmNpYDIYru8BeeL YkCMwQAAQoAHRYhBN3SYig9ERsjO264qME3ZuaGi4PXBQJmvMdqAAoJEME3ZuaGi4PXq6AP/jvd Iimx4qgmPCWd3AGNnGR+rQ0isWDzcSZQ93/mymBfT9iD3jkwm1+U+h245332W//C7xyrDnDvFEO O+z8IQ6QVDTylIa+aIly14fHTaGQ51qEEvVU/4sf0sKAjNFbclF4R8B8ODNyyyIQre4qEqDTQGa WGHHsBoWTYTTdBm7XMgA5Kl2aEyoabBzM6rKFZ8emQ0+yGbR5L6XxJjlwjTWzRxdpS/ZFNBwmBQ YPUHwKvyrgtoBpWY09moq3QNmVLyAxiOnXmeBG+EBYAA5m3FjTjwMo9JTHgjoxdSbHr6OAJ/eaI 46o3/Ono7o1YrlF3563wCxSwiwLb24/vt/arV7ZmY4yhAoMTJKALvCCtbLpSeAjRMeTXumyOfhK 6w06o9uPWfgzxDKpjkw8+MpmfWCMGKUUkAdzfbu/yem76YuWlt2iqkz00OKhYRXlgdrXaPzdejO 5858LZ163EUFa8telnsJtiYQQFmgwNALmBejk/7EbDehPyqOMAY01nulvbpWYsRf220BlU7xN1K TIWxwdmuQNzx9KhFJ56Gs1XGIvpf1dWOSaHM7FIhgymlpuFAgTx8wmDYs4vO5soTo9f9YAJ/0MG D9q4QsGtXdqz37clEN9yMkXAIYuCFND1xYHehOvVX1iyvLTpyGXczNwxabb6T50odkjWwTKlxWk +7TUE 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-20240814_160427_609952_1EEEDFF6 X-CRM114-Status: GOOD ( 14.13 ) 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/regulator/s5m8767.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index bfc0e143bf40..d25cd81e3f36 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -3,6 +3,7 @@ // Copyright (c) 2011 Samsung Electronics Co., Ltd // http://www.samsung.com +#include #include #include #include @@ -521,7 +522,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, struct sec_platform_data *pdata) { struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct device_node *pmic_np, *regulators_np, *reg_np; + struct device_node *pmic_np, *reg_np; struct sec_regulator_data *rdata; struct sec_opmode_data *rmode; unsigned int i, dvs_voltage_nr = 8, ret; @@ -532,7 +533,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, return -ENODEV; } - regulators_np = of_get_child_by_name(pmic_np, "regulators"); + struct device_node *regulators_np __free(device_node) = of_get_child_by_name(pmic_np, + "regulators"); if (!regulators_np) { dev_err(iodev->dev, "could not find regulators sub-node\n"); return -EINVAL; @@ -544,18 +546,14 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, rdata = devm_kcalloc(&pdev->dev, pdata->num_regulators, sizeof(*rdata), GFP_KERNEL); - if (!rdata) { - of_node_put(regulators_np); + if (!rdata) return -ENOMEM; - } rmode = devm_kcalloc(&pdev->dev, pdata->num_regulators, sizeof(*rmode), GFP_KERNEL); - if (!rmode) { - of_node_put(regulators_np); + if (!rmode) return -ENOMEM; - } pdata->regulators = rdata; pdata->opmode = rmode; @@ -581,7 +579,6 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, rdata->ext_control_gpiod = NULL; } else if (IS_ERR(rdata->ext_control_gpiod)) { of_node_put(reg_np); - of_node_put(regulators_np); return PTR_ERR(rdata->ext_control_gpiod); } @@ -603,8 +600,6 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, rmode++; } - of_node_put(regulators_np); - if (of_property_read_bool(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs")) { pdata->buck2_gpiodvs = true; From patchwork Wed Aug 14 15:04:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763630 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 73A3EC52D7B for ; Wed, 14 Aug 2024 15:07: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=9KwtbTNhxK6QLwV2KuYR/1Wk3sxaWn7bUkVHDhGR+MM=; b=uLILc1jbbDnZNCcFANuJ5an1bU 93iWd1+sAVba4uKUP5ZZlF74UYxkpIyffshddThtxeWKdu0tts+LxwVNe7pLBvL5zugbB0JwVSb/A VQeegkEUOQcTji0vmvAEUTxTuATYTDoqdP60G2K5+VIrBNGvCRVYnen/lvuNjuCdBF0Oan5TeGFOv A/ovsOEpLV81qoH+tKZFwrDyo1ADH6X4nHmGWSaqwlinwZRSK41CGV3wKK6JyubEFP4px44Ts/a3s WQspcGoOUps94sRN+QRy0Ticl63RolnazOWYl0dxzsWLYZljne0nMjdUHdMhq76WY/2AvoGIsBxjp Jh0yOjDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFak-00000007QQq-0ouv; Wed, 14 Aug 2024 15:07:14 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFY4-00000007Pin-2rZp for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 15:04:30 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-530e062217eso8359150e87.1 for ; Wed, 14 Aug 2024 08:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647867; x=1724252667; 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=9KwtbTNhxK6QLwV2KuYR/1Wk3sxaWn7bUkVHDhGR+MM=; b=C0VwtrAHNWhdynU97WdaWvotf3TrZTQWbFjEIx+d3rMwWAnVie1llp5KQH07jNBn6i aLy92w8BcrjnwnRbtOMq6kBR+hrcmf4AMdHwb/ayJUNlJaLHsXcqCsI7oiw/lwBlgLmV Fez7a8FEUNbpst7B84Fmf1E0WkHaPRTTo88H2DmvjaxZWWUZebdJvvWz4CK3pSVD4wjg feEuZI7n9G7kJis5VmRKUe1UTaZe8EXyMe87DXER0/bWXotMGAUD/iHcy6P1hMqzYlxq M82nfzpx+I4ZBv6BsTNCKjDnGGsBCyOQzahpR2Ghquj9clGjWXwLGnOHmwwLFm8Ezptf XHVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647867; x=1724252667; 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=9KwtbTNhxK6QLwV2KuYR/1Wk3sxaWn7bUkVHDhGR+MM=; b=AoVKetPQGF2gzntJy4pX8G2I441iOYYU5olNiIVuLatWPPMDRLPdG9BIiR4QsCU5Nt ekub/NdpcgE3e144xK1VCK+zr2NlCT/b4Q/SK1/YAq7krVyEcDbBUfb+IfTwDA7dkc16 YxtnOTGLIcTkBkP4QCpkrn/w+/Ky1uc+Vewm6VOoXLjj+4dPVR7HXTuESHv+zUzqtcZ6 wXCZMxtD76VF/mK8ipihylO3W9x3Yg/cbDYz6s8mWyvHk2W53/YEWWeyFmiMgnmPu2a0 2GJRHUtds6kLDOCWhGBg+dX6/6wImWJxVLU6As2QTkt8Te1yp/5VkRLOngLDKzz/Slc6 bNIQ== X-Forwarded-Encrypted: i=1; AJvYcCX9G9+0xD7apPotnj8BXuuuQ/S29xPqCT3/Qem2mrE5XiF+groyQu5gFIQHfKnFxpJSxn4WEKtE/g6aMpEHR4AeoL7sDYxV/2zFqBW61XbAWYStJmM= X-Gm-Message-State: AOJu0Yz9BwsiFIF09dTXlfWsxoxd2rHwa7biukpLPtsbRCXnwmUwvMuW NFrEtgSspQZf39E4u4BGyP3FqJiFOZVh3yF+0BUVP6Y7xzIyGtP3lCnj4jOl+nk= X-Google-Smtp-Source: AGHT+IHWzR0X1/chVI5nyA1bbHhSLG/im51ue7HmP59m16YndqKv/URofmBboXJLf4NWv6CumXY1WQ== X-Received: by 2002:a05:6512:128a:b0:52c:f3fa:86c with SMTP id 2adb3069b0e04-532edba1f04mr2399025e87.18.1723647866779; Wed, 14 Aug 2024 08:04:26 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:26 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:09 +0200 Subject: [PATCH 5/7] regulator: qcom-rpmh: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240814-cleanup-h-of-node-put-regulator-v1-5-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1376; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=eOLW+7XCSrgYl8oNaIQs1U9NSlOctUB76u7J7/B21Wk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdrmXbX+7wxh+iBPMjSGusVfyVLcDmyopVEi Nu88lC7I1yJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHawAKCRDBN2bmhouD 18SWD/9IPpuPdYyOE7Twj4hDzgTcOT9AIVyIT41gFT4Y4Z6jo8XeP+z5bovXs/kpHX3pEuzFq3h eyPfwoxpaUuIEY+UhO0808X6GZwdGqofvuRisDO6osxa11w+CVPKGqW5xJ6gUmOaXdoWUN4x12I TUDwvuGTZQ77KyG+cLBAovMp/YjDe+uqnkv9SHxh503dnBrEAanMsX7rtsWbywnhNmQc3MSdEYP MB3mZnzVxYepZNmDi6tBK6iz26Uc0sb3PX8nJQG9GsHN/M+OB42VMGegkPoxEB6eFAhbvkwtGjd hk95FjI2jS2r0psjHIo5+bUtUlZxlg1A/caT03HoixwHlXCv1I+R2VzgoHsw/mIxhItu+quTRI8 uBclKP91xKYg+M/+tAnFz+zwNuHUyT+JwYciz37mWfkYTnfdglfLz80ksdY7QiE9SNCqBHJmmU2 rlg9dHV8D5v9enKX6juMfbToc81LfN5HRCj2AFIH14lptzs0matpmHQWwR8r+lTimxzPQjQfGs7 4l9dtaYw8lcUPoWkRWWuy0V8eAwBjPh3JvdCL0Xi5VRgMp9BnqE/Vjni6DsVjMqcQ7gB0Jl23Gd wFkfK/kUNyJsQhXHmCppXV7SqODs0xCQ+cDpPLlgjokumG6D2SrLNi1+VPyIq93YuB9teHEAOLm X97Wj0+Qwn62jew== 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-20240814_080428_791638_1732174C X-CRM114-Status: GOOD ( 13.44 ) 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/regulator/qcom-rpmh-regulator.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/qcom-rpmh-regulator.c b/drivers/regulator/qcom-rpmh-regulator.c index 80e304711345..6b4cb7ba49c7 100644 --- a/drivers/regulator/qcom-rpmh-regulator.c +++ b/drivers/regulator/qcom-rpmh-regulator.c @@ -1537,7 +1537,6 @@ static int rpmh_regulator_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct rpmh_vreg_init_data *vreg_data; - struct device_node *node; struct rpmh_vreg *vreg; const char *pmic_id; int ret; @@ -1552,19 +1551,15 @@ static int rpmh_regulator_probe(struct platform_device *pdev) return ret; } - for_each_available_child_of_node(dev->of_node, node) { + for_each_available_child_of_node_scoped(dev->of_node, node) { vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL); - if (!vreg) { - of_node_put(node); + if (!vreg) return -ENOMEM; - } ret = rpmh_regulator_init_vreg(vreg, dev, node, pmic_id, vreg_data); - if (ret < 0) { - of_node_put(node); + if (ret < 0) return ret; - } } return 0; From patchwork Wed Aug 14 15:04:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763633 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 AEAB9C52D7B for ; Wed, 14 Aug 2024 15:09:55 +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=Uby3vx5C44xympQeIPbZuYUa73IoZNR3m1Cs5S0QTJc=; b=0I7l9W9AA/7VAhLdd1glvwOXpw pGeMWPyFBck68dV8jVX+9lD+mwRG6s4JNWaW3GgFi56G9AxSfX5NZiXVZxxaHRwctj/q8sLiai+qE I8kkmS26vVxph4pTcXCesAjn/RTkq2aYCjvD6A8b+8AkiHribNZD/0p6mczYL7L0EO7cYSggxWIcE 8eVJF0tsC+f/vL9nvdp4SgucTk5qS58OmXV4jfCTpwavKufDdUstFPN2fpk/Z0HEPMsqLMFM5GOW8 wFWdC4wfL8zcxo0KWZ/WKvGBd3gRCQGfyMZheblnSBc9OUrARd48aU7gbBBxgmozeosN0mg8Cjibi 96VId2ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFd9-00000007QuB-1104; Wed, 14 Aug 2024 15:09:43 +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 1seFYC-00000007PkC-1c9S for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Aug 2024 15:04:36 +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=Uby3vx5C44xympQeIPbZuYUa73IoZNR3m1Cs5S0QTJc=; b=Pr8NnsLHbm0sLm4/52jhVvuyWU exyn/IbhGhEHxOzE8bSWWrWzCjNJJSFuWLi5i0g40Ltbevso/IngLiVew3SXPY6RD7eT07BGq3mT0 pw6Lslb2XUkvj9RMkhnOGlJ8a354mWXn0QVrhyou6qBwYiE+Fm7tRaf6qK/bPX34E4w8pQeJrJdEI 8xu2ufoc3/s1lu6KyW/tddjpLreLNEAJ4aQJ+v3ee44G3KfTAl1eagmQq/R34Yd4b079EwEXDBDpY GdLE2VhGdrCFiICCDTQIWuKIYrxmcdOR9toUEWVhkEIY3g8JDONZovRac27RAzOeFTAE2AwUoVrv4 thToKqow==; Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFY9-000000085K4-0Ipk for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 15:04:35 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52fc4388a64so9490718e87.1 for ; Wed, 14 Aug 2024 08:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647869; x=1724252669; 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=Uby3vx5C44xympQeIPbZuYUa73IoZNR3m1Cs5S0QTJc=; b=nJZJQqgrJeynmrsX2jKqsJ3sv7jzcbZDhCBRTZev2WTxsIhbEGb9t7rurdNWTOtIRu js1sZJePoWvMRUfrqpHfgwt7X73XOg3bVFEwNWuWQajUYm1zirwODnwBTKf8O6F8dOCu el/uPJ98cbfewo4M3VpMzYxaY3QHQXlnFY3dMBiEEJFj/FMHo1xbglNvRJ+8XaU8993M WunaI3Tx0zF7fPVy2jSbGhg+r0ZLl+YWd7sy6jYSD47Tlgj71qTyDx0cbOzypp3r5kaq 5TrWW+x3rjKj30phN2bUdGupSfsf0Ist/16D2V5Chh8VOfRs41Mt7d1wNWuaY3194aXw s+vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647869; x=1724252669; 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=Uby3vx5C44xympQeIPbZuYUa73IoZNR3m1Cs5S0QTJc=; b=GM1ufBsQvulXvm+kXVndI7KT5ShF5gdd9KYrLZ1E+scjoTAphqSrcsMihv4IZlCyjV Fqovu3Mz0ZbsUo5fHJfNTi42y4jBHiA/MPveY2/6Yl9WNhPqAaOePqCt1XTS6ajQ5HSL GhAfNPRYsRtSvLMINhFcThzxRIAtE46cXLZ15uX4i/AII0hZNPyrJzrmfO4YyID06b53 KSEgQqJCx56+44GAQzVWFV3KIIp+zwVbd1AsPbba/qrzpJ09BJY4AyySK0cwtVAEzrrp Zrt9dn1YC8RKz+9Iq4AZ7Gi88kRtno6MGsQ3cVmbACUVHwJdQGyzUpex95zOGwk2N5tt J7bQ== X-Forwarded-Encrypted: i=1; AJvYcCXHQz+RHjM+Xkp+DIv3ySHlnsuyVau1ivWd7NDOFcc8EbFuZpcgn1hmOLnchAJ143WIBIVSzMBpzOJnZWpal++dHObzXffc32ANwi8lZTK5nLUTABI= X-Gm-Message-State: AOJu0YzUkOXSYx4SY/8qysfEetGDY4d4eiZV1FS4rTUr/YZZwm+eL5Ah bwtvHZf2t3ayFXSjT/qZ1Elxg8al/C+PqGlc93nASYYzJEPXZLGL4Ju2MQBxhYI= X-Google-Smtp-Source: AGHT+IGocQ+sfcCI0BsP7dFMq93jhRdGBeu3R77b4skm0zxlJaGhDpoe9Yu7aRhk+YK7m/4igocdpA== X-Received: by 2002:a05:6512:3daa:b0:52c:d9a3:58af with SMTP id 2adb3069b0e04-532edbbea6dmr1706687e87.49.1723647868534; Wed, 14 Aug 2024 08:04:28 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:28 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:10 +0200 Subject: [PATCH 6/7] regulator: qcom-smd: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240814-cleanup-h-of-node-put-regulator-v1-6-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1371; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=eBGTSGUpvddpWZ+1sT4gEslKcB5kBGvw5yw7ydkjC2k=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdsbGg5jhGJCbxxUs0v8Bv4OUF1uvi+EO1FC F3GEVhn6JeJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHbAAKCRDBN2bmhouD 1yPiEACadxHRdHC3Qbt35GS0lKK/OD/r0A69dULWvdqQ1NN9HvfQaK5Hx7jbFXnjONsqn3KPMDC EGL0ATj/SWGAUxYjIXNk/EzUw1vF461IkUHUstovhu7pqEZsMTdS8t9YxFzYBOh5DdmOQZrfHtU SWFo7VISazhvpFuge/3lQS7L/NYMeb1k6nREZd926dVaoL15IJpyAnrbd+k5nUP9eHsOGTIinUF b2sdJ9GsfnIWvUh503gqMx47bBb51hauURzkb9g6CmFJd7Gwo6wbCCwlhp2KKWGsGywJ9vozaSH 8ggbvKEVF1TsTNPHI19jkqdRD7yySvl73tsQTe6nOg2ueJWvBRfjMuhcmXeirtgeW2vAJGShEjN /iJ1+ep5RSfkl5QEKfO4OreTj2NELrlxm2B2HzCZGxv6c8b1GXVjqLSWvELfR34stg4/RgKcV7r FGCFwPGoQaaq0tHYOglqBaX/KnHKCjRH3CK/ZrjyaOBcF2rRzgZLT/7g6hJDkerfOCx7qcB7lWU HRlK9/Ocgj0gVyfCHppH4q1/bBtt33K0osv+E+1L51Hl5J4LWqMkDIaCo4pnG71h4lW8DGXYATs On62TrglDkCpWgvmimD3jbo704nE2gh/g+kZPrLN1lEEf33c5BKh1Nku83Oywr3QkwXySFt6d8R jrAv31M2iAyjOKQ== 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-20240814_160433_540642_384C7B5B X-CRM114-Status: GOOD ( 13.35 ) 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/regulator/qcom_smd-regulator.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c index 3b7e06b9f5ce..6761ada0cf7d 100644 --- a/drivers/regulator/qcom_smd-regulator.c +++ b/drivers/regulator/qcom_smd-regulator.c @@ -1435,7 +1435,6 @@ static int rpm_reg_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct rpm_regulator_data *vreg_data; - struct device_node *node; struct qcom_rpm_reg *vreg; struct qcom_smd_rpm *rpm; int ret; @@ -1455,18 +1454,14 @@ static int rpm_reg_probe(struct platform_device *pdev) if (!vreg_data) return -ENODEV; - for_each_available_child_of_node(dev->of_node, node) { + for_each_available_child_of_node_scoped(dev->of_node, node) { vreg = devm_kzalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); - if (!vreg) { - of_node_put(node); + if (!vreg) return -ENOMEM; - } ret = rpm_regulator_init_vreg(vreg, dev, node, vreg_data); - if (ret < 0) { - of_node_put(node); + if (ret < 0) return ret; - } } return 0; From patchwork Wed Aug 14 15:04:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13763685 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 749B7C52D7B for ; Wed, 14 Aug 2024 16:15: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=ACUznNue5Vc1PvREpF5uL8d3frSCLJ2XL4UNUgbbF6Q=; b=GrRUXTKvd7mDVih9/z1k4ucHyR 097vqID2eu0VrC52AnF8EIL4rKpRMrP9DE0SePk5OhBLFkPicDXn0hZKC+dmVxDHvkGsyA58/FpOX kj3urhPhemGwwLKO06yMFi61Z4hQiqZ62rL9zvD51k3g6M9GSiqqKtt9nTNruNCYpxfDEmQw9gvPP 44HOz9cro/bHI1h5S8ftdEr0ukZLg+kf2OZbvJICflM6tTjp03BSoKuqiEHWdjJ6Lcd/KVjE5OmOG Oe7EtNuzHL3TerUVcG1lyELidhaehDlibn1N5/dcNJxRmi+tp7DF+K/cnQxTbjODmSY6PzKnV9xw2 bczgqtsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seGf5-00000007cXV-3BZl; Wed, 14 Aug 2024 16:15:47 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seFY8-00000007PjX-2Yz0 for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 15:04:33 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-368440b073bso622614f8f.0 for ; Wed, 14 Aug 2024 08:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647870; x=1724252670; 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=ACUznNue5Vc1PvREpF5uL8d3frSCLJ2XL4UNUgbbF6Q=; b=fje92ESPX70bVxfrzix4zCSwLp+roX37dbKHB6Uh/RuBRlzH/B+MvF91UV+eGS2EK4 TAgLNYVEL/Wb8KdNu5u3yHjmw9q9WAc1V7LGJplEJFqics4Qkm3+06ok1Tr0DByd+WG0 eukmGTMkKV2sUImhoQLBww4JdK21P0J9cVS/uYMhZ8JJTXuwbIC4iRfV+bjNW1v5cZVp WZw+k+eKfFhidpVGvQC1GQ9S8XTkDCI2T6mTfVCpqO//g9M2r42fNozqXBMSDnDxn8fu AgHOYyA10jqVlT9r4Ovpq9hP0MjXbivJ/vA1+MTauxZjhn14Mb2at0t9QKxMIB6wqs0A PHwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647870; x=1724252670; 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=ACUznNue5Vc1PvREpF5uL8d3frSCLJ2XL4UNUgbbF6Q=; b=CGdcVde3saknlCmXmcx0bNVzhZWtkQn+2UAYj62ZidBDPJ71uTMnBwaZZghdNmByoN ze6kolSIAV33ag0v3okJUM03AQ804xqgnBpG9Unhn6qKVa+4Xvc7DLer3K6YX3/lql+I z2u9nt2vMzhGi6LfuZYDF2+b6GLGLFTKd3zmF08VMAQR63/O15dV4aEgq9cBvIQ19k+v NDAETkBZZR0+7FcRmpCObXLrHY4QvZ6Nmx+Q6GPNipv9MF5QfKWP4Ur9sQ4JRdLxjVFA Cak9SVnlDVr4Wu87b09l8JAOONd44JQhVE6PKZuCQRXJp08FvgLvQzXMn9/fbH2+xzSp TASg== X-Forwarded-Encrypted: i=1; AJvYcCUqiHesdVk+ln1TP7YtXCIN/wRdkx65aV2/6zvKI3cZFfRNTkULvzBiN1MKhJRLUJV1dtkMaO+zmsuB1ycNGDXoSypCCynXjjLx+IsVH4bH0tgDc5A= X-Gm-Message-State: AOJu0Ywq9F7Fx8qukcRsy0QCugl78ogxT5sQIfHDStlHEs+UySZW6rkC hFoCqU3kEfG1guJNRGIE5HrkqyPzAbekqy9mlHjgyD/Q1KbEZU9ZbuESoMjPLqQ= X-Google-Smtp-Source: AGHT+IF+u9tmYTlfOnF0EY/D0BDpgP+0OTvzQjNTeJeoB9+1fHj7S8CddXYLDq5O/F0RKg2kn5vuxw== X-Received: by 2002:adf:f3ce:0:b0:36b:bb7b:9244 with SMTP id ffacd0b85a97d-3716e3eaecamr5350141f8f.1.1723647870395; Wed, 14 Aug 2024 08:04:30 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:29 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:11 +0200 Subject: [PATCH 7/7] regulator: scmi: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240814-cleanup-h-of-node-put-regulator-v1-7-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1391; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=OoJl37VhWa2/ok3yWXn0smE+qe2VclKzB2yD7J0hAwk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdt9P9crcfh3Lp+LZmfqSw+yRnKP3vsTTgTz 4j9XGKy5+2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHbQAKCRDBN2bmhouD 14guEACS3kV18JgvbTMljOcJKLNuprPK6EWt3rzyAwJz6S/prQ5m8/dJcjR0LfXPOSIKpr8T07P RjGOLmrYXsdGs5RKuWilAcUETR+HBy75Fd7L6qWKvOgiEkF3f/zxxnrGJr1TywAhiJzNyZxnc7e D1oX9a00U9Nq/G7TzzId+WggIZVkMhVb6Wjvy6bMT13co6O7OJ3S2DwWuqW7vrG/rt09V6amwTJ c6fr5IINXgPXbfdgZMIlT3hSoZP5vCY+3hIUGQgFPNOtjR8oFIR7BHtnTgftiqqg2U0a2B7RdYv PIRFwmhK1wP5Ld75kd11lTS47+YajB59ydM6XTotcBcPYK5fTlwqInYN2s6SX1igw8axui7mYsT X8kDCi6zpnihNFTmXGZlTK5gqt+yZrPnMWUGyBl54qGI8nTq9zw9zGGNdp2ZAFPUFU2ARCibepr orZZAgeDiuFQUSQaaHd5uYLBmthqW3vWYl1uxEpgbX6l+0tvLNwN2//N9rM9sEnvHkwbLkhunWV 9gw9jKHQVdg4JHI3Fw2hzYoFwshNDapb7HWbJa0qU8g0nyVCFAvdfJix3aqSJwiQIkLO5dAbsJI l2VZSD4h0HLaesOv1QiiAOvn8x5X1Js77S24usuDWoCHb0yL60XqMFejLhdxqcKPm+rWOYnvO7r HL18HE2d+32PggQ== 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-20240814_080432_688987_D17971A1 X-CRM114-Status: GOOD ( 12.71 ) 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/regulator/scmi-regulator.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/regulator/scmi-regulator.c b/drivers/regulator/scmi-regulator.c index 29ab217297d6..9df726f10ad1 100644 --- a/drivers/regulator/scmi-regulator.c +++ b/drivers/regulator/scmi-regulator.c @@ -297,7 +297,7 @@ static int process_scmi_regulator_of_node(struct scmi_device *sdev, static int scmi_regulator_probe(struct scmi_device *sdev) { int d, ret, num_doms; - struct device_node *np, *child; + struct device_node *np; const struct scmi_handle *handle = sdev->handle; struct scmi_regulator_info *rinfo; struct scmi_protocol_handle *ph; @@ -341,13 +341,11 @@ static int scmi_regulator_probe(struct scmi_device *sdev) */ of_node_get(handle->dev->of_node); np = of_find_node_by_name(handle->dev->of_node, "regulators"); - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = process_scmi_regulator_of_node(sdev, ph, child, rinfo); /* abort on any mem issue */ - if (ret == -ENOMEM) { - of_node_put(child); + if (ret == -ENOMEM) return ret; - } } of_node_put(np); /*