]> Git Repo - J-linux.git/blobdiff - drivers/fpga/fpga-region.c
fpga: region: add owner module and take its refcount
[J-linux.git] / drivers / fpga / fpga-region.c
index b364a929425ce9b54345a0098e28837894359495..753cd142503e0e254bcbdb054a63c7131525cf1d 100644 (file)
@@ -53,7 +53,7 @@ static struct fpga_region *fpga_region_get(struct fpga_region *region)
        }
 
        get_device(dev);
-       if (!try_module_get(dev->parent->driver->owner)) {
+       if (!try_module_get(region->ops_owner)) {
                put_device(dev);
                mutex_unlock(&region->mutex);
                return ERR_PTR(-ENODEV);
@@ -75,7 +75,7 @@ static void fpga_region_put(struct fpga_region *region)
 
        dev_dbg(dev, "put\n");
 
-       module_put(dev->parent->driver->owner);
+       module_put(region->ops_owner);
        put_device(dev);
        mutex_unlock(&region->mutex);
 }
@@ -181,14 +181,16 @@ static struct attribute *fpga_region_attrs[] = {
 ATTRIBUTE_GROUPS(fpga_region);
 
 /**
- * fpga_region_register_full - create and register an FPGA Region device
+ * __fpga_region_register_full - create and register an FPGA Region device
  * @parent: device parent
  * @info: parameters for FPGA Region
+ * @owner: module containing the get_bridges function
  *
  * Return: struct fpga_region or ERR_PTR()
  */
 struct fpga_region *
-fpga_region_register_full(struct device *parent, const struct fpga_region_info *info)
+__fpga_region_register_full(struct device *parent, const struct fpga_region_info *info,
+                           struct module *owner)
 {
        struct fpga_region *region;
        int id, ret = 0;
@@ -213,6 +215,7 @@ fpga_region_register_full(struct device *parent, const struct fpga_region_info *
        region->compat_id = info->compat_id;
        region->priv = info->priv;
        region->get_bridges = info->get_bridges;
+       region->ops_owner = owner;
 
        mutex_init(&region->mutex);
        INIT_LIST_HEAD(&region->bridge_list);
@@ -241,13 +244,14 @@ err_free:
 
        return ERR_PTR(ret);
 }
-EXPORT_SYMBOL_GPL(fpga_region_register_full);
+EXPORT_SYMBOL_GPL(__fpga_region_register_full);
 
 /**
- * fpga_region_register - create and register an FPGA Region device
+ * __fpga_region_register - create and register an FPGA Region device
  * @parent: device parent
  * @mgr: manager that programs this region
  * @get_bridges: optional function to get bridges to a list
+ * @owner: module containing the get_bridges function
  *
  * This simple version of the register function should be sufficient for most users.
  * The fpga_region_register_full() function is available for users that need to
@@ -256,17 +260,17 @@ EXPORT_SYMBOL_GPL(fpga_region_register_full);
  * Return: struct fpga_region or ERR_PTR()
  */
 struct fpga_region *
-fpga_region_register(struct device *parent, struct fpga_manager *mgr,
-                    int (*get_bridges)(struct fpga_region *))
+__fpga_region_register(struct device *parent, struct fpga_manager *mgr,
+                      int (*get_bridges)(struct fpga_region *), struct module *owner)
 {
        struct fpga_region_info info = { 0 };
 
        info.mgr = mgr;
        info.get_bridges = get_bridges;
 
-       return fpga_region_register_full(parent, &info);
+       return __fpga_region_register_full(parent, &info, owner);
 }
-EXPORT_SYMBOL_GPL(fpga_region_register);
+EXPORT_SYMBOL_GPL(__fpga_region_register);
 
 /**
  * fpga_region_unregister - unregister an FPGA region
This page took 0.029535 seconds and 4 git commands to generate.