From 78c81cc89a40114d09a5ec0693cfd97831ffbe79 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 6 Nov 2019 19:56:41 -0800 Subject: libnvdimm: Move attribute groups to device type Statically initialize the attribute groups for each libnvdimm device_type. This is a preparation step for removing unnecessary exports of attributes that can be included in the device_type by default. Also take the opportunity to mark 'struct device_type' instances const. Cc: Ira Weiny Cc: Vishal Verma Signed-off-by: Dan Williams Reviewed-by: Aneesh Kumar K.V Link: https://lore.kernel.org/r/157309900111.1582359.2445687530383470348.stgit@dwillia2-desk3.amr.corp.intel.com --- drivers/nvdimm/pfn_devs.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'drivers/nvdimm/pfn_devs.c') diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 3ca6c97cd14d..17ceac5b5313 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -26,17 +26,6 @@ static void nd_pfn_release(struct device *dev) kfree(nd_pfn); } -static struct device_type nd_pfn_device_type = { - .name = "nd_pfn", - .release = nd_pfn_release, -}; - -bool is_nd_pfn(struct device *dev) -{ - return dev ? dev->type == &nd_pfn_device_type : false; -} -EXPORT_SYMBOL(is_nd_pfn); - struct nd_pfn *to_nd_pfn(struct device *dev) { struct nd_pfn *nd_pfn = container_of(dev, struct nd_pfn, dev); @@ -287,18 +276,30 @@ static umode_t pfn_visible(struct kobject *kobj, struct attribute *a, int n) return a->mode; } -struct attribute_group nd_pfn_attribute_group = { +static struct attribute_group nd_pfn_attribute_group = { .attrs = nd_pfn_attributes, .is_visible = pfn_visible, }; -static const struct attribute_group *nd_pfn_attribute_groups[] = { +const struct attribute_group *nd_pfn_attribute_groups[] = { &nd_pfn_attribute_group, &nd_device_attribute_group, &nd_numa_attribute_group, NULL, }; +static const struct device_type nd_pfn_device_type = { + .name = "nd_pfn", + .release = nd_pfn_release, + .groups = nd_pfn_attribute_groups, +}; + +bool is_nd_pfn(struct device *dev) +{ + return dev ? dev->type == &nd_pfn_device_type : false; +} +EXPORT_SYMBOL(is_nd_pfn); + struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn, struct nd_namespace_common *ndns) { @@ -337,7 +338,6 @@ static struct nd_pfn *nd_pfn_alloc(struct nd_region *nd_region) dev = &nd_pfn->dev; dev_set_name(dev, "pfn%d.%d", nd_region->id, nd_pfn->id); - dev->groups = nd_pfn_attribute_groups; dev->type = &nd_pfn_device_type; dev->parent = &nd_region->dev; -- cgit v1.2.3