Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1261765
  • 博文数量: 548
  • 博客积分: 7597
  • 博客等级: 少将
  • 技术积分: 4224
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-15 13:21
个人简介

嵌入式软件工程师&&太极拳

文章分类

全部博文(548)

文章存档

2014年(10)

2013年(76)

2012年(175)

2011年(287)

分类: 嵌入式

2012-01-11 17:28:19

 ov9550_misc.rar   
  1. #include <linux/init.h>
  2. #include <linux/module.h>
  3. #include <linux/miscdevice.h>
  4. #include <linux/io.h>
  5. #include <linux/fs.h>
  6. #include <linux/uaccess.h>

  7. #define MISC_MINOR    212
  8. #define MISC_NAME    "ov9550"

  9. [ov9550.c]
  10. /***ov9550.c*********************[misc start]*********************************/
  11. int ov9550_open(struct inode *i_nod, struct file *filp)
  12. {
  13.     return 0;
  14. }

  15. int ov9550_ioctl(struct inode *i_nod, struct file *filp, unsigned int cmd, unsigned long usr_ov9550_data)
  16. {
  17.     return 0;
  18. }

  19. int ov9550_read( struct file *file, char *buf, size_t count, loff_t *ppos )
  20. {
  21.      printk("function:%s, line: %d\n", __FUNCTION__, __LINE__);

  22. }

  23. struct file_operations ov9550_ops = {
  24.     .open = ov9550_open,
  25.     .ioctl = ov9550_ioctl,
  26.     .read = ov9550_read,
  27. };

  28. struct miscdevice ov9550_dev = {
  29.     .minor = MISC_MINOR,
  30.     .name = MISC_NAME,
  31.     .fops = &ov9550_ops,
  32. };

  33. /********************************[misc end]********************************/







  34. int ov9550_init(void)
  35. {
  36.     unsigned char ret;

  37.     misc_register(&ov9550_dev); //注册!    

  38.     printk("ov9550 initialization finished \n");
  39.     return 0;
  40. }

  41. void ov9550_exit(void)
  42. {
  43.     misc_deregister(&ov9550_dev);
  44.     printk("ov9550 module exit\n");
  45. }

  46. module_init(ov9550_init);
  47. module_exit(ov9550_exit);

  48. MODULE_AUTHOR("JK askingjk@gmail.com");
  49. MODULE_LICENSE("GPL");
      [Makefile]
      1. KERNEL_DIR = /route/?

      2. all:
      3.     make -C $(KERNEL_DIR) M=`pwd` modules

      4. clean:
      5.     make -C $(KERNEL_DIR) M=`pwd` modules clean
      6.     rm -f modules.order

      7. obj-m += ov9550.o

      8. super_rtc-objs =ov9550.o
      阅读(869) | 评论(0) | 转发(0) |
      0

      上一篇:内核升级的步骤

      下一篇:Win7下安装PADS9

      给主人留下些什么吧!~~