<1>>>In kernel code tree:
aa>>>update Kconfig, eg: drivers/sensors/Kconfig中加入一行,引入自己的Kconfig:
source "drivers/sensors/Kconfig"
ab>>>your kconfig in subdir, drivers/sensors/Kconfig, example:
menuconfig SENSORS tristate "Sensors class support" default n ---help--- Say Y here to enable sensors class support. This allows user manipulate the sensors from sysfs interface. if SENSORS config SENSORS_AKM8975 tristate "AKM8975/C Compass-senseor Driver" default n ---help--- Say Y here if you want to enable the AKM8975/C compass-sensor endif # SENSORS
ba>>>update Makefile:
>obj-m += sensors/ .or. >obj-$(CONFIG_SENSORS_AKM8975) += sensors/
bb>>>update Makefile in subdir:
>obj-m := akm8975_sensors.o .or. >obj-$(CONFIG_SENSORS_AKM8975) := akm8975_sensors.o
p.s.
module_param(name, type, perm);
1 The type argument holds the parameter's data type; it is one of byte, short, ushort, int, uint, long, ulong, charp, bool, or invbool.
2 the perm argument specifies the permissions of the corresponding file in sysfs.
<2>>>Outside kernel code tree, 只需要编写一个Makefile即可:
ifeq ($(KERNELRELEASE),) modules: $(MAKE) -C /home/sudolee/workstation/kernel-2.6.32/ M=$(shell pwd) $@ else obj-m := debugfs.o endif clean: rm -f *.o *.cmd *.mod.* modules.order Module.symvers *.ko .*.cmd rm -rf .tmp_versions/ .PHONY:modules clean