一、设备注册:
    1、首先需要对内核文件
    
     iTop4412_Kernel_3.0
    
    中的
    
    
    
     arch/arm/mach-exynos/mach-itop4412.c
    
    平台文件做修改,仿照leds的设备注册来写。该结构体定义在
    
     include/linux/platform_device.h
    
    中,
    
     这里还需要确认一下,是否有“HELLO_CTL”宏定义,只有定义了这个宏,在生成内核的时候才会将其编译到内核。
    
    在
    
     drivers/char/Kconfig
    
    中可查看是否定义
   
    2、make menuconfig在
    
     Device Drivers
    
    
     —>”→“Character devices —>”→“Enable HELLO config
    
   
    
     确认了宏定义“HELLO_CTL”
    
   
    3、
    
     打开“arch/arm/mach-exynos/mach-itop4412.c”平台文件可查找LEDS_CTL
    
    
     仿照着已有的初始化代码写即可
    
   
    
     4、
     
      保存退出,make zImage重新编译内核,烧写到开发板
     
     
    
   
    
     5、
     
      开发板启动之后,使用命令“ls /sys/devices/platform/”可以查看到新注册的设备
     
     
    
   
二、驱动注册:
    1、内核源码中 vim include/linux/platform_device.h 可看到驱动注册的相关函数,
    
     查找一下“platform_driver_register”
    
    可看到:
   
    
     注册驱动的函数:
     
     extern int platform_driver_register(struct platform_driver *)
     
     卸载驱动的函数:
     
    
   
    
     extern void platform_driver_unregister(struct platform_driver *)
    
   
    
     其中
     
      platform_driver 类型的结构体
     
     是非常重要的,该结构体在
     
      include/linux/platform_device.h
     
     头文件中,里面的几个操作函数和一个对象会在编写的驱动C文件中调用,相关函数可参照例程中仿写。
     
    
   
    
     2、在Makefile文件中把第四行的 .o 文件 修改为相应的驱动C文件的名字 如驱动C文件probe_linux_module.c,则改为probe_linux_module.o
    
   
 
