kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* What is this MODULE_ALIAS() used for?
@ 2016-12-10  1:36 Perr Zhang
  2016-12-10  8:40 ` Giedrius Statkevičius
  2016-12-14 13:01 ` Aruna Hewapathirane
  0 siblings, 2 replies; 3+ messages in thread
From: Perr Zhang @ 2016-12-10  1:36 UTC (permalink / raw)
  To: kernelnewbies

source code:

MODULE_ALIAS("platform:sm501");

static const struct of_device_id of_sm501_match_tbl[] = {
    { .compatible = "smi,sm501", },
    { /* end */ }
};
MODULE_DEVICE_TABLE(of, of_sm501_match_tbl);

location: http://lxr.free-electrons.com/source/drivers/mfd/sm501.c#L1711

Since there is the MODULE_DEVICE_TABLE(), why  the author additionally adds the MODULE_ALIAS()?
What exactly is this MODULE_ALIAS() used for?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* What is this MODULE_ALIAS() used for?
  2016-12-10  1:36 What is this MODULE_ALIAS() used for? Perr Zhang
@ 2016-12-10  8:40 ` Giedrius Statkevičius
  2016-12-14 13:01 ` Aruna Hewapathirane
  1 sibling, 0 replies; 3+ messages in thread
From: Giedrius Statkevičius @ 2016-12-10  8:40 UTC (permalink / raw)
  To: kernelnewbies

On Sat, Dec 10, 2016 at 3:36 AM, Perr Zhang <strongbox8@zoho.com> wrote:
> source code:
>
> MODULE_ALIAS("platform:sm501");
>
> static const struct of_device_id of_sm501_match_tbl[] = {
>     { .compatible = "smi,sm501", },
>     { /* end */ }
> };
> MODULE_DEVICE_TABLE(of, of_sm501_match_tbl);
>
> location: http://lxr.free-electrons.com/source/drivers/mfd/sm501.c#L1711
>
> Since there is the MODULE_DEVICE_TABLE(), why  the author additionally adds the MODULE_ALIAS()?
> What exactly is this MODULE_ALIAS() used for?
>
>
>

MODULE_ALIAS() adds some more info for the userspace programs. In
/lib/modules/VERSION/modules.alias you can see the aliases that were parsed from
the modules. In your case, running `modprobe platform:sm501` would insert the
sm501 module.

Thanks,
Giedrius

^ permalink raw reply	[flat|nested] 3+ messages in thread

* What is this MODULE_ALIAS() used for?
  2016-12-10  1:36 What is this MODULE_ALIAS() used for? Perr Zhang
  2016-12-10  8:40 ` Giedrius Statkevičius
@ 2016-12-14 13:01 ` Aruna Hewapathirane
  1 sibling, 0 replies; 3+ messages in thread
From: Aruna Hewapathirane @ 2016-12-14 13:01 UTC (permalink / raw)
  To: kernelnewbies

> source code:
>
> MODULE_ALIAS("platform:sm501");
>
> static const struct of_device_id of_sm501_match_tbl[] = {
>     { .compatible = "smi,sm501", },
>     { /* end */ }
> };
> MODULE_DEVICE_TABLE(of, of_sm501_match_tbl);
>
> location: http://lxr.free-electrons.com/source/drivers/mfd/sm501.c#L1711
>
> Since there is the MODULE_DEVICE_TABLE(), why  the author additionally
adds the MODULE_ALIAS()?
> What exactly is this MODULE_ALIAS() used for?

Short answer: to re-enable auto loading of the module, Please refer subject
line here:
https://lab.nexedi.cn/kirr/linux/commit/4f46d6e7e5ffbce0ee1d1a80767fdf45e56cc863

Long answer:
https://kerneltweaks.wordpress.com/2014/03/30/platform-device-and-platform-driver-linux/

References:
Review the section kmod vs kerneld: http://lpic2.unix.nl/ch02s03.html

What is MODULE_ALIAS:
http://stackoverflow.com/questions/22778879/what-is-module-alias-in-linux-device-driver-code

Review Alias section:
https://wiki.debian.org/Modules#Automatic_loading_of_modules

Review Identifying Device Driver Modules:
http://free-electrons.com/doc/udev.pdf

Useful to know:
1 - https://frankpzh.wordpress.com/2011/04/16/kmod-udev-and-modprobe/
2 -
https://www.quora.com/What-is-the-difference-between-platform-device-drivers-and-normal-device-drivers
3 - http://www.atmel.com/Images/doc32098.pdf

Where it all began:
http://www.linuxjournal.com/node/5604/print

Hope this helps.

Thanks - Aruna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20161214/5535050f/attachment.html 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-14 13:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-10  1:36 What is this MODULE_ALIAS() used for? Perr Zhang
2016-12-10  8:40 ` Giedrius Statkevičius
2016-12-14 13:01 ` Aruna Hewapathirane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).