Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Vishal Verma and committed by
Dan Williams
c347bd71 21c75763

+12
+12
drivers/dax/bus.c
··· 295 295 } 296 296 static DEVICE_ATTR_RO(target_node); 297 297 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 + 298 309 static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n) 299 310 { 300 311 struct device *dev = container_of(kobj, struct device, kobj); ··· 317 306 } 318 307 319 308 static struct attribute *dev_dax_attributes[] = { 309 + &dev_attr_modalias.attr, 320 310 &dev_attr_size.attr, 321 311 &dev_attr_target_node.attr, 322 312 NULL,