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");