亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標題: 大家來看看這個錯誤 [打印本頁]

作者: momojuan    時間: 2008-04-23 13:52
標題: 大家來看看這個錯誤

  1. #include <linux/module.h>
  2. #include <linux/init.h>
  3. #include <linux/fs.h>
  4. #include "khead.h"
  5. MODULE_LICENSE("GPL");

  6. static int Device_Open = 0;
  7. #define SUCCESS 0;
  8. #define CS3 0xD1000000;
  9. static void *cs3_mapped;
  10. static int global_var = 0;


  11. static int cs3_open(struct inode *, struct file *);
  12. static int cs3_close(struct inode *, struct file *);
  13. static int cs3_read(struct file *, char *, size_t, loff_t *);
  14. static int cs3_write(struct file *, const char *, size_t, loff_t *);

  15. static struct file_operations cs3_fops = {
  16.         open:       cs3_open,
  17.         read:                cs3_read,
  18.         write:      cs3_write,
  19.         release:    cs3_close,
  20. };

  21. static int cs3_open (struct inode *inode, struct file *file)
  22. {
  23.          cs3_mapped=ioremap(CS3,8); //出錯在此行       
  24.           printk("hello_open\n");
  25.     if(Device_Open)
  26.             return -EBUSY;
  27.        
  28.         Device_Open++;
  29.         MOD_INC_USE_COUNT;
  30.         return SUCCESS;
  31. }
  32. static int cs3_close (struct inode *inode, struct file *file)
  33. {
  34.         printk("hello_close\n");
  35.     Device_Open--;
  36.         MOD_DEC_USE_COUNT;       
  37.         return 0;
  38. }
  39. static int cs3_read (struct file *file, char *buf, size_t count, loff_t *ppos)
  40. {
  41.         printk("hello_read\n");
  42.         return count;
  43. }

  44. static int cs3_write (struct file *file, const char *buf, size_t count, loff_t *ppos)
  45. {  
  46.    void *cs3_buf;
  47.    
  48.   
  49.         printk("CS3: mapped address=%08lx\n", (unsigned long)cs3_mapped);      /* test-only */
  50.   
  51.      
  52.    
  53.     copy_from_user(cs3_buf,buf,count);
  54.     iowrite8_rep(cs3_mapped,cs3_buf,count);
  55.         printk("CS3: mapped address=%08lx\n",(unsigned long)cs3_mapped);      /* test-only */
  56.         printk("hello_write: %p\n", buf);

  57.         return count;       
  58. }


  59. static int __init cs3_init (void)
  60. {
  61.   int result;

  62.   result = register_chrdev(0,"cs3",&cs3_fops);
  63.   if(result<0)
  64.                 {
  65.   printk("cs3 warning:can't get major %d\n", result);
  66.   return -EIO;
  67.            }
  68. return 0;
  69. }           
  70.            
  71.            
  72. static void __exit cs3_exit (void)
  73. {
  74.   if(unregister_chrdev(251,"cs3")!=0)
  75.           printk("cs3 unregistered is failed \n");
  76.             printk("cs3 module exit\n");
  77.                  

  78. }
  79. module_init(cs3_init);
  80. module_exit(cs3_exit);
復(fù)制代碼

編譯后的出錯,出錯在此行cs3_mapped=ioremap(CS3,; “parse erro before';'token”
作者: scutan    時間: 2008-04-23 17:22
#define SUCCESS 0;
#define CS3 0xD1000000;

兩行都去掉最后的 ; 符號
作者: momojuan    時間: 2008-04-23 20:14
標題: 回復(fù) #2 scutan 的帖子
呵呵,';'的問題是解決了。謝謝哦!
可是我把頭文件一改原來的,<linux/io.h>改為,<asm/io.h>又出現(xiàn)了這個問題,undefined reference to 'printk'和'register_chrdev'

[ 本帖最后由 momojuan 于 2008-4-23 20:49 編輯 ]
作者: scutan    時間: 2008-04-23 20:59
標題: 回復(fù) #3 momojuan 的帖子
內(nèi)核開發(fā)和應(yīng)用程序開發(fā)都需要特定的頭文件啊.
作者: momojuan    時間: 2008-04-23 22:27
標題: 回復(fù) #4 scutan 的帖子
頭文件我都有添加,
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/config.h>
#include <linux/string.h>
#include <linux/errno.h>
作者: fantry_t    時間: 2008-04-25 23:07
確認你的linux-header已經(jīng)正確安裝。
作者: x84ch    時間: 2008-05-01 10:45
大哥,你的編程習(xí)慣也太不好了吧。
#define SUCCESS 0;
#define CS3 0xD1000000;
這兩句后面是不要分號的了




歡迎光臨 Chinaunix (http://www.72891.cn/) Powered by Discuz! X3.2