unknown symbol __class_create (err 0)

前端 未结 1 1348
清歌不尽
清歌不尽 2021-01-21 15:53

This is probably a stupid question, but I looked for hours online and couldn\'t find an answer...

I\'m writing a kernel module that also creates a character device. It c

相关标签:
1条回答
  • 2021-01-21 16:41

    The function __class_create is exported only for GPL modules (exported with EXPORT_SYMBOL_GPL). So, you need to use a GPL license with MODULE_LICENSE macro to make use of that function. Same goes for other functions as well.

    This should do the trick:

    MODULE_LICENSE("GPL");
    

    To learn about what exporting is, take a look at here. Basically, dynamic modules do not have access to variables and functions in kernel, and kernel needs to specify what to export, to enable access. That's the purpose of EXPORT_SYMBOL and EXPORT_SYMBOL_GPL macros, which are used everywhere.

    And the difference between EXPORT_SYMBOL and EXPORT_SYMBOL_GPL is that the latter only reveals the function or the variable if the module is GPL licensed.

    0 讨论(0)
提交回复
热议问题