美文网首页
设备注册

设备注册

作者: 文东之名 | 来源:发表于2017-06-27 14:02 被阅读0次

操作过程:

Setp 1:  注册设备。将设备结构体放到平台文件中,会自动注册设备,不用去调 用注册设备的函数。进入源码根目录。

    vim arch/arm/mach-exynos/mach-itop4412.c,以下是hello_ctl的设备注册

    #ifdef CONFIG_HELLO_CTL

        struct platform_device s3c_device_hello_ctl = {

            .name  = "hello_ctl",

                .id            = -1,

         };

    #endif

  在static struct platform_device *smdk4x12_devices[] __initdata 数组中增加下列三行

    #ifdef CONFIG_HELLO_CTL

        &s3c_device_hello_ctl,

    #endif

    platform_device 参见 include/linux/platform_device.h 

Setp 2. 在Kconfig文件中添加编译HELLO设备的宏定义

    vim drivers/char/Kconfig

    config HELLO_CTL

       tristate "Enable Hello config"    

       default n

       help

           Enable Hello config

Setp 3. 配置menuconfig中的HELLO宏定义,生成新的.config文件

        make menuconfig

        

        退出后保存。

Step4、生成新的zImage

        make zImage,等待编译。镜像保存在arch/arm/boot文件夹下

Setp5.下载镜像至开发板,然后使用命令查看是否注册设备成功

        ls /sys/devices/platform/

相关文章

网友评论

      本文标题:设备注册

      本文链接:https://www.haomeiwen.com/subject/zacecxtx.html