staging: fsl-mc: Refactored fsl_mc_object_allocator driver init/exit
authorJ. German Rivera <German.Rivera@freescale.com>
Fri, 27 Mar 2015 21:01:08 +0000 (16:01 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Apr 2015 11:55:03 +0000 (13:55 +0200)
 The fsl_mc_allocator driver does not need to be its own module
 as it is tightly integrated into the MC bus main driver. It is really
 just a sub-component of the MC bus driver. By not making fsl_mc_allocator
 its own module, we can have more control of when its initialization happens
 and we want it to happen before any driver that depends on the MC bus
 driver gets initialized.

Signed-off-by: J. German Rivera <German.Rivera@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/fsl-mc/bus/Makefile
drivers/staging/fsl-mc/bus/mc-allocator.c
drivers/staging/fsl-mc/bus/mc-bus.c
drivers/staging/fsl-mc/include/mc-private.h

index bd09fc8..25433a9 100644 (file)
@@ -5,15 +5,13 @@
 #
 # This file is released under the GPLv2
 #
-obj-$(CONFIG_FSL_MC_BUS) += mc-bus-driver.o \
-                           mc-allocator-driver.o
+obj-$(CONFIG_FSL_MC_BUS) += mc-bus-driver.o
 
 mc-bus-driver-objs := mc-bus.o \
                      mc-sys.o \
                      dprc.o \
                      dpmng.o \
-                     dprc-driver.o
-
-mc-allocator-driver-objs := mc-allocator.o \
-                           dpmcp.o \
-                           dpbp.o
+                     dprc-driver.o \
+                     mc-allocator.o \
+                     dpmcp.o \
+                     dpbp.o
index cc4a7d3..e36235d 100644 (file)
@@ -562,8 +562,12 @@ static struct fsl_mc_driver fsl_mc_allocator_driver = {
        .remove = fsl_mc_allocator_remove,
 };
 
-module_fsl_mc_driver(fsl_mc_allocator_driver);
+int __init fsl_mc_allocator_driver_init(void)
+{
+       return fsl_mc_driver_register(&fsl_mc_allocator_driver);
+}
 
-MODULE_AUTHOR("Freescale Semiconductor Inc.");
-MODULE_DESCRIPTION("Freescale's MC object device allocator");
-MODULE_LICENSE("GPL");
+void __exit fsl_mc_allocator_driver_exit(void)
+{
+       fsl_mc_driver_unregister(&fsl_mc_allocator_driver);
+}
index d943d99..b347db9 100644 (file)
@@ -730,8 +730,15 @@ static int __init fsl_mc_bus_driver_init(void)
        if (error < 0)
                goto error_cleanup_driver;
 
+       error = fsl_mc_allocator_driver_init();
+       if (error < 0)
+               goto error_cleanup_dprc_driver;
+
        return 0;
 
+error_cleanup_dprc_driver:
+       dprc_driver_exit();
+
 error_cleanup_driver:
        platform_driver_unregister(&fsl_mc_bus_driver);
 
@@ -750,6 +757,7 @@ static void __exit fsl_mc_bus_driver_exit(void)
        if (WARN_ON(!mc_dev_cache))
                return;
 
+       fsl_mc_allocator_driver_exit();
        dprc_driver_exit();
        platform_driver_unregister(&fsl_mc_bus_driver);
        bus_unregister(&fsl_mc_bus_type);
index 8e67075..c045f49 100644 (file)
@@ -102,6 +102,10 @@ int __init dprc_driver_init(void);
 
 void __exit dprc_driver_exit(void);
 
+int __init fsl_mc_allocator_driver_init(void);
+
+void __exit fsl_mc_allocator_driver_exit(void);
+
 int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
                                          enum fsl_mc_pool_type pool_type,
                                          struct fsl_mc_resource