]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.1/soc-tegra-pmc-remove-reset-sysfs-entries-on-error.patch
4.19-stable patches
[thirdparty/kernel/stable-queue.git] / queue-5.1 / soc-tegra-pmc-remove-reset-sysfs-entries-on-error.patch
1 From 666a99f7c287444062b80e7e97c040e9b3accdd5 Mon Sep 17 00:00:00 2001
2 From: Jon Hunter <jonathanh@nvidia.com>
3 Date: Tue, 16 Apr 2019 17:48:07 +0100
4 Subject: soc/tegra: pmc: Remove reset sysfs entries on error
5
6 [ Upstream commit a46b51cd2a57d52d5047e1d48240536243eeab34 ]
7
8 Commit 5f84bb1a4099 ("soc/tegra: pmc: Add sysfs entries for reset info")
9 added sysfs entries for Tegra reset source and level. However, these
10 sysfs are not removed on error and so if the registering of PMC device
11 is probe deferred, then the next time we attempt to probe the PMC device
12 warnings such as the following will be displayed on boot ...
13
14 sysfs: cannot create duplicate filename '/devices/platform/7000e400.pmc/reset_reason'
15
16 Fix this by calling device_remove_file() for each sysfs entry added on
17 failure. Note that we call device_remove_file() unconditionally without
18 checking if the sysfs entry was created in the first place, but this
19 should be OK because kernfs_remove_by_name_ns() will fail silently.
20
21 Fixes: 5f84bb1a4099 ("soc/tegra: pmc: Add sysfs entries for reset info")
22 Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
23 Signed-off-by: Thierry Reding <treding@nvidia.com>
24 Signed-off-by: Sasha Levin <sashal@kernel.org>
25 ---
26 drivers/soc/tegra/pmc.c | 5 ++++-
27 1 file changed, 4 insertions(+), 1 deletion(-)
28
29 diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
30 index 0df258518693..2fba8cdbe3bd 100644
31 --- a/drivers/soc/tegra/pmc.c
32 +++ b/drivers/soc/tegra/pmc.c
33 @@ -1999,7 +1999,7 @@ static int tegra_pmc_probe(struct platform_device *pdev)
34 if (IS_ENABLED(CONFIG_DEBUG_FS)) {
35 err = tegra_powergate_debugfs_init();
36 if (err < 0)
37 - return err;
38 + goto cleanup_sysfs;
39 }
40
41 err = register_restart_handler(&tegra_pmc_restart_handler);
42 @@ -2030,6 +2030,9 @@ cleanup_restart_handler:
43 unregister_restart_handler(&tegra_pmc_restart_handler);
44 cleanup_debugfs:
45 debugfs_remove(pmc->debugfs);
46 +cleanup_sysfs:
47 + device_remove_file(&pdev->dev, &dev_attr_reset_reason);
48 + device_remove_file(&pdev->dev, &dev_attr_reset_level);
49 return err;
50 }
51
52 --
53 2.20.1
54