Merge tag 'libnvdimm-for-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm...
[sfrench/cifs-2.6.git] / drivers / dax / bus.c
index eccdda1f7b71b58cc366069ef6436d70856184c2..46e46047a1f78724eca4ee9dcd35a541018386bd 100644 (file)
@@ -309,7 +309,7 @@ static ssize_t resource_show(struct device *dev,
 
        return sprintf(buf, "%#llx\n", dev_dax_resource(dev_dax));
 }
-static DEVICE_ATTR_RO(resource);
+static DEVICE_ATTR(resource, 0400, resource_show, NULL);
 
 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
                char *buf)
@@ -322,6 +322,13 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(modalias);
 
+static ssize_t numa_node_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       return sprintf(buf, "%d\n", dev_to_node(dev));
+}
+static DEVICE_ATTR_RO(numa_node);
+
 static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n)
 {
        struct device *dev = container_of(kobj, struct device, kobj);
@@ -329,8 +336,8 @@ static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n)
 
        if (a == &dev_attr_target_node.attr && dev_dax_target_node(dev_dax) < 0)
                return 0;
-       if (a == &dev_attr_resource.attr)
-               return 0400;
+       if (a == &dev_attr_numa_node.attr && !IS_ENABLED(CONFIG_NUMA))
+               return 0;
        return a->mode;
 }
 
@@ -339,6 +346,7 @@ static struct attribute *dev_dax_attributes[] = {
        &dev_attr_size.attr,
        &dev_attr_target_node.attr,
        &dev_attr_resource.attr,
+       &dev_attr_numa_node.attr,
        NULL,
 };
 
@@ -373,6 +381,11 @@ static void dev_dax_release(struct device *dev)
        kfree(dev_dax);
 }
 
+static const struct device_type dev_dax_type = {
+       .release = dev_dax_release,
+       .groups = dax_attribute_groups,
+};
+
 static void unregister_dev_dax(void *dev)
 {
        struct dev_dax *dev_dax = to_dev_dax(dev);
@@ -430,8 +443,7 @@ struct dev_dax *__devm_create_dev_dax(struct dax_region *dax_region, int id,
        else
                dev->class = dax_class;
        dev->parent = parent;
-       dev->groups = dax_attribute_groups;
-       dev->release = dev_dax_release;
+       dev->type = &dev_dax_type;
        dev_set_name(dev, "dax%d.%d", dax_region->id, id);
 
        rc = device_add(dev);