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;