提交 536559fe 编写于 作者: V Vishal Verma 提交者: Caspar Zhang

device-dax: Add a 'modalias' attribute to DAX 'bus' devices

commit c347bd71dcdb2d0ac8b3a771486584dca8c8dd80 upstream

Add a 'modalias' attribute to devices under the DAX bus so that userspace
is able to dynamically load modules as needed.

Normally, udev can get the modalias from 'uevent', and that is correctly
set up by the DAX bus. However other tooling such as 'libndctl' for
interacting with drivers/nvdimm/, and 'libdaxctl' for drivers/dax/ can
also use the modalias to dynamically load modules via libkmod lookups.

The 'nd' bus set up by the libnvdimm subsystem exports a modalias
attribute. Imitate this to export the same for the 'dax' bus.

Cc: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: NVishal Verma <vishal.l.verma@intel.com>
Signed-off-by: NDan Williams <dan.j.williams@intel.com>
Signed-off-by: NYang Shi <yang.shi@linux.alibaba.com>
Reviewed-by: NGavin Shan <shan.gavin@linux.alibaba.com>
上级 e444f72f
...@@ -295,6 +295,17 @@ static ssize_t target_node_show(struct device *dev, ...@@ -295,6 +295,17 @@ static ssize_t target_node_show(struct device *dev,
} }
static DEVICE_ATTR_RO(target_node); static DEVICE_ATTR_RO(target_node);
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
/*
* We only ever expect to handle device-dax instances, i.e. the
* @type argument to MODULE_ALIAS_DAX_DEVICE() is always zero
*/
return sprintf(buf, DAX_DEVICE_MODALIAS_FMT "\n", 0);
}
static DEVICE_ATTR_RO(modalias);
static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n) static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n)
{ {
struct device *dev = container_of(kobj, struct device, kobj); struct device *dev = container_of(kobj, struct device, kobj);
...@@ -306,6 +317,7 @@ static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n) ...@@ -306,6 +317,7 @@ static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n)
} }
static struct attribute *dev_dax_attributes[] = { static struct attribute *dev_dax_attributes[] = {
&dev_attr_modalias.attr,
&dev_attr_size.attr, &dev_attr_size.attr,
&dev_attr_target_node.attr, &dev_attr_target_node.attr,
NULL, NULL,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册