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

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 2511 | 回復(fù): 6
打印 上一主題 下一主題

大家來(lái)看看這個(gè)錯(cuò)誤 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-04-23 13:52 |只看該作者 |倒序?yàn)g覽

  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); //出錯(cuò)在此行       
  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ù)制代碼

編譯后的出錯(cuò),出錯(cuò)在此行cs3_mapped=ioremap(CS3,; “parse erro before';'token”

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2008-04-23 17:22 |只看該作者
#define SUCCESS 0;
#define CS3 0xD1000000;

兩行都去掉最后的 ; 符號(hào)

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2008-04-23 20:14 |只看該作者

回復(fù) #2 scutan 的帖子

呵呵,';'的問(wèn)題是解決了。謝謝哦!
可是我把頭文件一改原來(lái)的,<linux/io.h>改為,<asm/io.h>又出現(xiàn)了這個(gè)問(wèn)題,undefined reference to 'printk'和'register_chrdev'

[ 本帖最后由 momojuan 于 2008-4-23 20:49 編輯 ]

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2008-04-23 20:59 |只看該作者

回復(fù) #3 momojuan 的帖子

內(nèi)核開(kāi)發(fā)和應(yīng)用程序開(kāi)發(fā)都需要特定的頭文件啊.

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 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>

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2008-04-25 23:07 |只看該作者
確認(rèn)你的linux-header已經(jīng)正確安裝。

論壇徽章:
0
7 [報(bào)告]
發(fā)表于 2008-05-01 10:45 |只看該作者
大哥,你的編程習(xí)慣也太不好了吧。
#define SUCCESS 0;
#define CS3 0xD1000000;
這兩句后面是不要分號(hào)的了
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專(zhuān)區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP