]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
powerpc/vas: Fix cleanup when VAS is not configured
authorSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Fri, 9 Feb 2018 17:49:06 +0000 (11:49 -0600)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 27 Aug 2018 14:40:05 +0000 (16:40 +0200)
BugLink: http://bugs.launchpad.net/bugs/1786352
[ Upstream commit 45ddea8a73a25461387eb8e87f3e0ecca084799b ]

When VAS is not configured, unregister the platform driver. Also simplify
cleanup by delaying vas debugfs init until we know VAS is configured.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/powerpc/platforms/powernv/vas-debug.c
arch/powerpc/platforms/powernv/vas.c

index ca22f1eae050d25d4aef64f1db31f0f10b5641d4..3161e39eea1dc7c3b3504ec1fa773fd34cc15c5b 100644 (file)
@@ -179,6 +179,7 @@ void vas_instance_init_dbgdir(struct vas_instance *vinst)
 {
        struct dentry *d;
 
+       vas_init_dbgdir();
        if (!vas_debugfs)
                return;
 
@@ -201,8 +202,18 @@ free_name:
        vinst->dbgdir = NULL;
 }
 
+/*
+ * Set up the "root" VAS debugfs dir. Return if we already set it up
+ * (or failed to) in an earlier instance of VAS.
+ */
 void vas_init_dbgdir(void)
 {
+       static bool first_time = true;
+
+       if (!first_time)
+               return;
+
+       first_time = false;
        vas_debugfs = debugfs_create_dir("vas", NULL);
        if (IS_ERR(vas_debugfs))
                vas_debugfs = NULL;
index aebbe95c9230bc4b85016a945303307aa96c369e..5a2b24cbbc886df50f875a4674a635c159fef104 100644 (file)
@@ -160,8 +160,6 @@ static int __init vas_init(void)
        int found = 0;
        struct device_node *dn;
 
-       vas_init_dbgdir();
-
        platform_driver_register(&vas_driver);
 
        for_each_compatible_node(dn, NULL, "ibm,vas") {
@@ -169,8 +167,10 @@ static int __init vas_init(void)
                found++;
        }
 
-       if (!found)
+       if (!found) {
+               platform_driver_unregister(&vas_driver);
                return -ENODEV;
+       }
 
        pr_devel("Found %d instances\n", found);