HOWTO_build_your_own_module

<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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值