libnvdimm: move ->module to struct nvdimm_bus_descriptor
authorDan Williams <dan.j.williams@intel.com>
Fri, 22 Jul 2016 03:03:19 +0000 (20:03 -0700)
committerDan Williams <dan.j.williams@intel.com>
Fri, 22 Jul 2016 03:03:19 +0000 (20:03 -0700)
Let the provider module be explicitly passed in rather than implicitly
assumed by the module that calls nvdimm_bus_register().  This is in
preparation for unifying the nfit and nfit_test driver teardown paths.

Reviewed-by: Lee, Chun-Yi <jlee@suse.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/acpi/nfit.c
drivers/nvdimm/bus.c
drivers/nvdimm/core.c
drivers/nvdimm/e820.c
drivers/nvdimm/nd-core.h
include/linux/libnvdimm.h
tools/testing/nvdimm/test/nfit.c

index fb80f32db525a48e85dd1e4dc59b3441a069bf14..e7eb3b6f1514686c6be483de488545dda0901067 100644 (file)
@@ -2417,6 +2417,7 @@ void acpi_nfit_desc_init(struct acpi_nfit_desc *acpi_desc, struct device *dev)
        acpi_desc->blk_do_io = acpi_nfit_blk_region_do_io;
        nd_desc = &acpi_desc->nd_desc;
        nd_desc->provider_name = "ACPI.NFIT";
+       nd_desc->module = THIS_MODULE;
        nd_desc->ndctl = acpi_nfit_ctl;
        nd_desc->flush_probe = acpi_nfit_flush_probe;
        nd_desc->clear_to_send = acpi_nfit_clear_to_send;
index 1cc7880320fe68a8bfb7e326070c09e997e3c2ab..275dd5c0a3018a45cfa66ae03bd179779b9c7041 100644 (file)
@@ -73,7 +73,7 @@ static struct module *to_bus_provider(struct device *dev)
        if (is_nd_pmem(dev) || is_nd_blk(dev)) {
                struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
 
-               return nvdimm_bus->module;
+               return nvdimm_bus->nd_desc->module;
        }
        return NULL;
 }
index 757e0cf028bf61b85d2a55e6581be52cd26eaf65..e8528756f54f2c73c9806f8442081c3e71fe4040 100644 (file)
@@ -447,8 +447,8 @@ struct attribute_group nvdimm_bus_attribute_group = {
 };
 EXPORT_SYMBOL_GPL(nvdimm_bus_attribute_group);
 
-struct nvdimm_bus *__nvdimm_bus_register(struct device *parent,
-               struct nvdimm_bus_descriptor *nd_desc, struct module *module)
+struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
+               struct nvdimm_bus_descriptor *nd_desc)
 {
        struct nvdimm_bus *nvdimm_bus;
        int rc;
@@ -467,7 +467,6 @@ struct nvdimm_bus *__nvdimm_bus_register(struct device *parent,
                return NULL;
        }
        nvdimm_bus->nd_desc = nd_desc;
-       nvdimm_bus->module = module;
        nvdimm_bus->dev.parent = parent;
        nvdimm_bus->dev.release = nvdimm_bus_release;
        nvdimm_bus->dev.groups = nd_desc->attr_groups;
@@ -491,7 +490,7 @@ struct nvdimm_bus *__nvdimm_bus_register(struct device *parent,
        put_device(&nvdimm_bus->dev);
        return NULL;
 }
-EXPORT_SYMBOL_GPL(__nvdimm_bus_register);
+EXPORT_SYMBOL_GPL(nvdimm_bus_register);
 
 static void set_badblock(struct badblocks *bb, sector_t s, int num)
 {
index 95825b38559addb8a0dc5cca22bc305e228e65f6..11ea90120542dcbec8410147efca7a502eea9a77 100644 (file)
@@ -47,6 +47,7 @@ static int e820_pmem_probe(struct platform_device *pdev)
 
        nd_desc.attr_groups = e820_pmem_attribute_groups;
        nd_desc.provider_name = "e820";
+       nd_desc.module = THIS_MODULE;
        nvdimm_bus = nvdimm_bus_register(dev, &nd_desc);
        if (!nvdimm_bus)
                goto err;
index 6e961f7f43e7817b62935a358a8c5bfe04ab1f09..38ce6bbbc170bcdc40982d5f49473bab181e2071 100644 (file)
@@ -26,7 +26,6 @@ extern int nvdimm_major;
 struct nvdimm_bus {
        struct nvdimm_bus_descriptor *nd_desc;
        wait_queue_head_t probe_wait;
-       struct module *module;
        struct list_head list;
        struct device dev;
        int id, probe_active;
index d37fda6dd64c6d6c9e1fb63a874ed2a340183624..2ab869dece4aa080242cf12f092fbdd11ab49915 100644 (file)
@@ -70,6 +70,7 @@ struct nd_mapping {
 struct nvdimm_bus_descriptor {
        const struct attribute_group **attr_groups;
        unsigned long cmd_mask;
+       struct module *module;
        char *provider_name;
        ndctl_fn ndctl;
        int (*flush_probe)(struct nvdimm_bus_descriptor *nd_desc);
@@ -128,10 +129,8 @@ static inline struct nd_blk_region_desc *to_blk_region_desc(
 }
 
 int nvdimm_bus_add_poison(struct nvdimm_bus *nvdimm_bus, u64 addr, u64 length);
-struct nvdimm_bus *__nvdimm_bus_register(struct device *parent,
-               struct nvdimm_bus_descriptor *nfit_desc, struct module *module);
-#define nvdimm_bus_register(parent, desc) \
-       __nvdimm_bus_register(parent, desc, THIS_MODULE)
+struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
+               struct nvdimm_bus_descriptor *nfit_desc);
 void nvdimm_bus_unregister(struct nvdimm_bus *nvdimm_bus);
 struct nvdimm_bus *to_nvdimm_bus(struct device *dev);
 struct nvdimm *to_nvdimm(struct device *dev);
index 78cba1e3b1dada3bd6efdfa43f19b9649e96a09e..642713f1572367aa46050043753d0a59bcd3e997 100644 (file)
@@ -1463,6 +1463,7 @@ static int nfit_test_probe(struct platform_device *pdev)
        acpi_desc->blk_do_io = nfit_test_blk_do_io;
        nd_desc = &acpi_desc->nd_desc;
        nd_desc->provider_name = NULL;
+       nd_desc->module = THIS_MODULE;
        nd_desc->ndctl = nfit_test_ctl;
        acpi_desc->nvdimm_bus = nvdimm_bus_register(&pdev->dev, nd_desc);
        if (!acpi_desc->nvdimm_bus)