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)