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 <ira.weiny@intel.com> Cc: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Link: https://lore.kernel.org/r/157309900111.1582359.2445687530383470348.stgit@dwillia2-desk3.amr.corp.intel.com
This commit is contained in:
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user