]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: fsl-mc: move resource pool init/cleanup into allocator
authorStuart Yoder <stuart.yoder@nxp.com>
Tue, 23 Aug 2016 22:13:24 +0000 (17:13 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Sep 2016 15:57:25 +0000 (17:57 +0200)
The resource pool init/cleanup functions logically belong in the
allocator.  Move them to the allocator and rename to reflect the
move out of the dprc-driver.

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/fsl-mc/bus/dprc-driver.c
drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
drivers/staging/fsl-mc/include/mc-bus.h

index 83e72b3ed4c1d986c32ccb887d68b9171c6666b4..89d53daa3a32375792bcc6279016f156c9797da8 100644 (file)
@@ -190,55 +190,6 @@ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
        }
 }
 
-static void dprc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
-{
-       int pool_type;
-       struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
-
-       for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++) {
-               struct fsl_mc_resource_pool *res_pool =
-                   &mc_bus->resource_pools[pool_type];
-
-               res_pool->type = pool_type;
-               res_pool->max_count = 0;
-               res_pool->free_count = 0;
-               res_pool->mc_bus = mc_bus;
-               INIT_LIST_HEAD(&res_pool->free_list);
-               mutex_init(&res_pool->mutex);
-       }
-}
-
-static void dprc_cleanup_resource_pool(struct fsl_mc_device *mc_bus_dev,
-                                      enum fsl_mc_pool_type pool_type)
-{
-       struct fsl_mc_resource *resource;
-       struct fsl_mc_resource *next;
-       struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
-       struct fsl_mc_resource_pool *res_pool =
-                                       &mc_bus->resource_pools[pool_type];
-       int free_count = 0;
-
-       WARN_ON(res_pool->type != pool_type);
-       WARN_ON(res_pool->free_count != res_pool->max_count);
-
-       list_for_each_entry_safe(resource, next, &res_pool->free_list, node) {
-               free_count++;
-               WARN_ON(resource->type != res_pool->type);
-               WARN_ON(resource->parent_pool != res_pool);
-               devm_kfree(&mc_bus_dev->dev, resource);
-       }
-
-       WARN_ON(free_count != res_pool->free_count);
-}
-
-static void dprc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
-{
-       int pool_type;
-
-       for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++)
-               dprc_cleanup_resource_pool(mc_bus_dev, pool_type);
-}
-
 /**
  * dprc_scan_objects - Discover objects in a DPRC
  *
@@ -363,7 +314,7 @@ int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
        unsigned int irq_count;
        struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
 
-       dprc_init_all_resource_pools(mc_bus_dev);
+       fsl_mc_init_all_resource_pools(mc_bus_dev);
 
        /*
         * Discover objects in the DPRC:
@@ -390,7 +341,7 @@ int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
 
        return 0;
 error:
-       dprc_cleanup_all_resource_pools(mc_bus_dev);
+       fsl_mc_cleanup_all_resource_pools(mc_bus_dev);
        return error;
 }
 EXPORT_SYMBOL_GPL(dprc_scan_container);
@@ -802,7 +753,7 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
                dev_set_msi_domain(&mc_dev->dev, NULL);
        }
 
-       dprc_cleanup_all_resource_pools(mc_dev);
+       fsl_mc_cleanup_all_resource_pools(mc_dev);
 
        error = dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
        if (error < 0)
index 655056480414548a279f41ad47f49fa3a7788c19..9695f4425a199134ee173691808ea791cd6da261 100644 (file)
@@ -668,6 +668,55 @@ void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev)
 }
 EXPORT_SYMBOL_GPL(fsl_mc_free_irqs);
 
+void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
+{
+       int pool_type;
+       struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
+
+       for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++) {
+               struct fsl_mc_resource_pool *res_pool =
+                   &mc_bus->resource_pools[pool_type];
+
+               res_pool->type = pool_type;
+               res_pool->max_count = 0;
+               res_pool->free_count = 0;
+               res_pool->mc_bus = mc_bus;
+               INIT_LIST_HEAD(&res_pool->free_list);
+               mutex_init(&res_pool->mutex);
+       }
+}
+
+static void fsl_mc_cleanup_resource_pool(struct fsl_mc_device *mc_bus_dev,
+                                        enum fsl_mc_pool_type pool_type)
+{
+       struct fsl_mc_resource *resource;
+       struct fsl_mc_resource *next;
+       struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
+       struct fsl_mc_resource_pool *res_pool =
+                                       &mc_bus->resource_pools[pool_type];
+       int free_count = 0;
+
+       WARN_ON(res_pool->type != pool_type);
+       WARN_ON(res_pool->free_count != res_pool->max_count);
+
+       list_for_each_entry_safe(resource, next, &res_pool->free_list, node) {
+               free_count++;
+               WARN_ON(resource->type != res_pool->type);
+               WARN_ON(resource->parent_pool != res_pool);
+               devm_kfree(&mc_bus_dev->dev, resource);
+       }
+
+       WARN_ON(free_count != res_pool->free_count);
+}
+
+void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
+{
+       int pool_type;
+
+       for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++)
+               fsl_mc_cleanup_resource_pool(mc_bus_dev, pool_type);
+}
+
 /**
  * fsl_mc_allocator_probe - callback invoked when an allocatable device is
  * being added to the system
index f192aa8f07b9d1c381fdf922ae21e055819fefcd..2098b3c7431729a8c9605162d3cec2fc74c3ad57 100644 (file)
@@ -150,4 +150,8 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
 
 void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus);
 
+void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
+
+void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev);
+
 #endif /* _FSL_MC_MCBUS_H_ */