当前位置: 技术问答>linux和unix
这个怎么定义结构体的,不懂?????
来源: 互联网 发布时间:2016-09-23
本文导语: static struct file_operations dev_fops = { owner: THIS_MODULE, open: s3c2410_adc_open, read: s3c2410_adc_read, release: s3c2410_adc_release, }; static struct file_operations dev_fops 这样能行吗,中间有空格???????? static int s3c2410_adc_r...
static struct file_operations dev_fops = {
owner: THIS_MODULE,
open: s3c2410_adc_open,
read: s3c2410_adc_read,
release: s3c2410_adc_release,
};
static struct file_operations dev_fops 这样能行吗,中间有空格????????
static int s3c2410_adc_release(struct inode *inode, struct file *filp)
{
DPRINTK( "adc closedn");
return 0;
}
还有这个函数的参数都没用上,有什么意思啊?????、、
owner: THIS_MODULE,
open: s3c2410_adc_open,
read: s3c2410_adc_read,
release: s3c2410_adc_release,
};
static struct file_operations dev_fops 这样能行吗,中间有空格????????
static int s3c2410_adc_release(struct inode *inode, struct file *filp)
{
DPRINTK( "adc closedn");
return 0;
}
还有这个函数的参数都没用上,有什么意思啊?????、、
|
1,c和c++在定义结构体变量时的语法差异。
2,这个函数是一个空函数。这么定义可能是为了满足一些驱动框架上的要求。
2,这个函数是一个空函数。这么定义可能是为了满足一些驱动框架上的要求。
|
都是C基础,建议楼主好好学学C程序。
1。 static struct file_operations dev_fops 这样能行吗,中间有空格????????
可以。
2。还有这个函数的参数都没用上,有什么意思啊?????、、
只是做释放时,输出调试信息:DPRINTK( "adc closedn");
1。 static struct file_operations dev_fops 这样能行吗,中间有空格????????
可以。
2。还有这个函数的参数都没用上,有什么意思啊?????、、
只是做释放时,输出调试信息:DPRINTK( "adc closedn");
|
linux风格
在定义处初始化可以这样做
|
书上没讲但在实际中应用的地方多了去了。
那些结构体中赋值的形式有点旧了。新的内核有使用另一种格式,下面是S3C2410看门狗的fp结构体:
static const struct file_operations s3c2410wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.write = s3c2410wdt_write,
.ioctl = s3c2410wdt_ioctl,
.open = s3c2410wdt_open,
.release = s3c2410wdt_release,
};
至于那些函数的参数,看一下file_operations结构体的定义吧,应该能懂的。
那些结构体中赋值的形式有点旧了。新的内核有使用另一种格式,下面是S3C2410看门狗的fp结构体:
static const struct file_operations s3c2410wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.write = s3c2410wdt_write,
.ioctl = s3c2410wdt_ioctl,
.open = s3c2410wdt_open,
.release = s3c2410wdt_release,
};
至于那些函数的参数,看一下file_operations结构体的定义吧,应该能懂的。
|
学习了