Skip to content

Commit bae9fb2

Browse files
committed
soc/tegra: pmc: Simplify debugfs initialization
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 <jonathanh@nvidia.com> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
1 parent e180cf8 commit bae9fb2

1 file changed

Lines changed: 4 additions & 22 deletions

File tree

drivers/soc/tegra/pmc.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ struct tegra_pmc_soc {
396396
* @clk: pointer to pclk clock
397397
* @soc: pointer to SoC data structure
398398
* @tz_only: flag specifying if the PMC can only be accessed via TrustZone
399-
* @debugfs: pointer to debugfs entry
400399
* @rate: currently configured rate of pclk
401400
* @suspend_mode: lowest suspend mode available
402401
* @cpu_good_time: CPU power good time (in microseconds)
@@ -431,7 +430,6 @@ struct tegra_pmc {
431430
void __iomem *aotag;
432431
void __iomem *scratch;
433432
struct clk *clk;
434-
struct dentry *debugfs;
435433

436434
const struct tegra_pmc_soc *soc;
437435
bool tz_only;
@@ -1190,16 +1188,6 @@ static int powergate_show(struct seq_file *s, void *data)
11901188

11911189
DEFINE_SHOW_ATTRIBUTE(powergate);
11921190

1193-
static int tegra_powergate_debugfs_init(void)
1194-
{
1195-
pmc->debugfs = debugfs_create_file("powergate", S_IRUGO, NULL, NULL,
1196-
&powergate_fops);
1197-
if (!pmc->debugfs)
1198-
return -ENOMEM;
1199-
1200-
return 0;
1201-
}
1202-
12031191
static int tegra_powergate_of_get_clks(struct tegra_powergate *pg,
12041192
struct device_node *np)
12051193
{
@@ -3026,19 +3014,13 @@ static int tegra_pmc_probe(struct platform_device *pdev)
30263014

30273015
tegra_pmc_reset_sysfs_init(pmc);
30283016

3029-
if (IS_ENABLED(CONFIG_DEBUG_FS)) {
3030-
err = tegra_powergate_debugfs_init();
3031-
if (err < 0)
3032-
goto cleanup_sysfs;
3033-
}
3034-
30353017
err = tegra_pmc_pinctrl_init(pmc);
30363018
if (err)
3037-
goto cleanup_debugfs;
3019+
goto cleanup_sysfs;
30383020

30393021
err = tegra_pmc_regmap_init(pmc);
30403022
if (err < 0)
3041-
goto cleanup_debugfs;
3023+
goto cleanup_sysfs;
30423024

30433025
err = tegra_powergate_init(pmc, pdev->dev.of_node);
30443026
if (err < 0)
@@ -3061,12 +3043,12 @@ static int tegra_pmc_probe(struct platform_device *pdev)
30613043
if (pmc->soc->set_wake_filters)
30623044
pmc->soc->set_wake_filters(pmc);
30633045

3046+
debugfs_create_file("powergate", 0444, NULL, NULL, &powergate_fops);
3047+
30643048
return 0;
30653049

30663050
cleanup_powergates:
30673051
tegra_powergate_remove_all(pdev->dev.of_node);
3068-
cleanup_debugfs:
3069-
debugfs_remove(pmc->debugfs);
30703052
cleanup_sysfs:
30713053
device_remove_file(&pdev->dev, &dev_attr_reset_reason);
30723054
device_remove_file(&pdev->dev, &dev_attr_reset_level);

0 commit comments

Comments
 (0)