Linux Kernel Architecture

(Jacob Rumans) #1

Chapter7:Modules


__attribute_used__ \
__attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info

In addition to this general macro that generatestag = infoentries, there are a range of macros that create
entries with pre-defined meanings. These are discussed below.

Module License


The module license is set usingMODULE_LICENSE:

<module.h>
#define MODULE_LICENSE(_license) MODULE_INFO(license, _license)

The technical implementation is not particularly stunning. More interesting is the question as to which
license types are classified as GPL-compatible by the kernel.

❑ GPLandGPLv2stand for the second version of the GNU Public License; in the first definition, any
later version of the license (that may not yet exist) may also be used.
❑ GPL and additional rightsmust be used if further clauses, which must be compatible with the
free software definition software, have been added to the GPL.
❑ Dual BSD/GPL,Dual MIT/GPL,orDual MPL/GPLare used for modules whose sources are available
under a dual license (GPL combined with the Berkeley, MIT, or Mozilla license).
❑ Proprietary modules (or modules whose license is not compatible with GPL) must use
Proprietary.
❑ unspecifiedis used if no explicit license is specified.

Author and Description


Each module should contain brief information about the author (with e-mail address, if possible) and a
description of the purpose of the module:

<module.h>
#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)

Alternative Name


MODULE_ALIAS(alias)is used to give a module alternative names (alias) by which it can be addressed
in userspace. This mechanism enables a distinctionto be made between, for example, alternative drivers,
when only one of the drivers can be used although externally they all implement the same functionality.
It is also essential for constructing systematic names. This enables, for instance, assigning one or more
alias names to a module. These aliases specify the identification numbers of all PCI devices that are
supported by the module. When such a device is found in the system, the kernel can (with the help of the
userspace) automatically insert the corresponding module.

Elementary Version Control


Some indispensable version control information is always stored in the.modinfosection, regardless of
whether the version control feature is enabled or disabled. This allows a distinction to be made between
Free download pdf