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); From patchwork Fri Jun 9 14:42:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13274053 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 4DB0CC7EE29 for ; Fri, 9 Jun 2023 14:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=pLpvomz48V7u5VEu4fM1uBW4LreZ+gs9/onfjzoGblo=; b=1QJCMgNFQbWIhF 550gUucUqUNzTqL5IhKZtm9+RQQQ0SkBCd9hnqyPuwsgepCWX6DZZ2z7L9D+iJNOH03MVI3umwwQM uXP73BtK6ZYbmOxdm6WAnjmWCf4Np0nFvXJUE12A+M9XgBcpcvE4eUdC35zze0ZplBf6QlZr7XPJT 1gqDsk5wVXBiWCYT7H8c54+c2yLmvzQPlliVMYEjMei2Jj9BWsg+KiGc4McfyjI/LkNxEfAmd7eTx fzodJ6fnNRcV8jTXUsK+r9aehW8o1o/2OB+Nb6yw/YqoKk/bAjw4oWqT01DNbThK7opVNyN0t+k+h z83yUp+F7fkcBkOZAzHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7dK2-00DIwF-1E; Fri, 09 Jun 2023 14:42:38 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7dJy-00DIuw-2y for linux-arm-kernel@lists.infradead.org; Fri, 09 Jun 2023 14:42:36 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5149b63151aso3210513a12.3 for ; Fri, 09 Jun 2023 07:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686321751; x=1688913751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TtzcCW3xD18TXr/1ERdT9p7u3+NtMz6vgFJptk63/SY=; b=mgpa9S8tGZJFf5NJK3D6MNV4zdAmS2JgiiH92mUkQWYrqVooOU6u6ZL8oQa9QDFPon baGWTNc1oouB78me/vH2hjnMmeAhFWsbQ+GpFeeozWMWXJeIpXpqnpwuRy8xL0WZRkoQ JWCD+ZSNBLwDXV+dgX2lKtxUuaETB6m6hG5zoMNS8Ie2Y9bL4J2KmYcd5KSwBFcbmTSM N7jHqmsmS0kC31KCgPEzgcO4yy4dkACWjeZ9Fka/15/trH4qA4rVxH/wPrI7VQ59xE0n sE4eNC+0KUIkBuRfmhxsjrEwgqw+gYaHy7i0PV5s47GiSZLpqddZq3dL2fRJTxUrgXFF w92g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686321751; x=1688913751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TtzcCW3xD18TXr/1ERdT9p7u3+NtMz6vgFJptk63/SY=; b=cHoxsgIC6H4alGXBUHzNn4b5C9QMAVv9tlyEM87rdER5iZBppdhapxXIHeJzj0lbSu h6wG/hHxRdJxyMjTThRIfrkyk862kS8+bwq4VbHDhaLMt3k232zfNfmxeGlOJOTQRVaK fg+I9to5A63U1KyGlfvMSwMcEVDq59O3JOS4b8GSuyRB3KHsE0h5/szYuv8RUNld/vcd LH6VPDUbzEz6RBAxEuHOwn004OyczT6pPHKztrQmdiCCD4MqteJdJiHqJ23GeNzyxNBg nG8tjZI7fjg8NRoVzzbIpPKR+hEjQ5UKXnak8L+mk+LY5w5aQNFwbCg+g4EgCSXAC47U OKOw== X-Gm-Message-State: AC+VfDzTZ7FWJAKgKNXPxQ2wXrKS3BroIMiAwCBYqF7eUe1QE8k5UEne e8eVtpvBY5dKe7+ZjOE0pNgOJ0LeP5s= X-Google-Smtp-Source: ACHHUZ5h36wlks6GZSDF2PV335ofhl3q/qD8csh/iNLpA25DV4kl5qhTNIgyaTZ8xMrkio5FquDUQw== X-Received: by 2002:a05:6402:1a52:b0:516:af22:bccc with SMTP id bf18-20020a0564021a5200b00516af22bcccmr1307814edb.21.1686321751442; Fri, 09 Jun 2023 07:42:31 -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-20020a05640206d800b005169f9365c3sm1840788edy.20.2023.06.09.07.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:42:31 -0700 (PDT) From: Thierry Reding To: Thierry Reding Cc: Jon Hunter , linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] soc/tegra: pmc: Use devm_clk_notifier_register() Date: Fri, 9 Jun 2023 16:42:25 +0200 Message-Id: <20230609144225.3898934-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609144225.3898934-1-thierry.reding@gmail.com> References: <20230609144225.3898934-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230609_074234_956410_8D323A14 X-CRM114-Status: GOOD ( 13.07 ) 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 Move to the device-managed version of clk_notifier_register() to remove the need for manual cleanup. This fixes a potential issue where the clock notifier would stick around after the driver fails to probe at a later point. Signed-off-by: Thierry Reding Reviewed-by: Jon Hunter --- drivers/soc/tegra/pmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index 438c30c5d473..162f52456f65 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -2992,7 +2992,8 @@ static int tegra_pmc_probe(struct platform_device *pdev) */ if (pmc->clk) { pmc->clk_nb.notifier_call = tegra_pmc_clk_notify_cb; - err = clk_notifier_register(pmc->clk, &pmc->clk_nb); + err = devm_clk_notifier_register(&pdev->dev, pmc->clk, + &pmc->clk_nb); if (err) { dev_err(&pdev->dev, "failed to register clk notifier\n"); @@ -3052,7 +3053,6 @@ static int tegra_pmc_probe(struct platform_device *pdev) cleanup_sysfs: device_remove_file(&pdev->dev, &dev_attr_reset_reason); device_remove_file(&pdev->dev, &dev_attr_reset_level); - clk_notifier_unregister(pmc->clk, &pmc->clk_nb); return err; }