亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区
Chinaunix
標題:
大家來看看這個錯誤
[打印本頁]
作者:
momojuan
時間:
2008-04-23 13:52
標題:
大家來看看這個錯誤
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include "khead.h"
MODULE_LICENSE("GPL");
static int Device_Open = 0;
#define SUCCESS 0;
#define CS3 0xD1000000;
static void *cs3_mapped;
static int global_var = 0;
static int cs3_open(struct inode *, struct file *);
static int cs3_close(struct inode *, struct file *);
static int cs3_read(struct file *, char *, size_t, loff_t *);
static int cs3_write(struct file *, const char *, size_t, loff_t *);
static struct file_operations cs3_fops = {
open: cs3_open,
read: cs3_read,
write: cs3_write,
release: cs3_close,
};
static int cs3_open (struct inode *inode, struct file *file)
{
cs3_mapped=ioremap(CS3,8); //出錯在此行
printk("hello_open\n");
if(Device_Open)
return -EBUSY;
Device_Open++;
MOD_INC_USE_COUNT;
return SUCCESS;
}
static int cs3_close (struct inode *inode, struct file *file)
{
printk("hello_close\n");
Device_Open--;
MOD_DEC_USE_COUNT;
return 0;
}
static int cs3_read (struct file *file, char *buf, size_t count, loff_t *ppos)
{
printk("hello_read\n");
return count;
}
static int cs3_write (struct file *file, const char *buf, size_t count, loff_t *ppos)
{
void *cs3_buf;
printk("CS3: mapped address=%08lx\n", (unsigned long)cs3_mapped); /* test-only */
copy_from_user(cs3_buf,buf,count);
iowrite8_rep(cs3_mapped,cs3_buf,count);
printk("CS3: mapped address=%08lx\n",(unsigned long)cs3_mapped); /* test-only */
printk("hello_write: %p\n", buf);
return count;
}
static int __init cs3_init (void)
{
int result;
result = register_chrdev(0,"cs3",&cs3_fops);
if(result<0)
{
printk("cs3 warning:can't get major %d\n", result);
return -EIO;
}
return 0;
}
static void __exit cs3_exit (void)
{
if(unregister_chrdev(251,"cs3")!=0)
printk("cs3 unregistered is failed \n");
printk("cs3 module exit\n");
}
module_init(cs3_init);
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