drm/xe: Call exit functions when xe_register_pci_driver() fails
authorGustavo Sousa <gustavo.sousa@intel.com>
Thu, 11 May 2023 19:48:22 +0000 (16:48 -0300)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 19 Dec 2023 23:33:51 +0000 (18:33 -0500)
Move xe_register_pci_driver() and xe_unregister_pci_driver() to
init_funcs to make sure that exit functions are also called when
xe_register_pci_driver() fails.

Note that this also allows adding init functions to be run after
xe_register_pci_driver().

v2:
 - Move functions to init_funcs instead of having a special case for
   xe_register_pci_driver(). (Jani)

Cc: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Matt Atwood <matthew.s.atwood@intel.com>
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_module.c

index e2a61aaf50b68e5d445a560c98ce71d9f961758b..496a9001dc3e23472cf4850cb9bbcc9466c771d1 100644 (file)
@@ -45,6 +45,10 @@ static const struct init_funcs init_funcs[] = {
                .init = xe_sched_job_module_init,
                .exit = xe_sched_job_module_exit,
        },
+       {
+               .init = xe_register_pci_driver,
+               .exit = xe_unregister_pci_driver,
+       },
 };
 
 static int __init xe_init(void)
@@ -60,15 +64,13 @@ static int __init xe_init(void)
                }
        }
 
-       return xe_register_pci_driver();
+       return 0;
 }
 
 static void __exit xe_exit(void)
 {
        int i;
 
-       xe_unregister_pci_driver();
-
        for (i = ARRAY_SIZE(init_funcs) - 1; i >= 0; i--)
                init_funcs[i].exit();
 }