Skip to content

Commit c347bd7

Browse files
stellarhopperdjbw
authored andcommitted
device-dax: Add a 'modalias' attribute to DAX 'bus' devices
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: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 21c7576 commit c347bd7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/dax/bus.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,17 @@ static ssize_t target_node_show(struct device *dev,
295295
}
296296
static DEVICE_ATTR_RO(target_node);
297297

298+
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
299+
char *buf)
300+
{
301+
/*
302+
* We only ever expect to handle device-dax instances, i.e. the
303+
* @type argument to MODULE_ALIAS_DAX_DEVICE() is always zero
304+
*/
305+
return sprintf(buf, DAX_DEVICE_MODALIAS_FMT "\n", 0);
306+
}
307+
static DEVICE_ATTR_RO(modalias);
308+
298309
static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n)
299310
{
300311
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)
306317
}
307318

308319
static struct attribute *dev_dax_attributes[] = {
320+
&dev_attr_modalias.attr,
309321
&dev_attr_size.attr,
310322
&dev_attr_target_node.attr,
311323
NULL,

0 commit comments

Comments
 (0)