Explanation for MODULE_ALIAS in the code says
/* work with hotplug and coldplug */
MODULE_ALIAS("platform:omap2_mcspi");
But, what exactly is MODULE_ALIAS?
Is there a significance for : (colon) in the argument?
You need to use the lsmod command, which show the status of loaded modules in the Linux Kernel. Linux kernel use a term modules for all hardware device drivers. This is an important task. With lsmod you can verify that device driver is loaded for particular hardware.
Drivers are used to help the hardware devices interact with the operating system. In windows, all the devices and drivers are grouped together in a single console called device manager.
scull is a char driver that acts on a memory area as though it were a device. In this chapter, because of that peculiarity of scull, we use the word device interchangeably with “the memory area used by scull.” The advantage of scull is that it isn't hardware dependent.
MODULE_ALIAS
is macro, added in 2002 with update of linux kernel module loaders, and used since 2003. This macro allows module creator to define additional names of the module (aliases), for example to make autoloading of the module easier.
The aliases are used to give some special name, e.g. "block-major-100" directly in the module source, instead of using /etc/modules.conf
for defining aliases. When user program accesses the block device with major number 100, kernel will try to load "block-major-100". Without MODULE_ALIAS
kernel should go to userspace and read /etc/modules.conf
with helper. And with MODULE_ALIAS("block-major-100")
kernel will solve the search by itself.
You can read more about this macro in http://lwn.net/Articles/47412/ "MODULE_ALIAS" article by corbet, 2003-09-03.
There are several more special versions of the MODULE_ALIAS
, listed by corbet:
The actual variants used depend on the subsystem; block drivers use MODULE_ALIAS_BLOCKDEV, for example, while char devices use MODULE_ALIAS_CHARDEV or MODULE_ALIAS_MISCDEV and network protocols use MODULE_ALIAS_NETPROTO.
According to 2011 patch from Mans Rullgard (linaro), or to commit by Kay Sievers (vrfy), MODULE_ALIAS
with argument like "platform:...
is used to enable module auto-loading "when platform devices are scanned.". In SPI drivers, it is used for "hotpluggable SPI platform drivers, to allow module auto loading.", since 43cc71eed1250755986da4c0f9898f9a635cb3bf by Kay Sievers - "platform: prefix MODALIAS with "platform:"":
Prefix platform modalias strings with "platform:", which modprobe config to blacklist alias resolving if userspace configures it.
Driver aliases with "platform:" are used in drivers/base/platform.c
file, function modalias_show(...)
(snprintf(buf, PAGE_SIZE, "platform:%s\n", pdev->name);
) and in platform_uevent(...)
add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX, pdev->name);
where PLATFORM_MODULE_PREFIX
macro is defined as "platform:"
(so, colon mark is significant).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With