From patchwork Fri Aug 23 12:51:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13775163 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 BFD93C531DC for ; Fri, 23 Aug 2024 12:59:58 +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=FrO9VIOVY0Ri5IaSOP2cHACmrrm/g6eQHTHu7wmBZg8=; b=4r4Dzg1Fg6YuLrc1XF2NAc5R8F SIhbbBj3xhwFN7UgpA/ro3FrSJN/eMt9T+5hHXnAeAYQcsjrMh90BlCv8HwM2HBV3l42Mvo5TRLYa rze8upyTTXVSDWXLNOKNLeI3KrocgWA+DDDvCww1Q48foce9TAg5G0rZWPDDvJshiQg6i9e+MI7q8 dG9LNjnEZ2eWrKzbUPPCHav8DgiQzWtw58TLFxpFDODDgBlC/YchcBd8nOV86+YCYV6SzPWR8JsOf J4O0YAPWrnkULAxU+KfkaIQOmtE2PktQKuWT0ffe6g8xXCFPmU1YRDvPHNLAUOJ9Jf7HMaupObKe1 IjvCG71Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTtO-0000000Gn1V-0PvV; Fri, 23 Aug 2024 12:59:50 +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 1shTli-0000000GlH9-0vr1 for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Aug 2024 12:51:54 +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=FrO9VIOVY0Ri5IaSOP2cHACmrrm/g6eQHTHu7wmBZg8=; b=TdGLeBEhJwtagJbsGakqgoSdLj 9tNKqRcP2IluMKcCY665AUcQ4bk8WJbIzcSAhm7G8Zq9P51mG0PqHfla6ZB9wcA8Y69EsMTBgY2Vb KD49R5nYvkO+bHEM2vl0EEaejTUMAn0M0waDDZLmrCmLXp84GFd1Qw5zJ9x74I1PaiuUyOkufOyxX urWu1qynYo3cis2ZfJ7+XHrqObUyvZb8Qi9dpnmQmG2tQfiSebTDUAstLOzsUE1X1+aa1SX6eha2H PFWtN2L/Bu2B2c6yhu0XlXertG0bGL4Fr2DJ2IDxWujQdzWBRdksrGoFuQf2RgkoAh6atJ0Z3N8+R 0EGDaGiA==; Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlb-0000000A8Wl-0EDQ for linux-arm-kernel@lists.infradead.org; Fri, 23 Aug 2024 12:51:51 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2f4020d2c65so3930641fa.1 for ; Fri, 23 Aug 2024 05:51:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724417503; x=1725022303; 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=FrO9VIOVY0Ri5IaSOP2cHACmrrm/g6eQHTHu7wmBZg8=; b=O4hDa08fSkOs6UavaMHbIc4h/9d0wNiUu9YjPCA259xWMadbQKLvH0B19kPYOuMNjV qhDzddwHePhYhM+BSUOnmlZFvmI6lr5lalPxOMsmrXELhkVW/4M+s8sTUShnlIOr0wcO cwVMBUB1X8YNUWRros4J3PwlJBE7iQtYSqQMZl/PHbE7qcVUwngk0+XKMqVxKs2znf6G Ih6N5+b54kru/ob4lov6/QdBBpHRnvAeiSuc+76OChNI60+gthglZP/n/vmsFDRDhWc9 l5QwFbLkTVbwwVcwQFCXBgCbVNC32kMN5L6JYFA2RsXG39h96ZkToIwiCWm4DYfl3Sz1 yzhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724417503; x=1725022303; 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=FrO9VIOVY0Ri5IaSOP2cHACmrrm/g6eQHTHu7wmBZg8=; b=JnIMVjmm2aWrbQUykw4yIrOKHqis6lx398DAIBe/O3sugKbpYE6AA84B/WKBOegYcL q3T9m3DZZjSeObfONN3VjPRWfXfY06hQzLtWxzq32rmabIcm6tJrmJObyadv+FFW3Cn5 1DGXEkUWJR5Z1NbQf4h6jZCZj2zNRfuyJRy09X/KPwCBl/zzi1mZS4ATZ25N9w9NOLnS TFLmMN++s+H1UmRXqzQO6OLvY1QRIserLFSz+9mK20oJzb+4wOrPxIwuIdrN+8KNBweU 1H9/FH/GMHBoGpu4L4gdbRIkg3wbfsSpab9E7rIMy9enjsXm+bysHHN31dWyaEanZwg8 SDcQ== X-Forwarded-Encrypted: i=1; AJvYcCVIycM8dUmCFETz7brr3qzWhLHxIAnVkuyeIgHHbz5azatWaS2V6TW0L0A8KA2qwLscLH3r5ra4q6j5wtjASFOR@lists.infradead.org X-Gm-Message-State: AOJu0YzmzyE+YgAjdldxr7M39RwA6d3N8zZQOM7W91DbbjgOj37OtNl5 jPlhiL67pkJzT9SoG6ovLATtrAblt20DeePiNQrRqq38a7yKmUoDkUpAjCRCSR0= X-Google-Smtp-Source: AGHT+IHQt6XsQjCUfkUrlag0GNPSCDr9z/SiyDUFBx8p2vfO9ppalFsmm1bqmGaVYaUEm16X8IjYbw== X-Received: by 2002:a05:651c:2204:b0:2ef:17df:6314 with SMTP id 38308e7fff4ca-2f4f4932c8dmr7795291fa.4.1724417503135; Fri, 23 Aug 2024 05:51:43 -0700 (PDT) Received: from [127.0.1.1] ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a868f4f384bsm255931666b.192.2024.08.23.05.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 05:51:42 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 14:51:13 +0200 Subject: [PATCH 09/10] pmdomain: renesas: rcar-gen4-sysc: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-9-8320722eaf39@linaro.org> References: <20240823-cleanup-h-guard-pm-domain-v1-0-8320722eaf39@linaro.org> In-Reply-To: <20240823-cleanup-h-guard-pm-domain-v1-0-8320722eaf39@linaro.org> To: Ulf Hansson , Heiko Stuebner , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Bjorn Andersson , Konrad Dybcio , Geert Uytterhoeven , Magnus Damm Cc: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2725; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=XWmH+Hl1yGiIFL5fYsxLdEp7Bwy4xbJyw8YwEuJJ1k0=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyIXMuhF/r6XYZvbssPimAH7xSy/VPxtyP2RAn SKx6v/2vH+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsiFzAAKCRDBN2bmhouD 1xx0D/wOZ/Gin9mdDLVFXUWB37LsDCwOjzZhR9qfsq0n6W6JYFtvECA3bgQpv4nW/mYAB85dr+j ro8zgDq5YXul9FfRGG0ATZvZT2gcCHL/oAnDreUc8vfZLsSlJ1aX84TFJomiW+mQ3XXwCRmsZHB 1T0CJt70K1YB2eltp8jp0dig71yi2HdMF6UYhbDo/gYVGtlFtNiYB67Kwdw0UOeW9YzcmeFi6YK Tz8GvX3QEooih+bxbIDhHX8Z1IKftzyzty+quNuwmYUOyDi4eSZe2mp4j0/FoaW5MlY31kxW0rp 3S9JXPQfyAUVLKdG/0FQQEI8YLTvcupNPFisaS4Bby2Sn1U517UKrVFAFpZ9TDPTzWPFeQ7DUUe N8kAyUNMyWN+WNJx+ECpszWWFmk9bCNiZvIJN6pNvCy9N7GzJqATm4RWSxqwOZxL8H0sDTvlx5c SQz+eEInbU7p0zcJom64jgD1i2plMUsbuoINKbgMq1y+QdsEBmRi6astV/l1pDUIofIKm/A6u3Y N6sQEDEDv1e7tknn9+k5mh99Qk2SjG6+f2mhpMyv/XuC4yKpoHnihKWMMjM5xv97lj2iR1d0N26 3YLDkz0E6IEUTDsbNmc1w4Q/VgIsWFghm2U0TXGnTuF57hccO1BnQ1aFdYOM38AO3rCHpOxw96L jO9lsFhJ2yrQ1lw== 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-20240823_135147_554114_EF694AE3 X-CRM114-Status: GOOD ( 15.46 ) 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/pmdomain/renesas/rcar-gen4-sysc.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/pmdomain/renesas/rcar-gen4-sysc.c b/drivers/pmdomain/renesas/rcar-gen4-sysc.c index 66409cff2083..4ca85dbdedc2 100644 --- a/drivers/pmdomain/renesas/rcar-gen4-sysc.c +++ b/drivers/pmdomain/renesas/rcar-gen4-sysc.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -303,12 +304,12 @@ static int __init rcar_gen4_sysc_pd_init(void) const struct rcar_gen4_sysc_info *info; const struct of_device_id *match; struct rcar_gen4_pm_domains *domains; - struct device_node *np; void __iomem *base; unsigned int i; int error; - np = of_find_matching_node_and_match(NULL, rcar_gen4_sysc_matches, &match); + struct device_node *np __free(device_node) = + of_find_matching_node_and_match(NULL, rcar_gen4_sysc_matches, &match); if (!np) return -ENODEV; @@ -317,17 +318,14 @@ static int __init rcar_gen4_sysc_pd_init(void) base = of_iomap(np, 0); if (!base) { pr_warn("%pOF: Cannot map regs\n", np); - error = -ENOMEM; - goto out_put; + return -ENOMEM; } rcar_gen4_sysc_base = base; domains = kzalloc(sizeof(*domains), GFP_KERNEL); - if (!domains) { - error = -ENOMEM; - goto out_put; - } + if (!domains) + return -ENOMEM; domains->onecell_data.domains = domains->domains; domains->onecell_data.num_domains = ARRAY_SIZE(domains->domains); @@ -345,10 +343,8 @@ static int __init rcar_gen4_sysc_pd_init(void) n = strlen(area->name) + 1; pd = kzalloc(sizeof(*pd) + n, GFP_KERNEL); - if (!pd) { - error = -ENOMEM; - goto out_put; - } + if (!pd) + return -ENOMEM; memcpy(pd->name, area->name, n); pd->genpd.name = pd->name; @@ -357,7 +353,7 @@ static int __init rcar_gen4_sysc_pd_init(void) error = rcar_gen4_sysc_pd_setup(pd); if (error) - goto out_put; + return error; domains->domains[area->pdr] = &pd->genpd; @@ -369,14 +365,12 @@ static int __init rcar_gen4_sysc_pd_init(void) if (error) { pr_warn("Failed to add PM subdomain %s to parent %u\n", area->name, area->parent); - goto out_put; + return error; } } error = of_genpd_add_provider_onecell(np, &domains->onecell_data); -out_put: - of_node_put(np); return error; } early_initcall(rcar_gen4_sysc_pd_init);