用gcc,错误一大片:
[root@ForATIW Drivers]# gcc -c simple_chrdev.c
simple_chrdev.c:8:26: error: linux/module.h: No such file or directory
simple_chrdev.c:9:24: error: linux/init.h: No such file or directory
simple_chrdev.c:10:24: error: linux/cdev.h: No such file or directory
simple_chrdev.c:16: error: expected declaration specifiers or ‘...’ before string constant
simple_chrdev.c:16: warning: data definition has no type or storage class
simple_chrdev.c:17: error: expected declaration specifiers or ‘...’ before string constant
。。。。。。。。。。。。。。。。。。。
/*****************************************************/
/*** ******/
int simple_open(struct inode *inode ,struct file *flip)
{
printk("simple Device is opened \n");
try_module_get(THIS_MODULE);
return 0;
}
/****************************************************/
/**release ***/
int simple_release(struct inode *inode ,struct file *filp)
{
printk("simple device is released!\n");
module_put(THIS_MODULE);
return 0;
}
/****************************************************/
/**init ***/
static int __init simple_init(void)
{
int result;
//register major and the minor
if(CDRIVER_MAJOR)
{
simple_dev=MKDEV(CDRIVER_MAJOR,CDRIVER_MINOR);
result=register_chrdev_region(simple_dev,count,CDRIVER_NAME);
}
else
{
//dynamic assgin major
result=alloc_chrdev_region(&simple_dev,CDRIVER_MINOR,count,CDRIVER_NAME);
CDRIVER_MAJOR=MAJOR(simple_dev);
}
if(result<0)
{
printk(KERN_ERR"Cannot get major %d!\n",CDRIVER_MAJOR );
return -1;
}