From patchwork Fri Jun 9 14:42:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13274054 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 85424C7EE2E for ; Fri, 9 Jun 2023 14:43:00 +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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=H4DX3oD9YR4zldmihKvW3mRP+nY4kn+cuPaYVlcb7bE=; b=4Ajwv3s+y8kXTm kk6j5byTv0JKJxkBGSvNqjYh1rZB+p+xoxdtu8apfeod0KgUAPUivYiHjguCx8tieWe2Mci9C/YAU tO+qB+/K5SLF2GhBj6kK0AP4sx2nAYKNJswqY35tiZOswKZBrpJRZQ3VCUomsMj3aKsaNE+QsWiUs fA/sKoUF7BBkMmV0fHfYy+UobFUT67B0QpPvrWJNCGPDUs/heKeo9gvIHJx47miQJS04PLpKg+RXO HsUNfXuum9k7SyOzvWJaqHUyFiwv8xn1ICy24UR/vzv61V3ZQLfaZlto4mvJB/vq9Ydu+S9UelMhx Px43fkS0eCgfJUY30oEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7dK1-00DIw1-2d; Fri, 09 Jun 2023 14:42:37 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7dJy-00DIuq-2W for linux-arm-kernel@lists.infradead.org; Fri, 09 Jun 2023 14:42:36 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9786c67ec32so317573566b.1 for ; Fri, 09 Jun 2023 07:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686321750; x=1688913750; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=El8oyFZNh8lSxaHd6WMVJll3Yl13SXdC7CmGBCc6L7M=; b=YB1u65ToDOC+pWQYt1KzPAuH19hoVojOcBFOj1J5e5WBcBO9TTGSdseiD2jdmwxRyD xwfK/irFrEDjDMrs9Qpzn1ZdISYFiI3JVk6AOrlZ0wAohRE7jzzEAHKwoqTszdlxePMp lAD6z6hw9+3+bSjOd4ntqc92rb+/0CxNZt3S8oVgXql99FS3WQHgbO4se4LInYzOBPAc zS03pdVh9AciPOiKaqIIqo53jmCL0JL9/xFVDah3M0DKOiJuuvo+IWyKtuG87aH7dSsf PQlwavHvWNL7QJ8LYjlGBM1baeUuhMB9ANvyPqbdd3sX7bUejT63Cn6PvowqSpD+b9+s /Mug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686321750; x=1688913750; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=El8oyFZNh8lSxaHd6WMVJll3Yl13SXdC7CmGBCc6L7M=; b=SIOLQz5s7ElyrGfGKfhvHfS+dgUYfOdtaR2SctlG2G9fGAHfc+nnV+dXRSOxjVUY7W dopiZyDoYcy7OtJCPGpPpygOCE8vGu0bmnlci4vzU1otU56GQLI0Lgym2ncZNtRalP8n dfIgaAZ4DSZilx79UEiD3zk4ERdGDQDvfIoA3GIDKrQ+gZ3EBMIsV/t1f3apA19RdhLZ YR6p2LZyWmMNxJ236HS8NUD04VQp/jjZkcdtEx683lI2oW0K9czmU8FwBJji5oJ7vE3S pBajdvy2MWMlpTgNXNA9wdBx9wavOLxbaCvFVSNnaWhPWtmQieEtFyWHcLDzvUblB5cq GHZA== X-Gm-Message-State: AC+VfDwHmB/q6vOVPqQv76YZV86urKSxgZChgrM0AWYeCVOAKpSvLDph 4qyewij0nyTrvLJOXN1dXtJG4vUNWoI= X-Google-Smtp-Source: ACHHUZ7D24LFTrnXPRiDrj9e+XKa5xzzwKaC8DQZ215CswJ/N8WYDqV2E2MlS1yOTN0cXbSE8oRo7g== X-Received: by 2002:a17:907:72d2:b0:974:1ef1:81ae with SMTP id du18-20020a17090772d200b009741ef181aemr2052316ejc.54.1686321750337; Fri, 09 Jun 2023 07:42:30 -0700 (PDT) Received: from localhost (p200300e41f305300f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f30:5300:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id n24-20020a170906165800b00977c7566ccbsm1362029ejd.164.2023.06.09.07.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:42:30 -0700 (PDT) From: Thierry Reding To: Thierry Reding Cc: Jon Hunter , linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] soc/tegra: pmc: Simplify debugfs initialization Date: Fri, 9 Jun 2023 16:42:24 +0200 Message-Id: <20230609144225.3898934-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230609_074234_820585_C998C428 X-CRM114-Status: GOOD ( 16.58 ) 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 From: Thierry Reding debugfs calls should generally not be error-checked to simplify the case where debugfs is disabled. Since this driver is built-in and has the sysfs bind/unbind attributes disabled, it cannot be unloaded, so there is no need to hold onto a reference to the debugfs files that are created. We can further simplify this by moving the debugfs file creation to a later stage to avoid any cleanup we might have to do during error unwind operations. This is also a little cleaner because the debugfs file relies on data structures that are created at a later point than when the file was previously created. Suggested-by: Jon Hunter Signed-off-by: Thierry Reding Reviewed-by: Jon Hunter --- drivers/soc/tegra/pmc.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index b562b005744d..438c30c5d473 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -396,7 +396,6 @@ struct tegra_pmc_soc { * @clk: pointer to pclk clock * @soc: pointer to SoC data structure * @tz_only: flag specifying if the PMC can only be accessed via TrustZone - * @debugfs: pointer to debugfs entry * @rate: currently configured rate of pclk * @suspend_mode: lowest suspend mode available * @cpu_good_time: CPU power good time (in microseconds) @@ -431,7 +430,6 @@ struct tegra_pmc { void __iomem *aotag; void __iomem *scratch; struct clk *clk; - struct dentry *debugfs; const struct tegra_pmc_soc *soc; bool tz_only; @@ -1190,16 +1188,6 @@ static int powergate_show(struct seq_file *s, void *data) DEFINE_SHOW_ATTRIBUTE(powergate); -static int tegra_powergate_debugfs_init(void) -{ - pmc->debugfs = debugfs_create_file("powergate", S_IRUGO, NULL, NULL, - &powergate_fops); - if (!pmc->debugfs) - return -ENOMEM; - - return 0; -} - static int tegra_powergate_of_get_clks(struct tegra_powergate *pg, struct device_node *np) { @@ -3026,19 +3014,13 @@ static int tegra_pmc_probe(struct platform_device *pdev) tegra_pmc_reset_sysfs_init(pmc); - if (IS_ENABLED(CONFIG_DEBUG_FS)) { - err = tegra_powergate_debugfs_init(); - if (err < 0) - goto cleanup_sysfs; - } - err = tegra_pmc_pinctrl_init(pmc); if (err) - goto cleanup_debugfs; + goto cleanup_sysfs; err = tegra_pmc_regmap_init(pmc); if (err < 0) - goto cleanup_debugfs; + goto cleanup_sysfs; err = tegra_powergate_init(pmc, pdev->dev.of_node); if (err < 0) @@ -3061,12 +3043,12 @@ static int tegra_pmc_probe(struct platform_device *pdev) if (pmc->soc->set_wake_filters) pmc->soc->set_wake_filters(pmc); + debugfs_create_file("powergate", 0444, NULL, NULL, &powergate_fops); + return 0; cleanup_powergates: tegra_powergate_remove_all(pdev->dev.of_node); -cleanup_debugfs: - debugfs_remove(pmc->debugfs); cleanup_sysfs: device_remove_file(&pdev->dev, &dev_attr_reset_reason); device_remove_file(&pdev->dev, &dev_attr_reset_level);