From patchwork Fri Aug 23 12:51: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: 13775095 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 DFB5EC531DC for ; Fri, 23 Aug 2024 12:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=VfNoJxZkOrpvV25ZvM/pZhiD5GuLXpPNlYaK9em82zk=; b=pm8qV1IMGUi9H4 UJcHdh7l2RLV+y31ckJlLgBe9GOMJySHEcroaKvs7p3keJLJAUTjjlMw4G+9ZyUKBQZb2i6Ag6+Oq bYOj67yv/swnL6UKNf/isu7r3fuoAJ/h84EFau8qYSyZ29pHJ8vb2FKqcBZCPkrB4amuFRS8xx/CJ /rkIKgKxT2LqLTILRBdqo9t2YX18VtpMOkV1GzviE3q9DLOk+HwpLQ4E69SyVWTWRctvVQANzTP5P WGtJfFEDUMhJhu/CDbGdvMD5M0BjB0caJc1VDale1LpasKgrp2uGFxI1tnEcrh8ARsrmyHP6qi2mC OmV3sc05JktYts7Ky4WA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTm7-0000000GlLn-1eF9; Fri, 23 Aug 2024 12:52:19 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlL-0000000Gl8C-12sE for linux-rockchip@lists.infradead.org; Fri, 23 Aug 2024 12:51:32 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a868ec0d239so14625266b.2 for ; Fri, 23 Aug 2024 05:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724417489; x=1725022289; 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=pqZoUlf9FXxVw5XTreRUZPBs7/v+HjBAPIDWEHMdLrg=; b=nK3zNWfkxnneaocGwfo59t52RRnBlZIibqyJ+sWlp2bT3QTYoEKraDBVUlTpaUfK6p ez1PfHZI56tQZ8lioUO0HPl30Y0GH9cJC0Pm2RkqWG8HTe36y1wlpIvuAR8NgbgRzopV oYlCE/soBdBrRDZC9ruovmvg2FoQ5JjsXNwNzcPxUVJ5+ZZlvSbjtfGo5VZx5BuLifwk S4I7MtFmOF1RRG+O77Vzvcorz/7CpV4+Kt5xxf/rvWb2EVPRbOfpjlDLvf8BzTtGElFP 6FY6Wz887zyFlEWKoqyYeHmsTfNrQXgTTsleWHmlh840ApKNLo7+XwhXN5iESbv9ppQW m0nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724417489; x=1725022289; 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=pqZoUlf9FXxVw5XTreRUZPBs7/v+HjBAPIDWEHMdLrg=; b=a7DQUo3OO5k9BXP/jsa6K7ztaydCLR+AfsQeUnARV5tPqul5oi+EB3KKMB1zL4Ypus VBcdV43ti2HUSb9YnaIX+pqL/SXgQGLwNnoqM0I4L2pulY8yxJu89vGZzl+XnMuV0Bs0 Pd1XsT9CTKkK3yJNdeCyfvDHWjd1GgTISByL1CXFFQVYeoAaDIdUzO4T9tkWzksHcc0V P9FqtBiTGuzMmL+hlH0Edh0YR+AgYqDLX7uOuchyQftPVfSWw/xkR891kLuZo1MQVzMA 0qdfzmfNmSxfU3U0wUh45+YJIs4+zNtRZLUjWXQJCYaRZE9ULGvnX91kxDL2NemqTMfL jcuA== X-Forwarded-Encrypted: i=1; AJvYcCVldRbLaL/s0R+b1vNl85U7AHkJ/KzaOxwMLZXcn+q4Mn+3PdfEsybVjvOmTWsDtgjw8wgHb1ztSOUn8loMkg==@lists.infradead.org X-Gm-Message-State: AOJu0YxdzNumvIEI9IwThKpclg9f1AQVwPuWnRrh25zbKXBWGUPTMHrL 6rUdzX8071zO7PXFro956mhsAj6TWeirJznYe/Oveg8DhZXpzQu5hQ7OTPJn+zQ= X-Google-Smtp-Source: AGHT+IHFhimXCeBq1Wbp/Qo8sanPB2U9J/NJviX3SdYBYaOdu/gpBKluIRkFnIoy6jGG2DDcfdAykQ== X-Received: by 2002:a17:907:9724:b0:a7a:a33e:47cd with SMTP id a640c23a62f3a-a86a54b6508mr79978766b.8.1724417489316; Fri, 23 Aug 2024 05:51:29 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 05:51:28 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 14:51:05 +0200 Subject: [PATCH 01/10] pmdomain: rockchip: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-1-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=3370; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=iAvSFaGsUDYZxq4WQx5Z23ymXzI0A4MTtwCWNichnqc=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyIXEfKtBsZmUp5ta2YLZwS3sUTURaeY/K91+s GdqnZCFccqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsiFxAAKCRDBN2bmhouD 1/miD/9sqb/VfS0E5eSdkqMTP9BUn0QyIpD/1zkhakVYkcdbfbRO1J4fbIQy6ivtt22yqA0cF/E dapzg65Y/ms6uu6SOMeDn8A3Ux/v0H11tSSsjxwPIUvshnIBtSpUICJ43/aT7HrB1AZ8KXj7303 fjKLWh0M/kXCNLEmgmnaZla7eT5SyWxL86w7s/LmQVmf/v9x6481XcJMxvKFTiyulEWiMLl7O39 SM/1GdybwLP4Mrwl2CO4D02fr4QaUP6pwp5yfKLSVVJcqT7ojS6mnDtvAsmUzfy5v9vGvEdjZf4 XcGVejBE/gQHe+SDiyCUztR+2Alc2i59HHAMvPTl+E3TRLY0IeY1J71Qr0RIASGsYrwJa2lv6+w eou5bPoQBuM2UY3PWz8wRJdOlZlN0ppHYZrz89L57/U87bW/iREdkNPk9C9EkajVT3ZTsopV7Ch QuIh63mZ00thXJ68Yekopv1G+3Jyldicvc1pnAAmcmNk9/wIDdjN+pkGTWXgjX2TapOChOus7zI YlfIvKyDakxpFuy0n/iCLdXHrHEhSzRhci7v65ixuLvU3R6kHc0ltTlQh5QsKtYMF7m7aIVWfAy x6UXjngSQQY2qVflmHpNw+XsYM/7XNaeScdPr+P+xsJbEPVcmANtg2SAroolfyRltcIAgh3rngg yBjt0SYdMpyHcZA== 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_055131_328441_42096076 X-CRM114-Status: GOOD ( 14.56 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use scoped for_each_available_child_of_node_scoped() and for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Jonathan Cameron --- drivers/pmdomain/rockchip/pm-domains.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c index 64b4d7120d83..5679ad336a11 100644 --- a/drivers/pmdomain/rockchip/pm-domains.c +++ b/drivers/pmdomain/rockchip/pm-domains.c @@ -804,11 +804,10 @@ static void rockchip_configure_pd_cnt(struct rockchip_pmu *pmu, static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, struct device_node *parent) { - struct device_node *np; struct generic_pm_domain *child_domain, *parent_domain; int error; - for_each_child_of_node(parent, np) { + for_each_child_of_node_scoped(parent, np) { u32 idx; error = of_property_read_u32(parent, "reg", &idx); @@ -816,7 +815,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, dev_err(pmu->dev, "%pOFn: failed to retrieve domain id (reg): %d\n", parent, error); - goto err_out; + return error; } parent_domain = pmu->genpd_data.domains[idx]; @@ -824,7 +823,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, if (error) { dev_err(pmu->dev, "failed to handle node %pOFn: %d\n", np, error); - goto err_out; + return error; } error = of_property_read_u32(np, "reg", &idx); @@ -832,7 +831,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, dev_err(pmu->dev, "%pOFn: failed to retrieve domain id (reg): %d\n", np, error); - goto err_out; + return error; } child_domain = pmu->genpd_data.domains[idx]; @@ -840,7 +839,7 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, if (error) { dev_err(pmu->dev, "%s failed to add subdomain %s: %d\n", parent_domain->name, child_domain->name, error); - goto err_out; + return error; } else { dev_dbg(pmu->dev, "%s add subdomain: %s\n", parent_domain->name, child_domain->name); @@ -850,17 +849,12 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, } return 0; - -err_out: - of_node_put(np); - return error; } static int rockchip_pm_domain_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - struct device_node *node; struct device *parent; struct rockchip_pmu *pmu; const struct rockchip_pmu_info *pmu_info; @@ -918,12 +912,11 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev) */ mutex_lock(&dmc_pmu_mutex); - for_each_available_child_of_node(np, node) { + for_each_available_child_of_node_scoped(np, node) { error = rockchip_pm_add_one_domain(pmu, node); if (error) { dev_err(dev, "failed to handle node %pOFn: %d\n", node, error); - of_node_put(node); goto err_out; } @@ -931,7 +924,6 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev) if (error < 0) { dev_err(dev, "failed to handle subdomain node %pOFn: %d\n", node, error); - of_node_put(node); goto err_out; } } From patchwork Fri Aug 23 12:51: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: 13775143 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 BA498C531DC for ; Fri, 23 Aug 2024 12:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=OSWbTS4w5VyT53T1eXl72dlzPkbP6IhuRDcXUd7cw2s=; b=uK/wlEI3SSd6lc eLgBTM1mFRrkub1zb+kPs+5oNom2M2akXnt6pCspx+EtjKoN0xI6lGD7wst2IWTuR18pEB+sHjH4o kTqLvBpgx2RiNz3auO4JC/9DmXz9NL7ePUb239gZFJHPJg0cH4mx8sbowbQtV8X8Z6b1wybVtChy/ ZUF8sF02zSkBw/U9Maf9C07+DhF3vToMbw1UG65Xhx15vwUnTLGTlAh1XkSuLgNfMIl/Y5oBsmAwc ImPVleqeAEReZBTA+1HmN2KtnsuaSXdHwCxn9zUQdOG2IYeFaogQdlbT76V3BWNdSfXGUy8HiMw9F jVGkuOH6GDcMqNyHxWmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTmq-0000000Glax-2TWY; Fri, 23 Aug 2024 12:53:04 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlM-0000000Gl8w-3IDn for linux-rockchip@lists.infradead.org; Fri, 23 Aug 2024 12:51:34 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4280772333eso3413185e9.0 for ; Fri, 23 Aug 2024 05:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724417491; x=1725022291; 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=08WjYAlBBFEeMm+hEjWVyH9fkJaAAMN7ZuFtniSsgzY=; b=dTKoOXbqwbk7N+kHSN9d+z6HLwE0lgSS85dv2BKGHrU3DgXyz4gIsUhVmHQ8Rd2TsE 184FunHG/WjSdXPWQWgqrRK37Kt43T8LTfQLaZv9qXGmq7dT2/DaQ6oYMO9YLwOhyUok 17cIlRsje+A95nYGQiyHMyRlCUyfQYmdqlqT/H8yIXc9hC8bi3MfgRABjO2XaHH4Uq4w fYyPD9G6+o868QLJvKT0FVyNwiL2qLu95u3IpChISA/YJNPGPATRmXZzyi2GxReRy4OF 2w/NVLbOpfyfc1liWTn1Pnws3Mk5NZlaKc5xMgbxI+pove6cjupucE+GiRxj/QKMSrgQ lt6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724417491; x=1725022291; 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=08WjYAlBBFEeMm+hEjWVyH9fkJaAAMN7ZuFtniSsgzY=; b=aOCxmeC086et0wbwobu6qbFQ/ss1b/UVo+5uoUFIr7EIiaj1hoA9j0XpAmV9ClXUNS lEInazTNjt8xoD/XOfndxET9eM//4PQpBNJZY57rW4wLukj9kGgwMkGm/8d2XGKk3DN8 5XE/1ue2qAmQQVwYbs7gJ/s9OjW33gE6txURMUOkePDZeMuzB4KKVbMrnaSILts0hk5l ZL85JD+2wk54pi5VLHc009qmOa1rLxBLAUY/fo/Eppo7djrUDDtKzCfTPhVzSADWlHYe ozjHJ1VZaDASGBHJRrRTC9d6fDAZbIY9PNgxg7i9718lXK6WYDdQzxiHNseg+4o4cNiE CKOA== X-Forwarded-Encrypted: i=1; AJvYcCV0Qe8ibt15onBkxkEVewoqitYiIgiEJSqRk+7vNglw/fN7Kr5+HqBGWB6KK+o0ZrUJRhD51fqF4XUpVcUWAQ==@lists.infradead.org X-Gm-Message-State: AOJu0YwaxlamKSLE+nRUedo+lcM33yJqHsZSd1+e7FKoI8sA8ez3k83M qtJF8QP69R8SQjgYQGQPR5Ha6y+wqx63tMmKwIUp0X7HVCFaK+vyyabCPfB3UsA= X-Google-Smtp-Source: AGHT+IFvESEynb7DEBYY8hzcsJgziySe0iFY1cy2WIsrs8d5Dw+VUq4IdBOvbW6RhGMnpPDiy3f+xg== X-Received: by 2002:a05:6000:402a:b0:367:95e3:e4c6 with SMTP id ffacd0b85a97d-373118310a2mr763684f8f.1.1724417490919; Fri, 23 Aug 2024 05:51:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 05:51:30 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 14:51:06 +0200 Subject: [PATCH 02/10] pmdomain: rockchip: Simplify locking with guard() MIME-Version: 1.0 Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-2-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=1181; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=tKIx1euz/voqGvTWXrKxtVVbTahOhXCIVgZ5jLT/O6E=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyIXFrRydBY7pj/F8sriEDoh64iP0CNuv6npaj HfeNRwU4H2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsiFxQAKCRDBN2bmhouD 1ydTD/9YGdRcqk+Zok98MLP0sxqW8OpRmhtYJW2V4NNNbYyyky4ZJr4aGR1Odu+U8AtBgSsNa47 2nLXZ2bJ/5YbwBxRXa1l30xja/ULnh17kbIf7MVIbVbbuXU1oqsAyqX9zuje16YcLC5qF3v5ATI BCrONFjJ2VsbJgn4GHfBK89oDUSVCXIPjrzONIpHVL5vqBv0hBtzSAYjXcqtBAzvCcpGNRT0zDf LLAB5t2TCzU0sxWRUhXWVTGXcq6LRh178lslP4leZ0m2NrwNTRR2A2xbY90vS+yjVEXQJOGh00m VGi/TyviAJK/vok5UfhiiCnLk171BkRPjlAEv6BG6Pc8qLj/LWjCPJNlbwqD3LT+yvv05kEpmeP R/BGeiUEtv4xxgpRxfIuSZJhx8iDXIoog+OhAqs4FsFU1CY3Hz4SgTlVI2nkPthKcYdS8U2V16R 452XzYefITynrpOSYMuxMwfO/7/lil34uB1lR3L2Rc2ltoMqmrUpCr0p3qsuxfZdBogfQsvIpEZ dPcBUzyYD1q8vqQJveSoOBN1E5cDJuOiT39Yar1sk03UVz1B2MbvwJiE0L/ORWvknPaKPFbvtEX QY243Ebc6HD3s/4s6YzaO097h0Ba5tySJAZBbSKWoAHDKYpgQ3/NaSheTq0SdA+D6L2xGHJQ59p WJa/6IY/F6V89qQ== 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_055132_896739_825F2154 X-CRM114-Status: GOOD ( 11.41 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Simplify error handling (smaller error handling) over locks with guard(). Signed-off-by: Krzysztof Kozlowski Reviewed-by: Jonathan Cameron --- drivers/pmdomain/rockchip/pm-domains.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c index 5679ad336a11..538dde58d924 100644 --- a/drivers/pmdomain/rockchip/pm-domains.c +++ b/drivers/pmdomain/rockchip/pm-domains.c @@ -910,7 +910,7 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev) * Prevent any rockchip_pmu_block() from racing with the remainder of * setup (clocks, register initialization). */ - mutex_lock(&dmc_pmu_mutex); + guard(mutex)(&dmc_pmu_mutex); for_each_available_child_of_node_scoped(np, node) { error = rockchip_pm_add_one_domain(pmu, node); @@ -943,13 +943,10 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev) if (!WARN_ON_ONCE(dmc_pmu)) dmc_pmu = pmu; - mutex_unlock(&dmc_pmu_mutex); - return 0; err_out: rockchip_pm_domain_cleanup(pmu); - mutex_unlock(&dmc_pmu_mutex); return error; } From patchwork Fri Aug 23 12:51: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: 13775145 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 586A5C52D7C for ; Fri, 23 Aug 2024 12:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=TgdkXdHDlutGWAaT3gITpewt1jKG7nKs/mvFPIwp0aQ=; b=w6EE/tcFFGnnNZ jBHQoG8JB0mPzIJtmDiyj0rWJyjhrn3rKOmreXVtFx7m7k7dy6/jmTjoITJSjt6Djry1+R2+4/ua8 0ZAw+JiqBcGil3Z/ShxPNxgP76u2tRFxM5TI/BOaGB6RT5vX63L6DPy2BKjY9986Dixa6VPPz7HhG nCqRU+hbxvadtYJoWjheztdEGmUkSCk2/Fpefz2fz1Qf2v8S4b34h3WI6hJlWtmiZI96ayg5ADeI/ JIx44IqmeaoIrLX7KgV9OVCA8BE7O1iyjjPUuB7DPCSMV1HXUoO65qS+Wa2/C0gZ11/J3xlfUaiE0 ny2Kep7j2/tfluY17sUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shToI-0000000GluW-30qR; Fri, 23 Aug 2024 12:54:34 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlO-0000000Gl9b-2S71 for linux-rockchip@lists.infradead.org; Fri, 23 Aug 2024 12:51:35 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a866966ffceso8870566b.2 for ; Fri, 23 Aug 2024 05:51:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724417493; x=1725022293; 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=iRxioGT7mc7f/KyEL+IMNJTNgSsqnXXhip1lqUSU6yA=; b=rmmCBU3RVp1KqQU9LclXcdpAdtIV6fbIu/tHmxhz8Uw6OF8VXQjsVzVGE6uypRn4sc pSPxOMl6eNpD22Lqmsc4rYLrKTaN9Zjz88BJLKwHnJxGhllBDnFhvaW2+czhneaWhaNs /5VXio5ugNryIYx6rJhJjaf+WXqpSX0bJO7/juNTkM+IiUHIs8nwoGon/QvWm3u7QMjg C6u9RG1KmKn0x3wSfc+8q+c8IX4cU+TMlfsRT4WJLhVVgUbN/El7Cyelm+yF19UCOspD wMoTNhfkUD5hx13fxG4aTVdpYKi0uwXb0cixsQMsCW5AsWi9GeP3LLW8bWoHiMWFCZVu wqvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724417493; x=1725022293; 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=iRxioGT7mc7f/KyEL+IMNJTNgSsqnXXhip1lqUSU6yA=; b=wMUuOyPCz/1vmnoknP++lwpBoJS1XkzFnwgUtF+vcHFu+z0NE1VGE9EM2weGkvEoCi RhU2rOSsPz9nbZ1AZaNZ1kdfx3u/Z0Bi75+wU1N5mOjD3njtV1wGYad7jqGDDz1Q7kmm Ej7mDfHqRx5+TXp4qfEK6KBjl7CTXxefWnlZodXGjnxtF1M3ApLFShFjN1bieXJI+K5R FfmQehM3asXLB0VsFOr+y7rFAk1R/WQ8rUvp7AIZFMobvqP4uBDQMjYmkvd/KpN5RvMM tSuKMui9CuZKpVxIH2qfFHGpx9lvrRlfE1C0hlRcTlKihOWVgez1Km8ega1jchtAtymw ZgIA== X-Forwarded-Encrypted: i=1; AJvYcCUcUgii2/K3c7wGO+0kjTApoGZAoJF96RStdRTPWh+ZTJY95aDeaIGjTvn8D043VjHHDGhOY0oWpV3HhQtWxg==@lists.infradead.org X-Gm-Message-State: AOJu0Yz/2f9uQUrs7D2oHbOMCWEl+kKWqMBPNyomdOGQSGDKFWb3IzYq Izr0CoXye+VvQ/n/B0uknEmCWWHjuu4nXqgErElZSsHMtUWRSsTXYc5W7gWmLNk= X-Google-Smtp-Source: AGHT+IHMocKCRFEh+CWrcVL8T1z7ail94X2HtRLfeci96aOjLekKRRPWfihiPmUqT2nRTIvout3Lmw== X-Received: by 2002:a17:907:7e95:b0:a7a:87b3:722f with SMTP id a640c23a62f3a-a86a52b15d1mr93167966b.3.1724417492678; Fri, 23 Aug 2024 05:51:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 05:51:32 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 14:51:07 +0200 Subject: [PATCH 03/10] pmdomain: imx: gpc: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-3-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=1900; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=6qWKewqo7/bxcFlu9EkD12hoXBrxu7JPlLAdc+zUmSI=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyIXGryEowWY/W/NRlv0M7ukHF8AYtODYM2+yB /lAA0KMckOJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsiFxgAKCRDBN2bmhouD 18Q2EACKdgYqni98KR6DjkFKNTDdlnmQiPfC/qbDuSnGBnEHXyalbvgwz/aMLrsZ3GSBujZsFhU r7C2rdmokdifJOlhbP2COkCyb4D2KLy+EMJbLpqxQck74O3r7gLnBLe/Mt0e8RstNveD9o04L8N IMeUE8J3ASsB+IDsZ3KaFzO5+0q3PzFNPLkU0//h6a1ecdI7hDQlzv3moQkVjP5c1pnpd6prkbD n4lXn80mN4rSPMzRgIau/BXt3rxEOk4raqNjnWfcnkYcTpmz1LsKkN/ELHKd4ocNArnEhMB8jNU c/7vsNUOZPwLCJftpXX3fIbEOD6gN6khFFtkDJprS5po4aAFbSTwgvdDXnpqz8PA9DTMXkCSs9U xgUaLY1eJcIqudLRYBSSUIpnn2MAQjNi0jPxfQAkXBuMKJoC2pBMs7sZPzOGkcECbGH6BLqG1cY 26ZXqF9QACoOltgPRiNpO+mcx6ugDyvzoOF4kfXn2aN75iPIcbP+iJdJyyeYa9WoTo/juGjFdZC gq+M5hrVm68lUiJVb48Izn2LMSc8oAcXs2Kcu8XrNJcWzpnwYvk7cMQro4V/7xv0xTh9wQYodP5 AtRTAd0er+83B7fur7r3B5K6piGdH50PPRVLIy36uZPybik94FX61eQrBhk5oNtnT673W6jg7L6 eiFD4ui7kSmU3xA== 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_055134_640452_A288CFBC X-CRM114-Status: GOOD ( 12.92 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/pmdomain/imx/gpc.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c index 9517cce93d8a..80a4dcc77199 100644 --- a/drivers/pmdomain/imx/gpc.c +++ b/drivers/pmdomain/imx/gpc.c @@ -455,7 +455,6 @@ static int imx_gpc_probe(struct platform_device *pdev) } else { struct imx_pm_domain *domain; struct platform_device *pd_pdev; - struct device_node *np; struct clk *ipg_clk; unsigned int ipg_rate_mhz; int domain_index; @@ -465,28 +464,24 @@ static int imx_gpc_probe(struct platform_device *pdev) return PTR_ERR(ipg_clk); ipg_rate_mhz = clk_get_rate(ipg_clk) / 1000000; - for_each_child_of_node(pgc_node, np) { + for_each_child_of_node_scoped(pgc_node, np) { ret = of_property_read_u32(np, "reg", &domain_index); - if (ret) { - of_node_put(np); + if (ret) return ret; - } + if (domain_index >= of_id_data->num_domains) continue; pd_pdev = platform_device_alloc("imx-pgc-power-domain", domain_index); - if (!pd_pdev) { - of_node_put(np); + if (!pd_pdev) return -ENOMEM; - } ret = platform_device_add_data(pd_pdev, &imx_gpc_domains[domain_index], sizeof(imx_gpc_domains[domain_index])); if (ret) { platform_device_put(pd_pdev); - of_node_put(np); return ret; } domain = pd_pdev->dev.platform_data; @@ -500,7 +495,6 @@ static int imx_gpc_probe(struct platform_device *pdev) ret = platform_device_add(pd_pdev); if (ret) { platform_device_put(pd_pdev); - of_node_put(np); return ret; } } From patchwork Fri Aug 23 12:51: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: 13775144 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 736BDC531DC for ; Fri, 23 Aug 2024 12:54:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=qeFuLY3nQK3zyAjAZ/qc/lcFwMw2NTZP/VVe1cwByfY=; b=XmLqLO6WIm6H1+ AeJEli1FHhz9o6mxXfE46YiJwrPVY0MF5hHqsSiYoSnNwhcrFVWPbqJHWjlpCFUJM0mtukOVGy/WN ok+C0dZ4gxqGby6cKoDNz+ZBDn35XzSQZXe28iMb+smq0jLE4AcxKhbWsAIFTcnS5QPoO5wKItqiF nVLV7UuVyTg1/ohR56VUgPk15O+x1LIVIO/k/LySGEemiOW0YwHfQyITvOAmZGf+tpTrcmftTZMnv 6uulYterjySfFHAYKkD8d3kkI/SRF6TmOQtpBBPg1tVlOLq097zRkK+cHDywNUxj5OXPvL7fPqrlc 8vRdvgqtoQ78iB6NYpxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shToJ-0000000Glua-0UZp; Fri, 23 Aug 2024 12:54:35 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlQ-0000000GlAN-0mFX for linux-rockchip@lists.infradead.org; Fri, 23 Aug 2024 12:51:38 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a86939e9d7cso14946166b.2 for ; Fri, 23 Aug 2024 05:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724417494; x=1725022294; 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=sHFK9oK00JeF1se/dTUg3YYmCpO8UbFn8fNRi4/HQ38=; b=BLw1jngXA5L8aRWDpG2ZTC9R8VffoprGuktwpwYXZCjTtEp+2id/YryneKG6WBheZ2 TBO26nRISyb5NAhNfpOHl8U9z8n95mKv9hjhkhxXEdFwdcj2peexdjqG8Cxvs7ONjIWH A7xoDLmGcSJW+LWd2CROXkTZ1Jt/uDRg+8eM67PhWms1oNQzkAISmry+Um/zUMW47t79 exv4tMX3Lsh8Z6dJV75QA/G/exNont4QbCgPO03J139R6BlfEbUyRqU2FZeGZHh+8OYS 7udOVD9cJ8NkjHFLI+OdC+Jo5HIMIBJh7GcMvHYMj+CtbCh1P1RUHVcqhpwb12CBUWdD NXwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724417494; x=1725022294; 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=sHFK9oK00JeF1se/dTUg3YYmCpO8UbFn8fNRi4/HQ38=; b=ZSLDWYzV1JxZDLha6n4VlMVXGaiWIDWLPOVQoeW2vTp40OJ7yObIir2pI8Ih5ocRAS IbF/2ON8zZBVcAAmdn/S2Oc5XfenQPKuQNBCKcHBip+golXkSXpUl9hQ7TwnSsW4zj4q crrwq95/B1OT+t3wjEI6CxZrLshnJrS1jVF/bOYQhgbi098ZZsrzwT6AnSPJze9MNuRO dNsbnGSsx/da4yVnaZoW7eXnc4YmsuZkFRgB2h59sP1yUIqjXQj1FcsWSPDDkaRpl0zr vKqMnuz1XC8Z2qeG7n1PEr4qKEMcZG36bvKMZBYRci3sGsH/c3rTY7Dc1pOQdZqXBUIx ornw== X-Forwarded-Encrypted: i=1; AJvYcCV9QYmlu9pU3uKmAPzyM146578D0NF6oYIO7boG+GDIl3sdvyAsmTRLAu5RrnYTAA/4uPyi5C7tZnBA6Kgx8Q==@lists.infradead.org X-Gm-Message-State: AOJu0YxBVBFwqbbsD/8Byiv6w+i9SGg8EMRYY+OZofJSOmxcwplByMtv 7v7ShJ3GWuxHYRipyozAclBBWuHqg16iyBRyI480sfP/HxJz66o79GaWbcBnNdOErc9rQmoaG4X 9 X-Google-Smtp-Source: AGHT+IGkLcJr7qmx+kk0Mf1OqBzBcj8SESNmSZsO5RMr/2TNYehPzhiv8lDtB/y22+8VFZ21pTrA5w== X-Received: by 2002:a17:907:7251:b0:a72:499a:e5ba with SMTP id a640c23a62f3a-a86a54f1da8mr63264466b.7.1724417494310; Fri, 23 Aug 2024 05:51:34 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 05:51:33 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 14:51:08 +0200 Subject: [PATCH 04/10] pmdomain: imx: gpcv2: Simplify with scoped for each OF child loop MIME-Version: 1.0 Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-4-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=1990; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=SIonlcq8HOjQxVkHbI4gb73PSf5POET9O8rpuJdEiF4=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyIXHNWbTEZR3xTnH8G2XCUU3finRw/p+H/0Dk Ki10ETVi1mJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsiFxwAKCRDBN2bmhouD 10tmEACEF+qYwKmzCHJYENSf7RAfHIzyoHyh/f1mLGQkqyn3p1jq1yPTl2nbyGmLjAKNpm2yni6 WYlGbwEBM3ZQEIc9PNqMUh/62XH1qX4pphhGLQbRju3LUBWa4/o8x6a8DhYN45cvHh1v/M8KSi0 uvXr9YbeIq4JX41V6Q1sdqD0y8YZC5aNgQxUL+RB7Hrto+ABEjwPqh91tTgMQfybzV5rnUI7NPt jn0XWYy1DQU16Hl+nVS9knCodQcEs4UhRiuTjtY6aBzQcSpqqmmyRG60tkPmx93L1hL5eZIbg0C S147YiMUOrGg+vFi3xJdo8lrIOBbyFjm7A9AHl+Us0D7/WPjIECc7pS0D3Ezrt79IcG0Lm/s2Jm ZhHcm48D6AQcMCK7uWMafEfOxyuYVz5nEhycajYV5Cc09OF9DDTzZskURHU9GhwNA/ssgU33iqp 12eVZZG+rMMbCmcyoJdpd9Rlw+srlxNNl463Spy8mLZg40i90d9EM/PKdz8jiWgcbSC1Y+ZA1SA YyJ+BWT9RFhs+vpgDpFqr+gDd0Kx0ziExRw9u3UgwQRJaohnyOxS0Fa6EAo4UnvcQiIFRXEyfxi sfFM8/QOogPXG2mrQlkBAIJQ9er0CRctdXhTVlCPGYhjZUZFY8YLcGy+IB3eIGw7HpRgDHWHgoP VepROSAjXTke+lA== 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_055136_570927_E0EED619 X-CRM114-Status: GOOD ( 13.25 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/pmdomain/imx/gpcv2.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/pmdomain/imx/gpcv2.c b/drivers/pmdomain/imx/gpcv2.c index 856eaac0ec14..963d61c5af6d 100644 --- a/drivers/pmdomain/imx/gpcv2.c +++ b/drivers/pmdomain/imx/gpcv2.c @@ -1458,7 +1458,7 @@ static int imx_gpcv2_probe(struct platform_device *pdev) .max_register = SZ_4K, }; struct device *dev = &pdev->dev; - struct device_node *pgc_np, *np; + struct device_node *pgc_np; struct regmap *regmap; void __iomem *base; int ret; @@ -1480,7 +1480,7 @@ static int imx_gpcv2_probe(struct platform_device *pdev) return ret; } - for_each_child_of_node(pgc_np, np) { + for_each_child_of_node_scoped(pgc_np, np) { struct platform_device *pd_pdev; struct imx_pgc_domain *domain; u32 domain_index; @@ -1491,7 +1491,6 @@ static int imx_gpcv2_probe(struct platform_device *pdev) ret = of_property_read_u32(np, "reg", &domain_index); if (ret) { dev_err(dev, "Failed to read 'reg' property\n"); - of_node_put(np); return ret; } @@ -1506,7 +1505,6 @@ static int imx_gpcv2_probe(struct platform_device *pdev) domain_index); if (!pd_pdev) { dev_err(dev, "Failed to allocate platform device\n"); - of_node_put(np); return -ENOMEM; } @@ -1515,7 +1513,6 @@ static int imx_gpcv2_probe(struct platform_device *pdev) sizeof(domain_data->domains[domain_index])); if (ret) { platform_device_put(pd_pdev); - of_node_put(np); return ret; } @@ -1532,7 +1529,6 @@ static int imx_gpcv2_probe(struct platform_device *pdev) ret = platform_device_add(pd_pdev); if (ret) { platform_device_put(pd_pdev); - of_node_put(np); return ret; } } From patchwork Fri Aug 23 12:51:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13775146 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 D6A1FC531DC for ; Fri, 23 Aug 2024 12:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=FuH1hT/T1WtujXaDsirLXEWjciY3YH8c/QVu8qYWb4s=; b=B3GsENZ44+7QMz 4yVHVeUAR6IUHjggAyaWPELXCKvSxjlhGqb5iYaVUvXL+q2xEjR3uzjB2bt3Gfqkoaw3uMQYXoNp8 npa0QAHLdWL4cWODbQEnBwF0K8rAKftVSdbuO7ulAS7RqFpknLrobiP/PLW3Mx2xG86A58N2C5AV5 ikuCVA4lA3vKFs7p46RMOFpugSMA6gD0fciQPe0FiBhh4Xnc0xy/3wBe4WVjzhRIHJLP36fWhUeQR frucEVIbwkPUzoJlbKpU+7eFvVm20eZrR6vGRhHpTf27hhRgIu/Z/XFQQe8wHbhvsl4qvrhw9mMDV afDyCh1/iXK/K7k8fo3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTpm-0000000GmH9-22pi; Fri, 23 Aug 2024 12:56:06 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlR-0000000GlB9-1vbA for linux-rockchip@lists.infradead.org; Fri, 23 Aug 2024 12:51:39 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a86753ac89bso11417766b.0 for ; Fri, 23 Aug 2024 05:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724417496; x=1725022296; 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=Sa/KHRgT6a9iG3/ETlQHPI59tAN0SqbzEBXVbMy78Ls=; b=mkE6bvSMRJ0ubAQzg8rWS39MpNG5xhj81wtBdseamqDlGrjfVrupKZAA8fQqT4ZBam OzsZJGocZ4lLTswO+2wJ5jUW89isUrOB9uWpkPbPervSR4bLCK5wkisZdYp/CYIqkxwk JAD0RgVaolk1BB/hUgGcbK5xK6Y4IjDQ4Dwah6BiVD/HaylFIJnJagV/zl4N3oQDajct 8CxiucgVSjwLMEPulva2yaJbWNox1DLPo6KKwHnSAaN6n6sX15nFu+hpVWjmpbvd4hBs f+NeINwy4x/KE2C1htuAZF0wxSxFTx+B2HuFjLIqgDc9Azzw6NXzKbbhpFv+kguDuAEV OP+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724417496; x=1725022296; 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=Sa/KHRgT6a9iG3/ETlQHPI59tAN0SqbzEBXVbMy78Ls=; b=fl2nwI8yQmX9Ba7NWVaDN5TX2eJrJvwaHQ/f+nepm62gYmQVn2texkF17rJHcVYIps jGfZ46H44ASJem5UQeOod/aUKRnqQTCG6MSi7ygLYwmwA9JMyFxuwidCDuOztW+E1fAF tSELD6MAtvfgxLaHXSL53b+qokep17Wu86Nn6cNy+vngSGUNEBp6dPdETh1qKgYH+vD4 QSLU4CHZPy5gASpg5dBMIFwCQZSqv/9EqSsoeS5/oXHY2pUN6QKhAk4rc2G2fFGWLjhm bnl154T7Y/SlYqaIOXUzHsCGB3w80p8Zga5DLgfDUICMKJMoxRJ/WeWgFMvTvZ382fCW cyrA== X-Forwarded-Encrypted: i=1; AJvYcCXQn5b7Ux2BuXlzo8CujyblcidXey5UnwyBh5ZusuplrFyKWD8jKK/lzBEuWCVk1LoQw3TcaTxyWfP7XvrJZw==@lists.infradead.org X-Gm-Message-State: AOJu0YxuywPi5f6IFfUk/5nPJviUObC/4eVby5DNBD78gUI9REWElaMH DSukxex98xOkq/dbo0H60J+SuhRSrTdoXdWmQJyydKZp2EDBC921a/Wq7GaCyog= X-Google-Smtp-Source: AGHT+IEdA/oEZ97C2qOqfjgHLdf7GZtFRbhRivaHzioPPap69e5acBh4T0xkHuu904RyEID7S6Zhew== X-Received: by 2002:a17:907:968c:b0:a7a:a2e3:3736 with SMTP id a640c23a62f3a-a86a5489a72mr92536566b.5.1724417495945; Fri, 23 Aug 2024 05:51:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 05:51:35 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 14:51:09 +0200 Subject: [PATCH 05/10] pmdomain: qcom: cpr: Simplify with dev_err_probe() MIME-Version: 1.0 Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-5-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=863; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=SsKn+XKGNdg5Lu4TYJpa1Z5yeroNI9GQomQEQv1kKlo=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyIXIAE/UDGNyaNfdauaVBO6LIu+O/X2S8PcEz tOZoQCDU0SJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsiFyAAKCRDBN2bmhouD 1z9AD/0SCxM4givKRDsROWCOR5j/+4VWWxQLgTTNLssfQNDBH81XPQ0y6u5DXPpwX6GDZuFE0KG AGCPQbxe50w0leYIkSfhdQcmHV5GegOp93DcIhTKAThLFFJJfNFoNYm6NLqFo+2/JngjpIWosI/ jumqWnbvSxujOR/S5APTM6m2LisQte5FJFkVfp0fy7rTJNPjWBea8nhcre0gRoU+ECZ6hnDuogv Rc/ncG5TXQntXUbni/M98iXqDOMb79XVVsYwRMW0h2ZI5ATxcP+xF/BMpXSO4tSwAtuvaScNZrA +lOW8wz53KFD3F7iaOVpgEQ4vgqzNaWaBeh6g/8kgAwcWZZroJsPA/HGbulpkzCgvujAc8yIe4Y L3N7+1BRdGP1/+0DkFhr6q7hC6IoetUMtK8/S/OlnoZU6tIZCzL3dsFEGvIjlAGSJFV/eHSY5Ui X3BsRg5nI5eL5F5bwKuXxXzGX5IEu8uwLYdvRQfITeluiSylB/x5sDeQffM/PHtDoDQIddbd/D1 eTzAs/GUBiAJiWE5lLNx1Wa65YWa3olzZhJCbZtGbt3XKLVv+gxrwcCCtFCJt8KpW5X5kcMIFNq RbIza/sGz8mkdHAj5bG4X5zTXQ8cabGsaE2qdP9UWVpiyzj4Jv+c8oDlCZ5WWwUlU5Z9cnpnkrW xm+1Jwl7sUAchbA== 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_055137_545323_BDC2DA5E X-CRM114-Status: GOOD ( 11.28 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use dev_err_probe() to make defer code handling simpler. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Konrad Dybcio --- drivers/pmdomain/qcom/cpr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/pmdomain/qcom/cpr.c b/drivers/pmdomain/qcom/cpr.c index c64e84a27cc7..1bef89712188 100644 --- a/drivers/pmdomain/qcom/cpr.c +++ b/drivers/pmdomain/qcom/cpr.c @@ -1470,9 +1470,8 @@ static int cpr_pd_attach_dev(struct generic_pm_domain *domain, */ drv->cpu_clk = devm_clk_get(dev, NULL); if (IS_ERR(drv->cpu_clk)) { - ret = PTR_ERR(drv->cpu_clk); - if (ret != -EPROBE_DEFER) - dev_err(drv->dev, "could not get cpu clk: %d\n", ret); + ret = dev_err_probe(drv->dev, PTR_ERR(drv->cpu_clk), + "could not get cpu clk\n"); goto unlock; } drv->attached_cpu_dev = dev; From patchwork Fri Aug 23 12:51:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13775147 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 421C2C52D7C for ; Fri, 23 Aug 2024 12:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=59eVpTO72QB5EEPPmk4gGW/ErENpx2zIXhSPf6144yg=; b=QcIu5J1h6EoZH0 pcEqTXs6c9F205fMkktmIwCVvQdcPh8eQ8eDfFRZ/FPaqR4EFKt4NYGqZknu7Ev0eCFqVcIqxUf99 0Tqc70R2e1TzBtrZc+l6zUG3RF0gJ/YKpKFpVVw3pdPHGIM3rcmbu9OEuPkH80fPrp2LgBiQSXNPD 9vGhqdyvj0ddbiWLxhGWH2bocbrMaHLRYR3yiIddW6mNprAjHctw1xEXw3mSQU/35dRb20YyxQGrJ PqfikbNjxvKCqCwsh5aWUQ78J9J+d7TjrZ4swKl0R6JXomBiz8Ayd4o4rE3K/Ier01NVjPbJwXSgs yISkZ3itNYolKBShwoBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTqV-0000000GmPI-21gc; Fri, 23 Aug 2024 12:56:51 +0000 Received: from mail-lf1-f49.google.com ([209.85.167.49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlU-0000000GlC3-1DQX for linux-rockchip@lists.infradead.org; Fri, 23 Aug 2024 12:51:41 +0000 Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-53341decf9aso160279e87.3 for ; Fri, 23 Aug 2024 05:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724417498; x=1725022298; 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=c6bKAkGedL7UMMYs8TWEGDN1lbQV1wuJfp8Y9Forb6E=; b=y3pA1GEWliKRrT2HmDugX2uhIwSPe+2xwbOLb6F1RcFjwvGLCTzWuSPKE8uIvRxLt7 zw7RsIA0GEaAHxY7rgwj2p+vFGFfTHR96o9BMGKiM7COPSSvY9M45Hk6zFDOGa5P2E6/ 4kyR6yq+kBmHA5KrtkfwRC8ic74337BQ7KUBuToKCfcuwnffdyR17hU0fslpaYrGsqB5 cq7MykCX9fKmbAqlyKi0mnTCJnF4+MHx/9Cm9FIrcYbpCsnSh4JoWa+H/7cBWpHw7BZi mfUYNHalLEqdHEoXq92+XlIHQB8Sg6sNzwA8urC2KrF7jnzpE7njzF0mzLH7NRmqP7Ur 4jjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724417498; x=1725022298; 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=c6bKAkGedL7UMMYs8TWEGDN1lbQV1wuJfp8Y9Forb6E=; b=Zj427WOvTgcJwGJwg31XxE7m7wSYQevlCWXWkU66PiApM0B4ARaVyGyWSoR7gCTJBv 0AWrshUGAqH5s8RC4CSTgZ+OSKd23x230uU/tt6a/LmWFOvICPst0Lb8xpa1oQvvNjh5 WuB7Wbex6iHjTaINGc9lwQFjzRtp9ta042FG9jaHpTDrUXD1xQRQsyCxiogZd/MyDAUp iEL9dJXk9t8k8tIEO/K88t9Ks2Ox2TCmdWE9YJGEQSmM1CF7AR/ptYZtCIZ0NjII5RLE 7MM64E1LXxGmH36OGCtdLj8yrh6MnUhdQ+q6I6018bD6RMmoB+IBhVjWsPmZMzbkCZZV fZ3A== X-Forwarded-Encrypted: i=1; AJvYcCUsOa/RZGrUUq6h6to9GF2yYhFMqQKEuopPLcDLH4EOQ7RJV1IXXxbk6tu2vqfcmxMJ8aRGHvXXC75wzDBidQ==@lists.infradead.org X-Gm-Message-State: AOJu0Yzgp4aNcUn3kfNz5SH3CMJGGyL1OkzYFU3YvoD+bht8KxA0cZtO 2USPLs3XfRQJsIRhonSpV8vNDmTwDrCxt5gnl/EYrZdA2JXg7T3C4FETQ4D+/3Q= X-Google-Smtp-Source: AGHT+IGQmqwRaOXufNemZtZqwlmIa7+KcLUj1o3M308GEk2HOgVnw4mfufLO7YIOaCdPCj+V+eeimA== X-Received: by 2002:a05:6512:33c9:b0:530:bc24:bfc4 with SMTP id 2adb3069b0e04-53438755889mr818571e87.2.1724417497587; Fri, 23 Aug 2024 05:51:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 05:51:37 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 14:51:10 +0200 Subject: [PATCH 06/10] pmdomain: qcom: cpr: Simplify locking with guard() MIME-Version: 1.0 Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-6-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=4641; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Pp7V41UldIPg+yPXiDv46w4z040CH5vPeQYOKc3e1as=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyIXJ5m1RFokfXeXEQENi1lr7W2roZVhJaKfQX 1F8cz1XW5+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsiFyQAKCRDBN2bmhouD 169zEACSSjVVSneT4X8U1tvTYXw701X4Mt1YURXDVQNyPbd6io40jz4l1/14mYHZ2j1fswl2hTq RtjN9KVwmsWanbQXXlvy0ZiSGuJ26JWy9Vj4glcvOVop1hwQprfbyOcaOtPNsWd57giUKJEO1is Wmlun0Avn/UlvboOwSL6B+9AAOSzpLaVZ6eZ3ZeTbCO2N6ka0fAENGjTxagtjRU3ATJ8upBZp2R eoCztmFI9Tgee94KIgq0AXmtq+WMux/ucOSOZC3DonweLKRHS+AvNvUY/zM501AzMOWkugxcUHV FrmvRpIPNKwOozUrOQoHLQOLweqjqwkGISUtz/1fd+atji+ILsFSC1Ln2Aeju3scrI38H5HJIpA q7pbHMOaTo/GU9WpCpN/i2zCIayzqZR3YSpsP7YgAEjdy1c5PLq9Z8RcAdN1Ek2CxOtQ0Rky+AD 424BEbR7Bs5R7F8CBu0immxmykmrDysRH52t+k2rNbBBZsQH6gM/jClacAWW9SvjO6K0VykeT7y FbLdktwp6Ywm04/cR03o7MdE/gQc0ka7bMCSvBr3evAY+USmIJK26gfzIYZlVMO4+mzMNtd4eEO aLo6TNXXmB+qJkx3c6XvG07O2kFWyLoCF0iF7C2eyVf/eRqmLj02qGBVqlxgkpCqlMiibkgS3HB E2+Bz1fLpBPV4gg== 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_055140_341236_2CEE785B X-CRM114-Status: GOOD ( 16.98 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski Reviewed-by: Konrad Dybcio --- drivers/pmdomain/qcom/cpr.c | 57 ++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/drivers/pmdomain/qcom/cpr.c b/drivers/pmdomain/qcom/cpr.c index 1bef89712188..a616a3ec3d46 100644 --- a/drivers/pmdomain/qcom/cpr.c +++ b/drivers/pmdomain/qcom/cpr.c @@ -4,6 +4,7 @@ * Copyright (c) 2019, Linaro Limited */ +#include #include #include #include @@ -747,9 +748,9 @@ static int cpr_set_performance_state(struct generic_pm_domain *domain, struct cpr_drv *drv = container_of(domain, struct cpr_drv, pd); struct corner *corner, *end; enum voltage_change_dir dir; - int ret = 0, new_uV; + int ret, new_uV; - mutex_lock(&drv->lock); + guard(mutex)(&drv->lock); dev_dbg(drv->dev, "%s: setting perf state: %u (prev state: %u)\n", __func__, state, cpr_get_cur_perf_state(drv)); @@ -760,10 +761,8 @@ static int cpr_set_performance_state(struct generic_pm_domain *domain, */ corner = drv->corners + state - 1; end = &drv->corners[drv->num_corners - 1]; - if (corner > end || corner < drv->corners) { - ret = -EINVAL; - goto unlock; - } + if (corner > end || corner < drv->corners) + return -EINVAL; /* Determine direction */ if (drv->corner > corner) @@ -783,7 +782,7 @@ static int cpr_set_performance_state(struct generic_pm_domain *domain, ret = cpr_scale_voltage(drv, corner, new_uV, dir); if (ret) - goto unlock; + return ret; if (cpr_is_allowed(drv)) { cpr_irq_clr(drv); @@ -794,10 +793,7 @@ static int cpr_set_performance_state(struct generic_pm_domain *domain, drv->corner = corner; -unlock: - mutex_unlock(&drv->lock); - - return ret; + return 0; } static int @@ -1443,9 +1439,9 @@ static int cpr_pd_attach_dev(struct generic_pm_domain *domain, { struct cpr_drv *drv = container_of(domain, struct cpr_drv, pd); const struct acc_desc *acc_desc = drv->acc_desc; - int ret = 0; + int ret; - mutex_lock(&drv->lock); + guard(mutex)(&drv->lock); dev_dbg(drv->dev, "attach callback for: %s\n", dev_name(dev)); @@ -1457,7 +1453,7 @@ static int cpr_pd_attach_dev(struct generic_pm_domain *domain, * additional initialization when further CPUs get attached. */ if (drv->attached_cpu_dev) - goto unlock; + return 0; /* * cpr_scale_voltage() requires the direction (if we are changing @@ -1469,11 +1465,10 @@ static int cpr_pd_attach_dev(struct generic_pm_domain *domain, * the first time cpr_set_performance_state() is called. */ drv->cpu_clk = devm_clk_get(dev, NULL); - if (IS_ERR(drv->cpu_clk)) { - ret = dev_err_probe(drv->dev, PTR_ERR(drv->cpu_clk), - "could not get cpu clk\n"); - goto unlock; - } + if (IS_ERR(drv->cpu_clk)) + return dev_err_probe(drv->dev, PTR_ERR(drv->cpu_clk), + "could not get cpu clk\n"); + drv->attached_cpu_dev = dev; dev_dbg(drv->dev, "using cpu clk from: %s\n", @@ -1490,42 +1485,39 @@ static int cpr_pd_attach_dev(struct generic_pm_domain *domain, ret = dev_pm_opp_get_opp_count(&drv->pd.dev); if (ret < 0) { dev_err(drv->dev, "could not get OPP count\n"); - goto unlock; + return ret; } drv->num_corners = ret; if (drv->num_corners < 2) { dev_err(drv->dev, "need at least 2 OPPs to use CPR\n"); - ret = -EINVAL; - goto unlock; + return -EINVAL; } drv->corners = devm_kcalloc(drv->dev, drv->num_corners, sizeof(*drv->corners), GFP_KERNEL); - if (!drv->corners) { - ret = -ENOMEM; - goto unlock; - } + if (!drv->corners) + return -ENOMEM; ret = cpr_corner_init(drv); if (ret) - goto unlock; + return ret; cpr_set_loop_allowed(drv); ret = cpr_init_parameters(drv); if (ret) - goto unlock; + return ret; /* Configure CPR HW but keep it disabled */ ret = cpr_config(drv); if (ret) - goto unlock; + return ret; ret = cpr_find_initial_corner(drv); if (ret) - goto unlock; + return ret; if (acc_desc->config) regmap_multi_reg_write(drv->tcsr, acc_desc->config, @@ -1540,10 +1532,7 @@ static int cpr_pd_attach_dev(struct generic_pm_domain *domain, dev_info(drv->dev, "driver initialized with %u OPPs\n", drv->num_corners); -unlock: - mutex_unlock(&drv->lock); - - return ret; + return 0; } static int cpr_debug_info_show(struct seq_file *s, void *unused) From patchwork Fri Aug 23 12:51:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13775149 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 568F1C531DC for ; Fri, 23 Aug 2024 12:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=Owyyn+ycT4Am0mtJSH/Cta/8gTz44ayTx4aEBnPvbR4=; b=nhyJt9bgFnLbcG kbHs12h5ylVqW1Ud6LaUOlivTshxWSD7K0R8zzZTpCy9yMgLeY0FiMl9uiKRyVbFS8p0aNQCykEh6 MXwE6khRV3ysBpJHThCbwVWe5IXmZEzk+2YfdytNwrA/EJZX2pifNuQMtx6s1N99Ht1WhFJxGno2J 48lV/l86H67FDiooLZL4cZaqqWrJsNb7Gus1exAyTCaaYzw8E+18xiXjKRJFMmQHmfMFcdLxnP4AK a+LDounKLWEh9C2g65sfYoYpAIykccPUEJQRy2k53uo/LnMAs+QV3jt7IYMUZisXI49p+SStiMMTW bSi5f74uE9lZNjF0xoSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTqV-0000000GmPh-3dKS; Fri, 23 Aug 2024 12:56:51 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlW-0000000GlCr-0OqJ for linux-rockchip@lists.infradead.org; Fri, 23 Aug 2024 12:51:43 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5334eec7485so331405e87.3 for ; Fri, 23 Aug 2024 05:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724417500; x=1725022300; 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=pPH0zYeEKEXW0yb0C0QcNli7uy5nXQcT3Asm3cghOnA=; b=ZmkLZTRpXzdlgZzDFVJ31zXiZT+hRluWj/bCYIr5NM0I8UyrjEkU0tfU6hBshhTpjf wsoFSPfDPwY8n/vr+fCNcvd5ZMJL/xRcU/22tXNn4HvGeDcNm54b1XCSw9nyY+kWcQA1 LVEilFWfbbsgB6Injo5hGBf1w6eo7IDA8GuirBEN0hpYqU/trCyXURxKHzXtRMblETIK HPZfjU2mIf7OfJy36DTHVaSVjEAYhN4GoZsdAraoFyPQ2lifAmJ8vDFWGnbUpcykIzYG MEyhr58XX6P2E8xp0EUAj+aiwIH/oDGIfp/9gz7FIgFx3bg5/xjmlCxYPoE9s6mQi0HQ kRPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724417500; x=1725022300; 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=pPH0zYeEKEXW0yb0C0QcNli7uy5nXQcT3Asm3cghOnA=; b=LZYrDDCpbunDAdqp+0MB00RUGJwvPKEsitaF8gfItVWVnrtTB+6eLlynBmOjM0Rv3K TrDCtTqXcirQyaUZAqlNNJHJlp97WAgHl9vrgk/qqMvvbjVewKTQvYvDqli4wTW3kTgz ihL7jkBgFKlf00kT7Tu4mLYwNXtWHqKGK0izjFKqmnizZRcNq5t9ch8RhMARto/sHuHc OG542TSZW3KhjkhueXgiLwBpaSwcysh1zv46OWthABOQkvlekcRokIUp5CvIyX05GMg8 4DvkHtOv3PG/tWO/CNby14BwONcDQomu8eeDxy3BqF5YfPIcC4EZiS6FillSAh9QOnza Rfjg== X-Forwarded-Encrypted: i=1; AJvYcCUJ1j+1i0a/YKjBkVeyzteO4abrpQn9yghiqtK/fkLRUZ/opWEcaPUPj//tQKl13Itt1h9HwfttJyl2XUChyA==@lists.infradead.org X-Gm-Message-State: AOJu0YwJHjJXxi6GOA40sRaKMUVqCjTWZWRSy6qJfInUU4Ab+ZxVceE9 2tdmygDuqd4MtqZSsSbHZlrJUf5cU2GFNP5pf3rgpg2MfpXs8JhpGDlZBHRdI+g= X-Google-Smtp-Source: AGHT+IEx9QTBZ6Ig4dC6hFm6sSZWyp2NrZPz8Q5OQ6LiyVq1B5Hos95uvD5/wXcqZMFiFAQUCs44Kw== X-Received: by 2002:a05:6512:ea8:b0:52f:cf7e:b1bc with SMTP id 2adb3069b0e04-5343876c2a6mr830569e87.1.1724417499775; Fri, 23 Aug 2024 05:51:39 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 05:51:39 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 14:51:11 +0200 Subject: [PATCH 07/10] pmdomain: qcom: rpmhpd: Simplify locking with guard() MIME-Version: 1.0 Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-7-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=1388; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=y0QBIaJnf0/fSVbWVB0Xkg+ZYq4xy8XVXKh8rGpZrnE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyIXK0zZ4ZGoxkalISx0Oa0HQbALLrTngWax7j L5WXrBsTjyJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsiFygAKCRDBN2bmhouD 1xawD/4+ne9u+0w9Ge4yGMtpLBPqws51qJWUNwZocPNFdFCwDtnWIBM/MFNMy6G7mVaitbYRu8S NufmqYkj3DXtJ2sKLwHYQ+wbGJkH2CKegDUkrberoehE5ecSQYeq+L8IeWTDwZ9t/8rORPyEAn3 0x+pkG6t7Pup4fVh2PrYBqNBLimMVjnwPz/u3f9Da+qwY2cQzBoPcqDso2D9mBwsquclFCwEpQR RWeucQ/vUYJtFQqNxObOMA/GEDW+JSHCT4mD2CN1z1T2ASa0Co/ordw0ZJc4WuU4KjCZk9xq9Dj 5GPBqEWzwt5f9DxLtaELBbhsyGQLEa13QryylbpEhT4Ax9ArnWkugphkF+OWJ5ewm8g5uB5xEqR KoLcKhf8VO506EI2bhmXkAW8+vnZmUMVyHnFQzvkDEeI7IjHYozxMcG8iYb+/3HEhwyZOL68qBx 32uk1Gw5Yu5BWFddNZeihHUePRt4KK8NHdUfvtPQiHYylFkpEFwViCU4s3Gwuz1A8vDyFBVWvfZ KzAVDDXyVLMfYt/VO5iVeN4dwHtmPf9xQzkIIwd0gDwPKgC062VVJVqdTysn95/R+LPN6zp8qej cO2gtpfnk+e8mUL7UlFd3ZonuKOUmlacOqS2E1+zGdH5umSfmjMv+B2cyoGRXy7d/2Gac7Miz36 HqfXODj1mLYdYeA== 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_055142_171339_576D830D X-CRM114-Status: GOOD ( 13.15 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski Reviewed-by: Konrad Dybcio --- drivers/pmdomain/qcom/rpmhpd.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/pmdomain/qcom/rpmhpd.c b/drivers/pmdomain/qcom/rpmhpd.c index d2cb4271a1ca..65505e1e2219 100644 --- a/drivers/pmdomain/qcom/rpmhpd.c +++ b/drivers/pmdomain/qcom/rpmhpd.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2018, The Linux Foundation. All rights reserved.*/ +#include #include #include #include @@ -775,9 +776,9 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain, unsigned int level) { struct rpmhpd *pd = domain_to_rpmhpd(domain); - int ret = 0, i; + int ret, i; - mutex_lock(&rpmhpd_lock); + guard(mutex)(&rpmhpd_lock); for (i = 0; i < pd->level_count; i++) if (level <= pd->level[i]) @@ -797,14 +798,12 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain, ret = rpmhpd_aggregate_corner(pd, i); if (ret) - goto out; + return ret; } pd->corner = i; -out: - mutex_unlock(&rpmhpd_lock); - return ret; + return 0; } static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd) From patchwork Fri Aug 23 12:51:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13775148 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 080BEC5321E for ; Fri, 23 Aug 2024 12:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=Ui6x0vHhWs4bC6L0moglhGJkOyRteJMUNFH9FC+uMb8=; b=vh7ZzjJ+kqurjM 2Tmgp5mD8SCKzO5wO1h8BjF2Xi64pdd/y656eemGzXT/h6xSPWJFJgmrBs8a586V26mHAGFRpN/yC 1tNRy4DwztGoRVnAy90Nm1WZzRELd/u2yh587Lv6jZK0QAKtIZiG3iwm+yOzz7Oys+parGUIXm0Yk SqWTwjfKeWWpY1hCvekTKDysSaPfj9ZviX5BQe5/mnV/Iw7JTnvEti0A2ut1m/4+8AbpoBaU+evS6 jVt/eeyFIvJz9iLO2FL3oflYaIpX3YV43L2O7AKOmTqHM/RwLwS6kOyQqzBBOySYMggYWqUzGf4fe 38/mDMtii+mysiekwaqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTqW-0000000GmQ1-1MsT; Fri, 23 Aug 2024 12:56:52 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlX-0000000GlDj-0NKD for linux-rockchip@lists.infradead.org; Fri, 23 Aug 2024 12:51:45 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5334832fb94so440440e87.0 for ; Fri, 23 Aug 2024 05:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724417501; x=1725022301; 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=LWSvBRmFgwiSd3F2eMmjx+EmKWHuqV0doCXLi3Lc+dM=; b=Btnh+ypkALidOGHPoE4G9AeGl0joYDY1tQFlBlUHrLlgvq2ornBOpr1cX5pGXjktbs qkvj/9phLykShS9pE5UmJko1cnMWo9SiFH8jqGGIogT6ggyl6lVSmOyNtY0bnFuO/dkF Sqon5++cx3VbKiGlXqXAUsl+Ogi+VuPopk4DGRpTwlrjI2rMEEg/8fxxsGu15qBZ2yVm Amsp2/5zt77PdNUyllQDTQV7Mt2DRLLyS24s1+Qz96Vbgf7hsWPhCywQbAhwUhdGO/Ko /w0c22+yq0nWOmpFelty0p7EcPWWrDHq2C01u8fkHpfsJBGrHPEO/ZBJopzxyJvWSONh HH4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724417501; x=1725022301; 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=LWSvBRmFgwiSd3F2eMmjx+EmKWHuqV0doCXLi3Lc+dM=; b=CQH2fY9JKm6K1+OjB2eZ4BhWFPF7ZI+3UW/CCeVNBDAglgE8tBg/0YxcOANFjYKuI3 nu+Y59fObKd9ujXk2nQIvzQl033lUTNLsaFYXttwVo+MfLjV26V76d68ZESkt7ybh8mM oLmwS6AI4aHsdXCeyIop1w7Wd2wM5MKm4EubolaQ42WGfiv6P2/aIZw36fQueibDk97a mI84dyY8TS/gcBHTUX1EKf+ExnCpohmnWgsZV9KREiRezEBl7NXk/we6lP3rHPRN+Rlj Yhd4tGwg0H8gYzwh46hvVh+KFS0Clx+UmhRn7Hz15EnaoTO4aTQx7EsLJxIsY6Lb1Hyr 1kdQ== X-Forwarded-Encrypted: i=1; AJvYcCUN8tTSD/HF6bbMcQgd9l0jZrATkNMtgqaLZTA3ACuzflw+O/i9mx0LChyIoBP7dE/0ztL07m7YoKxQKaDeOw==@lists.infradead.org X-Gm-Message-State: AOJu0YxltjMoHaGozVVZxdVe6wGTvA19kB2dqDomAq6uxmryMFiiQnvL GFol/KV3tHXIUUvu/RHva57NhbmhFM2JrEoW5NMCSv/IP5FtaZEd+6mmvp0OraQ= X-Google-Smtp-Source: AGHT+IGLzwRApWGomk3qx7J1YXzN02rn4ed9Sav7TouTOUXRpc+oqNnzZE3qUGBBhBfveVxwQKMi4Q== X-Received: by 2002:a05:6512:1592:b0:52f:c142:6530 with SMTP id 2adb3069b0e04-534387c4976mr838734e87.6.1724417501464; Fri, 23 Aug 2024 05:51:41 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 05:51:40 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 14:51:12 +0200 Subject: [PATCH 08/10] pmdomain: qcom: rpmpd: Simplify locking with guard() MIME-Version: 1.0 Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-8-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=1922; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=dEBqeOHv8ua+SDX2xXix8P9X1j2XB3X9nrWuqhTFOoY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyIXLBp4hGT8aL0uXmCvXIwXYIZJjssZSgqVDO 1PWGdPkEI6JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsiFywAKCRDBN2bmhouD 17+LEACYB2RFCyuya6wvvIC2WOhsGUn/MwYWW26D+fCbIN3o0SrRL0t2RUDZEA6ix5++ngYOHHz QzLYgCb0NHUJyStgjAPq4rdjorCAfCMNPzPRzcKMz7Ni4uLeVgMM7Y5K79/3fJ95/Xm5iKCPxoe 3HSnllESICwowfturIQwU2ysa7Ge0sRD+cmfbl09MpqsieJTpUb4bDR5UZWGQe7c3za/UBg3lmu 3gyghMwahQlUz6gDqQP6MUtcpRBn1lXXZhzrvp/V6Qt7fAcC27W0AhVj0rJm33YiJJfSFc3Ofjc ztvOWf2PN9LIjEEXuGVN99lJ3FNoiBGv+9k5vEkWRCbg3jaQdZGUfLeM+vQ+u8XH6NPzGj4ysae FVHwHV+i/7fjb3Juob8j4ggZGkBGZfvikKcr77+YRYu6Lx7cflUhRU2MFQHi27YUL0kV9FLZq+V tHs4IhWcQk6eLe1IWsqjBAOhDSKeXHuTWXJfNOEz0Jy+8aFrGwqfg1lhAS9OC/v4X1en+mmoDty IcGGsSXywdd7ALcchH6LZL4snqzzWY89VlAyuiq70LeUbCKPU3KzBFIuahkawgYnuUu73eqKSEP IWvOoXAm/T0Jo2MFaLy499xsUXDMPZKRmx4DA9rOM8hTxlZJ+Exu9F5QoZJVQXHK1tsmeYlGacT 8GcUEqo80oZTQ0g== 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_055143_174141_36B92E4C X-CRM114-Status: GOOD ( 14.05 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski Reviewed-by: Konrad Dybcio --- drivers/pmdomain/qcom/rpmpd.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/pmdomain/qcom/rpmpd.c b/drivers/pmdomain/qcom/rpmpd.c index 5e6280b4cf70..0be6b3026e3a 100644 --- a/drivers/pmdomain/qcom/rpmpd.c +++ b/drivers/pmdomain/qcom/rpmpd.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -1024,20 +1025,17 @@ static int rpmpd_power_on(struct generic_pm_domain *domain) int ret; struct rpmpd *pd = domain_to_rpmpd(domain); - mutex_lock(&rpmpd_lock); + guard(mutex)(&rpmpd_lock); ret = rpmpd_send_enable(pd, true); if (ret) - goto out; + return ret; pd->enabled = true; if (pd->corner) ret = rpmpd_aggregate_corner(pd); -out: - mutex_unlock(&rpmpd_lock); - return ret; } @@ -1060,27 +1058,21 @@ static int rpmpd_power_off(struct generic_pm_domain *domain) static int rpmpd_set_performance(struct generic_pm_domain *domain, unsigned int state) { - int ret = 0; struct rpmpd *pd = domain_to_rpmpd(domain); if (state > pd->max_state) state = pd->max_state; - mutex_lock(&rpmpd_lock); + guard(mutex)(&rpmpd_lock); pd->corner = state; /* Always send updates for vfc and vfl */ if (!pd->enabled && pd->key != cpu_to_le32(KEY_FLOOR_CORNER) && pd->key != cpu_to_le32(KEY_FLOOR_LEVEL)) - goto out; + return 0; - ret = rpmpd_aggregate_corner(pd); - -out: - mutex_unlock(&rpmpd_lock); - - return ret; + return rpmpd_aggregate_corner(pd); } static int rpmpd_probe(struct platform_device *pdev) 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: 13775159 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 9C9E1C52D7C for ; Fri, 23 Aug 2024 12:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=Nw5D9PL28VLRabcNsgYM46eDfKZGxGP4CknHbj37MtQ=; b=4kQRsQ5NWqlEli zerXqVHM+hlmi6Xc3w8cu03Zc0jPqEeagISi3QdxkhVQh09qhyu/srfbYnxPBNlps6NQgpn46abZp M/9j96waQHlH+oqQx3QHrXB5hfsTZz+sBttsVzyrHfWAYpoOoust4vaDEKss0PkmXM9E5VHAHQKIF 2NC2EvQxX1nrulwcMQP/UFCF0Sc33P3siESzg8M60l8Zs0Jt5fd+UjudrzAgE16e/q9et1t0qkrqK q0m9QciYRpphKc2D4L00jWdxozDF+xpIJ4BZXpcRpYWAf1pLmxwE71KzrlBoKEmeh619Bm42LLvm6 630KEt0o8af9/y5NX3Hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTtO-0000000Gn1m-3AZf; Fri, 23 Aug 2024 12:59: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 1shTli-0000000GlHA-12L6 for linux-rockchip@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-x22f.google.com ([2a00:1450:4864:20::22f]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlb-0000000A8Wk-0EFx for linux-rockchip@lists.infradead.org; Fri, 23 Aug 2024 12:51:51 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2f3f2b86b2dso2492841fa.3 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=ldG6jMnSnjZHM3F7UKtHprq2rc/tP96JrHdf6cd/OM8XrIsVFdjtHjpTSkikbTLfKz YCoiyHBXle0uXHk58Xo9J4JehfMyh+wb0U41VkjAe7luxuOVazNREmNAm1UpHki7usn7 /uNlwACD2+fHZmqPNWyZdjd4peutMfLLAvaqaTNh61xgtpS/hfY8oTWd6tm7ZM9sThba cyiDz/JJy6sO+rzNp2f9bCMyzopih/GaoJ+TGWVNiBJpxGmnDnKwO8Y/XnnAcWqLjTtM Nc5ilO7UZVZjSmimY9D2VnNyDKCr15kbnbqeN84ioWWNqls8PVSLs3abItaL56RL/KG7 LIdg== X-Forwarded-Encrypted: i=1; AJvYcCUF8uOv0JDxBHQxGBlRALtsTBitQ7DX+CMJO039D4L7VD5ehOYr3Cqvpu7rreK0pSOkwEeysojNRN9VuBCnPg==@lists.infradead.org X-Gm-Message-State: AOJu0YzKjl+/D3UhEBuMfABDCyxymiIByBXSJnQ/5l3wzJoGte2tRsi1 H1rQ499EzL1vtL4ATUyzlGtvdN15SvGjY3tWWwnlm9phtD4c8M1kko2g86Fa+jM= 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_702180_2418E254 X-CRM114-Status: GOOD ( 14.16 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=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); From patchwork Fri Aug 23 12:51:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13775158 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 30633C531DC for ; Fri, 23 Aug 2024 12:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=GYqj7twSXoFq2+MsxQAuVZerFXhQfMBadykieQcVI0M=; b=x6IPAQY6MzZ5NO niowEB7G2OPXAHELUGhLsrFuGWIr2UTmsuzaPmJ2mlWc9YtdkISJFMTu8IdO4fZefHXyfyU04qRFJ ItbUJ14RSXy8/vpGREbIxYledHGTCNssT5ix00URKo932K4r+thGsVIcvxWQSfBf80yl7XGOT4D0G ecWHmXGaSFxiBJP8YpLMObo1Zs5Nh6K80Ht5ETtNynr8oYJ52A4sWOun/gqu/ILS7MOuM8KoZPTqO PbWDaWh/rY2YgpWXkjMunL3MOUF+Q0L/AEVQo686CVBYwgLF3wtJytu7lDor8DLzf41ykX/hje9CJ 8Wpq3/sH8honPaTYQQIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTrx-0000000Gmil-1gQY; Fri, 23 Aug 2024 12:58:21 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTla-0000000GlFI-3arx for linux-rockchip@lists.infradead.org; Fri, 23 Aug 2024 12:51:48 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a866902708fso10065566b.2 for ; Fri, 23 Aug 2024 05:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724417505; x=1725022305; 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=/rp37AUE8o1pDdOTGLdrCW8KtmisO6ANjwH8PgBb0ls=; b=u/WdOdKm2ofphiZfF2CFQQuuN7u/8k1UPlNidb7u9RpVZI1oHO0Lplu7hdysFD9LjA EzvGrOLLRDX8/xiOavth+3L+cXYwQgyfaVV3wDecNnptTkP3Wi2IX2W/BGRHPejfNIlH C1IX8gB6E3FN1tIrXeaY2qWP2vAiNOa5TV1lP4hGWS/8AbTQv6w6lgPcyjnaPbMabvsY jUZj3BCkrX/pZACgzPsr9Gd/36owqy9t2eCxsQketVGZ+FodYaGgsdS2Ou9HwhqBEYvG aSwsFXEgAlYfeeqT/L+vv7ByzyPCMC6Q0OYfH7U8Ujt18L8jAt/BYjpKyCvCuHBV0pt5 vCOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724417505; x=1725022305; 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=/rp37AUE8o1pDdOTGLdrCW8KtmisO6ANjwH8PgBb0ls=; b=IxKgy5oKke7fTb9zNYeB1mOZ1bvEltxqMRoq9Ndq3yeR1n6wJf6QIdXh+eZysNSUZR rrYF/QdOboENavbY0cViOWD/t2+mlSIWn+DGh8PiKXZew7r+bnLVnvA0lh8J5f8+vi6W Zjb4Ha775AbJqo5R7l+1H2IVL6sceyx17JTcVpyPJ5121QOU9Ldjqbp+9Urr9v5+BJnA n3oRBfOXm7adpOOq47LqGoNFsg+miHPvY6rh2wjPkGF0ThnBMIt6VHWfoduJemNundh/ 4QQm/vlvENx85Syq2g5yvvJMUSFA/7eImiSMUE0qyFmVnSPocdvZN/Eloo00CqWOSbIM GWbg== X-Forwarded-Encrypted: i=1; AJvYcCVQo8iLqu6qo5aiUW2OaMDUWTixwxwqPgQmH7ugVOJFIMZZOvdnIGwNDD2ojbqDR1cUATJHaz1v1eDiAQu2xg==@lists.infradead.org X-Gm-Message-State: AOJu0YwPoPG3UQSiYfsCJsk4Iv9H9Q6ytIKyO85jobkJ37RyTX4IT3vv GJ9eMKfy83OphGzVl6LiSy1LAbLCEI4NcKiKShDwZUnpYu0q50Ry7pV/UfYV0PQ= X-Google-Smtp-Source: AGHT+IE1+3Q98ogeUT94jLgiJMspBnSs1Bmg9/MGG8bMaWFikVo5szbklH8yaPLEJlsyUwI0svusGA== X-Received: by 2002:a17:906:c355:b0:a86:a694:aaff with SMTP id a640c23a62f3a-a86a694abe2mr75972666b.1.1724417504852; Fri, 23 Aug 2024 05:51:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 05:51:44 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 14:51:14 +0200 Subject: [PATCH 10/10] pmdomain: renesas: rcar-sysc: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-10-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=3056; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=RaCHoWfcvN19DBMmkgIRc0NGUjytTpFgVMcU13mcxgo=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyIXNR2zayhDCmXFhzQ1RKmq8aC4JQfASOX82l qQyhlx44UOJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsiFzQAKCRDBN2bmhouD 1xL8D/9RUFSYlgRZQEabYs+Zlod9oIJejL78n+4Ll7xzEa+aucx3mi/5XlXocpJxNV+gOzHmnL5 pTAKjf9vr2rrSCFpdxWqcebEDpOfdp3FhZVpBNUc1h/OP5bjr184cjhi7i9TuCDo/iVdB0pUXdN M76MCTdDAD/bgYmwRgVMQpXF1J769uZTGjSJmi58B0VRQhOhJgjmrSLchp8/NAEnWPwerPXMCkm eB714yX5DLHHI+JfhnayFx/N2/E534xyEO1HvsBvfioJrdNphfVPfe4xI/qOHupvYmd5t+/9Ghd in1T0ooZnRBOqqF/8HZO+fb5oZPBETF2hHD6X7fMDmFhHDfW6lReeoDHG+ru1B6TG9NLvU0x98u wrOOoAXHWLuo2AT/cJjkItEh9Q4T0t0HZ4GscFMohXEJ+GKyoOgFKiAgIBfVgaeJ9bfTpT6teuW zljMa7caswrosPMTvLgRiWDI6NIuUAP1HdpDhMSMerJwDdR3mM18CodSRTqDknlhCH8Tff/UyzE YQqB1Shvtr1g7dD8+6Ajdjhu72i65o1lOBEcq/i6nT6QV3efKKqIzTcF1WoXBmdjq5ZQQyxC71v yN682xplaXESoBHsCxOVmTmEK5SdClLG2XTLvLhB2ErFuaqOK91wtibYaqRUCEPcNvHLuNxW/fR 7csJsV6ahkbU4zA== 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_055146_913727_B5DCAE2E X-CRM114-Status: GOOD ( 15.04 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=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-sysc.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/pmdomain/renesas/rcar-sysc.c b/drivers/pmdomain/renesas/rcar-sysc.c index b99326917330..da169eed638c 100644 --- a/drivers/pmdomain/renesas/rcar-sysc.c +++ b/drivers/pmdomain/renesas/rcar-sysc.c @@ -6,6 +6,7 @@ * Copyright (C) 2015-2017 Glider bvba */ +#include #include #include #include @@ -348,12 +349,12 @@ static int __init rcar_sysc_pd_init(void) const struct rcar_sysc_info *info; const struct of_device_id *match; struct rcar_pm_domains *domains; - struct device_node *np; void __iomem *base; unsigned int i; int error; - np = of_find_matching_node_and_match(NULL, rcar_sysc_matches, &match); + struct device_node *np __free(device_node) = + of_find_matching_node_and_match(NULL, rcar_sysc_matches, &match); if (!np) return -ENODEV; @@ -362,7 +363,7 @@ static int __init rcar_sysc_pd_init(void) if (info->init) { error = info->init(); if (error) - goto out_put; + return error; } has_cpg_mstp = of_find_compatible_node(NULL, NULL, @@ -371,8 +372,7 @@ static int __init rcar_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_sysc_base = base; @@ -382,10 +382,8 @@ static int __init rcar_sysc_pd_init(void) rcar_sysc_extmask_val = info->extmask_val; 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); @@ -403,10 +401,8 @@ static int __init rcar_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; @@ -417,7 +413,7 @@ static int __init rcar_sysc_pd_init(void) error = rcar_sysc_pd_setup(pd); if (error) - goto out_put; + return error; domains->domains[area->isr_bit] = &pd->genpd; @@ -429,7 +425,7 @@ static int __init rcar_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; } } @@ -437,8 +433,6 @@ static int __init rcar_sysc_pd_init(void) if (!error) fwnode_dev_initialized(of_fwnode_handle(np), true); -out_put: - of_node_put(np); return error; } early_initcall(rcar_sysc_pd_init);