简体   繁体   中英

compile a static kernel driver to module

I am compiling linux kernel version 3.17. by default a driver is statically compiled into the linux kernel and is probed at boot time. But I want this particular driver to be build as a module so I changed the CONFIG_driver from 'y' to 'm'. But after doing so the kernel outputs an undefined reference error and breaks the build.

following console log

|   LD      drivers/built-in.o
|   LINK    vmlinux
|   LD      vmlinux.o
|   MODPOST vmlinux.o
|   GEN     .version
|   CHK     include/generated/compile.h
|   UPD     include/generated/compile.h
|   CC      init/version.o
|   LD      init/built-in.o
| drivers/built-in.o: In function `adv7511_irq_handler':
| /var/adnan/work/git/mel_repos/mel_cedar_2/build/build_zedboard-zynq7-mel/tmp/work-shared/zedboard-zynq7-mel/kernel-source/drivers/gpu/drm/i2c/adv7511_core.c:314: undefined reference to `drm_helper_hpd_irq_event'
| make: *** [vmlinux] Error 1
| ERROR: oe_runmake failed

where as the function drm_helper_hpd_irq_event is present in drm_probe_helper.c . and according to the makefile

obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o

the module which I am building selects CONFIG_DRM_KMS_HELPER . In the .config this is directly proportional to my module when I build my module this also gets build in module and otherwise it build statically. But when it builds in module the file is not compiled.

Any Idea ? How can I force this into static build while doing my driver in module ?

As a workaround, you can replace

obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o

by

obj-y += drm_kms_helper.o

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM