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; }